Skip to main content

Documentation 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.

The Schedules module manages recurring weekly availability slots for doctors. Each 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.
public sealed record CreateScheduleCommand(
    Guid DoctorId,
    DayOfWeek DayOfWeek,
    TimeOnly StartTime,
    TimeOnly EndTime
) : IRequest<Guid>;

Parameters

DoctorId
Guid
required
The doctor for whom this slot is being created. Must be a non-empty GUID.
DayOfWeek
DayOfWeek
required
The day of the week for this slot (0 = Sunday … 6 = Saturday). Must be a valid DayOfWeek enum member.
StartTime
TimeOnly
required
The start time of the availability window. Must be strictly before EndTime.
EndTime
TimeOnly
required
The end time of the availability window. Must be strictly after StartTime.
Returns: The newly created 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.
public sealed record UpdateScheduleCommand(
    Guid DoctorId,
    DayOfWeek DayOfWeek,
    TimeOnly StartTime,
    TimeOnly EndTime
) : IRequest<Guid>;

Parameters

DoctorId
Guid
required
The doctor whose slot is being updated. Must be a non-empty GUID.
DayOfWeek
DayOfWeek
required
The day of the week identifying the slot to update. Must be a valid DayOfWeek enum member.
StartTime
TimeOnly
required
New start time. Must be strictly before EndTime.
EndTime
TimeOnly
required
New end time. Must be strictly after StartTime.
Returns: The 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.
public sealed record DeactivateScheduleCommand(Guid ScheduleId) : IRequest;

Parameters

ScheduleId
Guid
required
The primary key of the schedule slot to deactivate. Must be a non-empty GUID.
Returns: 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.
public sealed record ScheduleSlot(DayOfWeek DayOfWeek, TimeOnly StartTime, TimeOnly EndTime);

public sealed record SetupWeeklyScheduleCommand(
    Guid DoctorId,
    IReadOnlyList<ScheduleSlot> Slots
) : IRequest<IReadOnlyList<Guid>>;

Parameters

DoctorId
Guid
required
The doctor for whom the weekly schedule is being set up. Must be a non-empty GUID.
Slots
IReadOnlyList<ScheduleSlot>
required
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:
FieldTypeDescription
DayOfWeekDayOfWeekDay of the week (0 = Sunday … 6 = Saturday). Must be a valid enum member.
StartTimeTimeOnlySlot start time.
EndTimeTimeOnlySlot end time. Must be strictly after StartTime.
Returns: A list of 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.
public sealed record GetScheduleByIdQuery(Guid ScheduleId) : IRequest<ScheduleDto>;

Parameters

ScheduleId
Guid
required
Primary key of the schedule slot. Must be a non-empty GUID.
Returns: A ScheduleDto or throws EntityNotFoundException.

GetSchedulesByDoctorId

Type: IRequest<IReadOnlyList<ScheduleDto>> Returns all schedule slots (active and inactive) associated with a given doctor.
public sealed record GetSchedulesByDoctorIdQuery(Guid DoctorId)
    : IRequest<IReadOnlyList<ScheduleDto>>;

Parameters

DoctorId
Guid
required
The doctor whose schedules to retrieve. Must be a non-empty GUID.
Returns: A read-only list of 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.
public sealed record GetScheduleByDoctorAndDayQuery(Guid DoctorId, DayOfWeek DayOfWeek)
    : IRequest<ScheduleDto?>;

Parameters

DoctorId
Guid
required
The doctor to look up. Must be a non-empty GUID.
DayOfWeek
DayOfWeek
required
The day of the week to query. Must be a valid DayOfWeek enum member.
Returns: A ScheduleDto if an active slot exists for that day, otherwise null.

Response Shape

ScheduleDto

public sealed record ScheduleDto(
    Guid Id,
    Guid DoctorId,
    DayOfWeek DayOfWeek,
    TimeOnly StartTime,
    TimeOnly EndTime,
    bool IsActive
);
Id
Guid
The unique identifier of this schedule slot.
DoctorId
Guid
The doctor this slot belongs to.
DayOfWeek
DayOfWeek
The day of the week as a .NET DayOfWeek enum value (0 = Sunday … 6 = Saturday).
StartTime
TimeOnly
The start time of the availability window.
EndTime
TimeOnly
The end time of the availability window.
IsActive
bool
true if the slot is currently accepting bookings; false if deactivated.

WeeklyScheduleSlot (Domain Service Arg)

The domain service WeeklyScheduleSetupService uses its own strongly typed argument:
// ClinicFlow.Domain.Services.Args.Schedule
public sealed record WeeklyScheduleSlot(
    DayOfWeek DayOfWeek,
    TimeOnly StartTime,
    TimeOnly EndTime
);
The command handler maps each 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.

Build docs developers (and LLMs) love