medOS Clinical
Internal scope:
ever-api-clinical— encounters, clinical notes, episode of care, and core clinical records.
medOS Clinical owns the of-record clinical entities at the centre of a patient's
visit: encounters, clinical documentation, episode-of-care linkage, and the
specialised clinical records that hang off them (referrals, medical certificates,
adverse drug reactions, bed-status transitions, and post-anaesthesia care). It
inherits most of its schema from the shared platform-api-schema package and
communicates with the rest of the mesh over NATS as a Moleculer service.
Many status-changing actions publish to the read-model layer so dashboards,
queues, and the encounter journey stay in sync.
Responsibilities
- Encounters & episode of care — the encounter is the unit clinical records attach to; episode-of-care linkage groups encounters into a longitudinal course of treatment.
- Clinical documentation — notes and structured clinical records inherited from shared schemas and exposed through composed services.
- Specialised clinical records — referrals, medical certificates, adverse drug reactions, and perioperative (PACU) handoff and discharge decisions.
- Bed status transitions — a state machine driving admit / transfer / discharge bed movements that feed the bed board read model.
- Scope-of-practice enforcement (AHP) — a server-side trust anchor for the AHP-led care pathway, the authoritative gate between an unlicensed operator and an of-record clinical write.
- Event emission — status changes are published to
hospital_eventsfor the read-model orchestrator to project.
Major modules
| Module | Purpose |
|---|---|
referral | Patient referral lifecycle (create, route, accept) with read-model event emission |
medicalCertificate | Issuance and management of medical certificates, with document numbering |
adverseDrugReaction | ADR recording linked to the encounter, surfaced to the patient record |
bedStatusMachine | Bed-status state machine — admit / transfer / discharge transitions feeding the bed board |
pacuHandoff | Post-anaesthesia care unit (PACU) handoff records and SBAR-style transfer of care |
pacuDischargeDecision | PACU discharge readiness decisions tied to the encounter |
ahp | AHP-led care pathway enforcement (entitlement, red-flag detector, lane-decision gate) |
_sequence | Clinical document / record numbering |
_setting | Per-deployment clinical service configuration |
Most core clinical entities (the encounter and its notes) are exposed through
composed services that pull from the shared platform-api-schema package rather
than from a dedicated module folder in this service.
Read-model events
Status-changing actions across referral, bed-status, ADR, medical certificate, and PACU modules emit to hospital_events so the encounter orchestrator can project department queues and the encounter journey cache.
AHP trust anchor
The ahp module re-makes the lane decision server-side (Lane A capped / Lane B cosign / refer / blocked) — advisory frontend UX is never the gate.
AHP-led care pathway (scope-of-practice gate)
The ahp module is the server-side trust anchor for the AHP-led care pathway
(physician-absent / doctorless clinics). It is a regulated, default-OFF module —
enforcement is enabled only when AHP_CARE_PATHWAY_ENABLED is exactly true.
| Helper | Role |
|---|---|
ahpEntitlement.helper.ts | Backend entitlement check; default-OFF for regulated safety |
redFlagDetector.shared.ts | Deterministic, presentation-based red-flag detector — missing input or evaluation error both escalate |
ahpEnforcement.helper.ts | enforceAhpGate() — re-derives the lane decision (Lane A capped / Lane B cosign / refer / blocked) |
The helpers ship as scaffolding (the hard gate is wired at a later phase before any AHP-led encounter touches a real patient). See the Architecture overview for the broader pattern.
Events & integration
Status-changing actions publish to the hospital_events stream consumed by the
read-model orchestrator. A simplified flow:
Clinical action (referral / bed transition / ADR / PACU / certificate)
│
▼
ever-api-clinical ──emit──► hospital_events
│ │
Mongo write orchestrator
(of record) │
▼
read models (queues, journey cache)
│
▼
frontend realtime subscription
Clinical entities are also mapped to FHIR R4 resources (for example
Encounter, Condition, and Appointment) for external read/write through the
FHIR layer — see FHIR Integration.
Configuration flags
Behaviour is additive and fail-open by default; regulated features such as AHP enforcement must be explicitly turned on per deployment.
Related catalog items
CL-8— Doctor Order Entry (CPOE)CL-11…CL-15— Clinical documentationCL-18…CL-20— DiagnosisCL-25,CL-26— Clinical Dashboard & Summary View