Dehydrate (serialize) as XML

Verified
Added by iNTERFACEWARE

How to dehydrate (serialize) raw XML data, this can be useful for storing in a databases

Source Code
local Vmd = 'example/demo.vmd'

function main(Data)
   local H = hl7.parse{vmd=Vmd,data=Data}
   local D = MyTemplate()

   D.data.ssn = H.PID[19]
   D.data.dob = H.PID[7][1]
   D.data.ascension_num = H.PID[3][1][1]

   local SerializedXml = D:S()

   D = DehydrateXml(SerializedXml)
   trace(D.data.ssn:nodeValue())
end

function MyTemplate()
   return xml.parse{data="<data ssn='' dob='' ascension_num=''/>"}
end

function DehydrateXml(Xml)
   return xml.parse{data=Xml}
end
Description
How to dehydrate (serialize) raw XML data, this can be useful for storing in a databases
Usage Details

Demonstrates how to serialize HL7 message data as XML, by using xml.parse{}. This can be very useful for storing raw data in a database, as opposed than breaking it out and saving it in various tables.

How to use the snippet:

  • Paste the code into your script
  • Inspect the annotations to see how it works