Data Flow
medOS-ultra separates the write path (operational, strongly consistent, Mongo) from the read path (projected, eventually consistent, Supabase).
Write path
- Frontend POSTs to the gateway.
- Gateway authenticates the JWT and forwards the Moleculer action.
- The owning microservice validates, writes to MongoDB, emits a Moleculer event.
- The event is consumed by any interested service (e.g.
foundation,messaging,public-api).
Projection path
- A change stream / Moleculer event fans out to the projector.
- A Supabase edge function (
fhir-subscription-matcher,family-feed-projector, etc.) writes to the read-model table. - Frontend subscriptions receive the realtime patch.
Read path
- Frontend calls a Supabase read endpoint (RLS-gated) — fast, cached, realtime.
- For write-through queries or complex joins, frontend calls the API gateway.
Realtime
Vitals stream
Bedside → messaging service → Socket.IO → nurse station chart.
Projection
Encounter rollup
Encounter aggregates are projected to Supabase every write.
FHIR
Subscription dispatch
Webhook dispatcher wraps events in FHIR Bundles and HMAC-signs them.
fhir_subscriptionsdelivery_logHMACBundle
HL7v2
MLLP ingestion
ADT / ORM / ORU parsed, mapped, and written through the interop service.
MLLP :2575ACK / NAKADT → patient + encounter
Event conventions
| Event | Emitter | Purpose |
|---|---|---|
patient.registered | administration | Triggers welcome SMS, chart init |
encounter.created | clinical | Kicks off worklist + FHIR subscription |
medication.administered | medication | Updates MAR + Kardex read models |
lab.result.ready | diagnostic | Notifies clinician via Socket.IO |
claim.submitted | financial | Pushes to NHSO / PhilHealth / Kaigo |