Integration & IT Modernization

Handling HL7 Data Using Apache Camel and JBoss Fuse

Introduction

HL7 is a healthcare related data format created by Health Level Seven International for electronic interchange of health information used in clinical practice, management and evaluation of health services. Over the years HL7 International Organization has defined standards for exchanging data between various medical entities and systems dubbed as HL7 Data Format.

Background

Why do we need HL7 or a Singular Data Format across Multiple Systems?

HL7 interface engine supports data interchange between multiple systems reducing the configuration and development time considerably in contrast with traditional point to point communication systems development. This standardized format comes with documentation, provides HIPAA security compliance, can communicate with medical instruments like EMR, RIS etc.

Different systems over the years have adopted and implemented these interfaces in their preferred programming language and created HL7 engines with easy connectors. Here in this document we are going to discuss how this is done in JBoss Fuse using Apache Camel a routing or mediation engine.

What is Apache Camel?

Apache Camel is an open-source routing/mediation engine that implements different Enterprise Application Integration patterns used in integrating complex enterprise entities and systems. Apache Camel comes with out-of-the-box different connectors/components for connecting to different types of input data sources and vice versa to connect to different systems.

Problem Statement

Multiple systems across healthcare providers and other entities rely on communicating using HL7 data and over the time JCAPS has been a leading vendor in the field.

TCP/IP HL7 eWay Sample:

TCP/IP HL7 eWay Sample:

HL7Inbound:

HL7Inbound Sample: A standard inbound HL7 messaging project that receives HL7 messages from an external system, sends an acknowledgement of the message, provides sequence numbering, writes the HL7 message to a JMS data queue, and also writes the HL7 message and ACK to a JMS Journal queue.

HL7ForwardMSG Inbound: Inbound Forward Message mode is use with the Outbound Delayed ACK. Its purpose is to get a message from an outbound Forwarder and return and acknowledgement.

HL7Outbound:

HL7Outbound Sample: A standard outbound HL7 messaging project that receives the HL7 message from the JMS data queue, provides sequence numbering, sends the HL7 message to an external system, receives an acknowledgement from the external system, and writes the HL7 message and the ACK to a JMS Journal queue.

HL7Forward Outbound: Outbound Forward Message is use with the Delayed ACK. Its purpose is to get a message from a JMS queue and send it to an external system. No validation is performed.

HL7OutboundDelayedAck: Delayed Acknowledgement is similar to HL7Outbound, but the initial acknowledgement is received from the receiving system. After the Sender receives the first ACK, it waits for a second ACK that indicates that the message was received by the external HL7 system.

As Oracle has announced discontinuation of JCAPS with support being completely stopped by April 2016, companies are looking for alternative options to save their investments.

This article outlines one of these alternatives using JBoss Fuse and Apache Camel’s abilities and in-built libraries, a real-time implementation along with source code.We’ll also cover how the product compares to other similar products on the market and financial aspects like cost of development and cost of ownership.

Solution

Implementation

Here we are going to read data from a Camel endpoint in String format. Using Apache Camel HL7 engine, the data is unmarshaled to HL7 format and parsed into XML format. The XML is logged and the again marshaled to HL7 format sent to an inbound queue.

The message is consumed from the inbound queue and mapped to person demographics and sent out again as HL7 message completing the routes.

Software/ System Requirements:

  1. JDK version – 1.7 or higher (1.7 preferred)
  2. JBoss Developer Studio – 7.1.1 GA
  3. Maven – 3.0 or higher
  4. JBoss Fuse – 6.1.0

Project Object Model (POM Configuration)

Project structure

Core (packaging – POM)                 —————- Inbound (packaging – bundle)

—————–Xlate (Translator packaging – bundle)

—————–Outbound (packaging – bundle)

The core project serves as the parent to the inbound, Xlate, and outbound modules. Configuring parent POM dependencies is as below:

Dependencies:

Configure the parent POM to use Fuse BOM to keep versions of dependencies constant across all the child projects. Add the below in you parent POM dependencies section.

 

Code HL7 1

Make sure parent POM i.e. core-pom.xml packaging is set to POM as shown below:

Code HL7 2

Configure the properties section to get default versions of JBoss Fuse BOM and other core dependencies as below:

Code HL7 3

Configuring POM for the child projects:

The child projects should be configured to generate a bundle as a packaging format using the Maven bundle plugin. See below for the configuration:

Code HL7 4

Deep dive into the code

Inbound Route

On the inbound side HL7FormatterRouterBuilder is the primary route builder class registered in the Camel context using the blueprint.xml. A sample HL7 string is sent as a message using a timer endpoint.

Code HL7 5

The HL7 string message is added as body to this route using a new processor.

Code HL7 6

The timer sends the message every 5 seconds. This message is sent to the hl7input endpoint. To parse a HL7 message, the HAPI provides a validator to validate the HL7 message using various criteria. The validated message can be parsed using various parsers that come inbuilt with HAPI engine. Here in this example we are going to use a generic parser and an XML parser. The first one to convert data to HL7 Object and the later prints out an XML form of the HL7 message.

CustomValidationRuleBuilder.java

Code HL7 7Code HL7 8

Extend the HAPI’s ValidationRuleBuilder to create a custom rules builder for validating HL7 depending on the requirement.

Xlate Route

The HL7FormatterRouteBuilder.java class converts the incoming string and unmarshalls it to HL7 object which is sent to the outbound queue activemq:queue:HL7InboundQueue for further mapping the HL7 to Person Object.

To do so, create a new HAPI Context that can configured with rule builder and parser to parse the HL7 String data as below:Code HL7 9

Once the parser configuration is registered the data can be parsed in the camel route as follows:Code HL7 10

HL7ParseProcessor.java

The HL7ParserProcessor implements Apache Camel Processor interface. This processor is configured to read the HL7 object and print out XML as a String to the log console.

Code HL7 11

Outbound Route

The outbound has one route builder XlateRouteBuilder that reads the HL7 String input and parses it back to HL7 Object. The data in the HL7 Object is mapped to Person Demographics using a type converter. The type converter generates person object from the HL7 object.Code HL7 12

Once the type conversion is completed the data is marshaled into HL7 data object and sent out to an outbound queue for consumption by other services.

DIEMPersonTypeConvertor.java

This is a custom type converter created to convert the HL7 message object to Person Object by using Apache Camel inbuilt type converter support.Code HL7 13

Type converter implementation code snippet
Code HL7 14

Running the use case

The use case can be run as local Camel context as shown below or can be run in a fuse environment by installing the modules as bundle using the Maven URL handler command. If you’re running it as a local Camel context for testing or other purposes, make sure an instance of ActiveMQ is up and running on your local system.

Code HL7 15

Maven Install Command:

mvn:[repositoryUrl!]groupId/artifactId[/[version][/[packaging][/[classifier]]]]

Sample data

Sample XML converted HL7 message is as below:

<?xml version=”1.0″ encoding=”UTF-8″?>

<ADT_A08 xmlns=”urn:hl7-org:v2xml”>

<MSH>

<MSH.1>|</MSH.1>

<MSH.2>^~\&amp;</MSH.2>

<MSH.3>

<HD.1>MATCHMETRIX</HD.1>

</MSH.3>

<MSH.4>

<HD.1>NEXTGATE</HD.1>

</MSH.4>

<MSH.5>

<HD.1>MATCHMETRIX</HD.1>

</MSH.5>

<MSH.6>

<HD.1>NEXTGATE</HD.1>

</MSH.6>

<MSH.7>

<TS.1>20140908215923.183-0700</TS.1>

</MSH.7>

<MSH.9>

<MSG.1>ADT</MSG.1>

<MSG.2>A08</MSG.2>

</MSH.9>

Useful resources

http://camel.apache.org/hl7.html

http://hl7api.sourceforge.net/v231/apidocs/index.html

https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.0/html/Deploying_into_the_Container/files/UrlHandlers-Maven.html

https://blogs.perficient.com/integrate/2016/04/05/solving-transformation-and-routing-of-an-edi-837-health-claim/

Conclusion

Apache Camel is a mature routing engine to handle HL7 data with a vibrant community to support the product. It offers high levels of flexibility in transferring data between different data formats and proves itself as worthy replacement for JCAPS, a leader in dealing with HL7 data. Apache Camel and JBoss Fuse are also worthy competitors in terms of cost.

How does Apache Camel and JBoss Fuse fit in the big picture of an enterprise?

  • Flexibility
  • Cost Savings
  • Ease of Development / Adaptability
  • Community support
  • Future Scope

Also check out John Hart’s post on Solving and Transformation of Routing with EDI Claims for more ways to leverage Fuse and Camel.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Venkateshwara Gowru

More from this Author

Subscribe to the Weekly Blog Digest:

Sign Up
Follow Us
TwitterLinkedinFacebookYoutubeInstagram