Exemplo n.º 1
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ADXP instance = o as ADXP;

            // Start with the part type and code attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, instance, result);

            // Format data
            if (instance.Type != null && instance.Type.HasValue)
            {
                s.WriteAttributeString("type", Util.ToWireFormat(instance.Type));
            }
            if (instance.Value != null)
            {
                s.WriteAttributeString("value", instance.Value);
            }
            if (instance.Code != null)
            {
                s.WriteAttributeString("code", instance.Code);
            }
            if (instance.CodeSystem != null)
            {
                s.WriteAttributeString("codeSystem", instance.CodeSystem);
            }
            if (instance.CodeSystemVersion != null)
            {
                s.WriteAttributeString("codeSystemVersion", instance.CodeSystemVersion);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Host             = this.Host;
            baseFormatter.GenericArguments = this.GenericArguments;

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

            // Instance
            IProbability instance = o as IProbability;

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

            // Graph UVP properties
            if (instance.Probability.HasValue)
            {
                s.WriteAttributeString("probability", Util.ToWireFormat(instance.Probability.Value));
            }

            // Value
            if (instance.Value != null)
            {
                s.WriteStartElement("value", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, instance.Value as IGraphable);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Format base attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            if ((o as ANY).NullFlavor != null)
            {
                return;                                // no need to continue formatting
            }
            // Get the values the formatter needs to represent in XML
            Type   eivlType          = o.GetType();
            object operatorValue     = eivlType.GetProperty("Operator").GetValue(o, null),
                   valueValue        = eivlType.GetProperty("Value").GetValue(o, null),
                   originalTextValue = eivlType.GetProperty("OriginalText").GetValue(o, null),
                   offsetValue       = eivlType.GetProperty("Offset").GetValue(o, null),
                   eventValue        = eivlType.GetProperty("Event").GetValue(o, null)
            ;

            // Low / high closed
            if (operatorValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Operator", "EIVL", s.ToString()));
            }
            if (valueValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Value", "EIVL", s.ToString()));
            }
            if (eventValue != null)
            {
                s.WriteAttributeString("event", Util.ToWireFormat(eventValue));
            }

            // Original text
            if (originalTextValue != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalTextValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            // Valid combinations
            if (offsetValue != null)
            {
                s.WriteStartElement("offset", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, offsetValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Graphs <paramref name="o"/> to <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Any formatter
            ANYFormatter anyFormatter = new ANYFormatter();

            anyFormatter.GenericArguments = this.GenericArguments;
            anyFormatter.Host             = this.Host;

            // Graph base
            anyFormatter.Graph(s, o, result);

            // Instance
            II iiInstance = o as II;

            // Other nullFlavor
            if (iiInstance.NullFlavor != null)
            {
                return;
            }

            // Properties
            if (iiInstance.Root != null)
            {
                s.WriteAttributeString("root", iiInstance.Root);
            }
            if (iiInstance.Extension != null)
            {
                s.WriteAttributeString("extension", iiInstance.Extension);
            }
            if (iiInstance.IdentifierName != null)
            {
                s.WriteAttributeString("identifierName", iiInstance.IdentifierName);
            }
            if (iiInstance.Displayable != null)
            {
                s.WriteAttributeString("displayable", Util.ToWireFormat(iiInstance.Displayable));
            }
            if (iiInstance.Scope != null)
            {
                s.WriteAttributeString("scope", Util.ToWireFormat(iiInstance.Scope));
            }
            if (iiInstance.Reliability != null)
            {
                s.WriteAttributeString("reliability", Util.ToWireFormat(iiInstance.Reliability));
            }
            if (iiInstance.AssigningAuthorityName != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(
                                           ResultDetailType.Warning, "AssigningAuthorityName", "II", s.ToString()
                                           ));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph the base data
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Is null flavor set?
            if ((o as ANY).NullFlavor != null)
            {
                return;
            }

            // Original text
            IOriginalText originalText = o as IOriginalText;

            if (originalText.OriginalText != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalText.OriginalText);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Get properties we'll be graphing
            object lowValue  = o.GetType().GetProperty("Low").GetValue(o, null),
                   highValue = o.GetType().GetProperty("High").GetValue(o, null);


            // Graph low / hi
            if (lowValue != null)
            {
                s.WriteStartElement("low", "urn:hl7-org:v3");
                s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(lowValue.GetType()));
                var hostResult = this.Host.Graph(s, lowValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (highValue != null)
            {
                s.WriteStartElement("high", "urn:hl7-org:v3");
                s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(lowValue.GetType()));
                var hostResult = this.Host.Graph(s, highValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Graph the object <paramref name="o"/> to <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            AD instance = o as AD;

            // Base formatting
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, instance, result);

            // Use
            if (instance.Use != null && !instance.Use.IsNull)
            {
                s.WriteAttributeString("use", Util.ToWireFormat(instance.Use));
            }

            // No need to format
            if (instance.NullFlavor != null)
            {
                return;
            }

            // Is not ordered
            if (instance.IsNotOrdered != null && instance.IsNotOrdered.HasValue)
            {
                s.WriteAttributeString("isNotOrdered", Util.ToWireFormat(instance.IsNotOrdered));
            }

            // Parts
            if (instance.Part != null)
            {
                foreach (var part in instance.Part)
                {
                    s.WriteStartElement("part", "urn:hl7-org:v3");
                    ADXPFormatter adFormatter = new ADXPFormatter();
                    adFormatter.Graph(s, part, result);
                    s.WriteEndElement();
                }
            }

            // Useable period
            if (instance.UseablePeriod != null)
            {
                s.WriteStartElement("useablePeriod", "urn:hl7-org:v3");
                GTSFormatter gtsFormatter = new GTSFormatter();
                gtsFormatter.Host = this.Host;
                gtsFormatter.Graph(s, instance.UseablePeriod, result);
                s.WriteEndElement();
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Graphs <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            ANYFormatter baseFormatter = new ANYFormatter();

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

            // Graph elements
            ISampledList instance = o as ISampledList;

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

            // Origin
            if (instance.Origin != null)
            {
                s.WriteStartElement("origin", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, instance.Origin as IGraphable);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            // Scaling
            if (instance.Scale != null)
            {
                s.WriteStartElement("scale", "urn:hl7-org:v3");

                // Output xsi type
                s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(instance.Scale.GetType()));

                var hostResult = this.Host.Graph(s, instance.Scale);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            // Digits
            if (instance.Items != null)
            {
                foreach (var itm in instance.Items)
                {
                    s.WriteStartElement("digit", "urn:hl7-org:v3");
                    var hostResult = this.Host.Graph(s, itm);
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Graph object <paramref name="o"/> to <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Get an instance ref
            ICodedSimple instance_ics = (ICodedSimple)o;

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

            baseFormatter.Graph(s, o as ANY, result);

            // Format the coded simple
            if (instance_ics.CodeValue != null && ((ANY)o).NullFlavor == null)
            {
                s.WriteAttributeString("code", Util.ToWireFormat(instance_ics.CodeValue));
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Quantity formatter
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Graph the others
            IQuantity qty = o as IQuantity;

            // Uncertainty type
            if (qty.NullFlavor == null && qty.UncertaintyType != null && qty.UncertaintyType.HasValue)
            {
                s.WriteAttributeString("uncertaintyType", Util.ToWireFormat(qty.UncertaintyType.Value));
            }

            // Elements
            // Expression
            if (qty.Expression != null)
            {
                s.WriteStartElement("expression", "urn:hl7-org:v3");
                this.Host.Graph(s, qty.Expression as IGraphable);
                s.WriteEndElement();
            }
            if (qty.OriginalText != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                this.Host.Graph(s, qty.OriginalText as IGraphable);
                s.WriteEndElement();
            }
            if (qty.NullFlavor == null && qty.Uncertainty != null)
            {
                s.WriteStartElement("uncertainty", "urn:hl7-org:v3");
                s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(qty.Uncertainty.DataType));
                this.Host.Graph(s, qty.Uncertainty as IGraphable);
                s.WriteEndElement();
            }
            if (qty.UncertainRange != null)
            {
                s.WriteStartElement("uncertainRange", "urn:hl7-org:v3");
                this.Host.Graph(s, qty.UncertainRange);
                s.WriteEndElement();
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <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;
            TEL  tel         = o as TEL;

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

            // Format attributes
            if (tel.Value != null) // Value
            {
                s.WriteAttributeString("value", tel.Value);
            }
            if (tel.Use != null) // Use
            {
                s.WriteAttributeString("use", Util.ToWireFormat(tel.Use));
            }
            if (tel.Capabilities != null) // Capabilities
            {
                s.WriteAttributeString("capabilities", Util.ToWireFormat(tel.Capabilities));
            }

            // format elements
            if (tel.UseablePeriod != null)
            {
                s.WriteStartElement("useablePeriod", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, tel.UseablePeriod);
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph the base
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Do not graph if null flavor is present
            if ((o as ANY).NullFlavor != null)
            {
                return;
            }

            var originalText = o as IOriginalText;

            // Write out the original text first
            if (originalText.OriginalText != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalText.OriginalText);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Now the terms
            foreach (var term in (o as IEnumerable))
            {
                s.WriteStartElement("term", "urn:hl7-org:v3");


                // JF: Output XSI:Type
                string xsiTypeName = DatatypeR2Formatter.CreateXSITypeName(term.GetType());
                s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, xsiTypeName);
                var hostResult = this.Host.Graph(s, term as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public virtual void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Base formatter
            ANYFormatter anyFormatter = new ANYFormatter();

            // Format the base
            anyFormatter.Graph(s, o, result);

            // Nullflavor?
            ST instance = o as ST;

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

            // format properties
            if (instance.Value != null)
            {
                s.WriteAttributeString("value", instance.Value);
            }
            if (instance.Language != null)
            {
                s.WriteAttributeString("language", instance.Language);
            }

            // format translation
            if (instance.Translation != null)
            {
                foreach (var tx in instance.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = this.Host.Graph(s, tx);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }
        }
Exemplo n.º 13
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));
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/> storing
        /// details in <paramref name="result"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Cast to strongly typed data
            IColl collInstance = o as IColl;
            IAny  anyInstance  = o as IAny;

            // Base formatter
            ANYFormatter baseFormatter = new ANYFormatter();

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

            // Graphing a COLL is easy, we just iterate over the items
            if (anyInstance.NullFlavor == null)
            {
                foreach (var itm in collInstance)
                {
                    // Start the item tag
                    s.WriteStartElement("item", "urn:hl7-org:v3");

                    // Output an XSI type if the type does not match the generic parameter
                    if (itm.GetType() != GenericArguments[0])
                    {
                        var xsiName = DatatypeR2Formatter.CreateXSITypeName(itm.GetType());
                        s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, xsiName);
                    }

                    // Format the item
                    var hostResult = this.Host.Graph(s, itm as IGraphable);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);

                    // End of item tag
                    s.WriteEndElement();
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Graphs <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public virtual void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Graph the EN
            ANYFormatter baseFormatter = new ANYFormatter();

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

            // EN instance
            var enInstance = o as EN;

            // Format the properties if not nul
            if (enInstance.NullFlavor != null)
            {
                return;
            }

            // Format the use
            if (enInstance.Use != null)
            {
                s.WriteAttributeString("use", Util.ToWireFormat(enInstance.Use));
            }

            // Parts
            foreach (var enxp in enInstance.Part)
            {
                s.WriteStartElement("part", "urn:hl7-org:v3");

                // Output the type
                var hostResult = this.Host.Graph(s, enxp);
                result.AddResultDetail(hostResult.Details);

                s.WriteEndElement(); // end part
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Format base attributes
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            if ((o as ANY).NullFlavor != null)
            {
                return;                                // no need to continue formatting
            }
            // Get the values the formatter needs to represent in XML
            Type   ivlType           = o.GetType();
            object operatorValue     = ivlType.GetProperty("Operator").GetValue(o, null),
                   lowValue          = ivlType.GetProperty("Low").GetValue(o, null),
                   highValue         = ivlType.GetProperty("High").GetValue(o, null),
                   widthValue        = ivlType.GetProperty("Width").GetValue(o, null),
                   originalTextValue = ivlType.GetProperty("OriginalText").GetValue(o, null),
                   lowClosedValue    = ivlType.GetProperty("LowClosed").GetValue(o, null),
                   highClosedValue   = ivlType.GetProperty("HighClosed").GetValue(o, null),
                   valueValue        = ivlType.GetProperty("Value").GetValue(o, null);

            // Low / high closed
            if (lowClosedValue != null)
            {
                s.WriteAttributeString("lowClosed", Util.ToWireFormat(lowClosedValue));
            }
            if (highClosedValue != null)
            {
                s.WriteAttributeString("highClosed", Util.ToWireFormat(highClosedValue));
            }
            if (operatorValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Operator", "IVL", s.ToString()));
            }

            // Original text
            if (originalTextValue != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalTextValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            bool invalidCombo = false;

            // Valid combinations
            if (lowValue != null)
            {
                s.WriteStartElement("low", "urn:hl7-org:v3");

                // Low value XSI?
                if (lowValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(lowValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, lowValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                if (highValue != null)
                {
                    s.WriteStartElement("high", "urn:hl7-org:v3");

                    if (highValue.GetType() != GenericArguments[0])
                    {
                        s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(highValue.GetType()));
                    }

                    hostResult  = this.Host.Graph(s, highValue as IGraphable);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
                invalidCombo |= valueValue != null || widthValue != null;
            }
            else if (highValue != null)
            {
                s.WriteStartElement("high", "urn:hl7-org:v3");

                // High value XSI
                if (highValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(highValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, highValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                invalidCombo |= valueValue != null || widthValue != null;
            }
            if (widthValue != null && ((lowValue == null) ^ (highValue == null) || lowValue == null && highValue == null))
            {
                s.WriteStartElement("width", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, widthValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                if (valueValue != null)
                {
                    s.WriteStartElement("any", "urn:hl7-org:v3");

                    // Value value xsi type
                    if (valueValue.GetType() != GenericArguments[0])
                    {
                        s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(valueValue.GetType()));
                    }

                    hostResult  = this.Host.Graph(s, valueValue as IGraphable);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
                invalidCombo |= lowValue != null || highValue != null;
            }
            else if (valueValue != null)
            {
                s.WriteStartElement("any", "urn:hl7-org:v3");

                // Value value xsi type
                if (valueValue.GetType() != GenericArguments[0])
                {
                    s.WriteAttributeString("xsi", "type", DatatypeR2Formatter.NS_XSI, DatatypeR2Formatter.CreateXSITypeName(valueValue.GetType()));
                }

                var hostResult = this.Host.Graph(s, valueValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
                invalidCombo |= lowValue != null || highValue != null;
            }
            else
            {
                invalidCombo = true;
            }

            // Invalid combination, warn
            if (invalidCombo)
            {
                result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "This IVL is not conformant to the ISO21090 data types specification. Only 'Value' and/or 'Width', or 'Low' and/or 'High' are permitted. All data has been serialized but may not be interpreted by a remote system", s.ToString(), null));
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        /// <remarks>For some reason this type is not defined in the ISO Data types XSD</remarks>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Format the base
            ANYFormatter anyFormatter = new ANYFormatter();

            anyFormatter.Graph(s, o, result);

            // If null flavor is not
            if ((o as IAny).NullFlavor != null)
            {
                return;
            }

            // Get the property information
            Type   pivlType                  = o.GetType();
            object valueValue                = pivlType.GetProperty("Value").GetValue(o, null),
                   operatorValue             = pivlType.GetProperty("Operator").GetValue(o, null),
                   alignmentValue            = pivlType.GetProperty("Alignment").GetValue(o, null),
                   phaseValue                = pivlType.GetProperty("Phase").GetValue(o, null),
                   periodValue               = pivlType.GetProperty("Period").GetValue(o, null),
                   institutionSpecifiedValue = pivlType.GetProperty("InstitutionSpecified").GetValue(o, null),
                   countValue                = pivlType.GetProperty("Count").GetValue(o, null),
                   frequencyValue            = pivlType.GetProperty("Frequency").GetValue(o, null),
                   originalTextValue         = pivlType.GetProperty("OriginalText").GetValue(o, null);

            // Attributes
            if (institutionSpecifiedValue != null)
            {
                s.WriteAttributeString("isFlexible", institutionSpecifiedValue.ToString().ToLower());
            }
            if (alignmentValue != null)
            {
                s.WriteAttributeString("alignment", Util.ToWireFormat(alignmentValue));
            }
            if (countValue != null)
            {
                s.WriteAttributeString("count", Util.ToWireFormat(countValue));
            }
            if (operatorValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Operator", "PIVL", s.ToString()));
            }
            if (valueValue != null)
            {
                result.AddResultDetail(new UnsupportedDatatypeR2PropertyResultDetail(ResultDetailType.Warning, "Value", "PIVL", s.ToString()));
            }

            // Original text
            if (originalTextValue != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, originalTextValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
            }

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

            // Frequency or period
            if (frequencyValue != null)
            {
                s.WriteStartElement("frequency", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, frequencyValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
            }
            else if (periodValue != null)
            {
                s.WriteStartElement("period", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, periodValue as IGraphable);
                result.Code = hostResult.Code;
                result.AddResultDetail(result.Details);
                s.WriteEndElement();
                if (frequencyValue != null)
                {
                    result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "'Period' and 'Frequency' specified, this is not permitted, either 'Period' xor 'Frequency' may be represented. Will only represent 'Period' property", s.ToString(), null));
                }
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Graph <paramref name="o"/> onto <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Base formatter
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Graph(s, o, result);

            // Next, start to format the properties
            ICodedSimple       cs = o as ICodedSimple;
            ICodedValue        cv = o as ICodedValue;
            ICodedEquivalents  ce = o as ICodedEquivalents;
            IConceptDescriptor cd = o as IConceptDescriptor;

            ST   displayName = cv.DisplayName;
            IAny any         = o as IAny;

            // Unless "other" is specified don't serialize
            if (any.NullFlavor != null && !((NullFlavor)any.NullFlavor).IsChildConcept(NullFlavor.Other))
            {
                return;
            }

            // First we need to serialize code, now Code in R2 is a little wierd
            // It is an IHTSDO standard as described:
            // http://www.ihtsdo.org/fileadmin/user_upload/Docs_01/Technical_Docs/abstract_models_and_representational_forms.pdf
            // Serialize attributes first
            if (cs.CodeValue != null)
            {
                try
                {
                    if (cd != null && cd.Qualifier != null && cd.Qualifier.Count > 0)
                    {
                        s.WriteAttributeString("code", CreateCodeExpression(cd));
                        displayName = null;
                    }
                    else
                    {
                        s.WriteAttributeString("code", Util.ToWireFormat(cs.CodeValue));
                    }
                }
                catch (Exception e)
                {
                    result.AddResultDetail(new VocabularyIssueResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e));
                }
            }
            if (cv.CodeSystem != null)
            {
                s.WriteAttributeString("codeSystem", Util.ToWireFormat(cv.CodeSystem));
            }
            if (cv.CodeSystemName != null)
            {
                s.WriteAttributeString("codeSystemName", Util.ToWireFormat(cv.CodeSystemName));
            }
            if (cv.CodeSystemVersion != null)
            {
                s.WriteAttributeString("codeSystemVersion", Util.ToWireFormat(cv.CodeSystemVersion));
            }
            if (cv.ValueSet != null)
            {
                s.WriteAttributeString("valueSet", Util.ToWireFormat(cv.ValueSet));
            }
            if (cv.ValueSetVersion != null)
            {
                s.WriteAttributeString("valueSetVersion", Util.ToWireFormat(cv.ValueSetVersion));
            }
            if (cv.CodingRationale != null)
            {
                s.WriteAttributeString("codingRationale", Util.ToWireFormat(cv.CodingRationale));
            }

            // Elements

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

            // Original text
            if (cv.OriginalText != null)
            {
                s.WriteStartElement("originalText", "urn:hl7-org:v3");
                var hostResult = this.Host.Graph(s, cv.OriginalText);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }

            // Translation
            if (ce != null && ce.Translation != null)
            {
                foreach (var translation in ce.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = this.Host.Graph(s, translation);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement();
                }
            }

            // Done
        }
Exemplo n.º 19
0
        /// <summary>
        /// Graph object <paramref name="o"/> onto stream <paramref name="s"/>
        /// </summary>
        public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result)
        {
            // Get an instance ref
            ED instance_ed = (ED)o;

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

            baseFormatter.Graph(s, o, result);

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

            // Attributes
            if (instance_ed.MediaType != null && instance_ed.Representation != EncapsulatedDataRepresentation.TXT)
            {
                s.WriteAttributeString("mediaType", instance_ed.MediaType);
            }
            if (instance_ed.Language != null)
            {
                s.WriteAttributeString("language", instance_ed.Language);
            }
            if (instance_ed.Compression != null)
            {
                s.WriteAttributeString("compression", Util.ToWireFormat(instance_ed.Compression));
            }
            if (instance_ed.IntegrityCheckAlgorithm != null)
            {
                s.WriteAttributeString("integrityCheckAlgorithm", Util.ToWireFormat(instance_ed.IntegrityCheckAlgorithm));
            }

            Encoding textEncoding = System.Text.Encoding.UTF8;

            // Representation of data
            if (instance_ed.Data != null && instance_ed.Data.Length > 0)
            {
                switch (instance_ed.Representation)
                {
                case EncapsulatedDataRepresentation.TXT:
                    s.WriteAttributeString("value", textEncoding.GetString(instance_ed.Data));
                    break;

                case EncapsulatedDataRepresentation.B64:
                    s.WriteStartElement("data", "urn:hl7-org:v3");
                    s.WriteBase64(instance_ed.Data, 0, instance_ed.Data.Length);
                    s.WriteEndElement();    // data
                    break;

                case EncapsulatedDataRepresentation.XML:
                    s.WriteStartElement("xml", "urn:hl7-org:v3");
                    s.WriteRaw(instance_ed.XmlData.OuterXml);
                    s.WriteEndElement();     // xml
                    break;
                }
            }

            // Elements
            if (instance_ed.Reference != null)
            {
                s.WriteStartElement("reference", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Reference);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (instance_ed.IntegrityCheck != null && instance_ed.IntegrityCheck.Length > 0)
            {
                s.WriteStartElement("integrityCheck", "urn:hl7-org:v3");
                s.WriteBase64(instance_ed.IntegrityCheck, 0, instance_ed.IntegrityCheck.Length);
                s.WriteEndElement(); // intcheck
            }
            if (instance_ed.Thumbnail != null)
            {
                s.WriteStartElement("thumbnail", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Thumbnail);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);

                s.WriteEndElement();
            }
            if (instance_ed.Description != null)
            {
                s.WriteStartElement("description", "urn:hl7-org:v3");
                var hostResult = Host.Graph(s, instance_ed.Description);
                result.Code = hostResult.Code;
                result.AddResultDetail(hostResult.Details);
                s.WriteEndElement();
            }
            if (instance_ed.Translation != null && !instance_ed.Translation.IsNull)
            {
                foreach (var trans in instance_ed.Translation)
                {
                    s.WriteStartElement("translation", "urn:hl7-org:v3");
                    var hostResult = Host.Graph(s, trans);
                    result.Code = hostResult.Code;
                    result.AddResultDetail(hostResult.Details);
                    s.WriteEndElement(); // translation
                }
            }
        }