Talend has added support for the HL7 Version 2 messaging format in the Talend Data Mapper. The screenshot below shows all the HL7 versions that can be downloaded into the Talend Studio. You can download these Talend Data Mapper packages by clicking on Help -> Install Additional Packages... option. It is advisable to only download and install the HL7 Version that you need. It is not mandatory to download and install all of them for the feature to work.
MLLP ( Minimal Lower Layer Protocol) is a requirement for all message transport protocols used to transport HL7 messages. The MLLP protocol is a minimalistic OSI-session layer framing protocol, and it is assumed that it will only be used in a network environment. Most of the details of the error detection and correction are handled by the lower levels network protocols like TCP/IP, SNA etc. In this respect, the MLLP protocol can be easily implemented using network programming and socket communication.
In this example, we will explore how to use Apache Camel Netty4 component which includes a HL7 encoder and decoder to read and produce HL7 messages. Alternatively Apache Camel MINA2 can also be used instead of Netty4 component as socket listener.Reading HL7 Message (Through MLLP)
To demonstrate how to manipulate HL7 message in talend, we will create a Producer and Consumer Routes. Producer Route will be sending messages to the port 8889 using netty component. We will send a 'Diet Order' Message using simple Java Code. Diet Order or OMD_O03 has different informations in dedicated sections.
OMD_O03 Message format
In first part we will design a route to simulate HL7 OMD message sender. Please create a new route in Route section of Talend Studio and name it accordingly.
- Place cConfig , cTimer , cProcessor and cMessagingEndpoint component on the pallete.
- Configure cConfig component to add Camel Netty4 Jar files. If these Jar files are not available in studio available Jar list, please download them from here.
- Configure cTimer component to start sending messages. This component is a
starting point for this route.
- Configure cProcessor component to build a OMD message as Java String.
- Please careful while building Java String as MLLP Protocol is 'Line Break' sensitive.
Copy and paste the code from below.
String msg = "MSH|^~\\&|DIETOOLS|1^DOMINION|JARA||20435435||OMD^O03^OMD_O03|204544545|P|2.5|||ER|AL\n" + "PID|1|1001|1001^5^M11^ADT1^MR^SHM~123456789^^^USSSA^SS||O'Tommy^Javeed^^||19810404|F||2103-3|1200 N ELM STREET^^Multan BEACH^PK^53111-1020^PK^H|OC|(92) 300-1234|(92) 61-3433||S||PATID3401^2^M21^ADT1^AN^A|123436789|U1234567^PK|\n" + "PV1|1|I|^^51C302-1^^^^^^^0005&51UHP31&UH TERCERA 1 HSPA&TIPOUOENF||||||||||||||||100002739^005^^^^^^^^0005&APARATO DIGESTIVO&5DIG&TIPOUOSERV|\n" + "ORC|XO||||||||20101117|1^^HERNAME\n" + "TQ1|1||CE||||20101117\n" + "ODS|D||PAN4^PEDIATRICA 1|\n" + "ODS|P||EVENTO^LACT|\n" + "ODS|P||CARACTERISTICA^SIN SAL|\n" + "ODS|P||CARACTERISTICA^DIABETICO|\n"; exchange.getIn().setBody(msg);
- Configure cMessagingEndpoint to use Camel Netty4 component to send
message. We will be sending message on port 8889. If this port is busy, please change it
accordingly. Please define Encoder and Decoder for HL7 as in screenshot.URI
- Run the route. It should compile but will give an Error on runtime at this stage as there is no listener on configured port.
In this section we will design a mediation route that will consume an HL7 message through the MLLP protocol and convert it to an XML message. As the MLLP protocol works on a different layer, we will use the camel-netty4 component here as well to listen to incoming messages.
Create a mediation route and place a cConfig, cMessagingEndpoint, cMap and cLog component as shown in the screenshot below.
Configure the Camel Netty4 component in the cConfig component. In Talend 6.3.1, we are using the 2.17.3 jars as shown below.
- Configure the cMessagingEndpoint to use the 'netty4' component
functionality by specifying the following in "netty4:
tcp://localhost:8889?sync=true&encoder=#hl7&decoder=#hl7decoder " in the URI
field. If port 8889 is already in use, then use a different port which is free. The system
will receive messages on the port specified.
- In this example, we are assuming that we are going to receive this message which has
information about Diet of patients. This message is sent by 'Producer Route' implemented
in earlier part.
"MSH|^~\\&|DIETOOLS|1^DOMINION|JARA||20435435||OMD^O03^OMD_O03|204544545|P|2.5|||ER|AL PID|1|1001|1001^5^M11^ADT1^MR^SHM~123456789^^^USSSA^SS||O'Tommy^Javeed^^||19810404|F||2103-3|1200 N ELM STREET^^Multan BEACH^PK^53111-1020^PK^H|OC|(92) 300-1234|(92) 61-3433||S||PATID3401^2^M21^ADT1^AN^A|123436789|U1234567^PK| PV1|1|I|^^51C302-1^^^^^^^0005&51UHP31&UH TERCERA 1 HSPA&TIPOUOENF||||||||||||||||100002739^005^^^^^^^^0005&APARATO DIGESTIVO&5DIG&TIPOUOSERV| ORC|XO||||||||20101117|1^^HERNAME TQ1|1||CE||||20101117 ODS|D||PAN4^PEDIATRICA 1| ODS|P||EVENTO^LACT| ODS|P||CARACTERISTICA^SIN SAL| ODS|P||CARACTERISTICA^DIABETICO|"
- In next step of the mediation route logic, we have to configure a cMap component
to map this incoming message into a HL7 structure. We will create a HL7 structure in
Talend Data Mapper from one of the standard message formats provided for mapping this MSH
message. We will map the attributes in the incoming message onto our XML output structure
as shown below.
- In the above example, we have mapped messageControldID, patientNumber, PatientIdentifierTypeCode and patientName.
- To complete the mediation route, we will send the output XML to a cLog component to print it in the console window.
- Start the talend mediation route and send a message to the port 8889, or other, to get
the route to process the HL7 message. The screenshot below shows the console log when a
HL7 MSH message is received. It is parsed, and the attributes we mapped in Talend Data
Mapper are extracted, and an XML is produced. The XML is printed in the console window.
The above Route is an example how to process HL7 messages. Talend Data Mapper intuitive interface and easy handling of HL7 format makes it an ideal candidate for healthcare systems integration platform.Download
Sample Job can be downloaded in the Downloads tab. Please import the job using Talend Job Import Items feature.