Ghasi e-Prescribing Gateway Service — Event Schemas
Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template · 03 platform-services · 02 DDD
Events Produced
All events use CloudEvents v1.0 envelope with mandatory extensions: tenantid, actorid, correlationid, prescriptionbusinessid.
| Event type (NATS subject) | Version | Retention class | Trigger |
|---|---|---|---|
eprescribing.medication_request.created.v1 | v1 | clinical — 10 years | MR persisted and routed |
eprescribing.medication_request.updated.v1 | v1 | clinical — 10 years | MR status/fields changed |
eprescribing.medication_request.cancelled.v1 | v1 | clinical — 10 years | MR cancelled |
eprescribing.medication_dispense.created.v1 | v1 | clinical — 10 years | MD accepted by gateway |
eprescribing.medication_dispense.updated.v1 | v1 | clinical — 10 years | MD status/quantity updated |
eprescribing.task.status_changed.v1 | v1 | clinical — 10 years | Renewal/clarification task state change (P1) |
eprescribing.subscription.delivery_failed.v1 | v1 | ops — 90 days | After retry exhaustion → DLQ |
eprescribing.subscription.replayed.v1 | v1 | ops — 90 days | Manual replay triggered |
Events Consumed
| Event type | Source service | Purpose |
|---|---|---|
identity.user.deactivated.v1 | identity-service | Check if prescriber is deactivated (alert) |
registration.patient.registered.v1 | registration-service | Async patient validation (non-blocking) |
Payload Schemas
eprescribing.medication_request.created.v1
{
"specversion": "1.0",
"type": "eprescribing.medication_request.created.v1",
"source": "https://platform.ghasi.health/services/ghasi-eprescribing-gateway-service",
"id": "evt_01...",
"time": "2026-04-18T10:00:00Z",
"tenantid": "ten_01...",
"actorid": "svc_ehr_01...",
"correlationid": "req_01...",
"prescriptionbusinessid": "prx_01...",
"datacontenttype": "application/json",
"data": {
"medicationRequestId": "mr_01...",
"prescriptionBusinessId": "prx_01...",
"tenantId": "ten_01...",
"patientId": "pat_01...",
"prescriberId": "prac_01...",
"targetPharmacyOrgId": "org_01...",
"medicationCode": { "system": "http://www.whocc.no/atc", "code": "J01CA01" },
"status": "active",
"authoredOn": "2026-04-18",
"etag": "W/\"a3f9...\"",
"routingEnvelope": {
"targetOrgId": "org_01...",
"targetEndpointId": "ep_01...",
"region": "AFG"
}
}
}
eprescribing.medication_dispense.created.v1
{
"data": {
"medicationDispenseId": "md_01...",
"medicationRequestId": "mr_01...",
"prescriptionBusinessId": "prx_01...",
"tenantId": "ten_01...",
"patientId": "pat_01...",
"pharmacistId": "prac_pharm_01...",
"dispensedQuantity": { "value": 30, "unit": "tablet" },
"status": "completed",
"whenHandedOver": "2026-04-20T14:00:00Z",
"etag": "W/\"b2c8...\""
}
}
eprescribing.subscription.delivery_failed.v1
{
"data": {
"subscriptionId": "sub_01...",
"tenantId": "ten_01...",
"endpointUrl": "https://pharmacy.example.com/webhooks/...",
"eventType": "eprescribing.medication_request.created.v1",
"resourceId": "mr_01...",
"prescriptionBusinessId": "prx_01...",
"attemptCount": 5,
"lastError": "connection refused",
"firstAttemptAt": "2026-04-18T10:00:05Z",
"dlqEnqueuedAt": "2026-04-18T10:30:00Z"
}
}
NATS JetStream Configuration
| Stream | Subjects | Retention | Max age | Replicas |
|---|---|---|---|---|
EPRESCRIBING_EVENTS | eprescribing.> | limits | 10 years (clinical), 90 days (ops) | 3 |
EPRESCRIBING_DLQ | eprescribing.dlq.> | workqueue | 90 days | 3 |
Consumer groups:
pharmacy-service—eprescribing.medication_request.created.v1,eprescribing.medication_request.updated.v1orders-service—eprescribing.medication_dispense.created.v1,eprescribing.medication_dispense.updated.v1population-health-service— all clinical eventsaudit-service— all events (audit trail)