예제 #1
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            CO instance = (o as ANY).Clone() as CO; // We'll be modifying data

            instance.Code = (instance.Code ?? new CD <String>()).Clone() as CD <String>;

            // CO is identical on the wire as a cv in dt r1
            CVFormatter formatter = new CVFormatter();

            formatter.Host = this.Host;

            // First, is the instance null?
            if (instance == null)
            {
                return;
            }
            else if (instance.IsNull)
            {
                if (instance.Code == null)
                {
                    instance.Code = new CD <string>();
                }
                else if (instance.Code.IsNull)
                {
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "NullFlavor from CO instance will overwrite NullFlavor from Code Property", s.ToString(), null));
                }
                instance.Code.NullFlavor = instance.NullFlavor;
            }
            else if (instance.Flavor != null)
            {
                if (instance.Code == null)
                {
                    instance.Code = new CD <string>();
                }
                else if (instance.Code.Flavor != null)
                {
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "Flavor from CO instance will overwrite Flavor from Code Property", s.ToString(), null));
                }
                instance.Code.Flavor = instance.Flavor;
            }

            // Graph
            formatter.Graph(s, instance.Code, result);


            // Append details
            if (instance.Value != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Value", "CO", s.ToString()));
            }
            else if (instance.Code != null && instance.Code.Qualifier != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code.Qualifier", "CO", s.ToString()));
            }
            else if (instance.Code != null && instance.Code.Translation != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code.Translation", "CO", s.ToString()));
            }
        }
예제 #2
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Since PQR is a CV , we can use the CD formatter to graph the basic attributes onto the stream
            CVFormatter formatter = new CVFormatter();
            PQR         instance  = o as PQR;

            if (instance.NullFlavor != null)
            {
                return;                              // Null, no need to format
            }
            // Watch out for nargles
            if (instance.Precision != null && instance.Precision != 0 && instance.Value.HasValue)
            {
                s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision))));
            }
            else if (instance.Value.HasValue)
            {
                s.WriteAttributeString("value", instance.Value.Value.ToString());
            }


            formatter.Graph(s, o as PQR, result);
        }
예제 #3
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream to graph to</param>
        /// <param name="o">The object to graph</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Get an instance ref
            ICodedEquivalents instance_ics = (ICodedEquivalents)o;

            // Do a base format
            CVFormatter baseFormatter = new CVFormatter();

            baseFormatter.Graph(s, o, result);


            // Format the coded simple
            if (instance_ics.Translation != null) // Original Text
            {
                foreach (IGraphable ig in instance_ics.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = Host.Graph(s, ig);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream to graph to</param>
        /// <param name="o">The object to graph</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result); // Graph the base data


            // If there is no null flavor then graph the rest of the object

            object invertedValue = o.GetType().GetProperty("Inverted").GetValue(o, null),
                   nameValue     = o.GetType().GetProperty("Name").GetValue(o, null),
                   valueValue    = o.GetType().GetProperty("Value").GetValue(o, null);

            // Graph the structural attributes
            s.WriteAttributeString("inverted", Util.ToWireFormat(invertedValue));

            // Graph the non-structural elements
            if (nameValue != null)
            {
                s.WriteStartElement("name");
                CVFormatter cdFormatter = new CVFormatter();
                cdFormatter.Host             = this.Host;
                cdFormatter.GenericArguments = this.GenericArguments;
                cdFormatter.Graph(s, nameValue, result);
                s.WriteEndElement(); // end name
            }
            if (valueValue != null)
            {
                s.WriteStartElement("value");
                CDFormatter cdFormatter = new CDFormatter();
                cdFormatter.Host             = this.Host;
                cdFormatter.GenericArguments = this.GenericArguments;
                cdFormatter.Graph(s, valueValue, result);
                s.WriteEndElement(); // end value
            }
        }
예제 #5
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Since PQR is a CV , we can use the CD formatter to graph the basic attributes onto the stream
            CVFormatter formatter = new CVFormatter();
            PQR instance = o as PQR;

            if (instance.NullFlavor != null) return; // Null, no need to format

            // Watch out for nargles
            if (instance.Precision != null && instance.Precision != 0 && instance.Value.HasValue)
                s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision))));
            else if (instance.Value.HasValue)
                s.WriteAttributeString("value", instance.Value.Value.ToString());

            formatter.Graph(s, o as PQR, result);
        }
예제 #6
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream to graph to</param>
        /// <param name="o">The object to graph</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            // Get an instance ref
            ICodedEquivalents instance_ics = (ICodedEquivalents)o;

            // Do a base format
            CVFormatter baseFormatter = new CVFormatter();
            baseFormatter.Graph(s, o, result);

            // Format the coded simple
            if (instance_ics.Translation != null) // Original Text
            {
                foreach (IGraphable ig in instance_ics.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = Host.Graph(s, ig);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }
        }
예제 #7
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream to graph to</param>
        /// <param name="o">The object to graph</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();
            baseFormatter.Graph(s, o, result); // Graph the base data

            // If there is no null flavor then graph the rest of the object

            object invertedValue = o.GetType().GetProperty("Inverted").GetValue(o, null),
                nameValue = o.GetType().GetProperty("Name").GetValue(o, null),
                valueValue = o.GetType().GetProperty("Value").GetValue(o, null);

            // Graph the structural attributes
            s.WriteAttributeString("inverted", Util.ToWireFormat(invertedValue));

            // Graph the non-structural elements
            if (nameValue != null)
            {
                s.WriteStartElement("name");
                CVFormatter cdFormatter = new CVFormatter();
                cdFormatter.Host = this.Host;
                cdFormatter.GenericArguments = this.GenericArguments;
                cdFormatter.Graph(s, nameValue, result);
                s.WriteEndElement(); // end name
            }
            if (valueValue != null)
            {
                s.WriteStartElement("value");
                CDFormatter cdFormatter = new CDFormatter();
                cdFormatter.Host = this.Host;
                cdFormatter.GenericArguments = this.GenericArguments;
                cdFormatter.Graph(s, valueValue, result);
                s.WriteEndElement(); // end value
            }
        }
예제 #8
0
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result)
        {
            CO instance = (o as ANY).Clone() as CO; // We'll be modifying data
            instance.Code = (instance.Code ?? new CD<String>()).Clone() as CD<String>;

            // CO is identical on the wire as a cv in dt r1
            CVFormatter formatter = new CVFormatter();
            formatter.Host = this.Host;

            // First, is the instance null?
            if (instance == null)
                return;
            else if (instance.IsNull)
            {
                if (instance.Code == null) instance.Code = new CD<string>();
                else if (instance.Code.IsNull)
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "NullFlavor from CO instance will overwrite NullFlavor from Code Property", s.ToString(), null));
                instance.Code.NullFlavor = instance.NullFlavor;
            }
            else if (instance.Flavor != null)
            {
                if (instance.Code == null) instance.Code = new CD<string>();
                else if (instance.Code.Flavor != null)
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "Flavor from CO instance will overwrite Flavor from Code Property", s.ToString(), null));
                instance.Code.Flavor = instance.Flavor;
            }

            // Graph
            formatter.Graph(s, instance.Code, result);

            // Append details
            if(instance.Value != null)
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Value", "CO", s.ToString()));
            else if(instance.Code != null && instance.Code.Qualifier != null)
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code.Qualifier", "CO", s.ToString()));
            else if (instance.Code != null && instance.Code.Translation != null)
                result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code.Translation", "CO", s.ToString()));
        }