ADR-0043: Ghasi e-prescribing gateway — Bounded context and FHIR contract
Status: Accepted
Date: 2026-04-04
Decision Makers: Platform Architect, Clinical/Pharmacy Leads
Affected Components: e-prescribing-gateway (Ghasi e-prescribing gateway), fhir-gateway (generic FHIR R4 edge — distinct role), pharmacy, ehr-web (prescribing/chart), Kong routes (/v1/ghasi-e-prescribing-gateway, /fhir/R4), audit pipeline
Canonical overview: GHASI_EPRESCRIBING_GATEWAY.md
Related: GHASI_EPRESCRIBING_GATEWAY.md, specs/modules/ghasi-e-prescribing-gateway/ARCHITECTURE_BASELINE.md, specs/modules/pharmacy/, gan-harness/spec.md
Context
Ghasi needs a national / enterprise e-prescribing gateway that connects prescriber-side systems (EMRs, EHRs, and other health provider platforms) with pharmacies. The first integration is Ghasi EHR and Ghasi Pharmacy; the same gateway must scale to third-party systems.
The platform exposes a standard FHIR R4 API via fhir-gateway so external partners can integrate with Ghasi EHR clinical domains; that service does not implement national medication routing, subscription SLAs, or gateway-mediated tenancy for prescribe–dispense — it routes FHIR to owning services (see GHASI_EPRESCRIBING_GATEWAY.md §2).
Requirements for the Ghasi e-prescribing gateway: multi-tenant routing, OAuth2/mTLS B2B clients, AuditEvent-aligned logging, store-and-forward for unreliable links, FHIR Subscriptions for status to connected systems, idempotency and version/conflict rules, and alignment with HL7 FHIR, IHE-style audit, WHO-oriented medication safety — without adopting NCPDP SCRIPT or other U.S.-exclusive licensed standards as the mandatory path.
Decision
- Introduce a dedicated e-prescribing bounded context implemented as
e-prescribing-gateway(product name: Ghasi e-prescribing gateway) responsible for cross-tenant routing, profile validation at the medication workflow boundary, idempotency and correlation, subscription delivery, and enforcement of who may transition which resource — rather than folding all of that intofhir-gateway.fhir-gatewayremains the general FHIR edge; medication resources on/fhir/R4remain routed per domain ownership (e.g.pharmacy). National e-prescribing traffic uses/v1/ghasi-e-prescribing-gatewayande-prescribing-gateway(GHASI_EPRESCRIBING_GATEWAY.md §2.1). - Standardize the public API contract on FHIR R4 for national IGs and tooling; allow R5 only where a jurisdiction explicitly requires it, with translation at the edge if needed.
- Use FHIR
Subscriptionas the normative notification contract; implement the channel as HTTPS with signed payloads, replay protection, and retries (webhook-shaped). Clients must tolerate at-least-once delivery and deduplicate on business/correlation identifiers. - Ownership: Prescriber-side authors and revises
MedicationRequest(create/update/cancel per policy). Pharmacy authorsMedicationDispenseand fulfills; it does not silently overwrite prescriber intent.MedicationRequest.statuschanges driven by fulfillment are applied only via explicit policy,Task, or prescriber-side action, withProvenancewhere required. Gateway enforces scopes (e.g. prescriber client cannot writeMedicationDispense; pharmacy cannot cancel orders without the allowed workflow). - Concurrency: clients use ETag /
If-Match(or equivalent) on writes; gateway returns 412/409 with enough context for clinical products to reconcile or open aTask.
Consequences
Positive: Clear test surface (contract tests prescriber↔gateway, pharmacy↔gateway); independent scaling of notification and queue workloads; consistent audit and tenancy at the medication hop; aligns with international order vs dispense FHIR patterns.
Negative: Another deployable to operate; duplication risk if validation logic is not shared via libraries — mitigate with shared FHIR validation/IG packages. Persistence: see ADR-0044 (e-prescribing-gateway stores authoritative interop copies; clinical owners remain EHR/Pharmacy products).
Rejected alternatives
| Alternative | Why rejected |
|---|---|
| SCRIPT as default | U.S.-centric licensing and semantics; not the international baseline. |
Only extend fhir-gateway | Medication workflow, queues, and subscription SLAs differ from generic FHIR proxy concerns; coupling risks slower releases and unclear ownership. |
| Ad-hoc webhooks without Subscription model | Harder to align with FHIR auditability and one contract for both first-party apps. |