Add HL7 v2 XML parsing and FHIR R4 transformation support#24
Draft
Add HL7 v2 XML parsing and FHIR R4 transformation support#24
Conversation
Co-authored-by: Loksly <1235649+Loksly@users.noreply.github.com>
…bump to v2.1.0 Co-authored-by: Loksly <1235649+Loksly@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for XML parsing and FHIR JSON transformation
Add HL7 v2 XML parsing and FHIR R4 transformation support
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends
nodehl7with two new capabilities: parsing HL7 v2 XML-encoded messages (parseXML) and converting any parsed message to a FHIR R4 Bundle (toFHIR). No new runtime dependencies; XML parsing is implemented via a lightweight built-in tokenizer.New API
hl7Parser.parseXML(xmlContent, ID, callback?): Promise<Hl7Message>Parses HL7 v2 XML (namespace
urn:hl7-org:v2xml). Returns a standardHl7Message— fully compatible with all existing methods (get,getSegments,toMappedObject, etc.), same Promise + callback API asparse.Handles:
MSH.1/MSH.2string[], single-component →string(mirrors ER7^-split behavior)<PATIENT>) via recursive segment extractionHl7Message.toFHIR(): Record<string, unknown>Converts to a FHIR R4
Bundleof typemessage. Works on bothparse()andparseXML()results.MessageHeader.idMessageHeader.source/destinationMessageHeader.eventCoding.codePatient.identifier/name/birthDate/gender/address/telecomDates converted from
YYYYMMDD→YYYY-MM-DD; gender codesM/F/O/U→male/female/other/unknown.Other changes
package.json: bumped to2.1.0CHANGELOG.md/README.md: updated with new method docs and FHIR field mapping tabletest/testfiles/ADTA01.xml: XML equivalent of the existingADTA01.admfixturetest/testXmlAndFhir.js: 33 new tests covering parsing, FHIR output, error paths, callback API, andtoMappedObjectinteropOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.