Add the CDA body
Contents
Now we need to create the body for our CDA document and append it underneath our header. Our CDA body section will be composed of a ‘component‘ element that contains a ‘structuredBody’ sub-element.
- Add the following lines of code to the
main()
function:
That’s it! Your shiny new CDA body should look like this in the resulting annotations:
Here is a copy-and-paste version of the entire main()
function, should you need it:
function main(Data) local Doc = cda.new() local CD = Doc.ClinicalDocument -- CDA Header FillHeader(CD) local RT = CD:addElement('recordTarget') FillPatient(RT) local A = CD:addElement('author') FillAuthor(A) local C = CD:addElement('custodian') FillCustodian(C) -- CDA Body local Body = CD:addElement('component') local SB = Body:addElement('structuredBody') net.http.respond{body=tostring(Doc)} -- TEST CODE: write CDA to file (in Iguana install dir) -- unformatted xml if iguana.isTest() then local f = io.open('cda_xml.xml','w+') f:write(tostring(Doc)) f:close() -- formatted with xsl stylesheet f = io.open('cda_web.xml','w+') f:write('\n') f:write(tostring(Doc)) f:close() end end
Review and Validate
Use the NIST Validation Tool (or the Lantana validation tool) to check our new changes to the cda_xml.xml file.
The confusing error message from our previous step is gone! Now the report simply confirms that our CDA body is not complete:
Continue: Populate the CDA body