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 Patients module manages the full lifecycle of patient profiles in ClinicFlow. A single user account can own multiple patient profiles — one Self profile for the account holder and any number of family-member profiles (Child, Spouse, Parent, Sibling, Other). All commands run through FluentValidation before reaching the handler, and all queries return PatientDto projections.
Basic vs. complete profiles: ClinicFlow distinguishes between a basic profile (name and date of birth only) and a complete profile (which also includes blood type, allergies, chronic conditions, and an emergency contact). A patient must hold a complete profile before the system will accept appointment bookings — EnsureCompleteProfile() is enforced at the booking stage.

Commands

CreatePatientProfile

Type: IRequest<Guid> Creates a minimal patient profile for the primary account holder. The RelationshipToUser is automatically set to PatientRelationship.Self. Medical profile fields (blood type, emergency contact) are left unset and must be filled in later via UpdatePatientProfile.
public sealed record CreatePatientProfileCommand(
    Guid UserId,
    string FirstName,
    string LastName,
    DateOnly DateOfBirth
) : IRequest<Guid>;

Parameters

UserId
Guid
required
The user account that owns this profile. Must be a non-empty GUID.
FirstName
string
required
Given name. Must be between PersonName.MinimumLength and PersonName.MaximumLength characters.
LastName
string
required
Family name. Same length constraints as FirstName.
DateOfBirth
DateOnly
required
Must not be in the future (validated against TimeProvider.GetUtcNow()).
Returns: The newly created Patient.Id as a Guid.

CreateCompletePatientProfile

Type: IRequest<Guid> Creates a fully populated patient profile for the primary account holder in one operation. Includes all the fields from CreatePatientProfile plus the medical profile and emergency contact, making the patient immediately eligible for booking appointments.
public sealed record CreateCompletePatientProfileCommand(
    Guid UserId,
    string FirstName,
    string LastName,
    DateOnly DateOfBirth,
    string BloodType,
    string Allergies,
    string ChronicConditions,
    string EmergencyContactName,
    string EmergencyContactPhone
) : IRequest<Guid>;

Parameters

UserId
Guid
required
The user account that owns this profile. Must be a non-empty GUID.
FirstName
string
required
Given name. Must satisfy PersonName length constraints.
LastName
string
required
Family name. Must satisfy PersonName length constraints.
DateOfBirth
DateOnly
required
Must not be in the future.
BloodType
string
required
The patient’s blood type (e.g. "O+", "AB-"). Must not be empty.
Allergies
string
Free-text list of known allergies. May be empty.
ChronicConditions
string
Free-text list of chronic conditions. May be empty.
EmergencyContactName
string
required
Full name of the emergency contact. Must satisfy PersonName length constraints.
EmergencyContactPhone
string
required
Phone number of the emergency contact. Must be between PhoneNumber.MinimumLength and PhoneNumber.MaximumLength characters.
Returns: The newly created Patient.Id as a Guid.

AddFamilyMember

Type: IRequest<Guid> Adds a basic-profile dependent (family member) to an existing user account. The relationship must not be Self — using PatientRelationship.Self is rejected with DomainErrors.Patient.CannotBeSelf.
public sealed record AddFamilyMemberCommand(
    Guid UserId,
    string FirstName,
    string LastName,
    DateOnly DateOfBirth,
    PatientRelationship Relationship
) : IRequest<Guid>;

Parameters

UserId
Guid
required
The owning user account. Must be a non-empty GUID.
FirstName
string
required
Given name of the family member. Must satisfy PersonName length constraints.
LastName
string
required
Family name. Must satisfy PersonName length constraints.
DateOfBirth
DateOnly
required
Must not be in the future.
Relationship
PatientRelationship
required
Enum value representing the relationship to the user. Must be a defined enum member and must not be Self. Valid values: Child (1), Spouse (2), Parent (3), Sibling (4), Other (5).
Returns: The newly created Patient.Id as a Guid.

AddCompleteFamilyMember

Type: IRequest<Guid> Adds a fully populated dependent profile to a user account in one step, including medical profile and emergency contact details.
public sealed record AddCompleteFamilyMemberCommand(
    Guid UserId,
    string FirstName,
    string LastName,
    DateOnly DateOfBirth,
    string BloodType,
    string Allergies,
    string ChronicConditions,
    string EmergencyContactName,
    string EmergencyContactPhone,
    PatientRelationship Relationship
) : IRequest<Guid>;

Parameters

