Mapping messages
Verified
Added by iNTERFACEWARE
How to map all or part of an HL7 message (similar principles apply to other message types)
Source Code
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 whole message -- Out:mapTree(Msg) -- uncomment to map the complete message -- map a range of fields in a message -- in this case the first three segments -- Out:mapRange(Msg, 1,3) -- uncomment to map message range -- map selected fields in a message -- comment out (or remove) when mapping whole message Out.PID[3][1][1] = Msg.PID[3][1][1] Out.PID[5][1][1][1] = Msg.PID[5][1][1][1] Out.PID[5][1][2] = Msg.PID[5][1][2] Out.PID[19] = Msg.PID[19] -- Push the outgoing message into the Iguana queue queue.push(Out) end
Description
How to map all or part of an HL7 message (similar principles apply to other message types)
Attachments
Usage Details
This example shows how to map data between two HL7 messages. The message is parsed into a read-only source HL7 node tree structure, and then copied into writeable HL7 node tree. The code shows how to map the whole message (using the mapTree()
function) or part of the message (by mapping individual fields).
The process for mapping other message types follows the same general pattern as partial mapping (there is no equivalent to mapTree()
or mapRange()
for other message types).
How to use the code:
- Use a Filter or To Translator script
- Add the code
- Load the sample messages from sample_data.txt
- Alternatively you can also load the attached project which already contains the sample messages
- Inspect the code and annotations to see how it works
Note: See the Interface Tutorials (Iguana 5 documentation) section for more information on mapping and transforming other message types.