fix: include imaging encounters in all outpatient encounter type checks#9503
Open
fix: include imaging encounters in all outpatient encounter type checks#9503
Conversation
- DischargeForm.jsx: use getPatientStatus() !== OUTPATIENT instead of !== CLINIC for discharge diagnosis mandatory check (both locations) - PharmacyOrderModal.jsx: use getPatientStatus() === OUTPATIENT for default prescription type (supersedes #9502) - EncounterActions.jsx: use getPatientStatus() === OUTPATIENT for 'Admit to hospital' condition - TopBar.jsx: add IMAGING to dotColors map with same color as CLINIC - RecentlyViewedPatientsList.jsx: add imaging to colorFromEncounterType map - EditEncounterModal.jsx: add IMAGING as fallthrough to CLINIC in FormFields and getFormInitialValues - PatientListingView.jsx: pass both CLINIC and IMAGING encounter types for outpatient recently-viewed list - user.js backend: support array of encounter types using IN clause (backward compatible) Agent-Logs-Url: https://github.com/beyondessential/tamanu/sessions/d109dd8c-a51f-4caa-be6c-14817bff86bc Co-authored-by: passcod <155787+passcod@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix UI logic for handling encounter categories
fix: include imaging encounters in all outpatient encounter type checks
Apr 3, 2026
Copilot stopped work on behalf of
passcod due to an error
April 3, 2026 03:35
Member
|
That all LGTM but I'll get someone from Tamanu UX to review for intent. |
|
🦸 Review Hero Summary No issues found. Looks good! Below consensus threshold (2 unique issues not confirmed by majority)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UI behaviour and logic throughout the codebase was gating on
ENCOUNTER_TYPES.CLINICwhen the intent was to match the outpatient category — which also includesENCOUNTER_TYPES.IMAGING. The canonical mapping ingetPatientStatus.jsalready treats both asPATIENT_STATUS.OUTPATIENT, but many callsites bypassed it.Changes
DischargeForm.jsx(×2) —dischargeDiagnosisMandatorynow usesgetPatientStatus(encounterType) !== PATIENT_STATUS.OUTPATIENTinstead of!== ENCOUNTER_TYPES.CLINICPharmacyOrderModal.jsx— Default prescription type usesgetPatientStatus() === PATIENT_STATUS.OUTPATIENT(supersedes fix(web): use patient status instead of specific encounter type for pharmacy prescription default #9502)EncounterActions.jsx— "Admit to hospital" condition usesgetPatientStatus() === PATIENT_STATUS.OUTPATIENTinstead of=== ENCOUNTER_TYPES.CLINICTopBar.jsx— Added[ENCOUNTER_TYPES.IMAGING]: '#F9BA5B'todotColors(same asCLINIC)RecentlyViewedPatientsList.jsx— Addedimaging: '#E9AC50'tocolorFromEncounterTypeEditEncounterModal.jsx— AddedIMAGINGfallthrough toCLINICin bothFormFieldsswitch andgetFormInitialValues(was rendering error string)PatientListingView.jsx— Outpatient recently-viewed now passes[CLINIC, IMAGING]instead of"clinic"user.js(facility-server) —recently-viewed-patientsfilter changed from= :encounterTypetoIN (:encounterTypes), accepting a single value or array (backward compatible)Auto-Deploy
Options
Tests
Review Hero
Remember to...
Original prompt
Problem
Throughout the codebase, UI behaviour and logic switches on specific hardcoded encounter type values (usually
ENCOUNTER_TYPES.CLINIC) when the actual intent is to check an encounter category (e.g. "outpatient"). This causesimagingencounters — which are also outpatient — to be missed, resulting in incorrect UI behaviour.The codebase already has a canonical source of truth for mapping encounter types to patient statuses in
packages/web/app/utils/getPatientStatus.js:And existing helpers
isInpatient()(inpackages/web/app/utils/isInpatient.js) andisEmergencyPatient()(inpackages/web/app/utils/isEmergencyPatient.js) already use this mapping correctly. But many places bypass these helpers and compare against a single hardcoded type.Fixes Required
1.
DischargeForm.jsx— Discharge diagnosis mandatory skips onlyCLINIC(missesIMAGING)File:
packages/web/app/forms/DischargeForm.jsx(two locations: lines ~420-422 and ~527-529)The current code:
Should be changed to use
getPatientStatusandPATIENT_STATUSto check for outpatient status instead:Both locations need to be fixed. The first is in
EncounterOverviewcomponent and usesencounterTypedirectly. The second is inDischargeFormScreenand usesencounter.encounterType.2.
PharmacyOrderModal.jsx— Default prescription type only checksCLINIC(missesIMAGING)File:
packages/web/app/components/Medication/PharmacyOrderModal.jsx(line ~242)The current code:
Should be changed to:
Also remove the now-unused
ENCOUNTER_TYPESimport if it's no longer needed by other code in this file.3.
EncounterActions.jsx— "Admit to hospital" only allows upgrade fromCLINIC(missesIMAGING)File:
packages/web/app/views/patients/components/EncounterActions.jsx(lines ~153-156)The current code:
The
ENCOUNTER_TYPE_PROGRESSIONmap only includes triage→observation→emergency→admission.CLINICis special-cased as an additional allowed source. ButIMAGINGencounters (also outpatient) can't be admitted to hospital.Should be changed to:
4.
TopBar.jsx—dotColorsmap missingIMAGINGFile:
packages/web/app/components/TopBar.jsx(lines ~47-53)The current code:
Should add
IMAGINGwith the same color asCLINIC:5.
RecentlyViewedPatientsList.jsx—colorFromEncounterTypemissingIMAGINGFile:
packages/web/app/components/RecentlyViewedPatientsList.jsx(lines ~15-22)The current code: