Skip to main content

Data Flow

medOS-ultra separates the write path (operational, strongly consistent, Mongo) from the read path (projected, eventually consistent, Supabase).

Write path

  1. Frontend POSTs to the gateway.
  2. Gateway authenticates the JWT and forwards the Moleculer action.
  3. The owning microservice validates, writes to MongoDB, emits a Moleculer event.
  4. The event is consumed by any interested service (e.g. foundation, messaging, public-api).

Projection path

  1. A change stream / Moleculer event fans out to the projector.
  2. A Supabase edge function (fhir-subscription-matcher, family-feed-projector, etc.) writes to the read-model table.
  3. Frontend subscriptions receive the realtime patch.

Read path

  1. Frontend calls a Supabase read endpoint (RLS-gated) — fast, cached, realtime.
  2. 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

EventEmitterPurpose
patient.registeredadministrationTriggers welcome SMS, chart init
encounter.createdclinicalKicks off worklist + FHIR subscription
medication.administeredmedicationUpdates MAR + Kardex read models
lab.result.readydiagnosticNotifies clinician via Socket.IO
claim.submittedfinancialPushes to NHSO / PhilHealth / Kaigo