Skip to main content

FHIR R4 Integration

medOS supports FHIR R4 read and write operations with subscription-based event delivery. FHIR is the standard for external healthcare exchange; SMART-on-FHIR apps talk to medOS through the public-api service.

R4
FHIR version
HMAC
Signed dispatch
Deno
Matcher runtime
100/min
Default rate limit

Architecture

SMART App ──▶ FHIR Write API ──▶ Moleculer Services ──▶ MongoDB
(external) (public-api) (clinical, admin) │
▲ Moleculer events
│ │
│ fhir-subscription- hospital_events ◀───┘
│ matcher (Deno) (Supabase trigger)
│ │
└──────────────┘ (FHIR Bundle POST, HMAC signed)

Key components

Read

FHIR Read API

GET / search for Patient, Encounter, Observation, Condition.

PatientEncounterObservationCondition
Write

FHIR Write API

POST / PUT / PATCH with reverse mappers → medOS domain models.

POSTPUTPATCH
Subscribe

FHIR Subscriptions

`fhir_subscriptions` + delivery log tables in Supabase.

fhir_subscriptionsdelivery_log
Dispatch

Subscription Matcher

Deno edge function: criteria matching + FHIR dispatch.

Denoedge function
Webhook

Webhook Dispatcher

`payloadFormat: 'fhir'` wraps events in FHIR Bundles, HMAC-signed.

HMACBundle
Meta

CapabilityStatement

GET /fhir/metadata advertising supported resources.

CapabilityStatement
Mappers

Transformers

Bidirectional medOS ↔ FHIR transformers per resource type.

medOS → FHIRFHIR → medOS

File locations

ComponentPath
Read APIservices/public-api/.../modules/fhir/resources/
Write APIservices/public-api/.../modules/fhir/resources/fhir-write.controller.ts
Subscriptions (Supabase)infrastructure/medbase/migrations/021_fhir_subscriptions.sql
Subscription Matcherinfrastructure/medbase/functions/fhir-subscription-matcher/index.ts
Webhook Dispatcherservices/administration/.../webhookDispatcher.service.mixin.ts
CapabilityStatementservices/public-api/.../modules/fhir/fhir-capability.controller.ts
Transformersservices/public-api/.../modules/fhir/transformers/
Admin UIweb/src/common/components/medical/builder/webhooks/FhirSubscription*.tsx
Bundle exportweb/src/utils/fhir-bundle-export.ts

Feature flags

FlagDefaultPurpose
fhir.write.enabledfalseTenant kill switch for FHIR write-back
fhir.subscription.rate_limit100Max dispatches/min per subscription

Bundle export (HealthWallet / ExitPath)

web/src/utils/fhir-bundle-export.ts serialises an IPS-compliant FHIR R4 Bundle for patient handoff — used by the HealthWallet QR export and the ExitPath workflow.