Appointment types (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.
AppointmentTypeDefinition) define the catalogue of clinical services a clinic offers. Each type carries a category, duration, an age eligibility policy, specialty restrictions, and a list of required clinical form templates that must be completed during the encounter. All write operations use soft-delete semantics — deactivation sets IsDeleted = true via SoftDeletableEntity.MarkAsDeleted() and is reversible with ReactivateAppointmentType.
Create and Update Commands
CreateAppointmentTypeCommand
Creates a new active appointment type definition.
Returns: IRequest<Guid> — the new type’s Id.
The clinical category. One of
FirstConsultation (1), FollowUp (2), Emergency (3), Checkup (4), Procedure (5).Unique display name for the appointment type. The handler throws
BusinessRuleValidationException (DomainErrors.AppointmentType.NameAlreadyExists) if the name is already in use. Cannot be null or whitespace.Human-readable description of the appointment type.
Expected consultation duration in minutes. Converted to
EncounterDuration.FromMinutes(value).Optional minimum patient age in years.
null means no lower bound.Optional maximum patient age in years.
null means no upper bound.When
true, patients below the minimum age require a legal guardian to consent. Stored in AgeEligibilityPolicy.RequiresLegalGuardian.- Checks name uniqueness via
IAppointmentTypeDefinitionRepository.ExistsByNameAsync. - Constructs
AgeEligibilityPolicy.Create(minAge, maxAge, requiresGuardian). - Calls
AppointmentTypeDefinition.Create(category, name, description, duration, agePolicy)— new types areIsUnrestrictedBySpecialty = trueby default. - Persists and returns the new
Guid.
UpdateAppointmentTypeCommand
Updates the core details of an existing appointment type (category, name, description, duration). Does not modify the age policy or specialty restrictions — use dedicated commands for those.
Returns: IRequest (no return value)
The type to update. Throws
EntityNotFoundException if not found.New category value.
New name. Checked for uniqueness against other types (excluding
AppointmentTypeId itself) via ExistsByNameExcludingAsync.New description.
New duration in minutes.
Activation Commands
DeactivateAppointmentTypeCommand
Soft-deletes an appointment type, removing it from the active catalogue.
Returns: IRequest (no return value)
The type to deactivate. Throws
BusinessRuleValidationException (DomainErrors.AppointmentType.AlreadyInactive) if already deactivated.appointmentType.Deactivate() which internally calls MarkAsDeleted().
ReactivateAppointmentTypeCommand
Restores a previously deactivated appointment type.
Returns: IRequest (no return value)
The type to reactivate. Must currently be soft-deleted. Uses
GetByIdIncludingDeletedAsync to find it.- Loads the type including soft-deleted records via
GetByIdIncludingDeletedAsync. - Re-checks name uniqueness against the active catalogue — throws
BusinessRuleValidationException(DomainErrors.AppointmentType.NameAlreadyExists) if another active type now has the same name. - Calls
appointmentType.Reactivate(), which callsUndoDeletion().
Specialty Restriction Commands
Specialty restrictions control which doctor specialties are eligible to perform a given appointment type. New types start asIsUnrestrictedBySpecialty = true (any doctor can schedule them). Use RestrictAppointmentTypeToSpecialties to narrow access.
RestrictAppointmentTypeToSpecialtiesCommand
Switches an unrestricted appointment type to specialty-restricted mode and sets the initial allowed specialty list.
Returns: IRequest (no return value)
The type to restrict. Throws
DomainValidationException (DomainErrors.AppointmentType.AlreadyRestricted) if already restricted.Non-empty list of
MedicalSpecialty.Id values. Duplicates and empty Guids are rejected. Must contain at least one entry (DomainErrors.AppointmentType.RequiresAtLeastOneSpecialty).MakeAppointmentTypeUnrestrictedCommand
Removes all specialty restrictions, making the type available to all doctor specialties.
Returns: IRequest (no return value)
The type to make unrestricted. Throws
DomainValidationException (DomainErrors.AppointmentType.AlreadyUnrestricted) if already unrestricted. Clears AllowedSpecialtyIds and sets IsUnrestrictedBySpecialty = true.AddAllowedSpecialtyToAppointmentTypeCommand
Adds a single specialty to the allowed list of an already-restricted appointment type.
Returns: IRequest (no return value)
The restricted appointment type to update. Throws
DomainValidationException (DomainErrors.AppointmentType.CannotAddSpecialtyToGlobalType) if the type is unrestricted.The
MedicalSpecialty.Id to allow. Throws if already present (DomainErrors.AppointmentType.SpecialtyAlreadyAllowed) or if the Guid is empty.RemoveAllowedSpecialtyFromAppointmentTypeCommand
Removes a single specialty from the allowed list. At least one specialty must remain.
Returns: IRequest (no return value)
The restricted appointment type. Throws
DomainValidationException (DomainErrors.AppointmentType.CannotRemoveSpecialtyFromGlobalType) if unrestricted.The specialty to remove. Throws if not found (
DomainErrors.AppointmentType.SpecialtyNotFound) or if it is the last remaining specialty (DomainErrors.AppointmentType.RequiresAtLeastOneSpecialty).Clinical Form Template Commands
Required templates define which clinical forms must be completed for an appointment of this type during the encounter.AddRequiredTemplateToAppointmentTypeCommand
Associates a clinical form template with an appointment type, making it required for all future appointments of that type.
Returns: IRequest (no return value)
The appointment type to update.
The
ClinicalFormTemplate.Id to require. The handler resolves the template via IClinicalFormTemplateRepository. Throws EntityNotFoundException if not found. Throws DomainValidationException (DomainErrors.AppointmentType.TemplateAlreadyRequired) if already attached (matched by Id or Code).RemoveRequiredTemplateFromAppointmentTypeCommand
Removes a clinical form template requirement from an appointment type.
Returns: IRequest (no return value)
The appointment type to update.
The
ClinicalFormTemplate.Id to remove. Throws DomainValidationException (DomainErrors.AppointmentType.TemplateNotFound) if not currently required.Age Policy Command
ChangeAppointmentTypeAgePolicyCommand
Replaces the age eligibility policy on an existing appointment type.
Returns: IRequest (no return value)
The type whose age policy to change.
New minimum age in years.
null removes the lower bound. Stored in AgeEligibilityPolicy.MinimumAge.New maximum age in years.
null removes the upper bound. Stored in AgeEligibilityPolicy.MaximumAge.New guardian consent requirement. Stored in
AgeEligibilityPolicy.RequiresLegalGuardian.AgeEligibilityPolicy.Create(minAge, maxAge, requiresGuardian) and calls appointmentType.ChangeAgePolicy(agePolicy). Passing null for both ages with false for guardian consent is equivalent to AgeEligibilityPolicy.NoRestriction.
Queries
GetAllActiveAppointmentTypesQuery
Returns all non-deleted appointment types.
Returns: IRequest<IReadOnlyList<AppointmentTypeDto>>
IAppointmentTypeDefinitionRepository.GetAllActiveAsync() which filters out soft-deleted records.
GetAppointmentTypeByIdQuery
Returns a single appointment type by its primary key.
Returns: IRequest<AppointmentTypeDto>
The type’s primary key. Throws
EntityNotFoundException if not found or if soft-deleted.GetAppointmentTypesByCategoryQuery
Returns all active appointment types for a specific clinical category.
Returns: IRequest<IReadOnlyList<AppointmentTypeDto>>
The category to filter by. One of
FirstConsultation (1), FollowUp (2), Emergency (3), Checkup (4), Procedure (5).GetEligibleAppointmentTypesQuery
Returns all active appointment types whose age policy allows a patient of the given age.
Returns: IRequest<IReadOnlyList<AppointmentTypeDto>>
The patient’s age in full years. Used to filter types via
IAppointmentTypeDefinitionRepository.GetEligibleByAgeAsync(ageInYears).AppointmentTypeDto Response Shape
All queries returnAppointmentTypeDto or IReadOnlyList<AppointmentTypeDto>.
The type’s primary key.
The category name as a string (e.g.,
"FirstConsultation"). Serialized from AppointmentCategory.ToString().The unique display name.
Human-readable description.
Expected consultation duration in minutes (from
EncounterDuration.Minutes).The minimum patient age in years required by
AgeEligibilityPolicy. null means no lower bound.The maximum patient age in years allowed by
AgeEligibilityPolicy. null means no upper bound.When
true, a legal guardian must be present and consent must be verified before scheduling.When
true, any doctor regardless of specialty can schedule this type. When false, AllowedSpecialtyIds is authoritative.Populated only when
IsUnrestrictedBySpecialty = false. Contains MedicalSpecialty.Id values of permitted specialties.Clinical form templates that must be completed during appointments of this type. See
ClinicalFormTemplateDto below.AgeEligibilityPolicy Fields
TheAgeEligibilityPolicy value object is flattened into AppointmentTypeDto and CreateAppointmentTypeCommand/ChangeAppointmentTypeAgePolicyCommand. Its three fields are:
| Field | Type | Description |
|---|---|---|
MinimumAge | int? | Minimum patient age in full years. null = unrestricted. |
MaximumAge | int? | Maximum patient age in full years. null = unrestricted. |
RequiresLegalGuardian | bool | Whether guardian consent must be verified before scheduling. |
AgeEligibilityPolicy.NoRestriction is a static sentinel with all three fields unset (both ages null, guardian false). It is the default applied when Create is called with all-null age arguments.
ClinicalFormTemplateDto
Embedded inAppointmentTypeDto.RequiredTemplates.
The template’s primary key.
Unique business key (e.g.,
"BLOOD_PRESS"). Used for stable programmatic reference.Human-readable template name.
Description of what the form captures.
Raw JSON Schema Draft-07 string used to validate form submissions at runtime.
Whether the template has been soft-deleted. A required template may reference a soft-deleted template if it was added before deletion.