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 Medical Specialties module manages the catalogue of clinical disciplines the clinic offers (e.g. Cardiology, Dentistry, General Practice). Each specialty carries two domain-level policy values: a typical encounter duration used as a default when creating appointment types, and a cancellation limit that specifies the minimum advance-notice window within which patients can cancel without incurring a penalty. All commands are validated by FluentValidation before reaching the handler.

CancellationLimit Explained

MinCancellationHours defines how many hours before an appointment a patient must cancel to avoid triggering an automatic penalty. Cancellations made within this window are treated as late cancellations by the penalty engine. The allowed values are constrained to CancellationLimit.AllowedHours — a fixed set defined in the domain value object: 0, 12, 24, 48, 72. A value of 0 means no restriction (any cancellation is penalty-free). Providing a value outside that set causes the validator to reject the command with DomainErrors.MedicalSpecialty.InvalidCancellationLimit.

Commands

CreateMedicalSpecialty

Type: IRequest<Guid> Creates a new active medical specialty. TypicalDurationMinutes is validated against EncounterDuration.IsValid; MinCancellationHours must be a member of CancellationLimit.AllowedHours. Both constraints are enforced in the FluentValidation validator as well as in the domain entity factory method.
public sealed record CreateMedicalSpecialtyCommand(
    string Name,
    string Description,
    int TypicalDurationMinutes,
    int MinCancellationHours
) : IRequest<Guid>;

Parameters

Name
string
required
Display name of the specialty (e.g. "Cardiology"). Must not be empty.
Description
string
required
Brief description of the specialty’s scope. Must not be empty.
TypicalDurationMinutes
int
required
Indicative appointment length in minutes. Must pass EncounterDuration.IsValid — invalid durations are rejected with DomainErrors.MedicalSpecialty.InvalidEncounterDuration. Used as a suggested default for appointment type definitions; does not directly drive scheduling.
MinCancellationHours
int
required
Minimum hours of advance notice required for penalty-free cancellation. Must be a value present in CancellationLimit.AllowedHours. Rejected with DomainErrors.MedicalSpecialty.InvalidCancellationLimit otherwise.
Returns: The newly created MedicalSpecialty.Id as a Guid.

UpdateMedicalSpecialty

Type: IRequest (returns Unit) Updates all mutable fields of an existing specialty. Applies the same EncounterDuration and CancellationLimit validation as CreateMedicalSpecialty.
public sealed record UpdateMedicalSpecialtyCommand(
    Guid SpecialtyId,
    string Name,
    string Description,
    int TypicalDurationMinutes,
    int MinCancellationHours
) : IRequest;

Parameters

SpecialtyId
Guid
required
Primary key of the specialty to update. Must be a non-empty GUID.
Name
string
required
Replacement display name. Must not be empty.
Description
string
required
Replacement description. Must not be empty.
TypicalDurationMinutes
int
required
New typical duration. Must pass EncounterDuration.IsValid.
MinCancellationHours
int
required
New cancellation notice window. Must be a value in CancellationLimit.AllowedHours.
Returns: Unit (void).

DeactivateMedicalSpecialty

Type: IRequest (returns Unit) Soft-deletes a specialty. The domain entity checks two preconditions before marking it deleted: the specialty must not already be inactive (DomainErrors.MedicalSpecialty.AlreadyInactive), and it must have no active doctors assigned to it (DomainErrors.MedicalSpecialty.HasActiveDoctors). These checks are enforced in MedicalSpecialty.Deactivate(bool hasActiveDoctors).
public sealed record DeactivateMedicalSpecialtyCommand(Guid SpecialtyId) : IRequest;

Parameters

SpecialtyId
Guid
required
The specialty to deactivate. Throws BusinessRuleValidationException if there are still active doctors assigned to this specialty.
Returns: Unit (void).

ReactivateMedicalSpecialty

Type: IRequest (returns Unit) Restores a previously deactivated (soft-deleted) specialty. The domain entity throws BusinessRuleValidationException with DomainErrors.MedicalSpecialty.AlreadyActive if the specialty is not currently inactive.
public sealed record ReactivateMedicalSpecialtyCommand(Guid SpecialtyId) : IRequest;

Parameters

SpecialtyId
Guid
required
The specialty to reactivate. Must currently be in a soft-deleted state.
Returns: Unit (void).

Queries

GetMedicalSpecialtyById

Type: IRequest<MedicalSpecialtyDto> Fetches a single specialty — active or inactive — by its primary key.
public sealed record GetMedicalSpecialtyByIdQuery(Guid MedicalSpecialtyId)
    : IRequest<MedicalSpecialtyDto>;

Parameters

MedicalSpecialtyId
Guid
required
The primary key of the specialty to retrieve. Must be a non-empty GUID.
Returns: A MedicalSpecialtyDto or throws EntityNotFoundException.

GetActiveMedicalSpecialties

Type: IRequest<IReadOnlyList<MedicalSpecialtyDto>> Returns all specialties that are currently active (not soft-deleted). Used to populate lists in appointment booking flows.
public sealed record GetActiveMedicalSpecialtiesQuery
    : IRequest<IReadOnlyList<MedicalSpecialtyDto>>;
This query has no parameters. No validator is registered for it. Returns: A read-only list of active MedicalSpecialtyDto records.

GetAllMedicalSpecialties

Type: IRequest<IReadOnlyList<MedicalSpecialtyDto>> Returns all specialties including soft-deleted ones. Intended for administrative views where the full catalogue history is needed.
public sealed record GetAllMedicalSpecialtiesQuery
    : IRequest<IReadOnlyList<MedicalSpecialtyDto>>;
This query has no parameters. No validator is registered for it. Returns: A read-only list of all MedicalSpecialtyDto records (active + inactive).

Response Shape

MedicalSpecialtyDto

public sealed record MedicalSpecialtyDto(
    Guid Id,
    string Name,
    string Description,
    int TypicalDurationMinutes,
    int MinCancellationHours,
    bool IsDeleted
);
Id
Guid
The unique identifier of the specialty.
Name
string
The display name of the specialty.
Description
string
A brief description of the specialty’s clinical scope.
TypicalDurationMinutes
int
The indicative appointment length in minutes. Used as a suggested default when defining appointment types for this specialty.
MinCancellationHours
int
The minimum hours of advance notice required for a penalty-free cancellation. Cancellations within this window may trigger an automatic Warning or TemporaryBlock penalty.
IsDeleted
bool
true if the specialty has been deactivated (soft-deleted); false if it is currently active.

Build docs developers (and LLMs) love