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 Records module captures the clinical output of a completed appointment. A MedicalRecord is always linked to exactly one appointment and holds the chief complaint plus an ordered list of ClinicalDetail entries — each one a JSON payload validated against a ClinicalFormTemplate schema. Records are immutable once created; individual clinical details can be appended after the fact via AddClinicalDetailToMedicalRecord.

Commands

CompleteMedicalEncounter

Type: IRequest<Guid> Atomically creates a MedicalRecord and transitions the linked appointment to a completed state. The handler orchestrates the MedicalEncounterService, which validates that the providing doctor matches the appointment’s assigned doctor, confirms the appointment is in InProgress status (throws DomainErrors.MedicalEncounter.AppointmentNotInProgress otherwise), and validates each DynamicClinicalDetail payload against its template’s JSON Schema before persisting.
This command is the only way to complete an appointment in ClinicFlow. The record creation and appointment completion happen within the same unit of work — either both are committed or neither is. If any clinical detail payload fails JSON Schema validation, the entire operation rolls back.
public record DynamicClinicalDetailDto(string TemplateCode, string JsonDataPayload);

public sealed record CompleteMedicalEncounterCommand(
    Guid PatientId,
    Guid DoctorId,
    Guid AppointmentId,
    string ChiefComplaint,
    IReadOnlyList<DynamicClinicalDetailDto> Details
) : IRequest<Guid>;

Parameters

PatientId
Guid
required
The patient involved in the encounter. Must be a non-empty GUID.
DoctorId
Guid
required
The doctor completing the encounter. Must match the appointment’s assigned doctor or the command is rejected. Must be a non-empty GUID.
AppointmentId
Guid
required
The appointment being completed. Must be a non-empty GUID. Throws EntityNotFoundException if no matching appointment exists.
ChiefComplaint
string
required
The primary symptom or reason for the visit as reported by the patient. Must not be empty.
Details
IReadOnlyList<DynamicClinicalDetailDto>
Zero or more structured clinical detail entries. Each entry contains:
  • TemplateCode (string, required) — the unique code of the ClinicalFormTemplate whose schema governs validation.
  • JsonDataPayload (string, required) — the JSON string containing the form field values. Validated against the template’s JsonSchemaDefinition (JSON Schema draft-07).
Returns: The newly created MedicalRecord.Id as a Guid.

AddClinicalDetailToMedicalRecord

Type: IRequest (returns Unit) Appends a single structured clinical detail entry to an existing medical record after the encounter has been completed. The handler looks up the ClinicalFormTemplate by TemplateCode and passes it to MedicalEncounterService.AppendClinicalDetail, which validates the payload against the template’s schema. Duplicate TemplateCode entries on the same record are rejected with DomainErrors.MedicalEncounter.DetailAlreadyExists.
public sealed record AddClinicalDetailToMedicalRecordCommand(
    Guid MedicalRecordId,
    string TemplateCode,
    string JsonDataPayload
) : IRequest;

Parameters

MedicalRecordId
Guid
required
The medical record to append the detail to. Must be a non-empty GUID. Throws EntityNotFoundException if not found.
TemplateCode
string
required
The unique code of the clinical form template (e.g. "BLOOD_PRESS"). Used to look up the template and its schema. Must not be empty.
JsonDataPayload
string
required
The JSON string containing the form field values for this entry. Validated against the template’s JsonSchemaDefinition. Must not be empty.
Returns: Unit (void).

Queries

GetMedicalRecordById

Type: IRequest<MedicalRecordDto> Fetches a complete medical record including all clinical details by primary key.
public sealed record GetMedicalRecordByIdQuery(Guid Id) : IRequest<MedicalRecordDto>;

Parameters

Id
Guid
required
The primary key of the medical record. Must be a non-empty GUID.
Returns: A MedicalRecordDto or throws EntityNotFoundException.

GetMedicalRecordByAppointmentId

Type: IRequest<MedicalRecordDto> Retrieves the medical record associated with a specific appointment. Because each appointment maps to at most one record, this returns a single DTO.
public sealed record GetMedicalRecordByAppointmentIdQuery(Guid AppointmentId)
    : IRequest<MedicalRecordDto>;

Parameters

AppointmentId
Guid
required
The appointment whose record to retrieve. Must be a non-empty GUID.
Returns: A MedicalRecordDto or throws EntityNotFoundException if the appointment has no associated record.

GetMedicalRecordsByPatientId

Type: IRequest<PaginatedList<MedicalRecordDto>> Returns a paginated list of all medical records belonging to a specific patient, ordered from most recent to oldest.
public sealed record GetMedicalRecordsByPatientIdQuery(
    Guid PatientId,
    int PageNumber,
    int PageSize
) : IRequest<PaginatedList<MedicalRecordDto>>;

Parameters

PatientId
Guid
required
The patient whose records to retrieve. Must be a non-empty GUID.
PageNumber
int
required
1-based page index. Must be ≥ 1.
PageSize
int
required
Number of records per page. Must be between 1 and 100 (inclusive).
Returns: A PaginatedList<MedicalRecordDto>.

GetMedicalRecordsByDoctorId

Type: IRequest<PaginatedList<MedicalRecordDto>> Returns a paginated list of all medical records authored by a specific doctor.
public sealed record GetMedicalRecordsByDoctorIdQuery(
    Guid DoctorId,
    int PageNumber,
    int PageSize
) : IRequest<PaginatedList<MedicalRecordDto>>;

Parameters

DoctorId
Guid
required
The doctor whose records to retrieve. Must be a non-empty GUID.
PageNumber
int
required
1-based page index. Must be ≥ 1.
PageSize
int
required
Number of records per page. Must be between 1 and 100 (inclusive).
Returns: A PaginatedList<MedicalRecordDto>.

GetClinicalDetailByTemplateCode

Type: IRequest<ClinicalDetailDto?> Retrieves a single clinical detail entry from a medical record, identified by the template code used to create it. Useful for reading a specific form (e.g. the blood-pressure reading) without loading the entire record.
public sealed record GetClinicalDetailByTemplateCodeQuery(
    Guid MedicalRecordId,
    string TemplateCode
) : IRequest<ClinicalDetailDto?>;

Parameters

MedicalRecordId
Guid
required
The record to search within. Must be a non-empty GUID.
TemplateCode
string
required
The template code to look for (e.g. "BLOOD_PRESS"). Must not be empty.
Returns: A ClinicalDetailDto if a detail with that template code exists on the record, otherwise null.

Response Shapes

MedicalRecordDto

public sealed record MedicalRecordDto(
    Guid Id,
    Guid PatientId,
    Guid DoctorId,
    Guid AppointmentId,
    string ChiefComplaint,
    IReadOnlyList<ClinicalDetailDto> ClinicalDetails
);
Id
Guid
The unique identifier of the medical record.
PatientId
Guid
The patient this record belongs to.
DoctorId
Guid
The doctor who completed the encounter.
AppointmentId
Guid
The appointment this record is linked to (one-to-one).
ChiefComplaint
string
The primary symptom or reason for the visit as recorded at the time of the encounter.
ClinicalDetails
IReadOnlyList<ClinicalDetailDto>
The ordered list of structured clinical detail entries collected during this encounter.

ClinicalDetailDto

public sealed record ClinicalDetailDto(string TemplateCode, string JsonDataPayload);
TemplateCode
string
The unique business key code of the ClinicalFormTemplate used (e.g. "BLOOD_PRESS").
JsonDataPayload
string
The raw JSON payload containing the form field values, previously validated against the template’s JSON Schema draft-07 definition.

Build docs developers (and LLMs) love