Merge data into a database

Added by iNTERFACEWARE

Basic example of merging data into a SQLite database (code is "plug and play" as the DB will be created if it does not exist)

Source Code
function main(Data)
   -- Parse the HL7 message
   local Msg, Name = hl7.parse{vmd = 'example/demo.vmd', data = Data}
   
   -- Create the database tables target node tree
   local Out       = db.tables{vmd = 'example/demo.vmd', name = Name}
   
   --Map (part of) the message
   Out.patient[1].Id        = Msg.PID[3][1][1]
   Out.patient[1].LastName  = Msg.PID[5][1][1][1]
   Out.patient[1].GivenName = Msg.PID[5][1][2]
   Out.patient[1].Ssn       = Msg.PID[19]
   
   -- (1) Save data to database
   
   -- connect to the database
   if not Conn or not Conn:check() then
      Conn = db.connect{
         api=db.SQLITE,
         name='test',
         user='',
         password='',
         live=true
      }
   end
   
   -- merge the data into the database
   Conn:merge{data=Out, live = true}
end
Description
Basic example of merging data into a SQLite database (code is "plug and play" as the DB will be created if it does not exist)