Healthcare: HL7 to FHIR pattern

The Healthcare: HL7 to FHIR pattern provides an example application that receives Health Level Seven International(HL7®) v2 messages by using Minimal Lower Layer Protocol (MLLP) over TCP/IP, and transforms them into HL7® FHIR® standard resources. The FHIR output resources are validated and then written to a local file output directory.

Solution

Fast Healthcare Interoperability Resources (FHIR®) is a standard from Health Level 7 International (HL7®) that is designed to allow the exchange of electronic health records. The HL7® FHIR® standard uses XML and JSON for data representation. FHIR solutions can be created by using components called resources, which are built around particular concepts, such as the patient or provider, as well as diagnostics and care plans.

The application that is generated by the Healthcare: HL7 to FHIR pattern receives HL7 messages, and transforms them into FHIR R4 resources in JSON or XML format. The transformation in the generated message flow is implemented by using ESQL. The pattern provides transformation code for the following FHIR resources:

The message flow decides which FHIR resource to transform the inbound HL7 message to based on an analysis of which segments are present in the input message. If the required collection of segments is available, the transformation attempts to create just one resource out of Observation, Patient, or AllergyIntolerance (in that order of preference) in JSON format. If insufficient segments exist to generate any of these three resources, no attempt is made to create a FHIR resource. Instead, a simple JSON file output is generated that describes the number of segments that were received.

The provided flow is intended as an example only. In real life scenarios, you might have segments arriving from a variety of HL7 messages, potentially being collected together over a period of time from multiple sources. In these more complex scenarios, a Collector message flow node might be used.

The FHIR resource in JSON format is then validated using a FHIRValidate message flow node, and written to a local file output directory. You can choose the level of FHIR validation that is performed. The Schema level comprises validation of Structure, Cardinality, and Value Domains. The All level comprises validation of Structure, Cardinality, Value Domains, Invariants, Bindings, and Profiles. For more information, see https://www.hl7.org/fhir/r4/validation.html. You can select whether unknown elements in the resource are ignored or cause validation to fail. Profiles validation is turned off by default.

If the resource passes validation, the output message is the validated FHIR resource. If you select JSON as the output format, the output domain is JSON. If you select XML as the output format, the output domain is XMLNSC, and the JSON resource is converted to XML by the FHIRValidate node. FHIR warnings are saved in the local environment and are sent to the file system.

If the resource fails validation, the resource is sent to the file system. The output domain is always JSON. FHIR errors and warnings are saved in the local environment and are sent to the file system.

If an error occurs during processing, the message passed in to the FHIR Validate message flow node is sent to the file system unmodified. The associated exception list is also sent to the file system.

Constraints on the use of the pattern
Parameters for the pattern