示例#1
0
        /// <summary>
        /// Gets a list of supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.Add(typeof(COLL <>).GetProperty("Item"));
            return(retVal);
        }
示例#2
0
        /// <summary>
        /// Parse the PQ back into a structure
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Create the base formatter
            PDVFormatter baseFormatter = new PDVFormatter();

            baseFormatter.Host = this.Host;

            // Read temporary values
            string tCurrency = String.Empty;

            if (s.GetAttribute("currency") != null)
            {
                tCurrency = s.GetAttribute("currency");
            }

            // Parse PDV content
            var retVal = baseFormatter.Parse <MO>(s, result);

            // Set PDV content
            retVal.Currency = tCurrency;

            // Validate
            ANYFormatter anyFormatter = new ANYFormatter();
            string       pathName     = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;

            anyFormatter.Validate(retVal as ANY, pathName, result);

            // Return instance
            return(retVal);
        }
示例#3
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);
            }
        }
示例#4
0
        /// <summary>
        /// Parses an object from stream <paramref name="s"/>
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Parse base (ANY) from the stream
            ANYFormatter baseFormatter = new ANYFormatter();

            // Parse BL
            BL retVal = baseFormatter.Parse <BL>(s);

            // Get the value
            if (s.GetAttribute("value") != null)
            {
                try
                {
                    retVal.Value = Util.Convert <Boolean>(s.GetAttribute("value"));
                }
                catch (Exception e)
                {
                    result.Code = ResultCode.Error;
                    result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e));
                }
            }

            // Base formatter
            baseFormatter.Validate(retVal, s.ToString(), result);

            return(retVal);
        }
示例#5
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();
            }
        }
示例#6
0
        /// <summary>
        /// Parse an object from <paramref name="s"/>
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Parse the base data
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Host = this.Host;
            LIST <IGraphable> retVal = baseFormatter.Parse <LIST <IGraphable> >(s);

            // parse items
            // Elements
            #region Elements
            if (!s.IsEmptyElement)
            {
                int    sDepth = s.Depth;
                string sName  = s.Name;

                s.Read();
                // string Name
                while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName))
                {
                    string oldName = s.Name; // Name
                    try
                    {
                        // Numerator
                        if (s.LocalName == "item")
                        {
                            var parseResult = Host.Parse(s, GenericArguments[0]);
                            result.Code = parseResult.Code;
                            result.AddResultDetail(parseResult.Details);
                            retVal.Add(parseResult.Structure);
                        }
                        else if (s.NodeType == System.Xml.XmlNodeType.Element)
                        {
                            result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, s.LocalName, s.NamespaceURI, s.ToString(), null));
                        }
                    }
                    catch (MessageValidationException e)
                    {
                        result.AddResultDetail(new ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e));
                    }
                    finally
                    {
                        if (s.Name == oldName)
                        {
                            s.Read();
                        }
                    }
                }
            }
            #endregion

            // Validate
            baseFormatter.Validate(retVal, s.ToString(), result);

            return(retVal);
        }
示例#7
0
        /// <summary>
        /// Gets a list of supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.AddRange(new PropertyInfo[] {
                typeof(UVP <>).GetProperty("Value"),
                typeof(UVP <>).GetProperty("Probability")
            });
            return(retVal);
        }
示例#8
0
        /// <summary>
        /// Gets a list of supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.AddRange(new PropertyInfo[] {
                typeof(EN).GetProperty("Use"),
                typeof(EN).GetProperty("Part")
            });
            return(retVal);
        }
示例#9
0
        /// <summary>
        /// Get supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.AddRange(new PropertyInfo[] {
                typeof(SLIST <>).GetProperty("Items"),
                typeof(SLIST <>).GetProperty("Origin"),
                typeof(SLIST <>).GetProperty("Scale")
            });
            return(retVal);
        }
示例#10
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();
            }
        }
示例#11
0
        /// <summary>
        /// Gets or sets the supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.AddRange(new PropertyInfo[] {
                typeof(TEL).GetProperty("Value"),
                typeof(TEL).GetProperty("Use"),
                typeof(TEL).GetProperty("Capabilities"),
                typeof(TEL).GetProperty("UseablePeriod")
            });
            return(retVal);
        }
示例#12
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()
                                           ));
            }
        }
示例#13
0
        /// <summary>
        /// Parse an object from <paramref name="s"/>
        /// </summary>
        public T ParseAttributes <T>(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) where T : ANY, IQuantity, new()
        {
            ANYFormatter baseFormatter = new ANYFormatter();
            T            retVal        = baseFormatter.Parse <T>(s);

            // attributes
            if (s.GetAttribute("uncertaintyType") != null)
            {
                retVal.UncertaintyType = Util.Convert <QuantityUncertaintyType>(s.GetAttribute("uncertaintyType"));
            }

            return(retVal);
        }
示例#14
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();
            }
        }
示例#15
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();
            }
        }
示例#16
0
        /// <summary>
        /// Gets the supported properties
        /// </summary>
        public List <System.Reflection.PropertyInfo> GetSupportedProperties()
        {
            var retVal = new ANYFormatter().GetSupportedProperties();

            retVal.AddRange(new PropertyInfo[]
            {
                typeof(II).GetProperty("Root"),
                typeof(II).GetProperty("Extension"),
                typeof(II).GetProperty("IdentifierName"),
                typeof(II).GetProperty("Displayable"),
                typeof(II).GetProperty("Scope"),
                typeof(II).GetProperty("Reliability")
            });
            return(retVal);
        }
示例#17
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();
                }
            }
        }
示例#18
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));
            }
        }
示例#19
0
        /// <summary>
        /// Parse only the attributes
        /// </summary>
        protected T ParseAttributes <T>(XmlReader s, DatatypeR2FormatterParseResult result) where T : ST, new()
        {
            // Base formatter
            ANYFormatter baseFormatter = new ANYFormatter();
            var          retVal        = baseFormatter.Parse <T>(s);

            // Attributes
            if (s.GetAttribute("value") != null)
            {
                retVal.Value = s.GetAttribute("value");
            }
            if (s.GetAttribute("language") != null)
            {
                retVal.Language = s.GetAttribute("language");
            }
            return(retVal);
        }
示例#20
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();
            }
        }
示例#21
0
        /// <summary>
        /// Parse an object from <paramref name="s"/>
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Parse the base
            ANYFormatter baseFormatter = new ANYFormatter();

            baseFormatter.Host             = this.Host;
            baseFormatter.GenericArguments = this.GenericArguments;
            var retVal = baseFormatter.Parse <II>(s);

            // Parse II specific data
            if (s.GetAttribute("root") != null)
            {
                retVal.Root = s.GetAttribute("root");
            }
            if (s.GetAttribute("extension") != null)
            {
                retVal.Extension = s.GetAttribute("extension");
            }
            if (s.GetAttribute("identifierName") != null)
            {
                retVal.IdentifierName = s.GetAttribute("identifierName");
            }
            if (s.GetAttribute("displayable") != null)
            {
                retVal.Displayable = Util.Convert <bool>(s.GetAttribute("displayable"));
            }
            if (s.GetAttribute("scope") != null)
            {
                retVal.Scope = Util.Convert <IdentifierScope>(s.GetAttribute("scope"));
            }
            if (s.GetAttribute("reliability") != null)
            {
                retVal.Reliability = Util.Convert <IdentifierReliability>(s.GetAttribute("reliability"));
            }

            // Validate
            baseFormatter.Validate(retVal, s.ToString(), result);

            return(retVal);
        }
示例#22
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();
            }
        }
示例#23
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();
            }
        }
示例#24
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();
                }
            }
        }
示例#25
0
        /// <summary>
        /// Parse object from the wire
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Parse base (ANY) from the stream
            ANYFormatter baseFormatter = new ANYFormatter();

            // Parse CS
            CS <String> retVal = baseFormatter.Parse <CS <String> >(s);

            // Now parse our data out... Attributes
            if (retVal.NullFlavor == null && s.GetAttribute("code") != null)
            {
                retVal.Code = s.GetAttribute("code");
            }

            // Validate
            string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name;

            baseFormatter.Validate(retVal, pathName, result);


            return(retVal);
        }
示例#26
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));
            }
        }
示例#27
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();
                }
            }
        }
示例#28
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
            }
        }
示例#29
0
        /// <summary>
        /// Parse <paramref name="s"/> to an instance of ADXP
        /// </summary>
        public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result)
        {
            // Create base
            ANYFormatter baseFormatter = new ANYFormatter();
            ADXP         retVal        = baseFormatter.Parse <ADXP>(s);

            // Read data
            if (s.GetAttribute("type") != null)
            {
                retVal.Type = Util.Convert <AddressPartType>(s.GetAttribute("type"));
            }
            if (s.GetAttribute("code") != null)
            {
                retVal.Code = s.GetAttribute("code");
            }
            if (s.GetAttribute("codeSystem") != null)
            {
                retVal.CodeSystem = s.GetAttribute("codeSystem");
            }
            if (s.GetAttribute("codeSystemVersion") != null)
            {
                retVal.CodeSystemVersion = s.GetAttribute("codeSystemVersion");
            }
            if (s.GetAttribute("language") != null)
            {
                result.AddResultDetail(new NotImplementedElementResultDetail(ResultDetailType.Warning, "@language", s.NamespaceURI, s.ToString(), null));
            }
            if (s.GetAttribute("value") != null)
            {
                retVal.Value = s.GetAttribute("value");
            }

            // Validate
            baseFormatter.Validate(retVal, s.ToString(), result);
            return(retVal);
        }
示例#30
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));
            }
        }