I need to add a custom attribute "ID" to the ObservationMedia class in order to get this:
<observationMedia ID="string identifier" classCode="OBS" moodCode="EVN">
To do so, I created a custom ObservationMedia as below:
[Structure(Name = "ObservationMedia", Model = "POCD_MT000040UV", StructureType = StructureAttribute.StructureAttributeType.MessageType)]
public class MyObservationMedia : ObservationMedia
{
[Property(
Name = "ID",
PropertyType = PropertyAttribute.AttributeAttributeType.Structural,
Conformance = PropertyAttribute.AttributeConformanceType.Optional)]
[System.Xml.Serialization.XmlAttribute("ID")]
public string ID { get; set; }
}
Then I registered the class in the formatter objet using:
Finally I use my custom class just like a classic ObservationMedia object:
Component4 component4 = new Component4();
MyObservationMedia obs_l = new MyObservationMedia();
obs_l.ID = "myID";
// other object initializations
component4.SetClinicalStatement(obs_l);
Unfortunately I get the error "MyObservationMedia is not a valid choice according to available choice elements and won't be formatted".
I already did this for a custom ServiceEvent class and it worked fine. It seems that the Component4.ClinicalStatement is not allowing to a MyObservationMedia objet.
Do I need to override Component4.SetClinicalStatement(ObservationMedia value) and what to put in that function ?
Hello,
I need to add a custom attribute "ID" to the ObservationMedia class in order to get this: <observationMedia ID="string identifier" classCode="OBS" moodCode="EVN">
To do so, I created a custom ObservationMedia as below:
[Structure(Name = "ObservationMedia", Model = "POCD_MT000040UV", StructureType = StructureAttribute.StructureAttributeType.MessageType)] public class MyObservationMedia : ObservationMedia { [Property( Name = "ID", PropertyType = PropertyAttribute.AttributeAttributeType.Structural, Conformance = PropertyAttribute.AttributeConformanceType.Optional)] [System.Xml.Serialization.XmlAttribute("ID")] public string ID { get; set; }
}
Then I registered the class in the formatter objet using:
fmtr.RegisterXSITypeName("POCD_MT000040UV.ObservationMedia", typeof(MyObservationMedia));
Finally I use my custom class just like a classic ObservationMedia object: Component4 component4 = new Component4(); MyObservationMedia obs_l = new MyObservationMedia(); obs_l.ID = "myID"; // other object initializations component4.SetClinicalStatement(obs_l);
Unfortunately I get the error "MyObservationMedia is not a valid choice according to available choice elements and won't be formatted".
I already did this for a custom ServiceEvent class and it worked fine. It seems that the Component4.ClinicalStatement is not allowing to a MyObservationMedia objet. Do I need to override Component4.SetClinicalStatement(ObservationMedia value) and what to put in that function ?
Thanks Remy