Blog

    Test Hospital Integrations Without PHI: HL7 Fixtures from Synthea

    By GauravAugust 3, 20269 mins read
    On this page

    To test hospital integrations without PHI, the fixture should be a person who was never a patient. Synthea generates that population. The channel still needs the HL7 v2 shape it will see in production, which you build from the synthetic chart, and every one of those files stays out of the production engine.

    Integration leads, QA engineers and the managers who own interface risk get the fixture pack, the assertions, the common mistakes and the pipeline setup.

    How do you test hospital integrations without PHI using Synthea?

    Testing hospital integrations without PHI means running every interface test on Synthea patients: a FHIR export of that synthetic population, HL7 v2 fixtures mapped from it for the channel, all stored only in the test environment. Agnotic Technologies treats a fixture that contains a real identifier as a failed test, even when the channel parsed it.

    Need fixtures a channel can read without PHI?

    We generate a Synthea population, shape the messages the channel expects, and keep them out of production.

    Synthea is a synthetic patient population simulator. Its default export is HL7 FHIR R4. C-CDA and CSV are off unless the settings file turns them on. The project describes the records as synthetic, not real.

    • Generate: run Synthea for a small population, with FHIR R4 export left on.
    • Shape: from that chart, write the HL7 v2 message the channel source actually accepts.
    • Store: put the fixtures in the test repository. Do not drop them in a production pickup folder.
    • Label: every file says synthetic, and the sending facility is a name that does not exist at the hospital.

    Synthea does not emit the ORM or ADT your channel already parses. Copying a FHIR bundle onto an HL7 listener will not pass. The fixture step is a mapping, with the synthetic patient as the only input.

    What goes in the fixture pack?

    The fixture pack holds one message per event the channel claims to handle, plus a second message where a segment is optional. Agnotic names the file after the event, not after a patient.

    • Registration: an admit and an update, if the channel has both.
    • Order: one order message with the placer number your test destination will echo.
    • Result: one observation message whose filler number matches that order.
    • Negative: one message the channel must reject, with the expected error in the test, not in a comment.

    HL7's v2 event type table (0003) defines O01 as ORM - Order message, and R01 as ORU/ACK - Unsolicited transmission of an observation message.

    Use those event names in the test title. A green build that only checked 'a message arrived' did not test the channel.

    How do you keep synthetic patients out of production?

    Keep synthetic patients out of production by giving the fixture a sending facility and an identifier namespace that the production filters reject, and by running the suite against a test engine. Agnotic adds that reject rule on the production channel as a backstop.

    • Namespace: fixture patient ids use a prefix no registration system at the hospital allocates.
    • Facility: the sending facility code is one the production channel drops.
    • Engine: the test suite addresses the test engine. The production host is not in the test configuration.
    • Review: a pull request that adds a fixture is checked for a real name, a real medical record number or a real address. Any one of those fails the review.

    A synthetic record that lands in a production chart is still a bad chart. The person is invented, and the orders around them are not. Stop the channel, remove the row, and fix the path that allowed the file to be picked up.

    What does the test assert?

    The test asserts the acknowledgement, the field the transformer was supposed to set, and the destination the message took. Agnotic writes those three checks per event and leaves volume and failover to their own tests.

    • ACK: the code you expect for a valid fixture, and the code you expect for the negative fixture.
    • Field: one value the transformer writes, present in the outbound message.
    • Route: the destination that received it, when the channel has more than one.
    • Absence: the production host received nothing. Assert that, do not assume it.

    Refresh the pack when the channel's message profile changes. A fixture that no longer matches the profile is a stale test, and a stale test hides a broken map.

    How do you turn a Synthea chart into an HL7 v2 message?

    Turn a Synthea chart into an HL7 v2 message with a small mapping script that reads the FHIR bundle and writes the segments your channel expects. The script is test code: it lives in the test repository and runs only against synthetic bundles.

    • Header: the MSH segment carries the fixture sending facility and the message type for the event.
    • Patient: PID takes the synthetic identifier, name, birth date and sex from the Patient resource.
    • Visit: PV1 takes the class and location from an Encounter in the same bundle.
    • Order and result: OBR and OBX take the test, the value and the time from the matching request and Observation.

    Keep the mapping one way. The script reads Synthea output and writes HL7. It never reads a production message, so a bug in it cannot copy a real person into the pack.

    Which acknowledgement should each fixture expect?

    Each fixture should name the acknowledgement code it expects, so the test can fail on a wrong code rather than on a missing reply. A valid fixture expects an accept. The negative fixture expects an error or a reject, and the test says which.

    HL7 v2 table 0008 defines the acknowledgment codes AA (application accept), AE (application error) and AR (application reject), plus the commit codes CA, CE and CR for enhanced mode.

    Ask the destination team which code they return for a message they cannot store. Some systems answer AE for a bad field and AR for a message they refuse outright. Write that answer into the negative test instead of accepting either.

    How do you keep the fixture pack reproducible?

    Keep the pack reproducible by recording the Synthea version, the command line and the settings file next to the fixtures. Another engineer should be able to rebuild the same population and get the same messages.

    • Version: the release or commit of Synthea you ran.
    • Settings: the properties file, including which exporters were on.
    • Command: the population size, the location options and any seed you passed.
    • Output: the generated bundles are checked in, or the script regenerates them in the test job.

    What edge cases belong in the pack?

    The pack should include the shapes that break parsers in production: long values, special characters, repeating fields and optional segments left out. A suite of clean, average patients passes on a channel that fails on its first unusual admission.

    • Names: a hyphenated family name and a name with an apostrophe or an accented character.
    • Identifiers: a patient with two identifiers in the repeating field.
    • Timing: an event stamped just before midnight, so date handling is tested across the day boundary.
    • Missing data: a message where an optional segment is absent, not just empty.
    • Escapes: a value that contains one of the HL7 delimiter characters, so the escape handling runs.

    Synthea will not produce all of these on its own. Edit the generated values in the mapping step, and keep the edit in code so it is repeated on every rebuild.

    A worked example: one synthetic admit and one result

    A worked example: a lab results channel needs an admit, an order and a result for the same patient. The team generates a small population and picks one synthetic adult with an encounter and a lab Observation.

    The mapping script writes three files: an admit that registers the patient under the fixture namespace, an order whose placer number the test records, and a result whose filler number matches that order.

    The test sends all three to the test engine, checks the accept on each, confirms the result routed to the lab destination with the order number intact, and checks that the production host saw nothing. A fourth file with a missing patient identifier expects the reject.

    Who reviews a new fixture before it merges?

    A second engineer reviews every new fixture before it merges, and the review checks origin as well as format. The question is not only whether the message parses, but whether every value in it came from the generator.

    • Origin: the fixture was produced by the mapping script, not pasted in.
    • Namespace: the patient id carries the fixture prefix.
    • Facility: the sending facility is the fixture code production drops.
    • Free text: notes and comments contain no copied clinical text.

    How should the fixture suite run in the build pipeline?

    Run the suite on every change to the channel export, against a test engine started for that job, and fail the build on any assertion. A suite that runs only when someone remembers is a suite that drifts.

    • Engine: started fresh in the job from a pinned image, with the channel under test imported.
    • Configuration: the job holds only test hosts. A production address in the job settings fails a lint step before the tests start.
    • Output: the acknowledgement, the routed destination and the marker field for each fixture, kept as a build artifact.

    How do you catch a fixture that reached production?

    Catch a leaked fixture with an alert on the production channel that fires whenever the fixture sending facility or namespace appears. The reject rule stops the message. The alert tells a person it was tried.

    Treat each alert as an incident with a cause. Usually a test job pointed at the wrong host, or a file was copied into a pickup folder by hand. Fix the path, not only the file.

    What are the common mistakes with synthetic test data?

    The common mistakes are letting a real value slip into a fixture, testing only clean patients, and running the suite where production can see it. Each one turns a safe test pack into a risk or a blind spot.

    • Hand-edited fixtures: a developer pastes a real medical record number to reproduce a bug, and it is merged.
    • Average patients only: every fixture has a short name, one identifier and every optional segment present.
    • Shared hosts: the test job and production share a pickup folder or a listener port.
    • Unrecorded generator settings: nobody can rebuild the population after the mapping script changes.

    How does Agnotic build the pack?

    Agnotic generates a small Synthea population, maps the events your channel lists, and wires the assertions into the channel test you already run. You choose the events. We do not point the suite at production.

    Send the channel export and the list of events. We will return fixtures that carry a synthetic facility code and a test that fails if that code is missing.

    Build the fixture pack

    Synthetic patients, the HL7 shape your channel reads, and a rule that production rejects the fixture facility.

    Sources

    Frequently Asked Questions

    No. The default export is FHIR R4. C-CDA and CSV are optional. You build the HL7 v2 fixture from that synthetic chart so it matches the channel.

    Talk to an engineer about your project

    Send the channel export and the events it must accept. We will shape synthetic fixtures and a check that production would reject them.

    Go deeper

    Services and solutions on this topic