Laboratory report template

Patient details in a grid, a results table with computed flags and a sample barcode.

A rendered laboratory report with a patient grid, a results table with High and Low flags, and a barcode

What it demonstrates

  • A three column grid for the patient and sample details
  • A results table with a flag column computed by nested if expressions
  • A footer row that counts the results
  • A Code 128 barcode bound to the sample identifier

Rendered with the screen target. In print and PDF output page numbers show the real total and long tables continue onto further pages. See pagination.

Use it

render.ts
import { renderDocument } from 'docstudio';
import template from './template.json' with { type: 'json' };
import data from './data.json' with { type: 'json' };

const result = renderDocument(template, data, { target: 'print' });
if (!result.ok) {
  throw new Error(result.diagnostics.map((item) => item.message).join('; '));
}
const html = result.html;

Get the files

Copy the template and the sample data as JSON, save them as template.json and data.json, and use the snippet above to render them.