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

Nedd to customize observationMedia element

Jul 3, 2015 at 10:36 AM

With your wrapper i've succeded to create my CDAr2 document at 99 %.

ObservationMedia class generates the following xml :
<observationMedia classCode="OBS" moodCode="EVN">
                  <value representation="B64" mediaType="image/jpeg" />
But we need to add an ID like this :
                  <renderMultiMedia referencedObject="CRT"/>
<observationMedia classCode="OBS" moodCode="EVN" ID="CRT">
                  <value representation="B64" mediaType="image/jpeg" />
Is it possible to do this with the existing class ObservationMedia ?

Thanks in advance.

Jul 6, 2015 at 3:44 PM
Edited Jul 6, 2015 at 3:45 PM

It is possible to do this and actually quite easy, if you have access to the developer's guide (2nd edition) chapter 7 has some examples of how to do this, more specifically pages 279 - 281. I've included an example of how to do this below (where "Model" is the local model or the original model property):
[Structure(Name = "ObservationMedia", Model = "XXXX_MTXXXXXXXX", StructureType = StructureAttribute.StructureAttributeType.MessageType)]
public class MyObservationMedia : ObservationMedia
      [Property(Name = "ID", Conformance = PropertyAttribute.AttributeConfirmanceType.Populated, PropertyType = PropertyAttribute.AttributeAttributeType.Structural)]
      public ST ID { get; set; }
One thing that this will result in is an xsi:type like this:
<observationMedia xsi:type="XXXX_MTXXXXXX.ObservationMedia" typeCode="SND" classCode="OBS" moodCode="EVN" ID="CRT"> 
To get rid of the xsi:type or to parse this structure without an XSI:type you will have to register the type with your formatter:
fmtr.RegisterXSITypeName("XXXX_MTXXXXXXUV.Sender", typeof(MySender));
fmtr.Settings |= SettingsType.AlwaysCheckForOverrides;
Hope that helps!
Marked as answer by Kirk67 on 7/6/2015 at 9:09 AM
Jul 6, 2015 at 5:09 PM
It works like a charm, our schematron returns only "OK" !!!

Many thanks for your help.