This project has moved. For the latest updates, please go here.

Clinical Document Generation sdtc:valueSet

May 31, 2016 at 9:38 PM
Edited May 31, 2016 at 9:39 PM
Hi,
I'm using the Everest framework to create CDA clinical documents for CQMs. I have encountered an issue when testing with the Cypress Certification Tool relating to the Encounter Event.

The error returned is 'Cannot find expected entry with templateId = 2.16.840.1.113883.10.20.24.3.23 with valueset 2.16.840.1.113883.3.464.1003.101.12.1001'

I have determined that the error relates to the code xml. My generated xml is:
<code code="99201" codeSystem="2.16.840.1.113883.6.12" />
but the sample files produced by Cypress has:
<code code="99201" codeSystem="2.16.840.1.113883.6.12" sdtc:valueSet="2.16.840.1.113883.3.464.1003.101.12.1001"/>

If I include the sdtc:valueSet the XML validates correctly but I can't figure out how to do this via code.

My existing code is below:
EncounterCustomized enc = new EncounterCustomized();

            enc.MoodCode = new CS<x_DocumentEncounterMood>(x_DocumentEncounterMood.Eventoccurrence);
            enc.Code = new CV<ST>("99201", "2.16.840.1.113883.6.12");            
            
            enc.TemplateId = new LIST<II>();
            enc.TemplateId.Add(new II("2.16.840.1.113883.10.20.24.3.23"));
            enc.TemplateId.Add(new II("2.16.840.1.113883.10.20.22.4.49"));

Any help would be appreciated.
Thanks!
Jun 3, 2016 at 5:48 AM
I was also looking for a way to handle this. Here is what I came up with:
// string result = GetXmlDocument(cd, new QrdaIts1Formatter());

        private static string GetXmlDocument(ClinicalDocument cd, XmlIts1Formatter fmtr)
        {
            using (var sw = new StringWriter())
            {
                using (XmlStateWriter xw = new XmlStateWriter(XmlWriter.Create(sw, new XmlWriterSettings() { Indent = true })))
                {
                    xw.WriteStartElement("ClinicalDocument", "urn:hl7-org:v3");
                    xw.WriteAttributeString("xmlns", "sdtc", null, "urn:hl7-org:sdtc"); 
                    xw.WriteAttributeString("xmlns", "xsi", null, XmlIts1Formatter.NS_XSI);

                    fmtr.Graph(xw, cd);

                    xw.WriteEndElement();
                }
                return sw.ToString();
            }
        }

        public class QrdaIts1Formatter : XmlIts1Formatter
        {
            protected override void GraphObject(XmlWriter s, IGraphable o, Type useType, IGraphable context, XmlIts1FormatterGraphResult resultContext)
            {
                base.GraphObject(s, o, useType, context, resultContext);

                var cv = o as CV<string>;
                if (cv != null && !string.IsNullOrEmpty(cv.ValueSet))
                {
                    s.WriteAttributeString("valueSet", "urn:hl7-org:sdtc", Util.ToWireFormat(cv.ValueSet));
                }

            }
        }
Jun 8, 2016 at 6:10 PM
That's great thanks! I had to amend slightly as I was getting XML invalid document errors but all working now with that concept.
Jun 8, 2016 at 8:50 PM
You're welcome. I also ran into an error when a child element (within a code or value tag etc.) is written before the valueSet attribute, so I had to move the GraphObject after the WriteAttributeString call. Can you please explain the issue you ran into and how you resolved it?