The Schedules module manages recurring weekly availability slots for doctors. EachDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/0Crazy-0/ClinicFlow/llms.txt
Use this file to discover all available pages before exploring further.
Schedule entity represents a single day-of-week window during which a doctor accepts appointments. Slots carry an IsActive flag — inactive slots no longer accept new bookings but do not retroactively affect existing appointments. All commands and queries are dispatched via MediatR and validated with FluentValidation before any domain logic runs.
Commands
CreateSchedule
Type:IRequest<Guid>
Creates a single recurring schedule slot for a doctor on a given day of the week. The domain enforces that a doctor cannot have two active slots on the same day — Schedule.EnsureNoDuplicateDay throws ScheduleAlreadyExistsException if a conflict is detected.
Parameters
The doctor for whom this slot is being created. Must be a non-empty GUID.
The day of the week for this slot (0 = Sunday … 6 = Saturday). Must be a valid
DayOfWeek enum member.The start time of the availability window. Must be strictly before
EndTime.The end time of the availability window. Must be strictly after
StartTime.Schedule.Id as a Guid.
UpdateSchedule
Type:IRequest<Guid>
Updates the time window of an existing active schedule slot identified by DoctorId and DayOfWeek. If no active slot matches the provided day, the operation behaves as a create for that slot. The same EndTime > StartTime constraint applies.
Parameters
The doctor whose slot is being updated. Must be a non-empty GUID.
The day of the week identifying the slot to update. Must be a valid
DayOfWeek enum member.New start time. Must be strictly before
EndTime.New end time. Must be strictly after
StartTime.Schedule.Id of the affected slot as a Guid.
DeactivateSchedule
Type:IRequest (returns Unit)
Marks a schedule slot as inactive. Once deactivated, the slot no longer accepts new bookings. Calling Deactivate() on an already-inactive slot throws DomainValidationException with DomainErrors.Schedule.AlreadyInactive. The domain entity raises a ScheduleDeactivatedEvent(Id, DoctorId, DayOfWeek) after the state change.
Parameters
The primary key of the schedule slot to deactivate. Must be a non-empty GUID.
Unit (void).
Domain event raised: ScheduleDeactivatedEvent(ScheduleId, DoctorId, DayOfWeek)
SetupWeeklySchedule
Type:IRequest<IReadOnlyList<Guid>>
Bulk-creates multiple schedule slots for a doctor in a single operation — one slot per day of the week provided. The handler delegates to WeeklyScheduleSetupService.SetupWeeklySchedule, which validates each slot against the doctor’s existing schedules, enforces the no-duplicate-day rule, and returns a collection of new Schedule entities that are then persisted via scheduleRepository.CreateRangeAsync.
SetupWeeklySchedule is the preferred way to configure a doctor’s full weekly availability when onboarding or restructuring their schedule. It creates all provided slots atomically — if any slot fails domain validation (e.g. duplicate day), the entire operation is rolled back.Parameters
The doctor for whom the weekly schedule is being set up. Must be a non-empty GUID.
A non-empty list of
ScheduleSlot items. Each slot must have a valid DayOfWeek enum value and EndTime > StartTime. Duplicate days within the same request or against existing active slots are rejected.ScheduleSlot fields:
| Field | Type | Description |
|---|---|---|
DayOfWeek | DayOfWeek | Day of the week (0 = Sunday … 6 = Saturday). Must be a valid enum member. |
StartTime | TimeOnly | Slot start time. |
EndTime | TimeOnly | Slot end time. Must be strictly after StartTime. |
Guid values — the IDs of all newly created Schedule entities, in the same order as the input slots.
Queries
GetScheduleById
Type:IRequest<ScheduleDto>
Fetches a single schedule slot by its primary key.
Parameters
Primary key of the schedule slot. Must be a non-empty GUID.
ScheduleDto or throws EntityNotFoundException.
GetSchedulesByDoctorId
Type:IRequest<IReadOnlyList<ScheduleDto>>
Returns all schedule slots (active and inactive) associated with a given doctor.
Parameters
The doctor whose schedules to retrieve. Must be a non-empty GUID.
ScheduleDto records. May be empty.
GetScheduleByDoctorAndDay
Type:IRequest<ScheduleDto?>
Retrieves the active schedule slot for a specific doctor on a particular day of the week. Returns null if no active slot exists for that combination.
Parameters
The doctor to look up. Must be a non-empty GUID.
The day of the week to query. Must be a valid
DayOfWeek enum member.ScheduleDto if an active slot exists for that day, otherwise null.
Response Shape
ScheduleDto
The unique identifier of this schedule slot.
The doctor this slot belongs to.
The day of the week as a .NET
DayOfWeek enum value (0 = Sunday … 6 = Saturday).The start time of the availability window.
The end time of the availability window.
true if the slot is currently accepting bookings; false if deactivated.WeeklyScheduleSlot (Domain Service Arg)
The domain serviceWeeklyScheduleSetupService uses its own strongly typed argument:
ScheduleSlot from SetupWeeklyScheduleCommand to a WeeklyScheduleSlot before passing them to the service. The structures are intentionally kept separate to isolate the application layer from the domain service API.