This project has moved and is read-only. For the latest updates, please go here.

Adding "statusCode" in documentationOf using specific "lab" namespace

Aug 17, 2016 at 8:02 AM
Edited Aug 17, 2016 at 8:06 AM
Hello,

I need to add statusCode markup in the documentationOf section, like the one existing in act sections but with a specific namespace :

<ClinicalDocument xmlns="urn:hl7-org:v3" xmlns:lab="urn:oid:1.3.6.1.4.1.19376.1.3.2" ...>
<documentationOf>
    <serviceEvent>
            <id...>
            <code...>
            <lab:statusCode code="active"/>
            <effectiveTime>
            ...
</documentationOf>

I have seen other discussions that add attributes and override GraphObject function, but I am not quite sure about what to do... What would be the easiest way to achieve this ?

Thanks
Aug 17, 2016 at 8:12 AM
Everest supports this behavior through class inheritance as well, from the developer guide (not specifically answering your question, but shows an example):
/// <summary> 
/// Custom sender for eHealth EL
/// </summary> 
[Structure(Name = "Sender", Model = "MCCI_MT100200EL01", StructureType = StructureAttribute.StructureAttributeType.MessageType)] 
public class MySender : Sender 
{ 
 
    /// <summary>     
   /// Active time
   /// </summary>     
  [Property(Name = "activeTime", Conformance = PropertyAttribute.AttributeConformanceType.Populated, PropertyType = PropertyAttribute.AttributeAttributeType.NonStructural)]
     public GTS ActiveTime { get; set; } 
 
} 
To place this in a different namespace, I believe there is a Namespace property on the [Property] attribute. By default Everest will emit an xsi:type when you use this (since you're overloading the class element the original property was assigned). To get rid of this behavior you can register the type via RegisterXsiType() on the formatter, and give your new class the appropriate XSI type:
PRPA_IN201305UV02 message = new PRPA_IN201305UV02(); 
message.Sender = new MySender() {
     ActiveTime = new GTS(new TS(DateTime.Today, DatePrecision.Day).ToIVL()),
     Device = new Device(),
     Telecom = (TEL)"http://today.myserver.com" 
}; 
 
XmlIts1Formatter fmtr = new XmlIts1Formatter(); 
fmtr.GraphAides.Add(new DatatypeFormatter());  
fmtr.RegisterXSITypeName("MCCI_MT100200UV01.Sender", typeof(MySender)); 
This will stop Everest from emitting the xsi:type attribute. However, on parsing you won't be able to de-serialize the results unless you set AlwaysCheckOverrides setting.
fmtr.Settings |= XmlIts1FormatterSettings.AlwaysCheckForOverrides;
We're working on getting the full 365 page developers guide to be complementary, however this won't happen for a little while (you can still get the paid copy through Lulu).

Cheers
-justin
Nov 14, 2016 at 2:17 PM
Thanks for your answer, I added a class inheritance and had my statusCode property generated like I wanted.

But I could not place it in a different namespace using a prefix. The only property I could found on the [Property] attribute was "NamespaceUri", which adds an xmlns attribute like this:
<statusCode code="completed" xmlns="urn:oid:1.3.6.1.4.1.19376.1.3.2" />

Thanks,
Remy
Nov 16, 2016 at 5:23 PM
I managed to do it changing the library code, in WriteElementUtil function (MARC.Everest.Formatters.XML.ITS1, XmlIts1Formatter class):

if (namespaceUri == "urn:oid:1.3.6.1.4.1.19376.1.3.2")
            s.WriteStartElement("lab", elementName, namespaceUri);
        else
            s.WriteStartElement("c", elementName, namespaceUri);
But one problem remains : the property is not generated in the right order : it should be before effective time, not after.

<code .../>
<effectiveTime>...</c:effectiveTime>
<lab:statusCode ... />
<performer ... />

I tried to use "SortKey" property option, but to no avail.

Thanks
Remy
Nov 18, 2016 at 12:38 AM
You could also have it use a lab prefix without changing the formatter code by instead serializing to an XmlStateWriter with the namespace prefix registered .. This unit test illustrates how this is done:

https://everest.codeplex.com/SourceControl/latest#MARC.Everest.Test/Instances/CustomNamespaceTest.cs