Merge into a database

Verified
Added by iNTERFACEWARE

Use conn:merge{} to merge data into a database

Source Code
   -- connect to a SQLite database
   conn = db.connect{
      api = db.SQLITE,
      name = 'test',
      live = true
   }   
   
   -- Create the database tables target node tree
   local Out       = db.tables{vmd = 'example/demo.vmd', name = 'ADT'}
   
   -- use test data (normally mapped from HL7 or other source)
   Out.patient[1].Id        = 1
   Out.patient[1].LastName  = 'Smith'
   Out.patient[1].GivenName = 'Fred'
      
   -- merge data into a database table
   conn:merge{data=Out, live = true}
Description
Use conn:merge{} to merge data into a database
Usage Details

Use conn:merge{} to merge data into a database.The example merges data into a single table only, but you can merge into multiple tables with a single merge statement.

The code connects to a SQLite database, you can substitute with any database connection.

How to use the snippet:

  • Paste the merge code into your script