Skip to main content

Orders Service — Domain Model

Status: populated Owner: TBD Last updated: 2026-04-18 Companion: Service Template

1. Aggregate Roots

1.1 Order

The central aggregate. Represents a single clinical order of any type.

ID prefix: ord_

Order types:

  • medication → FHIR MedicationRequest
  • laboratory → FHIR ServiceRequest (category: laboratory)
  • radiology → FHIR ServiceRequest (category: imaging)
  • procedure → FHIR ServiceRequest (category: procedure)
  • referral → FHIR ServiceRequest (category: referral)
  • nursing → FHIR ServiceRequest (category: nursing)
  • diet → FHIR NutritionOrder
  • activity → FHIR ServiceRequest (category: activity)

Invariants:

  1. patientId must reference an active, non-deceased registered patient.
  2. encounterId is required for all order types (orders must be encounter-bound).
  3. orderedBy must hold a role with order entry permission for the order type.
  4. CDS checks must complete before an order transitions from draft to active. A CDS hard-stop blocks activation; warning allows activation with acknowledgement.
  5. A cancelled or completed order cannot be reactivated.
  6. Optimistic locking: version field required on all mutations.
  7. Tenant isolation enforced at DB level via RLS.
  8. Idempotency-Key / clientMutationId prevents duplicate order creation.

State machine:

FHIR status mapping: draftdraft, activeactive, on-holdon-hold, completedcompleted, cancelledrevoked, entered-in-errorentered-in-error.


1.2 OrderSet

A named template containing a pre-defined collection of order parameters that can be instantiated as a batch.

ID prefix: ords_

Invariants:

  1. An OrderSet must contain at least one order template.
  2. OrderSet templates are tenant-scoped but may be flagged as global (read-only system-wide templates).
  3. Instantiation creates one Order aggregate per template entry.

2. Entities

EntityDescriptionID prefix
OrderAggregate root; single clinical orderord_
OrderSetTemplate collection for batch order creationords_
CdsAlertCDS check result attached to an ordercds_
OrderNoteClinical note appended to an orderon_

3. Value Objects

Value ObjectFieldsNotes
OrderCodesystem, code, displaySNOMED CT for procedures; RxNorm/ATC for medications
MedicationDetailmedicationCode, dose, doseUnit, route, frequency, durationDays, prnMedication-specific fields
LabDetailspecimenType, priority (routine/urgent/stat), fastingRequiredLaboratory-specific fields
RadiologyDetailmodality, region, laterality, contrastRequiredRadiology-specific fields
ReferralDetailreferralType (internal/external), referToFacilityId, referToSpecialty, urgency, clinicalSummaryReferral-specific fields
CdsSeveritylevel (info/warning/hard-stop), message, ruleIdCDS alert severity
OrderPriorityroutine/urgent/stat/asapOrder priority

4. Domain Events

EventTriggerKey payload fields
clinical.orders.order.createdOrder created in draftorderId, patientId, orderType, encounterId, orderedBy
clinical.orders.order.activatedOrder transitions to activeorderId, patientId, orderType, cdsAlerts[]
clinical.orders.order.completedOrder fulfilled by downstreamorderId, patientId, orderType, completedAt
clinical.orders.order.cancelledOrder cancelledorderId, patientId, cancelReason, cancelledBy
clinical.orders.order.on-holdOrder placed on holdorderId, patientId, holdReason
clinical.orders.referral.createdReferral order activatedorderId, patientId, referralDetail, referToFacilityId
clinical.orders.order.correctedOrder entered-in-errororderId, patientId, correctionReason

5. Consumed Events

EventSource servicePurpose
REGISTRATION.patient.vital-status-changed.v1registration-serviceBlock new orders for deceased patients
REGISTRATION.allergy.recorded.v1registration-serviceRefresh allergy cache for CDS checks
SCHEDULING.appointment.fulfilled.v1scheduling-serviceTrigger completion of associated referral orders

6. Ubiquitous Language

TermDefinition
CPOEComputerised Physician Order Entry — electronic entry of clinician orders
OrderA clinical instruction to perform a service, administer a medication, or refer a patient
Order typeThe classification of an order: medication, laboratory, radiology, procedure, referral, nursing, diet, activity
CDSClinical Decision Support — automated checks applied at order entry
Hard-stopA CDS alert that prevents order activation until clinically resolved
WarningA CDS alert that can be acknowledged and overridden by an authorized clinician
Order setA named template of grouped orders that can be instantiated together
ReferralAn order type directing a patient to another provider or facility
RequisitionLegacy term for laboratory or radiology order; replaced by laboratory and radiology order types per ADR-0046
Encounter-boundEvery order must be associated with an active encounter