Skip to main content

Medical Prescription

The prescription a clinic's record system prints for a patient to take to a pharmacy. The prescriber, the patient and every medicine come from the record, so one document serves every prescription the clinic writes. The page carries the security features prescription paper is printed with, drawn as part of the document, so they print with the prescription instead of on pre-printed stock.

  • Prescriber and patient. Two ruled cards of equal height, side by side: the prescriber's name, clinic, address, telephone, licence number and controlled-substance registration, and the patient's name, date of birth, address and record number. The allergies sit under both in a red box behind a warning sign, a Font Awesome glyph (vendored/fa-solid-900.otf) in a span of its own, where the pharmacist reads them before the medicines.
  • One row for each medicine. The table repeats over the record's medications list: the drug, its strength and form, the directions in plain words, the quantity in figures and in words inside a boxed column, the refills, and whether the pharmacy may substitute. A closing line states how many medicines were prescribed, so an added row is plain to see.
  • Security drawn on the page. A pale wash from teal to rose under a fine screen of wavy lines, a microlettered border, a VOID pantograph behind the medicines, and a signature line that is a rule of microprinted text. The footer lists each feature as a "Do not accept if" check for the pharmacist.
  • A signature from the record. The prescriber's signed name comes from the data, set in a handwriting face, Mrs Saint Delafield (fonts/MrsSaintDelafield-Regular.ttf), over the microprinted line, so every prescriber signs with their own name and no image is stored per doctor.
  • A code the pharmacy scans. The prescription ID as a Data Matrix code beside the signature, with the ID printed in a fixed-pitch face under its caption.
  • Archival and accessible. It claims PDF/A-2a and PDF/UA-1. The medicines table has header cells, the signature is real text set in a script face, so it is read out and copied as the name, and every security feature is a watermark, so it is an artifact a screen reader skips.

Features used: PDF/A-2a, PDF/UA-1 conformance, watermarks, columns, tables, SVG, barcodes (datamatrix), data binding, components, headers and footers

How it's built​

The medicines are a table with a source. The first row is the header; the second is the template, written once with $item tokens and repeated for each entry in the list. A [span, …] gives the drug name, the directions and the quantity their own sizes inside one cell, and the substitution cell takes its style from the data, so "Dispense as written" prints in red:

{
"table": {
"style": "medTable",
"widths": [1, 10, 3, 2, 3],
"source": "$data.medications",
"rows": [
[
{ "th": "NO.", "style": "thC" },
{ "th": "MEDICATION AND DIRECTIONS", "style": "th" },
{ "th": "QUANTITY", "style": "thC" },
{ "th": "REFILLS", "style": "thC" },
{ "th": "SUBSTITUTION", "style": "thC" }
],
[
{ "td": "$item.number", "style": "tdNum" },
{ "td": "[span, drug]$item.drug[/span] [span, strength]$item.strength[/span] $item.form[br][span, sigLead]SIG[/span] [span, sig]$item.sig[/span]", "style": "tdMed" },
{ "td": "[span, qtyFig]$item.quantity[/span][br][span, qtyWords]$item.quantityWords[/span]", "style": "tdQty" },
{ "td": "[span, refillFig]$item.refills[/span][br]($item.refillsWords)", "style": "tdC" },
{ "td": "[span, $item.substitutionTone]$item.substitution[/span]", "style": "tdC" }
]
]
}
}

Each entry in medications is one medicine, with the quantity written both ways by the record system:

{ "number": "1", "drug": "Lisinopril", "strength": "10 mg", "form": "tablet",
"sig": "Take 1 tablet by mouth once a day in the morning, for blood pressure.",
"quantity": "30", "quantityWords": "THIRTY", "refills": "5", "refillsWords": "five",
"substitution": "Substitution permitted", "substitutionTone": "subOk" }

