The Medical Records module captures the clinical output of a completed appointment. 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.
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.
Parameters
The patient involved in the encounter. Must be a non-empty GUID.
The doctor completing the encounter. Must match the appointment’s assigned doctor or the command is rejected. Must be a non-empty GUID.
The appointment being completed. Must be a non-empty GUID. Throws
EntityNotFoundException if no matching appointment exists.The primary symptom or reason for the visit as reported by the patient. Must not be empty.
Zero or more structured clinical detail entries. Each entry contains:
TemplateCode(string, required) — the unique code of theClinicalFormTemplatewhose schema governs validation.JsonDataPayload(string, required) — the JSON string containing the form field values. Validated against the template’sJsonSchemaDefinition(JSON Schema draft-07).
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.
Parameters
The medical record to append the detail to. Must be a non-empty GUID. Throws
EntityNotFoundException if not found.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.The JSON string containing the form field values for this entry. Validated against the template’s
JsonSchemaDefinition. Must not be empty.Unit (void).
Queries
GetMedicalRecordById
Type:IRequest<MedicalRecordDto>
Fetches a complete medical record including all clinical details by primary key.
Parameters
The primary key of the medical record. Must be a non-empty GUID.
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.
Parameters
The appointment whose record to retrieve. Must be a non-empty GUID.
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.
Parameters
The patient whose records to retrieve. Must be a non-empty GUID.
1-based page index. Must be ≥ 1.
Number of records per page. Must be between 1 and 100 (inclusive).
PaginatedList<MedicalRecordDto>.
GetMedicalRecordsByDoctorId
Type:IRequest<PaginatedList<MedicalRecordDto>>
Returns a paginated list of all medical records authored by a specific doctor.
Parameters
The doctor whose records to retrieve. Must be a non-empty GUID.
1-based page index. Must be ≥ 1.
Number of records per page. Must be between 1 and 100 (inclusive).
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.
Parameters
The record to search within. Must be a non-empty GUID.
The template code to look for (e.g.
"BLOOD_PRESS"). Must not be empty.ClinicalDetailDto if a detail with that template code exists on the record, otherwise null.
Response Shapes
MedicalRecordDto
The unique identifier of the medical record.
The patient this record belongs to.
The doctor who completed the encounter.
The appointment this record is linked to (one-to-one).
The primary symptom or reason for the visit as recorded at the time of the encounter.
The ordered list of structured clinical detail entries collected during this encounter.
ClinicalDetailDto
The unique business key code of the
ClinicalFormTemplate used (e.g. "BLOOD_PRESS").The raw JSON payload containing the form field values, previously validated against the template’s JSON Schema draft-07 definition.