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.

Clinical Form Templates define the structured data schemas that govern what information is collected during a medical encounter. Each template has an immutable Code (its natural business key), a human-readable Name and Description, and a JsonSchemaDefinition string — a JSON Schema draft-07 document that the backend uses to validate DynamicClinicalDetail payloads and that the frontend uses to render the appropriate form fields dynamically. Templates are soft-deletable; deactivated templates can no longer be used in new encounters but their existing clinical detail records remain intact.
The JsonSchemaDefinition field is validated at command time by IJsonSchemaDefinitionValidator.IsValidSchema. Providing a value that is not valid JSON Schema draft-07 causes the FluentValidation step to reject the command with DomainErrors.Validation.InvalidFormat before any domain logic runs. If JsonSchemaDefinition is omitted or whitespace-only, the domain stores an empty schema {}.

Commands

CreateClinicalFormTemplate

Type: IRequest<Guid> Creates a new active clinical form template. The Code must be unique across all templates (including soft-deleted ones) — the repository enforces this constraint. Name is validated for maximum 100 characters; Description for maximum 500 characters.
public sealed record CreateClinicalFormTemplateCommand(
    string Code,
    string Name,
    string Description,
    string JsonSchemaDefinition
) : IRequest<Guid>;

Parameters

Code
string
required
The immutable natural key for this template (e.g. "BLOOD_PRESS", "DENTAL_ODONTOGRAM"). Must not be empty. After creation, the Code cannot be changed — altering it would break all historical ClinicalDetail records that reference it.
Name
string
required
A descriptive display name (e.g. "Blood Pressure Reading"). Must not be empty and must be ≤ 100 characters.
Description
string
A brief explanation of the template’s clinical purpose. Optional; must be ≤ 500 characters if provided.
JsonSchemaDefinition
string
A JSON Schema draft-07 string defining the form’s field structure, types, and constraints. Validated by IJsonSchemaDefinitionValidator.IsValidSchema when provided. If omitted or whitespace, the domain stores {} (empty schema). See the example below for a minimal schema.
Returns: The newly created ClinicalFormTemplate.Id as a Guid.
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "required": ["systolic", "diastolic"],
  "properties": {
    "systolic": {
      "type": "integer",
      "minimum": 60,
      "maximum": 250,
      "description": "Systolic pressure in mmHg"
    },
    "diastolic": {
      "type": "integer",
      "minimum": 40,
      "maximum": 150,
      "description": "Diastolic pressure in mmHg"
    },
    "notes": {
      "type": "string",
      "maxLength": 500
    }
  }
}
A JsonDataPayload submitted against this template must provide systolic and diastolic as integers within the specified ranges.

UpdateClinicalFormTemplate

Type: IRequest (returns Unit) Updates the Name, Description, and JsonSchemaDefinition of an existing template. The Code is always immutable and cannot be modified. The same IJsonSchemaDefinitionValidator check applies to the new schema.
public sealed record UpdateClinicalFormTemplateCommand(
    Guid TemplateId,
    string Name,
    string Description,
    string JsonSchemaDefinition
) : IRequest;

Parameters

TemplateId
Guid
required
The primary key of the template to update. Must be a non-empty GUID.
Name
string
required
Replacement display name. Must not be empty and must be ≤ 100 characters.
Description
string
Replacement description. Must be ≤ 500 characters if provided.
JsonSchemaDefinition
string
Replacement JSON Schema draft-07 string. Validated by IJsonSchemaDefinitionValidator when non-empty.
Returns: Unit (void).

DeactivateClinicalFormTemplate

Type: IRequest (returns Unit) Soft-deletes a template, preventing it from being used in new CompleteMedicalEncounter or AddClinicalDetailToMedicalRecord operations. Throws BusinessRuleValidationException with DomainErrors.ClinicalFormTemplate.AlreadyInactive if the template is already deactivated.
public sealed record DeactivateClinicalFormTemplateCommand(Guid TemplateId) : IRequest;

Parameters

TemplateId
Guid
required
The template to deactivate. Must be a non-empty GUID.
Returns: Unit (void).

ReactivateClinicalFormTemplate

Type: IRequest (returns Unit) Restores a previously deactivated template, making it available again for new clinical detail submissions. Throws BusinessRuleValidationException with DomainErrors.ClinicalFormTemplate.AlreadyActive if the template is not currently deactivated.
public sealed record ReactivateClinicalFormTemplateCommand(Guid TemplateId) : IRequest;

Parameters

TemplateId
Guid
required
The template to reactivate. Must be currently soft-deleted.
Returns: Unit (void).

Queries

GetClinicalFormTemplateById

Type: IRequest<ClinicalFormTemplateDto> Fetches a single template by its primary key (UUID).
public sealed record GetClinicalFormTemplateByIdQuery(Guid ClinicalFormTemplateId)
    : IRequest<ClinicalFormTemplateDto>;

Parameters

ClinicalFormTemplateId
Guid
required
The primary key of the template. Must be a non-empty GUID.
Returns: A ClinicalFormTemplateDto or throws EntityNotFoundException.

GetClinicalFormTemplateByCode

Type: IRequest<ClinicalFormTemplateDto> Fetches a template by its immutable Code business key. Preferred over ID-based lookup when referencing templates by code from external systems or frontend form renderers.
public sealed record GetClinicalFormTemplateByCodeQuery(string Code)
    : IRequest<ClinicalFormTemplateDto>;

Parameters

Code
string
required
The unique business key code (e.g. "BLOOD_PRESS"). Must not be empty. Case-sensitive.
Returns: A ClinicalFormTemplateDto or throws EntityNotFoundException.

GetAllActiveClinicalFormTemplates

Type: IRequest<IReadOnlyList<ClinicalFormTemplateDto>> Returns all templates that are currently active (not soft-deleted). Used to populate template selection lists in the encounter UI.
public sealed record GetAllActiveClinicalFormTemplatesQuery
    : IRequest<IReadOnlyList<ClinicalFormTemplateDto>>;
This query accepts no parameters and has no validator. Returns: A read-only list of active ClinicalFormTemplateDto records.

GetAllClinicalFormTemplates

Type: IRequest<IReadOnlyList<ClinicalFormTemplateDto>> Returns the complete template catalogue, including soft-deleted entries. Intended for administrative management views.
public sealed record GetAllClinicalFormTemplatesQuery
    : IRequest<IReadOnlyList<ClinicalFormTemplateDto>>;
This query accepts no parameters and has no validator. Returns: A read-only list of all ClinicalFormTemplateDto records (active + inactive).

Response Shape

ClinicalFormTemplateDto

public sealed record ClinicalFormTemplateDto(
    Guid Id,
    string Code,
    string Name,
    string Description,
    string JsonSchemaDefinition,
    bool IsDeleted
);
Id
Guid
The unique identifier of the template.
Code
string
The immutable natural key used to reference this template in clinical detail records (e.g. "BLOOD_PRESS"). Changing this value would break historical records.
Name
string
The display name of the template (e.g. "Blood Pressure Reading").
Description
string
A brief description of the template’s clinical purpose.
JsonSchemaDefinition
string
The raw JSON Schema draft-07 string. Used by the backend to validate JsonDataPayload values submitted against this template and by the frontend to render the appropriate input form. Defaults to {} when no schema was provided at creation.
IsDeleted
bool
true if the template has been deactivated (soft-deleted) and is no longer available for new encounters; false if currently active.

Build docs developers (and LLMs) love