Mapping messages

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