Guides
Emergency
ER triage, boarding, and disposition — the third specialty kiosk.
Two parts:
- Part A — Business level. What ER staff are responsible for, what the screen looks like when they sign in, and how the day flows.
- Part B — Technical level. What the routes, components, RBAC, and APIs do under the hood.
Companion docs: docs/ICU_GUIDE.md, docs/MATERNITY_GUIDE.md, docs/WORKFLOWS.md, docs/ADMISSIONS_OFFICER_GUIDE.md.
Part A — Business level
A.1 What an Emergency doctor / nurse owns
| Responsibility | Detail |
|---|---|
| ER triage board | The single screen they sign in to. One row per active emergency case, colour-coded by triage level (critical / urgent / standard / non-urgent). Banner shows the four counts. |
| Pending Triage queue | Patients admitted as emergency from Reception who haven’t been triaged yet. Each row has an + Add Triage button that opens the triage form pre-filled with the admission. |
| Patient chart | A popup that opens when they click a patient name. Holds Triage snapshot, Vitals, Allergies, Conditions, Nursing Assess., Medications, Lab/Imaging Orders, Results, Care Plans, Consents. |
| Recording observations | They can add new vitals, allergies, conditions, and nursing assessments directly from the chart popup. Vitals form has a GCS chip alongside the standard BP/HR/Temp/SpO2/RR/Pain. |
| Placing orders | The + Order button on each row opens Quick Orders (Prescription / Lab / Imaging). Pharmacy / Laboratory / Radiology are notified but invisible to the ER clinician. |
| Disposition | Three transfer buttons on each row: To ICU, To Operation, To Ward. Each opens a structured handoff form (severity for ICU, surgery type for OR, ward type for stepdown). |
| Discharge | Removing the case (or transferring out) ends the ER encounter. |
A.2 What they cannot do
The Emergency shell is intentionally narrow — kiosk-style, like ICU and Maternity:
- No sidebar, no global navigation, no dashboard.
- No access to lab, pharmacy, radiology, billing, HR, or admissions screens.
- No access to other wards (ICU, Maternity, Operations) — except through the structured transfer buttons on a case row.
- No access to patients who are not on the ER board.
Forbidden URLs land on the standard Forbidden page.
A.3 What the screen looks like
When an emergency doctor or nurse logs in:
┌──────────────────────────────────────────────────────────────────────────────┐
│ M Mando · Emergency [ Emergency ] 🔔 Dr. Karim Nasr ┄ │
├──────────────────────────────────────────────────────────────────────────────┤
│ │
│ ● Emergency Department + New Emergency Case │
│ 3 active cases — Triage board overview │
│ │
│ ┌ Critical (1) ┐ ┌ Urgent (1) ┐ ┌ Standard (1) ┐ ┌ Non-Urgent (0) ┐ │
│ │
│ ⏱ Pending Triage (1) │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ Maria Garcia Room 12 · Dr. Karim N [ + Add Triage ] │ │
│ └──────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌ critical ─ John Smith ─ Dr. Karim N ─ [ critical ] [ ambulance ] ┐ │
│ │ Chief: Chest pain, dyspnoea │ │
│ │ Vitals: BP 92/58 · HR 110 · Temp 38.9 · SpO2 88% │ │
│ │ AVPU: alert │ │
│ │ ───────────────────── [To ICU] [To Operation] [To Ward] [+ Order]│ │
│ └────────────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────┘
Top bar: brand → single static tab “Emergency” → notification bell → user pill → Sign out.
A.4 The day, end to end
- Sign in. The system bounces them straight to
/emergency. No dashboard. - Read the board. Four triage-level cards at the top show counts. Pending-triage queue under that. Triaged cases under that.
- Triage a pending patient. Click + Add Triage → modal opens pre-filled with the admission. Fill chief complaint, AVPU, vitals, triage level, arrival mode, trauma type, current meds, allergies. Save → case appears on the board.
- Click the patient name. The chart popup opens with 11 cards: Triage, Vitals, Allergies, Conditions, Nursing Assess., Medications, Lab Orders, Imaging Orders, Results, Care Plans, Consents. Each card shows a count.
- Click “Triage”. Read-only snapshot: chief complaint, arrival mode, AVPU, stabilized-at, trauma type, free-text vitals/allergies/meds (the values entered in the triage form), notes. Banner highlights critical or trauma cases. The chart’s bottom hint reminds the user that editing the triage record happens on the board (Edit / To ICU / To Operation / To Ward) and that structured vitals belong in the Vitals card.
- Click “Vitals” → + Add. Form has seven chips: BP, HR, Temp, SpO2, RR, GCS, Pain. Click a chip → fields pre-fill → type the value → Save.
- Click “Allergies / Conditions / Nursing Assess.” → + Add. Same flow. The Nursing Assess. dropdown adds ER-specific types (GCS, ESI re-triage, Trauma primary survey) alongside the shared ones.
- Place an order. Close the chart, click
+ Orderon the row. Three tabs: Prescription, Lab, Imaging. Submit → Pharmacy / Lab / Radiology gets the alert; the ER clinician sees nothing about who’s working on it until the result shows up under Results. - Disposition. When the case is ready to leave the department:
- To ICU → opens the ICU handoff form (severity, ventilator mode, O2 flow, IV lines, isolation, diet…). Submitting creates an ICU detail and moves the patient.
- To Operation → opens the OR handoff form (surgery type, procedure, anaesthesia, anaesthesiologist, scheduled time, room, pre-op diagnosis & instructions). Submitting books the case.
- To Ward → opens the ward handoff form (wing, room, ward type, bed, attending nurse, care plan).
- Discharge / delete. If the case was a quick treat-and-release, just delete the record after the patient leaves. The admission record stays.
A.5 Notifications
Inbound (the bell flashes):
- New emergency admission landed on the wing — fired by the Reception / Admissions Officer at admit time. The patient appears in the Pending-Triage queue.
- Stat lab or imaging result finalised on one of their patients (planned).
Outbound (they create them implicitly):
- Placing a Lab order → Laboratory.
- Placing an Imaging order → Radiology.
- New prescription → MAR / pharmacy queue.
- To ICU / To Operation / To Ward transfers each fire department alerts to the receiving team (ICU staff, OR coordinator, ward charge nurse).
A.6 Common pitfalls
- “I want to update the triage level.” Close the chart, click Edit on the row.
- “I just admitted a patient — why aren’t they on the board?” They are, but in the Pending Triage strip near the top. Use + Add Triage to get them onto the main triage board. The chart’s Triage card is empty until you do this.
- “I tried to open the lab page and got Forbidden.” Correct — ER staff place orders but never browse lab/pharmacy/radiology. Use
+ Orderon the row. - “The patient I’m looking for isn’t here.” They aren’t admitted to Emergency. Reception admits patients with admission_type =
emergency— until that happens, the patient won’t appear on this board. - “I want to transfer to two places.” A patient can only have one disposition at a time. If the case turns: pick the right destination based on current state, do the handoff, and start a new case if they re-present.
Part B — Technical level
B.1 Identity & ward shell
A user is treated as an “Emergency ward user” when all of these are true:
users.roleisdoctorornurse.users.department(case-insensitive, trimmed) is one of:emergency,er,emergency medicine,trauma surgery.
This list lives in AppRoot.WARD_CONFIG.emergency.depts and matches WARD_NAV in frontend/src/services/role-permissions.js.
Shell decision is generic — AppRoot.wardForUser(user) returns the ward key ('icu' / 'maternity' / 'emergency') or null. When non-null, app-root.js:
- Sets the post-login home to
#/<wardRoute>(skips/dashboard). - Bounces any
#/dashboardhit back to the ward route. - Renders
renderWardShell(wardKey)instead of the sidebar shell. Brand label, tab label, and embedded page tag come fromWARD_CONFIG[wardKey]. For emergency the slot hosts<emergency-page>directly. renderWardPage(wardKey)switches on the key and returns the right page element.
B.2 Seed data
Four ward-doctor logins are created idempotently on every boot by ensureWardDoctors. For Emergency:
- email:
emergency.doctor@hospital.com - password:
admin123 - name: Dr. Karim Nasr
- department:
Emergency - role:
doctor
Idempotency: users.email UNIQUE → ON CONFLICT (email) DO NOTHING for users; INSERT … WHERE NOT EXISTS for the matching doctors row.
Nurses are seeded the same way once a user record with role='nurse' and department='Emergency' is created (no nurse seed today — add via /hr or /users).
B.3 RBAC
Backend (path-based middleware): the doctor and nurse role permission tables in backend/internal/middleware/roles.go do not include lab, pharmacy, pharmacy-dispense, radiology, general-inventory. They allow prescriptions, service-requests, diagnostic-reports, imaging-studies, observations, allergies, conditions, nursing-assessments, care-plans, consents, plus the ward routes (icu, emergency, maternity, operations).
Frontend: getNavigationForUser(user) in frontend/src/services/role-permissions.js narrows frontDesk to ['emergency'] for any doctor/nurse whose department resolves to emergency.
B.4 Emergency board
frontend/src/pages/emergency-page.js — unchanged in shape, plus the chart wiring:
loadData()callsGET /api/emergency-details,GET /api/admissions?...&type=emergency,GET /api/wingsin parallel.- Triage segment cards (
critical / urgent / standard / non-urgent) at the top. - “Pending Triage” strip lists admissions whose
idis not yet present in any emergency_details row. Each row has an + Add Triage button that opens the triage modal pre-filled. _isWardUsergetter (new) hides the Quick Navigation chip-bar for doctors and nurses, since those chips routed to pages outside their permission set.- Patient name click now calls
openChart(c)→<emergency-patient-chart>.show(emergencyDetailsRecord)instead of the older<patient-encounter-popup>. The popup is still imported and stays available. - Three transfer buttons (
To ICU,To Operation,To Ward) keep their existing modals — the chart does not duplicate that logic.
B.5 Emergency patient chart popup
frontend/src/components/emergency-patient-chart.js is a sibling of icu-patient-chart.js and maternity-patient-chart.js with one extra card. Two views inside one panel:
Grid view (default after show() is called):
- Header:
name • MRN • gender • DOB · arrival_mode · chief_complaint. “All categories” button hidden. - Info bar: gender, DOB, blood type, phone, admission #, triage level pill (colour-coded).
- Body: 11 category cards. Each card has icon + label + hint + count badge.
- Counts are loaded by
loadCounts()— Triage is always 1 (the emergency_details record passed in viashow()); the rest mirror ICU/Maternity.
Detail view (after a card click):
- Triage renders as a single read-only snapshot card (chief complaint, arrival mode, AVPU, stabilized-at, trauma type, free-text vitals/allergies/meds, notes). Critical or trauma cases get a red banner. A tip-banner reminds users that edits happen on the ER board and that structured vitals belong in the Vitals card.
- The remaining 10 categories are identical to ICU and Maternity.
B.6 Categories — list and create endpoints
| Card | List API | Add API | Editable |
|---|---|---|---|
| Triage | passed in via show(emergencyDetails) | (use Edit / To ICU / To Operation / To Ward on the board) | no |
| Vitals | GET /api/observations/patient/:id/vitals | POST /api/observations category: vital-signs | yes |
| Allergies | GET /api/allergies/patient/:id | POST /api/allergies | yes |
| Conditions | GET /api/conditions/patient/:id | POST /api/conditions | yes |
| Nursing Assess. | GET /api/nursing-assessments/patient/:id | POST /api/nursing-assessments | yes |
| Medications | GET /api/prescriptions?patient_id= | (use Quick Orders → Prescription) | no |
| Lab Orders | GET /api/service-requests?patient_id= filter category ~ “lab” | (use Quick Orders → Lab) | no |
| Imaging Orders | same, filter category ~ “rad|imag” | (use Quick Orders → Imaging) | no |
| Results | GET /api/diagnostic-reports?patient_id= | n/a | no |
| Care Plans | GET /api/care-plans?patient_id= | (use the care-plan workflow) | no |
| Consents | GET /api/consents?patient_id= | (use the consents workflow) | no |
For each editable category the chart’s submitAdd(e) method assembles the FHIR-shaped payload and POSTs it. On success it re-fetches the active category and re-runs loadCounts().
B.7 Vitals quick chips
Vitals add form has seven chips. The first six match ICU; the seventh swaps the maternity-specific FetalHR for GCS:
| Chip | code | display | unit |
|---|---|---|---|
| BP | 85354-9 | Blood Pressure | mmHg |
| HR | 8867-4 | Heart Rate | bpm |
| Temp | 8310-5 | Body Temperature | °C |
| SpO2 | 59408-5 | Oxygen Saturation | % |
| RR | 9279-1 | Respiratory Rate | /min |
| GCS | 9269-2 | Glasgow Coma Scale total | (none) |
| Pain | 38208-5 | Pain Severity | 0-10 |
Click chip → code, display, unit pre-fill → user only types the value.
B.8 Quick Orders & disposition workflows
The + Order button opens frontend/src/components/quick-orders.js with source="emergency". Submitting routes to:
| Tab | Endpoint | Receiving alert |
|---|---|---|
| Prescription | POST /api/prescriptions source=emergency | Pharmacy queue |
| Lab | POST /api/service-requests category=laboratory | Laboratory department |
| Imaging | POST /api/service-requests category=radiology | Radiology department |
Disposition stays on the page itself:
- To ICU →
POST /api/emergency-details/:id/transfer-to-icuwith severity, ventilator, O2, vitals, AVPU, IV lines, meds, monitor alerts, isolation, diet. - To Operation →
POST /api/emergency-details/:id/transfer-to-operationwith surgery type, procedure, anaesthesia, anaesthesiologist, scheduled date/time, OR, pre-op diagnosis & instructions. - To Ward →
POST /api/emergency-details/:id/transfer-to-wardwith wing, target room, ward type, bed, attending nurse, care plan. - Edit → updates the emergency_details record itself.
B.9 Build / verification
- Backend:
go build ./...— clean. - Frontend:
npx vite build— 1.42 MB / 221 kB gzip in ~2s.
B.10 Known follow-ups (not done yet)
- Triage edit from inside the chart. Today the chart is read-only on the Triage card; users have to close the popup and click Edit on the row. Worth wiring an inline edit for vitals + AVPU + triage level (the values that change as the patient is reassessed).
- In-chart re-triage assessment. The Nursing Assess. card already supports an
ESItype — surface a one-click “Re-triage” path that pre-fills it. - Critical-result back-alerts on stat labs/imaging. Same gap noted in ICU_GUIDE / MATERNITY_GUIDE.
- Per-patient row-level filter on reads. RBAC is path-based today.
- Apply the same kiosk shell + chart popup pattern to Operations. Last ward remaining.
Last updated: 2026-04-26