In this tutorial you will learn how to transform message data. We will copy an incoming HL7 message, correct a misspelled code, capitalize patient names, and forward the outgoing HL7 message.
These are the steps:
- Preparation: Parse the message into a source HL7 node tree structure
- Preparation: Create a target node tree with the same HL7 node tree structure
- Preparation: Copy the data from source to target using
node:mapTree{}
- Transform the message to modify the data in some way, e.g., capitalize names etc.
This tutorial only addresses the last step, the preparatory steps have already been completed for you.
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.
Create the Channel [top]
- Create a Channel with the the following settings:
- Source = LLP Listener
- Destination = LLP Client
- Channel name = Transformation 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 Transformation_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, create the outgoing message, and map the message.
- The code for this is included from the imported project zip file
- No action is needed
- An incorrect code of “Mix” is used for mixed race, we will use an “if” statement to change this to “Mixed” when it occurs.
Replace line 10 with this if statement code, auto-completion will help you to find the fields and methods:
- Navigate through the sample messages to see the spelling correction in action.
- First add a
trace()
statement on the next line, and click on the Msg and Out (ADT) annotations to view them:
- Click through the sample messages, here the “MIX” race code is corrected:
- First add a
- Capitalize the patient Given Name and Surname.
- Navigate through the sample messages to see how patient names are capitalized.
- First add a
trace()
statement on the next line, and click on the Msg and Out (ADT) annotations to view them:
- Then click through the sample data, here the patient surname has been corrected:
- First add a
Complete Sample Code [top]
Here is the completed transformation code that you can cut and paste into your script.
require 'stringutil' function main(Data) -- 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} -- Map the complete message Out:mapTree(Msg) -- (1) Transform the message data -- Correct misspelling of the Race Code if Out.PID[10][1][1]:nodeValue():lower() == "mix" then Out.PID[10][1][1] = "Mixed" end -- Capitalize patient Given Name and Surname Out.PID[5][1][2] = Out.PID[5][1][2]:nodeValue():capitalize() Out.PID[5][1][1][1] = Out.PID[5][1][1][1]:nodeValue():capitalize() -- 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