Skip to main content

Medication Service — Event Schemas

Status: populated Owner: TBD Last updated: 2026-04-17 Companion: Service Template · Naming · 04 Event-driven

1. Envelope

All events use the platform EventEnvelope (CloudEvents v1.0). Subject pattern: medication.{aggregate}.{event}.v{N}.

2. Events Produced

SubjectvRetentionAggregateTrigger
medication.prescription.drafted.v1130dPrescriptionDraft created
medication.prescription.signed.v112yPrescriptionSign success
medication.prescription.discontinued.v112yPrescriptionDiscontinue
medication.prescription.held.v1190dPrescriptionHold
medication.prescription.resumed.v1190dPrescriptionResume
medication.alert.overridden.v117yAlertOverrideOverride recorded
medication.dispensing.completed.v117yDispensingEventDispense success
medication.dispensing.partial.v117yDispensingEventPartial dispense
medication.dispensing.returned.v117yDispensingEventReturn
medication.controlled_substance.dispensed.v1110yDispensingEventSchedule II–V dispense
medication.administration.recorded.v112yMARAdmin event
medication.reconciliation.completed.v112yReconciliationSessionSession complete
medication.inventory.stock_received.v112yStockItemGRN
medication.inventory.reorder_alert.v1190dStockItemBelow reorder point
medication.inventory.expiry_alert.v1190dStockItemExpiry horizon
medication.inventory.recall_triggered.v117yStockItemLot recalled
medication.fulfillment.queued.v1130dPrescriptionMR ingested from gateway

Example — medication.prescription.signed.v1

{
"specversion": "1.0",
"type": "medication.prescription.signed.v1",
"source": "ghasi/medication-service",
"id": "evt_01HX...",
"time": "2026-04-17T09:12:31Z",
"tenantid": "ten_...",
"actorid": "usr_...",
"correlationid": "corr_...",
"data": {
"prescriptionId": "rx_01HX...",
"patientId": "pat_...",
"medicationCode": "RxNorm|197361",
"medicationDisplay": "Amoxicillin 500 MG Oral Capsule",
"dose": { "amount": 500, "unit": "mg" },
"route": "oral",
"frequency": "TID",
"durationDays": 7,
"quantity": 21,
"quantityUnit": "capsule",
"refillsAuthorized": 0,
"isControlled": false,
"signedAt": "2026-04-17T09:12:30Z",
"prescriberId": "usr_...",
"overrides": []
}
}

Example — medication.dispensing.completed.v1

{
"type": "medication.dispensing.completed.v1",
"data": {
"dispenseId": "dsp_...",
"prescriptionId": "rx_...",
"patientId": "pat_...",
"dispensedQuantity": 30,
"quantityUnit": "tablet",
"stockItemId": "stk_...",
"lotNumber": "LOT-2026-04",
"expiryDate": "2027-12-31",
"pharmacistId": "usr_...",
"counterSignId": null,
"isPartial": false,
"gatewayMedicationDispenseFhirId": "MedicationDispense/..."
}
}

3. Events Consumed

SubjectProducerPurpose
orders.medication_request.activated.v1orders-serviceSeed medication list on CPOE activation
eprescribing.medication_request.created.v1ghasi-eprescribing-gateway-serviceInbound Rx from external prescriber
eprescribing.medication_request.updated.v1ghasi-eprescribing-gateway-serviceUpdates to ingested Rx
patient-chart.allergy.updated.v1patient-chart-serviceInvalidate cached allergy checks
tenant.formulary.updated.v1tenant-serviceReload formulary cache

4. Legacy Event Mapping

Legacy shorthandLegacy subjectNew subject
med.order.createdMEDICATION.medication.prescribedmedication.prescription.drafted.v1
med.order.signedMEDICATION.medication.signedmedication.prescription.signed.v1
med.order.discontinuedMEDICATION.medication.discontinuedmedication.prescription.discontinued.v1
med.alert.overriddenMEDICATION.alert.overriddenmedication.alert.overridden.v1
PHARMACY.dispensing.completedsamemedication.dispensing.completed.v1
PHARMACY.inventory.*samemedication.inventory.*.v1
PHARMACY.controlled-substance.dispensedsamemedication.controlled_substance.dispensed.v1

Dual-publish window: M2 — both subjects emitted; consumers migrate. Legacy subjects retired in M3.

5. Dead-Letter Handling

  • Failed consumer deliveries (inbound gateway events) → DLQ medication.ingestion.dlq with 5-retry policy (exponential backoff, max 2h).
  • Failed outbound publishes → outbox stays, OutboxRelay retries; oldest-event alert at 10min.