Exemple #1
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto the stream
        /// </summary>
        public void Graph(XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph ANY
            QTYFormatter baseFormatter = new QTYFormatter();

            baseFormatter.Host = this.Host;

            // Null ?
            IAny anyInstance        = o as IAny;
            IPrimitiveDataValue pdv = o as IPrimitiveDataValue;
            IRealValue          rv  = o as IRealValue;

            // Format
            if (pdv.Value != null && anyInstance.NullFlavor == null)
            {
                if (rv == null || rv.Precision == 0)
                {
                    s.WriteAttributeString("value", Util.ToWireFormat(pdv.Value));
                }
                else if (rv != null)
                {
                    s.WriteAttributeString("value", String.Format(DatatypeR2Formatter.FormatterCulture, String.Format("{{0:0.{0}}}", new String('0', rv.Precision), DatatypeR2Formatter.FormatterCulture.NumberFormat.NumberDecimalSeparator), rv.Value));
                }
            }

            // Format the base
            baseFormatter.Graph(s, o, result);
        }
Exemple #2
0
        public override void Graph(XmlWriter xw, object o, DatatypeFormatterGraphResult result)
        {
            // Graph this object to the stream
            base.Graph(xw, o, result); // Graph the any part of this

            IPrimitiveDataValue pv = o as IPrimitiveDataValue;

            if (pv.NullFlavor != null)
            {
                return; // No further graphing
            }
            // Now comes the fun part .. we'll need to graph the Value property onto the stream,
            if (pv.Value != null)
            {
                xw.WriteAttributeString("value", Util.ToWireFormat(pv.Value));
            }
        }
Exemple #3
0
        /// <summary>
        /// Graphs object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

            // Graph
            baseFormatter.Graph(s, o, result);

            // Null ?
            IAny anyInstance        = o as IAny;
            IPrimitiveDataValue pdv = o as IPrimitiveDataValue;

            // Null flavor
            if (anyInstance.NullFlavor != null)
            {
                return;
            }

            // Format
            if (pdv.Value != null)
            {
                s.WriteAttributeString("value", Util.ToWireFormat(pdv.Value));
            }
        }
Exemple #4
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        /// <param name="s">The stream being graphed to</param>
        /// <param name="o">The object being graphed</param>
        /// <param name="result">The result of the graph operation</param>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph the QTY portions
            QTYFormatter qty = new QTYFormatter();

            qty.Host = this.Host;
            qty.Graph(s, o, result);

            // Any null flavors
            IAny anyO = o as IAny;
            IPrimitiveDataValue ipdv = o as IPrimitiveDataValue;

            if (anyO.NullFlavor != null)
            {
                return;
            }

            // PDV Value does not support value
            if (ipdv.Value != null)
            {
                result.AddResultDetail(new NotPermittedDatatypeR2EntityResultDetail(MARC.Everest.Connectors.ResultDetailType.Warning, "Value", "RTO", s.ToString()));
            }

            // Get the numerator / denominator
            PropertyInfo numeratorProperty   = o.GetType().GetProperty("Numerator"),
                         denominatorProperty = o.GetType().GetProperty("Denominator");
            object numerator   = numeratorProperty.GetValue(o, null),
                   denominator = denominatorProperty.GetValue(o, null);

            // Serialize the numerator
            if (numerator != null)
            {
                s.WriteStartElement("numerator", "urn:hl7-org:v3");

                // Write the XSI type
                string xsiTypeName = DatatypeR2Formatter.CreateXSITypeName(numerator.GetType());

                // Write the type
                if (this.Host.Host == null)
                {
                    s.WriteAttributeString("type", DatatypeR2Formatter.NS_XSI, xsiTypeName.ToString());
                }
                else
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, xsiTypeName.ToString());
                }

                var hostResult = this.Host.Graph(s, (IGraphable)numerator);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            // Serialize Denominator
            if (denominator != null)
            {
                s.WriteStartElement("denominator", "urn:hl7-org:v3");

                // Write the XSI type
                string xsiTypeName = DatatypeR2Formatter.CreateXSITypeName(denominator.GetType());

                // Write the type
                if (this.Host.Host == null)
                {
                    s.WriteAttributeString("type", DatatypeR2Formatter.NS_XSI, xsiTypeName.ToString());
                }
                else
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, xsiTypeName.ToString());
                }

                var hostResult = this.Host.Graph(s, (IGraphable)denominator);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }