Bug 15902

Title: Formatter doesn't set the default namespace for CD
Status: Resolved Priority: Low
Triage: Triaged  
Created On: Tue Sep 17 2013 at 13:38 Created By: jira
Last Update: Thu Mar 13 2014 at 16:44 Updated By: jira
Found In:
      In JEverest:
      When assigning a type of CD to the value element of an observation the resulting Clinical Document fails schema validation.
      This is because the default namespace hasn't been assigned "urn:hl7-org:v3".
      See the attached file (not a complete, valid ClinicalDocument) for the value element where xsi:type="CD".
      When validating the following message is generated:
      cvc-elt.4.2: Cannot resolve 'CD' to a type definition for element 'hl7:value'.
      Below is the code used to generate the xml string from the formatter:
      public static String toXmlString(IGraphable graphable, boolean createRequiredElements)
              XmlIts1Formatter formatter = new XmlIts1Formatter();
              String retVal = null;
                  //DatatypeFormatter dtfUniversal = new DatatypeFormatter(R1FormatterCompatibilityMode.Universal);
                  DatatypeFormatter dtfCda = new DatatypeFormatter(R1FormatterCompatibilityMode.ClinicalDocumentArchitecture);
                  ByteArrayOutputStream bos = new ByteArrayOutputStream();
                  formatter.graph(bos, graphable);
                  retVal = new String(bos.toByteArray(), 0);
              } catch (Exception e)
                  throw new IheException("Could not construct the graphable object", e);
              return retVal;