The background tint is two watermarks laid under everything else. The first is one rect the size of the sheet, filled through its style with a linearGradient from pale teal at the top left to pale rose at the bottom right. The second is the Sine Wave Stack from the SVG Patterns Gallery, its three wave paths tiled: a g with translate brings the motif to the origin, the svg draws it at 24.48 by 24.75 points, and the watermark repeats it with repeat and spacing at that same pitch, so each wave meets the next and the lines run unbroken across the page, teal and rose in turn. The pitch divides the sheet into whole tiles, 25 across 612 points and 32 down 792, so the page edge never cuts a wave short; the three waves are set 24.265 units apart instead of 25 so that the motif keeps its proportions at that height. Scraping out an entry takes off the wash and the lines together and leaves a white patch:

{
"styles": {
"paperWash": { "fill": { "linearGradient": { "angle": 135, "stops": [
{ "offset": 0, "color": "#E3F2F4" },
{ "offset": 1, "color": "#F8EAEF" }
] } }, "stroke": "none" },
"waveTeal": { "fill": "none", "stroke": "#A6D0D8", "strokeWidth": 1.2 },
"waveRose": { "fill": "none", "stroke": "#E8BFCD", "strokeWidth": 1.2 }
},
"watermarks": [
{
"scope": "page",
"content": { "svg": { "viewBox": [612, 792], "desc": "Security tint: the sheet printed in a pale wash that runs from teal at the top left to rose at the bottom right, so an erasure leaves a white patch.",
"children": [ { "rect": { "x": 0, "y": 0, "width": 612, "height": 792, "style": "paperWash" } } ] } }
},
{
"repeat": true,
"spacing": [24.48, 24.75],
"content": { "svg": { "width": 24.48, "height": 24.75, "viewBox": [72, 72.794], "desc": "Line screen: the sine wave stack tiled across the sheet in fine teal and rose lines.",
"children": [ { "g": { "translate": [-595, -237.868], "children": [
{ "path": { "d": "M 595 250 Q 604 240 613 250 T 631 250 T 649 250 T 667 250", "style": "waveTeal" } },
{ "path": { "d": "M 595 274.265 Q 604 264.265 613 274.265 T 631 274.265 T 649 274.265 T 667 274.265", "style": "waveRose" } },
{ "path": { "d": "M 595 298.529 Q 604 288.529 613 298.529 T 631 298.529 T 649 298.529 T 667 298.529", "style": "waveTeal" } }
] } } ] } }
}
]
}

The VOID pantograph is the latent-band component with VOID as its text: an even tint of fine lines in which the word is ruled across the grain. Four of these watermarks are stacked behind the medicines table, each centred by spacing from the bottom-left corner of the page, one band per watermark:

{
"style": "pantoLayer",
"spacing": [306, 446],
"content": {
"svg": {
"width": 512, "height": 50, "viewBox": [512, 50],
"desc": "Copy-void pantograph: the word VOID hidden in the line work behind the medicines",
"children": [
{ "use": { "name": "latent-band", "x": 0, "y": 0, "width": 512, "height": 50, "params": { "text": "VOID" } } }
]
}
}
}

The band is as wide as the table, 512 points, so it lines up with the table's edges, and keeps the component's cream ground and gold lines, so the medicines stand on a tint of their own.

The signature line is 240 points of 2-point bold text in an svg as wide as the line. textLength with lengthAdjust: "spacing" spreads the letters to fill it exactly, which only adds space: the text is sized to just under 240 points, four repeats of the line, because a textLength shorter than the text closes the gaps until the letters overlap.

{
"svg": {
"viewBox": [240, 3],
"title": "Microprinted signature line",
"children": [
{ "text": { "x": 0, "y": 0, "text": "ORIGINAL PRESCRIPTION · VERDANIA MEDICAL CLINIC · …", "style": "sigMicro", "textLength": 240, "lengthAdjust": "spacing" } }
]
}
}

The code is an svg barcode element bound to the prescription ID:

{
"svg": {
"width": 64, "height": 64, "viewBox": [64, 64],
"title": "Data Matrix code of prescription $data.rx.number",
"children": [
{ "barcode": { "x": 0, "y": 0, "width": 64, "height": 64, "spec": { "type": "datamatrix", "code": "$data.rx.number" } } }
]
}
}