In ClinicFlow, a patient is not the same as a user. A user account represents the person who logs in; a patient profile represents the person who receives medical care. One user can own multiple patient profiles — their own (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.
Self) and any number of family members. This separation enables a parent to book appointments for a child, or a spouse to manage care for a partner, all under a single login.
The Patient Entity
Patient extends SoftDeletableEntity, meaning closed or removed patients are never physically deleted from the database — they are flagged with IsDeleted = true.
Soft-deletion is used throughout the patient lifecycle. Calling
RemoveFamilyMember or CloseAccount sets IsDeleted = true on the patient record. All repository queries that list active patients automatically filter these out. The deleted record can be reactivated internally if the same name and date of birth are later re-registered under the same user (see ReactivateAsPrimary / ReactivateAsFamilyMember).PatientRelationship Enum
Every patient profile declares its relationship to the owning user account:| Value | Integer | Meaning |
|---|---|---|
Self | 0 | The primary profile for the user (one per account) |
Child | 1 | A dependent child |
Spouse | 2 | Married partner |
Parent | 3 | Parent or guardian |
Sibling | 4 | Brother or sister |
Other | 5 | Any other relationship |
Self relationship carries special domain rules: it is the only profile that can close its own account, and it cannot be removed as a family member.
Value Objects
PersonName
PersonName wraps a full name string with validation:
BloodType
BloodType is validated against a fixed set of exactly eight accepted values:
BusinessRuleValidationException.
EmergencyContact
EmergencyContact combines a PersonName and a PhoneNumber into a single value object:
Patient entity.
Creating Patient Profiles
CreatePatientProfileCommand — Basic Self Profile
Creates the primary patient profile for a user with just identity information:Patient.CreateSelf(...) internally. DateOfBirth must not be in the future. Medical profile data (BloodType, Allergies, ChronicConditions) and EmergencyContact are not set yet and must be added via UpdatePatientProfile before the patient can book any appointment.
CreateCompletePatientProfileCommand — Full Profile in One Step
An alternative command that collects all required fields upfront:UpdateMedicalProfile and UpdateEmergencyContact so the patient is booking-eligible from the moment of creation. Prefer this command for registration flows where all information is collected in a single form.
Adding Family Members
AddFamilyMemberCommand
Adds a non-Self patient profile linked to an existing user account:
Patient.CreateFamilyMember(...). Passing Relationship = Self throws a DomainValidationException — use CreatePatientProfileCommand to create the primary profile.
AddCompleteFamilyMemberCommand
An alternative that creates a family member profile with all medical data in one step, mirroringCreateCompletePatientProfileCommand for self profiles:
Updating Patient Data
UpdatePatientProfileCommand — Medical Profile & Emergency Contact
patient.UpdateMedicalProfile(bloodType, allergies, chronicConditions) and patient.UpdateEmergencyContact(emergencyContact) in the same transaction. After this command succeeds, EnsureCompleteProfile() will pass for that patient.
Booking Eligibility — EnsureCompleteProfile
Before any appointment is created for a patient (via patient-initiated or staff-initiated scheduling), the domain calls:BloodType and EmergencyContact must be non-null. Attempting to book for a patient whose profile is incomplete throws IncompleteProfileException before any slot availability check is performed.
Removing Family Members
patient.RemoveFamilyMember(initiatorUserId), which enforces two rules:
UserIdmust match the patient’sUserId— you can only remove your own family members.RelationshipToUsermust not beSelf— the primary profile cannot be removed this way.
IsDeleted = true).
Closing an Account
CloseAccount can only be called on the user’s Self patient profile. The handler checks IAppointmentRepository.HasActiveAppointmentsForUserAsync and passes the result as hasPendingAppointments:
Querying Patients
GetPatientsByUserId
PatientDto:
BloodType, EmergencyContactName, EmergencyContactPhone) indicate an incomplete profile. Consumers should prompt the user to fill in missing data before allowing appointment booking.
Command Reference
| Command | Actor | Restrictions |
|---|---|---|
CreatePatientProfileCommand | User (self-registration) | One Self profile per user; DateOfBirth must not be in future |
CreateCompletePatientProfileCommand | User (self-registration) | Same as above; also validates BloodType and emergency contact fields |
AddFamilyMemberCommand | User | Relationship must not be Self; no limit on family member count |
AddCompleteFamilyMemberCommand | User | Same as above; also sets medical profile and emergency contact immediately |
UpdatePatientProfileCommand | User / Staff | Updates medical data and emergency contact for any patient the user owns |
RemoveFamilyMemberCommand | User | UserId must own the patient; cannot remove Self |
ClosePatientAccountCommand | User | Must be Self; no pending appointments allowed |