T0023 — FHIR XML fixture conversion
Part of the roadmap. Phase 1 · wave 3 · size M.
Goal
Convert the suite's XML input files to FHIR JSON once, so that every test can run.
Scope
- A model-driven FHIR XML → JSON converter in
tools/conformance, using@callis/fhir-r4and@callis/fhir-r5:- arrays according to cardinality
- typed primitives, with decimals kept as lossless text
id/extensionon primitives written as_fieldxhtml→ stringresourceType, contained resources and choice element names
- The converted JSON is committed as
name.jsonnext toname.xmlin the same fixture folder. The runner reads that exact path and skips the test asfixture not convertedwhile it is missing (T0022: converted inputs,tools/conformance/src/fixtures.ts, #48). - A check against an official JSON example where one exists (for example
patient-examplefromhl7.fhir.r4.examples), allowing only documented differences. - The conformance CI job becomes blocking, with the baseline ratchet.
Decisions made while building
- XML reader: the converter reads XML with its own strict reader (
tools/conformance/src/xml-reader.ts), notfast-xml-parser, which does not normalize whitespace in attribute values (XML 1.0 §3.3.3) and leaves undefined entities in the text. DTDs are refused. - Numbers keep their XML text in the committed JSON (
1.50,9.5e2). The runner parses inputs withJSON.parse, which loses it, until T0018 sets the adapter'sparseInputto the losslessparseJson(tools/conformance: converted inputs). - Interpretations (narrative XHTML copied as written, attribute whitespace,
integer64) are in spec notes. - Official examples: the ten inputs that copy a FHIR example are compared with the official JSON from
hl7.fhir.r4.examples4.0.1 andhl7.fhir.r5.examples5.0.0, vendored intools/conformance/official-examples/.tools/conformance/src/official-examples.tslists every difference with its reason. - Out of scope:
r5/ccda.xml, a CDA document used only by the unsupportedcdaTestsgroup (UNCONVERTED_INPUTSintools/conformance/src/fixture-conversion.ts). - Baseline: it records the tests that pass with the adapter in
engine-adapter.ts. With the stub adapter that is none: every phase-1 test runs and fails as "not implemented", or is skipped as a documented exception.
Acceptance criteria
- Every XML input referenced by the suite converts. Any input that is out of scope (such as
ccda.xml) is listed. - The comparison with official JSON examples shows no unexplained differences.
- After this task, the conformance report covers every phase-1 test, and the baseline is committed.