← Knowledge library

Laboratory & radiology

Diagnostic Report

A DiagnosticReport records the results and interpretation of a diagnostic test, tied to the ServiceRequest that ordered it. You create one to report on an investigation, then read it back with its observations, encounter, and requester…

3.1 · versioned documentation · 6 min read

A DiagnosticReport records the results and interpretation of a diagnostic test, tied to the ServiceRequest that ordered it. You create one to report on an investigation, then read it back with its observations, encounter, and requester embedded.

The Django model (care/emr/models/diagnostic_report.py) imposes no shape: it persists category and code as opaque JSONFields and status as a free CharField. Shape and validation come from the Pydantic resource specs (care/emr/resources/diagnostic_report/) — the status enum, the coded-concept structure, the bound value sets, and the separate read/write API schemas. The specs build on EMRResource and serialize between the API and the model.

Source:

Models

Model Purpose
DiagnosticReport Results and interpretation of a diagnostic test or investigation, tied to a ServiceRequest

DiagnosticReport extends EMRBaseModel, the shared MANSOQ EMR base that provides external_id, created_date/modified_date, soft-delete via deleted, created_by/updated_by, and history/meta JSON.

DiagnosticReport fields

Classification

Field Model type Spec shape Notes
status CharField(255) DiagnosticReportStatusChoices (enum, required) Lifecycle status. Stored as free text but constrained to the enum below on write. Optional on update.
category JSONField (null) Coding { system, version?, code, display? }, required Service section the report belongs to. code is validated against the Diagnostic Service Sections value set.
code JSONField (null) Coding { system, version?, code, display? }, optional The test or panel performed. code is validated against the Observation value set (LOINC). Nullable.

The Coding shape (from care/emr/resources/common/coding.py, extra="forbid"):

Field Type Required Notes
system str optional Code system URI (e.g. http://terminology.hl7.org/CodeSystem/v2-0074, http://loinc.org)
version str optional Code system version
code str required The code; validated against the bound value set
display str optional Human-readable label

Narrative

Field Model type Spec shape Notes
note TextField (null) str | None Free-text comments. Not parsed by the platform.
conclusion TextField (null) str | None Clinical interpretation/summary of the results. Not parsed by the platform.

Relationships

Field Type Notes
facility FK → facility.Facility PROTECT, nullable. Facility the report is scoped to. Set server-side; not a writable spec field.
patient FK → emr.Patient CASCADE. Subject of the report. Set server-side; not a writable spec field.
encounter FK → emr.Encounter CASCADE. Encounter the report was produced under. Set server-side; not a writable spec field.
service_request FK → emr.ServiceRequest CASCADE. The order this report fulfils. Write-only on create (resolved from external_id); excluded from base serialization via __exclude__.

Enum values

DiagnosticReportStatusChoices

From spec.py. (modified is defined in source but commented out and is not an active value.)

Value Meaning
registered Report exists / has been registered
partial Some results available, report incomplete
preliminary Provisional results pending verification
final Verified, complete report

Bound value sets

Coded fields validate their code against a registered MANSOQ value set (ValueSetBoundCoding). A code outside the bound set is rejected at deserialization.

Field Value set Slug Included system(s)
category Diagnostic Service Sections system-diagnostic-service-sections-code http://terminology.hl7.org/CodeSystem/v2-0074
code Observation system-observation http://loinc.org

Resource specs (API schema)

Every spec extends EMRResource (care/emr/resources/base.py) through DiagnosticReportSpecBase. serialize builds the read payload from the model (mapping external_id → id); de_serialize writes spec fields back to the model. The perform_extra_serialization/perform_extra_deserialization hooks handle server-side behaviour — resolving foreign keys on write, embedding related resources on read.

Spec class Role Fields / behaviour
DiagnosticReportSpecBase shared base id?, status (enum, required), category (bound Coding, required), code? (bound Coding), note?, conclusion?. __model__ = DiagnosticReport, __exclude__ = ["service_request"].
DiagnosticReportCreateSpec write · create Base + service_request: UUID4 (required, the request's external_id). perform_extra_deserialization resolves it via get_object_or_404(ServiceRequest, external_id=...) and sets obj.service_request.
DiagnosticReportUpdateSpec write · update Base, but status is optional (DiagnosticReportStatusChoices | None). service_request is not writable on update.
DiagnosticReportListSpec read · list Base + created_date, modified_date, service_request: dict | None. perform_extra_serialization sets id = external_id and embeds the linked request via BaseServiceRequestSpec.serialize(...).
DiagnosticReportRetrieveSpec read · detail Extends ListSpec + observations: list[dict], encounter: dict, created_by?, updated_by?, requester?. See serialization below.

DiagnosticReportRetrieveSpec.perform_extra_serialization (server-side, read)

The detail read enriches the list payload so a viewer gets the report, its observations, and its context in one call:

These embedded fields (service_request, observations, encounter, requester, audit users) are read-only and are not accepted on create/update.

Related models

DiagnosticReport is the only model defined in this file. It sits downstream of a ServiceRequest and is anchored to a patient and encounter:

diagnostic_report
  facility        → FK facility.Facility (PROTECT, nullable)
  patient         → FK emr.Patient (CASCADE)
  encounter       → FK emr.Encounter (CASCADE)
  service_request → FK emr.ServiceRequest (CASCADE)

Deleting a Patient, Encounter, or ServiceRequest cascades to its diagnostic reports; the facility link is PROTECTed. Routine deletes are soft, via EMRBaseModel. On retrieve, related Observation records are pulled in through the reverse FK (Observation.diagnostic_report).

Methods & save behaviour

API integration notes

Related

Source evidence

References are pinned to the private MANSOQ source repository. Repository access is required to open these links.