feat(fhir): NASS-1868: Lab request rejected status#9128
feat(fhir): NASS-1868: Lab request rejected status#9128
Conversation
When SENAITE rejects a sample, it sends a FHIR diagnostic report with status 'cancelled'. This change introduces a new 'rejected' status to distinguish rejected samples from cancelled ones. Changes: - Add REJECTED status constant to lab request statuses - Map FHIR cancelled status to Tamanu rejected status - Update UI to display and handle rejected status appropriately - Update tests to expect rejected instead of cancelled - Add rejected to hidden statuses and status change exclusions Co-authored-by: Thomas Codling <tcodling@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Summary of ChangesHello @tcodling, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the lab request management system by introducing a distinct Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly introduces a new REJECTED status for lab requests, mapping it from the FHIR cancelled status. The changes are consistently applied across constants, backend logic, UI components, and tests. The implementation is solid, but I have one minor suggestion to improve code maintainability in the LabRequestChangeStatusModal component.
|
bugbot run |
|
Android builds 📱
|
🍹
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: New REJECTED status missing from FHIR ServiceRequest mapping
- Added REJECTED status case to statusFromLabRequest function to map it to FHIR_REQUEST_STATUS.REVOKED alongside other revoked statuses.
Or push these changes by commenting:
@cursor push c1e88aa7e4
Preview (c1e88aa7e4)
diff --git a/packages/database/src/utils/fhir/ServiceRequest/getValues.ts b/packages/database/src/utils/fhir/ServiceRequest/getValues.ts
--- a/packages/database/src/utils/fhir/ServiceRequest/getValues.ts
+++ b/packages/database/src/utils/fhir/ServiceRequest/getValues.ts
@@ -238,6 +238,7 @@
case LAB_REQUEST_STATUSES.PUBLISHED:
return FHIR_REQUEST_STATUS.COMPLETED;
case LAB_REQUEST_STATUSES.CANCELLED:
+ case LAB_REQUEST_STATUSES.REJECTED:
case LAB_REQUEST_STATUSES.INVALIDATED:
case LAB_REQUEST_STATUSES.DELETED:
return FHIR_REQUEST_STATUS.REVOKED;
Changes
This PR introduces a new
REJECTEDstatus for lab requests in Tamanu.Previously, when a sample was rejected in SENAITE, the FHIR diagnostic report with
cancelledstatus would map toCANCELLEDin Tamanu. Now, thiscancelledFHIR status will map to the newREJECTEDstatus in Tamanu.Key changes include:
REJECTEDtoLAB_REQUEST_STATUSESwith a red color.FhirDiagnosticReportto map FHIRcancelledstatus to TamanuREJECTED.REJECTEDin the list of hidden statuses in theLabRequestView.REJECTEDstatus in theLabRequestChangeStatusModalas it's an externally set status.Deploys
Tests
Remember to...
Linear Issue: NASS-1868
Note
Medium Risk
Introduces a new domain status and changes FHIR↔︎Tamanu status mapping, which can impact downstream workflows and UI filtering if any code paths still assume
cancelledis the only terminal state. Coverage is improved via updated materialisation tests, reducing regression risk.Overview
Introduces a new lab request terminal status
REJECTED(label + red status config) alongside existingLAB_REQUEST_STATUSES.FHIR materialisation logic now maps
DiagnosticReport.status = cancelledtoLAB_REQUEST_STATUSES.REJECTED(instead ofCANCELLED), andREJECTEDis treated asServiceRequest.status = revokedwhen exposing lab requests as FHIRServiceRequest.Web UI updates hide
REJECTEDlab requests like other terminal states and prevents manually selectingREJECTEDin the change-status modal (keeping it externally driven). Tests are updated to reflect the new mapping.Written by Cursor Bugbot for commit 9ee475a. This will update automatically on new commits. Configure here.