Skip to content

fix(nurse): show server message when general OPD nurse save fails - #290

Open
Aarti-panchal01 wants to merge 1 commit into
PSMRI:mainfrom
Aarti-panchal01:fix/nurse-gopd-save-error-message
Open

Aarti-panchal01 wants to merge 1 commit into
PSMRI:mainfrom
Aarti-panchal01:fix/nurse-gopd-save-error-message

Conversation

@Aarti-panchal01

Copy link
Copy Markdown
Member

📋 Description

JIRA ID:

Pairs with PSMRI/HWC-API#211, which makes generalOPD/save/nurseData return real HTTP status codes instead of always 200.

Once that lands, a failed General OPD nurse save comes back as HTTP 500 with the usual {statusCode, errorMessage, status} body. Angular routes that to the subscriber's error callback. That callback passed the whole HttpErrorResponse to confirmationService.alert(), so the nurse saw an error dialog reading [object Object].

The error callback in submitNurseGeneralOPDVisitDetails now shows err.error.errorMessage. If the body has no message (for example, Spring's default error body from an uncaught exception), it falls back to the existing common.unableSave translation, which is present in English, Hindi, Kannada and Assamese. The success-path res.statusCode === 200 check is unchanged.

Merge order does not matter. HWC-UI now handles both response shapes:

Forced logout is unaffected. Session errors (5002, or the Redis session message) are written as HTTP 200 by HWC-API's HTTPRequestInterceptor.preHandle, before the controller runs. JwtUserIdValidationFilter already returns a real 401. #211 doesn't touch either path, and toStringWithHttpStatus() never emits 401 or 403, so HttpInterceptorService sees the same statuses as before.

Scope: only the save/nurseData callback. The same alert(err, 'error') pattern exists in other callbacks in this component, including the General OPD doctor save (save/doctorData) and update (update/doctorData). They're left alone because #211 only converts save/nurseData. They should change together with their backend endpoints.


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

How this was tested:

  • ng build --configuration=production (AOT) passes.
  • ESLint (the repo's .eslintrc.json, including prettier/prettier) is clean on the changed file, and the husky lint-staged eslint --fix hook passed on commit.
  • ng test cannot run on main today. The spec bundle fails to compile with 119 TypeScript errors in existing spec files and mocks (search.component.spec.ts, vitals.component.spec.ts, examination.component.spec.ts, and others), plus a duplicate getUserId key in environment.test.ts. I checked this branch and untouched main: both give the same 119 errors, and none of them are in workarea.component.ts. workarea.component.ts has no spec file.
  • Not exercised against a running backend.

🤖 Generated with Claude Code

The error callback for saveNurseGeneralOPDDetails passed the whole
HttpErrorResponse to the alert dialog, which rendered [object Object].
Show err.error.errorMessage instead, falling back to common.unableSave.

Pairs with PSMRI/HWC-API#211, which makes save/nurseData return real
HTTP status codes. The success-path statusCode check is unchanged, so
both response shapes work and merge order does not matter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 99d24d8c-f129-4caf-8f4a-74463758a280

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant