Skip to main content


An Easy Way to Write HL7(TDS) Messages in XML Format in IIB

The Perficient project lead handling an Enterprise Integration project at one of the largest healthcare providers in the country called me one afternoon and asked me to find a quick solution to write HL7 messages in XML format as some vendors that were being integrated needed the messages in XML. I knew that the solution had to be simple and I assured him of that.

Representing the HL7 message in XML format is not normative below v.3, and they are represented in physical format as TDS(Tagged/Delimiter String) messages. The TDS format of the message implies that the parser has the message schema(message set) available, which it uses to parse and validate the messages. The XML format is self-defining, while constraints on the message can be defined through XSDs .

I began to think about how to accomplish the task without accessing every HL7 field and copying every single field to the output XML. In IIB, data is represented in trees, parsed TDS messages are no different. After the incoming HL7 message is parsed, it is under the data part of the Root(Body). The names of the fields appear as defined in the message schema.

In view of this information, to accomplish the task,  I realized that it just suffices that the parsed content in the InputBody be assigned to the OutputRoot while using the XMLNS or XMLSNC parser. After this is done, while writing the output message, IIB writes the data in XML format. If the DFDL message set and parser are used, then the following has to be done:

SET OutputRoot.XMLNSC = InputRoot.DFDL;

Since, XML is self-defining, it does not need a message set to specify the physical format of the data. But, if validation of the values is required, it has to be made sure that the properties part of the Root contains a reference to the message set and of course, validation has to be turned on at appropriate exit points. Both DFDL and MRM message schemas in IIB are model driven and they will validate the values before writing the output XML. For example, if the name of the message set is HL7v251DFDLSharedLib, then:

IBM / Red Hat - Unlock Potential App Modernization
Unlock Your Potential with Application Modernization

Application modernization is a growing area of focus for enterprises. If you’re considering this path to cloud adoption, this guide explores considerations for the best approach – cloud native or legacy migration – and more.

Get the Guide

SET OutputRoot.Properties.MessageSet = ‘{HL7v251DFDLSharedLib}’;

For physical formats of the input and output, please refer below:

Input message:

Output XML:


The field names in the output XML as defined in the message schema  can be changed by modifying it.


Note: 1) IBM provides a HL7 healthcare pack with message sets both in MRM and DFDL formats with various HL7 nodes. DFDL formats are defined for v 2.5 and above. To avail this, the IIB Healthcare pack has to be installed on the top of IIB installation.

2) HL7 v.3 now provides specification for the HL7 messages in XML.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Sujai Pandit

More from this Author

Follow Us