Example: Mapping HL7 to XML

www.altova.com Print this Topic Previous Page Up One Level Next page

Home >  Data Sources and Targets > EDI > HL7 Version 2 >

Example: Mapping HL7 to XML

This example illustrates how to map a file which contains two HL7 messages ("Query for vaccination record" and "Unsolicited vaccination record update") to two separate XML target files. It is accompanied by a mapping available at the following path: <Documents>\Altova\MapForce2019\MapForceExamples\HL7_MultiMessageTypes.mfd.

mf_map_HL7_MultiMessageTypes

HL7_MultiMessageTypes.mfd

The mapping can be created as shown in the steps below.

 

Step 1: Add the source HL7 file to the mapping

1.On the Insert menu, click EDI.
2.Select the collection "HL7", and then select the check boxes next to the message types "VXQ - Query for vaccination record" and "VXU - Unsolicited vaccination record update".
3.When prompted to supply an instance file, open the source file available at the following path: <Documents>\Altova\MapForce2019\MapForceExamples\hl7multi_v02_v04.hl7.
4.When prompted, adjust the settings of the newly added HL7 component if necessary (for more information, see EDI Component Settings).

 

Step 2: Add the target schema to the mapping

1.On the Insert menu, click the XML Schema/File, and open the VaccinationQueryReport.xsd file from the <Documents>\Altova\MapForce2019\MapForceExamples\ directory.
2.When prompted to supply a sample XML file, click Skip.

 

Follow the same steps to add the UnsolicitedVaccinationLog.xsd as a mapping component.

 

Step 3: Add functions and draw the mapping connections

In the source HL7 file, dates have the format YYYYMMDD. To convert such dates to a format suitable for the target XML file YYYY-MM-DD, we will add a date conversion function, as follows:

 

1.Drag the parse-date function from the Libraries window into the mapping. For more information about functions, see Working with Functions.
2.On the Insert menu, click Constant, and enter [Y,4-4][M,2-2][D,2-2] as constant value.
3.Draw the following connections:

From

To

Purpose

Constant

format input item of the parse-date function

Supplies to the function the format according to which the date should be parsed.

RXA-3

value input item of the parse-date function

Supplies to the function the actual value to be formatted.

result output item of the parse-date function

startdate input item of the XML target

Supplies the value returned by the function to the startdate XML node.

Follow the same steps to a new parse-date function, so as to convert the value of RXA-4 and copy it to the enddate item of the target XML.

 

The patientname item in the second target XML is created by concatenating two fields of the source HL7 file: FN-1 (Surname) and XPN-2 (Given Name). To achieve this, this drag the concat function from the Libraries window onto the mapping. Also, add a constant that will supply the space character to separate the two names.

 

Draw the remaining mapping connections as shown in the example mapping (these are too many to be listed here; essentially, each connection copies values from the source HL7 file to the target XML files. For basic information about mapping connections, see Working with Connections.)

 

To preview the output generated by any of the target XML components, first click its Preview ( btn_component_preview_pressed ) button, and then click the Output tab.


© 2019 Altova GmbH