Skip to main content

Ghasi e-Prescribing Gateway Service — Service Overview

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD

Purpose

The ghasi-eprescribing-gateway-service is the national/enterprise medication interoperability spine of the Ghasi platform. It routes FHIR R4 MedicationRequest and MedicationDispense resources between authorized prescriber systems (Ghasi EHR first, then third-party EMRs) and pharmacy systems (Ghasi Pharmacy first, then external networks). It validates profiles at the interop boundary, enforces role-based write constraints, correlates end-to-end prescription identifiers, delivers reliable Subscription notifications, and maintains a complete HIPAA-equivalent audit trail.

This is the FLAGSHIP cross-tenant interoperability service of the platform. It is architecturally distinct from the generic fhir-gateway — it owns the authoritative interop persistence of medication workflow resources (ADR-0043, ADR-0044).

Kong route: /v1/ghasi-e-prescribing-gateway (direct); also proxied via fhir-gateway /fhir/R4/interop/ghasi-eprescribing/* for first-party services.

Bounded Context Responsibilities

In scopeOut of scope
Authoritative interop persistence of MedicationRequest, MedicationDispenseClinical medication list and MAR (medication-service)
FHIR R4 profile validation (tenant-configured IG packages)Clinical CPOE order lifecycle (orders-service)
Role enforcement: EHR writes MR; Pharmacy writes MD; neither can impersonate the otherPharmacy inventory/ERP (pharmacy-service)
Idempotent create (Idempotency-Key + payload fingerprint)Generic FHIR routing for non-medication resources (fhir-gateway)
ETag / If-Match optimistic concurrency; 412 on staleReal-time insurance adjudication (future adapter)
Subscription notifications (HTTPS, signed, replay-safe)Full national HIE (XCA/XDS/PIX) beyond medication path
DLQ, outbox, retry for reliable deliveryNCPDP SCRIPT (explicitly excluded from mandatory; optional adapter only)
Prescription business identifier correlation across EHR–Gateway–PharmacyClinical CDS (EHR-first; optional passthrough in P4)
Tenant routing rules: preferred pharmacy, fallback, region
Directory APIs: Organization and Endpoint discovery
HIPAA-equivalent audit trail per mutation (AuditEvent + platform audit)
Multi-tenant isolation; per-tenant IG pin

Delivery Phases

PhaseNameStatus
Phase 0Documentation and ADR closureDone
Phase 1First-party vertical slice (Ghasi EHR ↔ Pharmacy)In Progress
Phase 2Enterprise hardening (Task/Directory depth, Redis, HAPI validation)Planned
Phase 3National/third-party onboardingPlanned
Phase 4P2 gated features (bulk export, CDS passthrough, multi-region)Gated

Upstream Dependencies

ServiceWhy
identity-service (Keycloak)JWT validation; B2B client credentials for EHR/Pharmacy backends
orders-service (CPOE)Only first-party service that POSTs MedicationRequest to gateway
medication-serviceReads medication list context; does NOT post MR to gateway
pharmacy-servicePosts MedicationDispense; reads MR via Subscription or GET
fhir-gatewayProxies first-party service calls via interop path
terminology-serviceATC, RxNorm, SNOMED CT coding validation
audit-servicePlatform audit pipeline
provider-directory-serviceOrganization/Endpoint directory for routing

Downstream Dependents

ServiceDependency
pharmacy-serviceReceives MR via NATS events and Subscription; posts MD back
orders-serviceGets ACK/correlation ID from gateway post-MR submit
population-health-serviceAggregate medication prescribing metrics
patient-portal-serviceRead-only projection of patient's prescription history

Key Architectural Decisions

  1. Dual entrypoint (ADR-0043 B1). Direct: Kong /v1/ghasi-e-prescribing-gateway. Via fhir-gateway: /fhir/R4/interop/ghasi-eprescribing/*. First-party services SHOULD use the interop path; B2B integrators may use the direct path.
  2. Authoritative interop persistence (ADR-0044). gepgw_* Postgres tables own the interop copy of MR/MD. EHR remains clinical owner; Pharmacy remains fulfillment owner.
  3. Write ownership enforced at gateway. EHR/orders-service → MR only. Pharmacy-service → MD only. Gateway returns 403 FORBIDDEN_WRITE if wrong actor type.
  4. Profile validation. Tenant-configured IG packages (Zod in MVP; HAPI validator in Phase 2). Validation failure returns 422 OperationOutcome.
  5. FHIR R4 mandatory; NCPDP excluded. International-first. NCPDP SCRIPT is an optional regional adapter in pharmacy-service — not in gateway core.
  6. Outbox-based reliable notifications. Subscription notifications are delivered from the outbox; DLQ + replay for failed deliveries.

Architecture Diagram

Source Reconciliation

Sources: _sources/ghasi-e-prescribing-gateway/. Key files: SPEC.md v1.3, ARCHITECTURE_BASELINE.md, PHASED_IMPLEMENTATION_PLAN.md v2.0, INTEGRATOR_GUIDE.md, P2_STAKEHOLDER_REVIEW.md. Legacy FR prefix FR-RX-* preserved alongside new FR-EPRX-*. ADR-0043 and ADR-0044 are normative co-references.