UserId
Guid
required
The owning user account. Must be a non-empty GUID.
FirstName
string
required
Given name. Must satisfy PersonName length constraints.
LastName
string
required
Family name. Must satisfy PersonName length constraints.
DateOfBirth
DateOnly
required
Must not be in the future.
BloodType
string
required
Blood type string (e.g. "B+"). Must not be empty.
Allergies
string
Free-text allergies. May be empty.
ChronicConditions
string
Free-text chronic conditions. May be empty.
EmergencyContactName
string
required
Full name of emergency contact. Must satisfy PersonName length constraints.
EmergencyContactPhone
string
required
Phone of emergency contact. Must satisfy PhoneNumber length constraints.
Relationship
PatientRelationship
required
Relationship to the user. Must be a valid enum member (Child, Spouse, Parent, Sibling, or Other).
Returns: The newly created Patient.Id as a Guid.

UpdatePatientProfile

Type: IRequest (returns Unit) Updates the medical profile and emergency contact for an existing patient. This is the primary way to upgrade a basic profile to a complete one after creation.
public sealed record UpdatePatientProfileCommand(
    Guid PatientId,
    string BloodType,
    string Allergies,
    string ChronicConditions,
    string EmergencyContactName,
    string EmergencyContactPhone
) : IRequest;

Parameters

PatientId
Guid
required
ID of the patient profile to update. Must be a non-empty GUID.
BloodType
string
required
Blood type string. Must not be empty.
Allergies
string
Free-text allergies. May be empty.
ChronicConditions
string
Free-text chronic conditions. May be empty.
EmergencyContactName
string
required
Emergency contact full name. Must satisfy PersonName length constraints.
EmergencyContactPhone
string
required
Emergency contact phone number. Must satisfy PhoneNumber length constraints.
Returns: Unit (void).

RemoveFamilyMember

Type: IRequest (returns Unit) Soft-deletes a family-member patient profile. The UserId must match the Patient.UserId (the initiator must own the profile). Attempting to remove a Self profile via this command is rejected with DomainErrors.Patient.CannotRemovePrimaryUser.
public sealed record RemoveFamilyMemberCommand(Guid PatientId, Guid UserId) : IRequest;

Parameters

PatientId
Guid
required
ID of the family-member profile to remove.
UserId
Guid
required
ID of the initiating user. Must match the profile’s owner — enforced in the domain entity.
Returns: Unit (void).

ClosePatientAccount

Type: IRequest (returns Unit) Soft-deletes all patient profiles belonging to a user account. Only callable on the primary (Self) profile; the domain enforces that the patient has no pending or active future appointments before proceeding.
public sealed record ClosePatientAccountCommand(Guid UserId) : IRequest;

Parameters

UserId
Guid
required
The user account to close. All linked patient profiles are soft-deleted. Throws DomainValidationException with CannotCloseAccountWithPendingAppointments if active future appointments exist.
Returns: Unit (void).

Queries

GetPatientById

Type: IRequest<PatientDto> Fetches a single patient profile by primary key.
public sealed record GetPatientByIdQuery(Guid PatientId) : IRequest<PatientDto>;

Parameters

PatientId
Guid
required
The primary key of the patient profile to retrieve.
Returns: A PatientDto or throws EntityNotFoundException.

GetPatientsByUserId

Type: IRequest<IReadOnlyList<PatientDto>> Returns all patient profiles (self + family members) associated with a user account.
public sealed record GetPatientsByUserIdQuery(Guid UserId)
    : IRequest<IReadOnlyList<PatientDto>>;

Parameters

UserId
Guid
required
The user account to query. Must be a non-empty GUID.
Returns: A read-only list of PatientDto records (may be empty if the user has no profiles).

Response Shape

PatientDto

public sealed record PatientDto(
    Guid Id,
    Guid UserId,
    string FullName,
    PatientRelationship RelationshipToUser,
    DateOnly DateOfBirth,
    string? BloodType,
    string? Allergies,
    string? ChronicConditions,
    string? EmergencyContactName,
    string? EmergencyContactPhone
);
Id
Guid
The unique identifier of the patient profile.
UserId
Guid
The identifier of the user account that owns this patient profile.
FullName
string
The patient’s full name as a single string.
RelationshipToUser
PatientRelationship
Enum describing this patient’s relationship to the account holder. Self=0, Child=1, Spouse=2, Parent=3, Sibling=4, Other=5.
DateOfBirth
DateOnly
The patient’s date of birth.
BloodType
string | null
Blood type string (e.g. "A+"). null for basic (incomplete) profiles.
Allergies
string | null
Free-text allergies. null or empty for basic profiles.
ChronicConditions
string | null
Free-text chronic conditions. null or empty for basic profiles.
EmergencyContactName
string | null
Emergency contact name. null for basic profiles.
EmergencyContactPhone
string | null
Emergency contact phone. null for basic profiles.

PatientRelationship Enum

public enum PatientRelationship
{
    Self    = 0,
    Child   = 1,
    Spouse  = 2,
    Parent  = 3,
    Sibling = 4,
    Other   = 5,
}

Build docs developers (and LLMs) love