Search code examples
javahl7hapihl7-v2

Creating multiple versions of HL7 messages within a single application using Hapi


I am new to HL7 and Hapi. By reading hapi tutorials, I figured out how to support parsing of multiple versions of HL7 in a single application: http://hl7api.sourceforge.net/xref/ca/uhn/hl7v2/examples/HandlingMultipleVersions.html

However, I am not sure how to support multiple HL7 versions while creating new messages. i.e. If I use packages and structure of version 2.6 and I want to construct HL7 message of version 2.3, How can I do that with Hapi?


Solution

  • The easiest way to accomplish this is actually to just use the structures for the highest version you want to support.

    In HL7 v2.x nothing is ever removed, they only add things to the structures and sometimes mark things as obsolete. So it's possible to create a valid 2.3 message using a 2.6 structure (but not necessarily vice versa).

    The only thing to watch out for is that you put "2.3" in the version field in the MSH segment, and that you don't accidentally use 2.6 fields that don't exist in HL7 v2.3.