Report Templates¶
Every report is rendered from a DOCX template. The template drives layout, headers, placeholder fields, and the overall clinical tone of the final PDF.
Template types¶
iFlow ships with three canonical template types:
template_type |
When used | Typical sections |
|---|---|---|
clinical |
Default for unspecified modes | Summary, variant table, methodology |
hereditary |
Germline / family testing | Family history, ACMG classifications, carrier status |
somatic |
Tumour testing | AMP tier table, therapeutic implications, NCCN / CKB / FDA evidence |
How the type is selected¶
Template selection happens at report creation. The logic prefers signals from the VCF metadata first, then falls back to the order:
- If the VCF metadata explicitly specifies
somaticorhereditary, use that. - Otherwise, take the order's
AnalysisMode(somaticorhereditary). - Otherwise, default to
clinical.
The chosen type is stored on the Report.template_type column and is
stable for the life of the report (re-rendering reuses the same template).
Template type is stable for the life of a report
Once assigned at creation, the template_type is not changed by
subsequent renders. To switch templates on a draft, update the field
explicitly — on a signed report, create an
amendment.
Where template files live¶
Template DOCX files are stored under
client-resources/report-templates/ in the project bucket. This directory
is exempt from retention cleanup — templates must survive even if older
orders are archived. See File Paths.
Placeholders¶
Templates consume a context dictionary assembled from:
- The report record (summary, status, signer, signed_at).
- The order (display_id, mode, priority, ordering provider).
- Subject demographics.
- Sample metadata (specimen type, collection date).
- Variant associations with their overrides, grouped by tier.
- Annotation source dates.
Placeholders are standard Jinja2-style tags inside the DOCX. Each project can extend its template with organisation-specific fields — consult your template author.
Templates are retention-exempt
Report templates live under client-resources/report-templates/ which
is exempt from retention cleanup. Do not store non-template files here.
Testing a template¶
Template changes should be validated by rendering against representative orders before being applied to real cases. The recommended workflow:
- Copy the draft template to a staging project's
client-resources/ report-templates/path. - Override the project's
template_typeconfiguration to point at the staging template. - Render a preview on a test order; check both the layout and that every placeholder resolves.
- When satisfied, promote the template to the production project.
Changing the template on an existing report¶
Re-assigning template_type on a draft report is allowed and causes the
next render to use the new template. Changing it on a signed report is
blocked — the signed PDF is the immutable truth. If a template error is
discovered post-sign-off, create an amendment
with the corrected template.
Related reading¶
- Rendering — the render pipeline.
- Sign-off PDF — how the final PDF is produced.
- File Paths — where templates live.