Skip to content

[EHR] use API Error type for in-house medications and show errors on Frontend#7021

Merged
ValeriyDyachenko merged 5 commits intodevelopfrom
vdyachenko/otr-2130-update-medication-order-zambda-throwing-500-error-when
Apr 15, 2026
Merged

[EHR] use API Error type for in-house medications and show errors on Frontend#7021
ValeriyDyachenko merged 5 commits intodevelopfrom
vdyachenko/otr-2130-update-medication-order-zambda-throwing-500-error-when

Conversation

@ValeriyDyachenko
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes backend error responses for the in-house medication order flow by throwing APIError-shaped errors (instead of generic Error) and updates the EHR frontend to display server-provided error messages when medication updates/deletes fail.

Changes:

  • Backend: replace generic Error throws with INVALID_INPUT_ERROR, MISSING_REQUEST_BODY, and FHIR_RESOURCE_NOT_FOUND_CUSTOM for medication order validation and resource fetching.
  • Frontend: update medication delete/save error handling to surface API-provided error messages to users (when available).
  • Introduce additional “not found” error handling in medication order resource loading.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/zambdas/src/ehr/create-update-medication-order/validateRequestParameters.ts Uses APIError types for request validation failures.
packages/zambdas/src/ehr/create-update-medication-order/index.ts Uses APIError types for invalid state transitions and missing FHIR resources.
packages/zambdas/src/ehr/create-update-medication-order/helpers.ts Uses APIError types for provider/access validation and missing resources.
apps/ehr/src/features/visits/in-person/components/medication-administration/medication-editable-card/EditableMedicationCard.tsx Displays API error messages in snackbars for delete/save failures.
apps/ehr/src/features/visits/in-person/components/medication-administration/mar/MedicationActions.tsx Displays API error messages for MAR delete failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/zambdas/src/ehr/create-update-medication-order/helpers.ts
Comment thread packages/zambdas/src/ehr/create-update-medication-order/index.ts Outdated
@ValeriyDyachenko ValeriyDyachenko merged commit 1bef69f into develop Apr 15, 2026
15 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