 <p>I agree, there are better ways to create a header for CCDA documents, however, if you'd like to stick with your solution here is the missing part:</p> <pre><code>var clinicalDocument = new XML ("&lt;clinicalDocument&gt;&lt;/clinicalDocument&gt;"); clinicalDocument['realmCode']['@code']="US"; clinicalDocument['typeId']['@extension']="POCD_HD000040"; clinicalDocument['typeId']['@root']="2.16.840.1.113883.1.3"; createSegment('templateId', clinicalDocument); createSegment('templateId', clinicalDocument, 1); createSegment('templateId', clinicalDocument, 2); clinicalDocument['templateId'][0]['@root']="2.16.840.1.113883.10.20.22.1.1"; clinicalDocument['templateId'][1]['@root']="2.16.840.1.113883.10.20.24.1.1"; clinicalDocument['templateId'][2]['@root']="2.16.840.1.113883.10.20.24.1.2"; clinicalDocument['documentationOf']['serviceEvent']['performer']['assignedEntity']['code']['@codeSystemName']="Healthcare Provider Taxonomy"; clinicalDocument['documentationOf']['serviceEvent']['performer']['assignedEntity']['code']['@displayName']="Adult Medicine"; logger.info("Data : "+clinicalDocument); </code></pre>