This article addresses mapping data between two HL7 messages. We placed the mapping code in the Filter component, which is (usually) the most logical place when you are mapping messages.
These are the steps:
- Parse the message into a read-only source HL7 node tree structure
- Create a writeable HL7 node tree for the target message
- Map the data from the source node tree to the target node tree
We recommend that you type in the code for each step, but we also include complete Sample Code if you prefer to paste it in and follow along.
Tip: If you want to modify the message data see the “Transforming Messages:” tutorials in this section. Mapping and transformation use very similar techniques, the main difference is the intention: When you are mapping you are just copying the data, when you are transforming a message you are modifying the data (as well as copying it).
Create the Channel [top]
- Create a Channel with the the following settings:
- Source = LLP Listener
- Destination = LLP Client
- Channel name = Mapping HL7 to HL7
- Activate the Filter Component: Click the Filter tab and check Use Filter.
- Click the Add Channel button to create the channel.
Ignore the red warning messages, see resolving the milestone configuration error. - Open the Translator by clicking the Edit Script link at the bottom of the Filter tab.
- Download and import the Mapping_HL7_to_HL7_Filter.zip project file.
This file contains a skeleton project and six sample HL7 messages. - Iguana will load the project and data into the Translator, your screen should look like this:
Tutorial Instructions [top]
- Pass the message data to the script.
- Iguana automatically passes the message data to the
main()
function - The message can be accessed using the
Data
parameter - No action is needed
- Iguana automatically passes the message data to the
- Parse the message into a convenient read-only “node tree” structure.
Add the following line of code to your script:
- Compare the text message and the parsed message.
Click on the Data parameter (red text) and the ADT message icon:
The messages should look something like this (we clicked on the PID segment to expand it):
- Create the writeable outgoing message.
Add the following line of code to your script:
- Map the complete message into the outgoing message, using the
node:maptree()
function.
Add the following line of code to your script:
- Compare the incoming and outgoing messages.
Add atrace()
command and click on the Msg and Out (ADT) annotations to view them:
As you can see the mapping worked correctly, the incoming and outgoing messages are identical. - Push the outgoing message into the Iguana queue.
Add the following code to your script:
Note: This is not part of the mapping process, but it is needed to forward the message to the Destination Component.
Complete Sample Code [top]
Here is the completed mapping code that you can cut and paste into your script.
function main(Data) -- (1) Parse the HL7 message local Msg, Name = hl7.parse{vmd = 'example/demo.vmd', data = Data} local Out = hl7.message{vmd = 'example/demo.vmd', name = Name} -- (2) Map the message Out:mapTree(Msg) -- (3) Push the outgoing message into the Iguana queue queue.push(Out) end
More Information [top]
- See our other interface tutorials in this section
- See our general tutorials section
- See our code samples section