Skip to content

Read multi-page PDF reports and dates without a time - #16

Merged
adrian-crainic merged 1 commit into
developfrom
fix/pdf-report-pages-and-dates
Nov 25, 2026
Merged

adrian-crainic merged 1 commit into
developfrom
fix/pdf-report-pages-and-dates

Conversation

@adrian-crainic

Copy link
Copy Markdown
Collaborator

Problem

New synthetic newborn screening reports from the laboratory were all refused with the shipped template:

  • Multi-page reports: page 2 carries only the footer, whose DOB: prints the date without the time. The dob field read the grid value on page 1 and the footer value on page 2, so the pages disagreed (template_mismatch).
  • Dates without a time: some reports print DOB or Date Collected as M/d/yyyy only, which the M/d/yyyy HH:mm format refused (field_invalid). The HL7 mapping's datetime rules take one input format, so they would also have failed on such values.

What changes

  • Template field setting first_page_only (default false): the field is read on page 1 only and its label on later pages is ignored (packie-pdf, packie-config, engine reader, generated TypeScript type). Specified in pdf-reports.md §4.2 and configuration.md §7.7.
  • Preset pdf_newborn_screening_report: dob has first_page_only: true. dob and collected are type: date with formats M/d/yyyy HH:mm and M/d/yyyy (datetime refuses a format without hours).
  • Preset pdf_newborn_screening_to_hl7_oru: PID-7, OBR-7 and SPM-17 are a when on matches ":": yyyyMMddHHmm when the value has a time, otherwise yyyyMMdd.
  • Channels created from the earlier presets keep their settings; deployers apply the presets again or make the same edits (changelog technical notes).

Tests and checks

  • New conformance test: a synthetic 2-page report whose footer repeats the birth date without the time is refused without first_page_only and reads every field with it.
  • New profile test: the ORU preset maps a report without times to date-only PID-7, OBR-7 and SPM-17.
  • cargo test for packie-pdf, packie-config, packie-engine, packie-transform, packie-routing: pass.
  • cargo clippy --all-targets -- -D warnings for packie-pdf, packie-config, packie-engine: clean.
  • Console: tsc --noEmit and the preset tests pass; npm run changelog:check passes.
  • Manual: 18 synthetic laboratory reports (1 and 2 pages, with and without times; kept outside the repository) read and map end to end with the engine reader and the shipped mapping. A local engine with the change, configured with the same edits, routed 4 new reports over SFTP to hl7_file; the embedded PDFs match the originals byte for byte.

Changelog

changelog.d/2026-11-25-pdf-report-pages-and-dates.md; CHANGELOG.md regenerated.

Dependencies

None.

Remaining limits

  • Not seen yet: reports of 3 or more pages, and a below-label block (recipient, facilities) split across a page break; the latter would read only the lines on the label's page.

🤖 Generated with Claude Code

A template field can be limited to page 1 (`first_page_only`), so a footer that repeats a
label with a different value on later pages no longer makes the report invalid. The newborn
screening preset reads `dob` on page 1 only, accepts `dob` and `collected` with or without a
time, and writes PID-7, OBR-7 and SPM-17 to the minute or as a date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@adrian-crainic
adrian-crainic merged commit cb960de into develop Nov 25, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant