Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleLet's breakdown this example script:

If you’d like to try this out in the Translator, create a custom component and use the following files:

  • View file
    nameadt.vmd

  • View file
    namepatients.vdb

Code Block
function main(Data)
   local msg, name = hl7.parse{vmd='adt.vmd', data=Data}
   local outboundTable = db.tables{vdb='patients.vdb'}

   if name == 'ADT' then 
      processADT(outboundTable, msg)
   end 
end

function mapPatient(T, PID) 
   T.id        = PID[3][1]
   T.firstName = PID[5][2]
   T.lastName  = PID[5][1][1]
   T.birthdate = PID[7]
end 

function mapKin(T, NK1) 
   if not NK1:isNull() then
      T.firstName = NK1[2][2]
      T.lastName = NK1[2][1][1]
      T.relationship = NK1[3][1]
   end
end 

function processADT(T, msg) 
   for i=1, #msg.NK1 do
      mapPatient(T.Patients[1], msg.PID)
      mapKin(T.Kin[i], msg.NK1[i])
   end 
   trace(T)
end 

...