ClinicFlow models each physician as aDocumentation 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.
Doctor entity that is tightly linked to a user account and a medical specialty. The domain enforces license uniqueness, validates consultation room bounds, and propagates suspension side-effects to future appointments through a domain event — keeping scheduling always consistent with the doctor’s active status.
The Doctor Entity
Doctor extends SoftDeletableEntity, which adds IsDeleted, DeletedAt, and the MarkAsDeleted / UndoDeletion helpers used by suspension and reactivation.
| Field | Type | Notes |
|---|---|---|
UserId | Guid | Foreign key to the User account |
FullName | PersonName | Value object — wraps a full name string (2–100 chars) |
MedicalSpecialtyId | Guid | References the MedicalSpecialty aggregate |
LicenseNumber | MedicalLicenseNumber | Validated value object (4–15 chars) |
Biography | string | Free-form text; mutable via UpdateProfile |
ConsultationRoom | ConsultationRoom | Value object with bounds-checked number and floor |
Value Objects
MedicalLicenseNumber
MedicalLicenseNumber is a record that enforces a length constraint on the raw string. It is used as a natural key — the system prevents two doctors from sharing the same license number.
MedicalLicenseNumber.Create is internal, so it may only be called from within ClinicFlow.Domain. The application layer passes the raw string through the command, and the handler constructs the value object before calling DoctorRegistrationService.Register.ConsultationRoom
ConsultationRoom captures the physical location of a doctor’s room and validates that the room number and floor fall within the clinic’s physical layout.
DomainValidationException.
DoctorRegistrationService
DoctorRegistrationService.Register is a static domain service that guards against duplicate license numbers. Before calling it, the application handler queries the repository with GetIncludingDeletedByLicenseNumberAsync — this intentionally retrieves soft-deleted (previously suspended) doctors too.
InactiveProfileExists. To bring a previously suspended physician back, use ReactivateDoctorProfile instead (see below).
Commands
CreateDoctorProfile
Creates a new doctor profile. The handler builds theMedicalLicenseNumber and ConsultationRoom value objects, runs the duplicate-license check via DoctorRegistrationService.Register, and persists the new entity.
Guid — the new Doctor.Id.
FluentValidation rules:
FirstName/LastName— required, length withinPersonName.MinimumLength/PersonName.MaximumLengthLicenseNumber— required, 4–15 charactersConsultationRoomNumber— 1–35ConsultationRoomFloor— 1–8MedicalSpecialtyId— non-emptyGuid
UpdateDoctorProfile
Mutates theBiography and ConsultationRoom on an existing, active doctor. The LicenseNumber and MedicalSpecialtyId are immutable after creation.
SuspendDoctorProfile
Marks the doctor as soft-deleted and raisesDoctorSuspendedEvent. A downstream event handler reads the event and marks all of the doctor’s future scheduled appointments as RequiresReassignment.
Doctor entity:
ReactivateDoctorProfile
Lifts the soft-delete flag and refreshes the biography and consultation room. Reactivation requires re-providing the room details because they may have changed during the suspension period.Doctor.Reactivate(biography, consultationRoom), which calls UndoDeletion() and throws AlreadyActive if the doctor is not currently suspended.
Command Summary
| Command | Typical Actor | Effect |
|---|---|---|
CreateDoctorProfile | Admin | Creates a new Doctor; blocks duplicate license numbers |
UpdateDoctorProfile | Admin / Doctor | Updates Biography and ConsultationRoom |
SuspendDoctorProfile | Admin | Soft-deletes doctor; raises DoctorSuspendedEvent → all future appointments set to RequiresReassignment |
ReactivateDoctorProfile | Admin | Restores soft-deleted doctor; refreshes room details |
Queries
GetDoctorsBySpecialtyId
Returns a paginated list of active doctors filtered byMedicalSpecialtyId.
GetDoctorByIdQuery(Guid DoctorId)— fetch a single doctor by primary key.GetDoctorByUserIdQuery(Guid UserId)— fetch the doctor profile linked to a given user account; useful after login to resolve the acting doctor.
Soft-Delete Behaviour
BecauseDoctor extends SoftDeletableEntity, the global EF Core query filter excludes rows where IsDeleted = true from all standard queries. This means suspended doctors are invisible to GetDoctorsBySpecialtyId and GetDoctorById. Only the specialised GetIncludingDeletedByLicenseNumberAsync repository method bypasses the filter — and only for the duplicate-license check during registration.