Skip to main content

Scheduling Service — Domain Model

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

1. Aggregates

1.1 AppointmentAggregate

Root aggregate for a single patient appointment.

Invariants

#Invariant
I-APT-01Status transitions must follow the allowed graph (no backward transitions, no arbitrary jumps).
I-APT-02A booked appointment holds an exclusive reference to a Slot; that slot is marked busy.
I-APT-03Double-booking is rejected unless allowDoubleBooking=true is supplied by an authorized role.
I-APT-04Cancelled appointment releases slot back to free.
I-APT-05patientId references a patient in the same tenant (validated against registration-service events).
I-APT-06Optimistic lock version required on status updates, cancellation, and reschedule.

FHIR Status State Machine

1.2 ScheduleAggregate

Governs resource availability windows for a provider, room, or piece of equipment.

Invariants

#Invariant
I-SCH-01A schedule belongs to exactly one actor (provider, location, or device) per tenant.
I-SCH-02Schedule exceptions (blocked windows) override the base availability pattern.
I-SCH-03timezone must be a valid IANA timezone string.

1.3 SlotAggregate

A bookable time window within a Schedule.

Invariants

#Invariant
I-SLT-01status is one of free, busy, blocked, entered-in-error.
I-SLT-02A slot becomes busy atomically when an appointment is confirmed to it.
I-SLT-03A slot cannot overlap with another slot of the same schedule in free or busy state.

1.4 WaitlistEntry

Represents a patient's desire for an appointment type when no slot is available.

State Machine: waitingfulfilled | deleted

2. Entities

EntityAggregateKey attributes
AppointmentActorAppointmentactorType (patient, practitioner, location, device), actorId, required flag
AppointmentResponseAppointmentactorId, participantStatus (accepted/declined/tentative)
ScheduleExceptionSchedulestart, end, reason, type (holiday/maintenance)
ScheduleAvailabilityPatternScheduledays[] with dow, start, end (weekly template)

3. Value Objects

Value ObjectType
AppointmentIdBranded<string, 'AppointmentId'> — UUID
ScheduleIdBranded<string, 'ScheduleId'> — UUID
SlotIdBranded<string, 'SlotId'> — UUID
AppointmentStatusproposed|pending|booked|arrived|fulfilled|cancelled|noshow|entered-in-error
SlotStatusfree|busy|blocked|entered-in-error
AppointmentTypeCoded value (ROUTINE, WALKIN, EMERGENCY, etc.)
ActorTypeprovider|location|device
WaitlistStatuswaiting|fulfilled|deleted

4. Domain Events

NATS SubjectCloudEvents TypeTriggerVersion
SCHEDULING.appointment.createdghasi.scheduling.appointment.createdAppointment booked or portal bridge creates proposedv1
SCHEDULING.appointment.updatedghasi.scheduling.appointment.updatedStatus updated or rescheduledv1
SCHEDULING.appointment.cancelledghasi.scheduling.appointment.cancelledAppointment cancelledv1
SCHEDULING.appointment.noshowghasi.scheduling.appointment.noshowStatus set to noshowv1
SCHEDULING.appointment.fulfilledghasi.scheduling.appointment.fulfilledStatus set to fulfilledv1
SCHEDULING.checkin.completedghasi.scheduling.checkin.completedStatus set to arrivedv1
SCHEDULING.schedule.publishedghasi.scheduling.schedule.publishedSchedule createdv1
SCHEDULING.slot.openedghasi.scheduling.slot.openedSlot createdv1
SCHEDULING.waitlist.slot-availableghasi.scheduling.waitlist.slot-availableCancellation frees a matching waitlist slotv1
SCHEDULING.appointment.reminder.sentghasi.scheduling.appointment.reminder.sentReminder dispatched by async reminder servicev1

5. Ubiquitous Language

TermDefinition
AppointmentA planned patient visit to a provider/location at a specific time
SlotA bookable time window within a schedule
ScheduleA recurring availability definition for a resource (provider, room, equipment)
ActorA participant in an appointment (patient, provider, location, device)
Double-bookingTwo appointments overlapping the same resource time window
No-showPatient did not attend a booked appointment
WaitlistQueue for patients awaiting an appointment type when no slot is currently available
Check-inRecording that a patient has arrived (arrived status transition)
ReminderOutbound notification sent to patient before appointment
Portal bridgePattern: patient-portal-service creates proposed appointment via NATS; staff confirms to booked
Availability patternWeekly template defining which time windows are open for a schedule
Schedule exceptionA blocked window (holiday, maintenance) that overrides the availability pattern