Build an HL7 v2 to FHIR R4 translation pipeline for ADT A01 (admit) messages, mapping all relevant PID, PV1, DG1, and AL1 segments to corresponding FHIR resources
domain: hl7.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
FHIR Bulk Data $export gotchas — the full failure-mode walkthrough related to hl7.org, checked against official docs, with linked verified routes.
Steps
Parse the HL7 v2 ADT A01 message into its segment components using a v2 parsing library, extracting fields by segment name and field position according to the HL7 v2 message structure for ADT events
Map PID segment fields to a FHIR Patient resource: PID-3 patient identifiers to Patient.identifier, PID-5 name to Patient.name, PID-7 date of birth to Patient.birthDate, PID-8 sex to Patient.gender, and PID-11 address to Patient.address
Map PV1 segment fields to a FHIR Encounter resource: PV1-2 patient class to Encounter.class, PV1-3 assigned patient location to Encounter.location, PV1-7 attending physician to Encounter.participant, and PV1-44 admit date to Encounter.period.start
Map DG1 segments to FHIR Condition resources using DG1-3 diagnosis code (ICD-10) for Condition.code, DG1-6 diagnosis type to Condition.category, and link each Condition to the Encounter via Condition.encounter reference
Map AL1 segments to FHIR AllergyIntolerance resources using AL1-3 allergy code for AllergyIntolerance.code, AL1-2 allergy type for AllergyIntolerance.category, and AL1-4 allergy severity for AllergyIntolerance.reaction.severity
Known gotchas
HL7 v2 field encoding characters (|, ^, &, ~, \) must be unescaped before mapping field values to FHIR string elements; unmapped escape sequences appear as literal backslash characters in FHIR resources
PID-3 can contain multiple patient identifier repetitions (MRN, SSN, driver's license) separated by ~ repeating field delimiters; each repetition must be mapped to a separate Patient.identifier with the correct system URI derived from the identifier type code in component 5
The HL7 v2 to FHIR mapping specifications published by HL7 provide guidance but are not exhaustive; many sites add Z-segments with custom fields that have no standard FHIR mapping and require custom extension definitions
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?