Modeling HL7 data by using DFDL
View Details

IBM Knowledge Center

Learn how to model HL7 healthcare data by using Data Format Description Language (DFDL).
Back To Gallery

Import projects

Click Import and a shared library is imported into your workspace.

Library HL7-2.7 contains a set of DFDL schemas that model HL7 Version 2.7 messages.

The GenericHL7.xsd schema models the overall HL7 message in a generic manner that allows it to parse all HL7 message types. Segments are defined in segments.xsd comprising fields, components and sub-components defined in fields.xsd and datatypes.xsd. Z segments may be added to Z_Segments.xsd. The HL7Format.xsd schema defines suitable default values for DFDL properties.

Test data files are included in the library.

Exploring the schemas

The HL7-2.7 library is shown in the Application Development view of your workspace.

The GenericHL7.xsd schema opens in the DFDL editor. If it does not open, double-click the DFDL schema to open it in the editor.

The HL7 message is highlighted and it models a HL7 message consisting of the MSH segment followed by any number of other HL7 segments or Z segments. The main editor view shows the logical components of the message, such as elements and sequences. You can explore the HL7 message structure by expanding the elements.

The physical rendering of each logical component is described by the DFDL properties in the Representation Properties tab. DFDL properties can be specified locally on the component, or can be inherited from pre-defined sets of DFDL properties. Inherited properties have an icon shown next to them, and hovering over the icon reveals where the property is defined. In this schema, inherited properties are obtained from the HL7Format.xsd schema.

Because the settings of delimiters in a HL7 message can vary, the DFDL property Separator is set dynamically using DFDL expressions that refer to DFDL variables. The variables have default values and are overridden by the settings in the MSH segment. You can see this if you expand the MSH element in the HL7 message and look at the definition of MSH.1.FieldSeparator. Hover over MSH.1.FieldSeparator, click on the yellow 'Go to' arrow that pops up, and then in the segments.xsd schema that opens click on the Variables tab next to Representation Properties. When you have finished close segments.xsd.

You will be test parsing example HL7 data by using the HL7 message. The test parsing takes place entirely within the DFDL editor, so there is no message flow in this tutorial and no Deploy step. Before test parsing, switch to the DFDL Test perspective by clicking Window > Open Perspective and then clicking DFDL Test. (Alternatively, you can use the toolbar icon ).

Tip: If this Tutorial Steps View tab disappears when you switch perspectives, use the Window > Show View menu option to add it back.

Follow these steps to complete the tutorial

The GenericHL7.xsd DFDL schema is open in the DFDL editor. The HL7 message should be visible in the Messages section of the editor.

  1. Test parse an example data file:
    1. Click the Test Parse Model button in the DFDL editor toolbar. The Test Parse Model window opens.
    2. In the Message section, select HL7.
    3. In the Parser Input section, select Content from a data file then click Browse.
    4. Select the A01.txt file from HL7-2.7 then click OK.
    5. Set the Encoding to ASCII.
    6. Click OK. If asked to confirm switching to the DFDL Test perspective, click Yes.
  2. The results of the test parse are displayed. You should see the message Parsing completed successfully. You can dismiss this message.
  3. You can view the parsed data file in the DFDL Test - Parse view. The results of the parse can be viewed in the DFDL Test - Logical Instance view, as a tree or as XML. You can view a log of the parser actions in the DFDL Test - Trace view.
  4. Test serialize the logical instance that resulted from the parse:
    1. Click the Test Serialize Model button in the DFDL editor toolbar. The Test Serialize Model window opens.
    2. In the Serializer Input section, select Content from 'DFDL Test - Logical Instance'.
    3. Set the Encoding to ASCII.
    4. Click OK.
  5. The results of the test serialize are displayed. You should see the message Serialization completed successfully. You can dismiss this message.
  6. You can view the serialized data file in the DFDL Test - Serialize view. You can view a log of the serializer actions in the DFDL Test - Trace view.
  7. Repeat steps 1 through 6 for the ORU.txt example data file.
  8. As an alternative to the toolbar buttons, you can also test from the DFDL Test - Parse and DFDL Test - Serialize views, using the Browse button to select a data source and the green play icon to run the DFDL parser or serializer.

The shared library can be deployed to an integration node for use by message flows.

The IBM Integration Bus Healthcare Pack contains a more comprehensive set of DFDL schemas for HL7, including definitions of all HL7 message types. It also contains prebuilt patterns and connections enabling rapid clinical application and device integration for connected healthcare systems.