CDA Schema specification
fieranmason@gmail.com
#1 Posted : Thursday, August 1, 2013 5:05:25 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/8/2013(UTC)
Posts: 22
Points: 66
Location: University of Victoria

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Hello Everest,

We are making good progress on our project thanks to your tool. We have arrived a point where we would like to specify the document schema with the header information for the CDA document. We have taken a close look through the formatters, settings and .Net writers available in Everest and have been unable to find functionality that would allow this. Could someone provide advice on how to accomplish this.

Regards,
Fieran
justin.fyfe1
#2 Posted : Thursday, August 1, 2013 9:47:44 PM(UTC)

Rank: Administration

Medals: Mobile Tech Grasshopper: Mobile Tech GrasshopperHealth Informatics MVP

Groups: Registered, Administrators
Joined: 7/22/2010(UTC)
Posts: 96
Points: 297
Man
Location: Hamilton, ON

Thanks: 2 times
Was thanked: 17 time(s) in 17 post(s)
Hi Fieran,

I'm not sure if this is what you're looking for, but it sounds very similar to example 82 in the developers guide (overriding the root element of serialization). Here is an adaptation for CDA:

Code:

using (XmlWriter xw = XmlWriter.Create(@"C:\temp\test.xml"))
{
    // Setup Formatter
    var structureFormatter = new XmlIts1Formatter() { ValidateConformance = false };
    structureFormatter.GraphAides.Add(new DatatypeFormatter() { ValidateConformance = false });
    // Whenever a formatter is passed an already opened XmlStateWriter with elements in-tact it won't output its own root
    using (XmlStateWriter xsw = new XmlStateWriter(xw))
    {
        // Clinical document - Root element
        xsw.WriteStartElement("ClinicalDocument", "urn:hl7-org:v3");
        // Output any additional attributes you want in the header here
        xsw.WriteAttributeString("schemaLocation", XmlIts1Formatter.NS_XSI, "urn:hl7-org:v3 file://C:/Temp/CDA.xsd");

        // Construct your CDA
        ClinicalDocument doc = new ClinicalDocument(
            Guid.NewGuid(),
            "1234-4",
            DateTime.Now,
            x_BasicConfidentialityKind.Normal,
            new RecordTarget(
                ContextControl.AdditiveNonpropagating,
                new PatientRole(
                    SET<II>.CreateSET(new II("1.2.3.4.5.6", "123"))
                )
            ),
            new Author(
                ContextControl.AdditiveNonpropagating,
                DateTime.Now,
                new AssignedAuthor(
                    SET<II>.CreateSET(new II("1.2.3.4.5.6", "321"))
                )
            ),
            null,
            new Component2(
                ActRelationshipHasComponent.HasComponent,
                true,
                BodyChoice.CreateNonXMLBody(
                    new ED("Hello!")
                )
            )
        );

        // Output body
        structureFormatter.Graph(xsw, doc);

        xsw.WriteEndElement(); // clinical document
           
    }
}


Which results in this XML:

Code:

<ClinicalDocument p1:schemaLocation="urn:hl7-org:v3 file://C:/Temp/CDA.xsd" classCode="DOCCLIN" moodCode="EVN" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:hl7-org:v3">
  <id root="EC7DF4FE-0898-4286-B696-76AF7DEB02D7" />
  <code code="1234-4" />
  <effectiveTime value="20130801220110.620-0400" />
  <confidentialityCode code="N" codeSystem="2.16.840.1.113883.5.25" displayName="normal" />
  <recordTarget typeCode="RCT" contextControlCode="AN">
    <patientRole classCode="PAT">
      <id root="1.2.3.4.5.6" extension="123" />
    </patientRole>
  </recordTarget>
  <author typeCode="AUT" contextControlCode="AN">
    <time value="20130801220110.741-0400" />
    <assignedAuthor classCode="ASSIGNED">
      <id root="1.2.3.4.5.6" extension="321" />
    </assignedAuthor>
  </author>
  <component typeCode="COMP" contextConductionInd="true">
    <nonXMLBody classCode="DOCBODY" moodCode="EVN">
      <text representation="TXT" mediaType="text/plain">Hello!</text>
    </nonXMLBody>
  </component>
</ClinicalDocument>


You can also change p1 to xsi if you add this line of code to the root element:

Code:

        xsw.WriteAttributeString("xmlns", "xsi", null, XmlIts1Formatter.NS_XSI);


Hope that helps

Cheers
-Justin
fieranmason@gmail.com
#3 Posted : Thursday, August 22, 2013 2:06:11 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/8/2013(UTC)
Posts: 22
Points: 66
Location: University of Victoria

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Thanks Justin. That got us almost all the way to what our sample files look like. The sample headers look like:

<ClinicalDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:hl7-org:v3 Schemas/CDA-PITO-E2E.xsd"
xmlns="urn:hl7-org:v3"
xmlns:hl7="urn:hl7-org:v3"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:e2e="http://standards.pito.bc.ca/E2E-DTC/cda">

To match this I modified your sample code to be:

xsw.WriteStartElement("ClinicalDocument", "urn:hl7-org:v3");
xsw.WriteAttributeString("xmlns", "xsi", null, XmlIts1Formatter.NS_XSI);
xsw.WriteAttributeString("schemaLocation", XmlIts1Formatter.NS_XSI, @"urn:hl7-org:v3 Schemas/CDA-PITO-E2E.xsd");
xsw.WriteAttributeString("xmlns", "hl7", null, @"urn:hl7-org:v3");
xsw.WriteAttributeString("xmlns", "e2e", null, @"http://standards.pito.bc.ca/E2E-DTC/cda");
xsw.WriteAttributeString("xmlns", "xs", null, @"http://www.w3.org/2001/XMLSchema");

IFormatterGraphResult result = fmtr.Graph(xsw, clinicalDocument);
xsw.WriteEndElement(); // clinical document

Upon adding the line
xsw.WriteAttributeString("xmlns", "hl7", null, @"urn:hl7-org:v3");

I started getting the hl7: prefix added to every element in the document:
<hl7:realmCode code="CA" />
<hl7:typeId root="2.16.840.1.113883.1.3" extension="POCD_HD000040" />
<hl7:templateId root="2.16.840.1.113883.3.1818.10.7.1" />
<hl7:templateId root="2.16.840.1.113883.3.1818.10.1.1" />

So it looks like when it goes to write the elements it uses the default namespace, but it looks like it's trying to disambiguate between the namespaces and uses the xmlns:hl7 namespace which tacks on the prefix. I'm not sure if this is something with the formatter or if there is another way to make it not tack on the hl7 prefix.

Can you advise?
justin.fyfe1
#4 Posted : Thursday, August 22, 2013 2:13:28 PM(UTC)

Rank: Administration

Medals: Mobile Tech Grasshopper: Mobile Tech GrasshopperHealth Informatics MVP

Groups: Registered, Administrators
Joined: 7/22/2010(UTC)
Posts: 96
Points: 297
Man
Location: Hamilton, ON

Thanks: 2 times
Was thanked: 17 time(s) in 17 post(s)
Hi Fieran,

To fix this you can omit this line:

Code:

//xsw.WriteAttributeString("xmlns", "hl7", null, "urn:hl7-org:v3");


or you can do this:

Code:

xsw.WriteStartElement("hl7", "ClinicalDocument", "urn:hl7-org:v3");
//xsw.WriteAttributeString("xmlns", "hl7", null, "urn:hl7-org:v3");


The first should get rid of the hl7: prefix, and the second will make sure that hl7: prefix is on all elements (including the root element). The sample you provided is technically correct as ClinicalDocument and anything prefixed with hl7: is in the urn:hl7-org:v3 namespace (but it is an eyesore).

Cheers
-Justin
fieranmason@gmail.com
#5 Posted : Friday, August 23, 2013 12:01:47 PM(UTC)
Rank: Member

Groups: Registered
Joined: 7/8/2013(UTC)
Posts: 22
Points: 66
Location: University of Victoria

Thanks: 5 times
Was thanked: 1 time(s) in 1 post(s)
Hi Justin,

I spent some time playing with your suggested solutions and I found the following behaviour.

If I follow suggestion 1
A - the prefixes disappear which is good
B - the namespace declaration if the ClinicalDocument element also disappears which is not good

If I follow the second suggestion
A - I get all of the behaviour you indicated which is good
B - xmlns="urn:hl7-org:v3" is no longer expressed as an attribute of my start element which is not good

What I would really like is some mechanism to suppress the expression of the local name prefix.

Any further advice would be appreciated.

Thanks again for your efforts,
Fieran
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

SoClean Theme By Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.154 seconds.