Skip to content

Conversation

@snehar-nd
Copy link
Contributor

@snehar-nd snehar-nd commented Sep 30, 2025

πŸ“‹ Description

JIRA ID:

https://support.piramalfoundation.org/jira/browse/AMM-1857

βœ… Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)

Summary by CodeRabbit

  • New Features
    • Added username-based fallback to retrieve doctor signatures when the specialist ID is unavailable, improving reliability of signature downloads.
  • Bug Fixes
    • Resolved failures in signature download by automatically fetching the missing user ID via username.
    • Provided clearer error messages when signature retrieval fails to aid user understanding.
  • Chores
    • Updated environment configuration to support the user ID lookup endpoint.

@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Introduces a username-based fallback to fetch a user ID before downloading a signature in the doctor diagnosis case sheet component. Adds a new DoctorService.getUserId API method and a corresponding environment URL. Updates the component with a new public userName property and an observable flow with improved error logging.

Changes

Cohort / File(s) Summary of changes
Component: username fallback & reactive flow
src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts
Added public userName property; introduced getUserId(): Observable<any> using DoctorService.getUserId; modified downloadSign to fetch userId via username when tCSpecialistUserID is missing; imported map and Observable; improved error logging.
Service: user lookup API
src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts
Added getUserId(userName: any) that performs HTTP GET to environment getUserId endpoint.
Config: environment URL
src/environments/environment.ci.ts.template
Added getUserId URL field to environment pointing to ${COMMON_API}user/userName/.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Component as DoctorDiagnosisCaseSheetComponent
  participant DoctorService
  participant UserAPI as UserId API
  participant SignAPI as Signature API

  User->>Component: downloadSign()
  alt tCSpecialistUserID present
    Component->>SignAPI: GET signature(tCSpecialistUserID)
    SignAPI-->>Component: signature blob/bytes
  else missing tCSpecialistUserID
    Component->>DoctorService: getUserId(userName)
    DoctorService->>UserAPI: GET /user/userName/{userName}
    UserAPI-->>DoctorService: { userId }
    DoctorService-->>Component: userId
    Component->>SignAPI: GET signature(userId)
    SignAPI-->>Component: signature blob/bytes
  end
  Note over Component: On error, log descriptive message
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny taps the keys with cheer,
β€œIf ID is lost, no need to fear!”
I’ll ask your name, then hop to find,
The signature that’s left behind.
New trails mapped in tidy codeβ€”
Carrots cached, and bugs forebode. πŸ₯•βœ¨

Pre-merge checks and finishing touches

βœ… Passed checks (3 passed)
Check name Status Explanation
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check βœ… Passed The title clearly summarizes the primary change by indicating an enhancement to the signature functionality in the case sheet and aligns with the JIRA reference for traceability.
Docstring Coverage βœ… Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share
πŸ§ͺ Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts (1)

2851-2854: Consider stricter typing for better type safety.

The userName parameter is typed as any, and the return type is implicit. For better type safety and code clarity, consider:

-  /* Get UserID using UserName */
-  getUserId(userName: any) {
-    return this.http.get(environment.getUserId + userName);
-  }
+  /* Get UserID using UserName */
+  getUserId(userName: string): Observable<any> {
+    return this.http.get(environment.getUserId + userName);
+  }
πŸ“œ Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 73af2f6 and cea587a.

πŸ“’ Files selected for processing (3)
  • src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts (3 hunks)
  • src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts (1 hunks)
  • src/environments/environment.ci.ts.template (1 hunks)
🧰 Additional context used
πŸͺ› GitHub Actions: ESLint and NPM Audit
src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts

[error] 384-384: prettier/prettier: Delete Β·

πŸͺ› GitHub Check: lint-and-audit / lint-and-audit
src/app/app-modules/nurse-doctor/shared/services/doctor.service.ts

[failure] 2855-2855:
Delete Β·Β·

src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts

[failure] 385-385:
Delete Β·


[failure] 384-384:
Delete Β·

πŸ”‡ Additional comments (4)
src/environments/environment.ci.ts.template (1)

498-499: LGTM! Clean environment configuration addition.

The new getUserId endpoint configuration follows the established pattern and correctly constructs the URL for username-based user ID lookups.

src/app/app-modules/nurse-doctor/case-sheet/general-case-sheet/doctor-diagnosis-case-sheet/doctor-diagnosis-case-sheet.component.ts (3)

32-32: LGTM! Appropriate RxJS imports.

The import of map and Observable from rxjs is necessary to support the new observable-based getUserId() flow.


385-398: Clean fallback logic with improved error handling.

The updated downloadSign() method introduces a sensible fallback: if tCSpecialistUserID is missing, it retrieves the user ID via username. The error logging is also more descriptive.

However, this logic depends on userName being properly initialized (see separate comment on line 104).

Also note: trailing whitespace at lines 384 and 385 must be removed to pass linting.

-  
- downloadSign() {
+
+  downloadSign() {

400-404: LGTM! Well-structured helper method.

The getUserId() method correctly wraps the service call and extracts the userId from the response using the map operator, with a fallback to null if unavailable.

@snehar-nd snehar-nd changed the base branch from main to release-3.5.0 September 30, 2025 12:43
@sonarqubecloud
Copy link

@5Amogh 5Amogh merged commit b7480d3 into release-3.5.0 Sep 30, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants