/// <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; }
/// <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; }
public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Want to control the output of value ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); MO instance = o as MO; if (instance.NullFlavor != null) return; // Don't graph anymore if (instance.Expression != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "PQ", s.ToString())); if (instance.OriginalText != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "PQ", s.ToString())); if (instance.Uncertainty != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "PQ", s.ToString())); if (instance.UncertaintyType != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "PQ", s.ToString())); if (instance.UncertainRange != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "PQ", s.ToString())); if (instance.Currency != null) s.WriteAttributeString("currency", instance.Currency); // Precision if (instance.Precision != null && instance.Precision != 0 && instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision), DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator), DatatypeFormatter.FormatterCulture)); else if (instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString(DatatypeFormatter.FormatterCulture)); }
/// <summary> /// Graph object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter baseFormatter = new ANYFormatter(); Type sxprType = typeof(SXPR<>); Type sxprGenericType = sxprType.MakeGenericType(GenericArguments); // Format the base type baseFormatter.Graph(s, o, result); // Was a nullflavor present if ((o as ANY).NullFlavor != null) return; // Current path string currentPath = s is XmlStateWriter ? (s as XmlStateWriter).CurrentPath : "NA"; // Graph the operator PropertyInfo operatorProperty = sxprGenericType.GetProperty("Operator"), componentProperty = sxprGenericType.GetProperty("Terms"); SetOperator? operatorValue = (SetOperator?)operatorProperty.GetValue(o, null); IEnumerable componentValue = (IEnumerable)componentProperty.GetValue(o, null); // Write the operator out if (operatorValue != null) s.WriteAttributeString("operator", Util.ToWireFormat(operatorValue)); // Elements if (componentValue != null) { int count = 0; foreach (var component in componentValue) { s.WriteStartElement("comp", "urn:hl7-org:v3"); object value = component; var compType = component.GetType(); string xsiTypeName = Util.CreateXSITypeName(compType); // Write the type if (this.Host.Host == null) s.WriteAttributeString("type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString()); else s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName.ToString()); if (count == 0) // the first element should have no operator { var pi = compType.GetProperty("Operator"); if (pi.GetValue(component, null) != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "Operator won't be represented in the first object in the SXCM", s.ToString(), null)); pi.SetValue(component, null, null); } var hostGraphResult = Host.Graph(s, (IGraphable)value); result.AddResultDetail(hostGraphResult.Details); s.WriteEndElement(); // comp count++; } } }
/// <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 } }
/// <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; }
/// <summary> /// Graph <paramref name="o"/> onto <paramref name="s"/> /// </summary> /// <param name="s">The stream to graph to</param> /// <param name="o">The object to graph</param> public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // We don't use base.graph() here because we want to control the value property ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); REAL instance = o as REAL; if (instance.NullFlavor != null) return; // Don't graph anymore // Precision if (instance.Value.HasValue && instance.Precision != 0) s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision), DatatypeFormatter.FormatterCulture.NumberFormat.NumberDecimalSeparator), DatatypeFormatter.FormatterCulture)); else if (instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString(DatatypeFormatter.FormatterCulture)); // Unsupported properties if (instance.Expression != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "REAL", s.ToString())); if (instance.OriginalText != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "REAL", s.ToString())); if (instance.Uncertainty != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "REAL", s.ToString())); if (instance.UncertaintyType != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "REAL", s.ToString())); if (instance.UncertainRange != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "REAL", s.ToString())); }
/// <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(); } }
/// <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"); var hostResult = this.Host.Graph(s, term as IGraphable); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } }
/// <summary> /// Parse <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse TEL TEL retVal = baseFormatter.Parse<TEL>(s); // Get the value if (s.GetAttribute("value") != null) retVal.Value = s.GetAttribute("value"); if (s.GetAttribute("use") != null) retVal.Use = Util.Convert<SET<CS<TelecommunicationAddressUse>>>(s.GetAttribute("use")); if (s.GetAttribute("capabilities") != null) retVal.Capabilities = Util.Convert<SET<CS<TelecommunicationCabability>>>(s.GetAttribute("capabilities")); // 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 == "useablePeriod") { var parseResult = this.Host.Parse(s, typeof(GTS)); result.Code = parseResult.Code; result.AddResultDetail(parseResult.Details); retVal.UseablePeriod = Util.Convert<GTS>(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 // Base formatter baseFormatter.Validate(retVal, s.ToString(), result); return retVal; }
/// <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(); } }
public virtual void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Has this formatter found the elemScopeStack yet? string currentElementName = null; // TODO: Make all parameters XmlStateWriters, next release of Everest // TODO: Don't have enough time to test what this may change upstream if (s is XmlStateWriter) currentElementName = (s as XmlStateWriter).CurrentElement.Name; else { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Can't represent a SET or LIST using this Xml Stream as it does not inherit from an XmlStateWriter", s.ToString(), null)); return; } // Graph base ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Host = this.Host; baseFormatter.Graph(s, o, result); if (((ANY)o).IsNull) return; // Write the array IEnumerable instance = (IEnumerable)o; int count = 0; // Get each element in the instance IEnumerator enumerator = instance.GetEnumerator(); if (!enumerator.MoveNext()) return; // No elements // Loop through elements while (enumerator.Current != null) { if (count != 0) // Not the first element, write the element name again s.WriteStartElement(currentElementName, "urn:hl7-org:v3"); // JF: Output XSI:Type if (GenericArguments != null && !enumerator.Current.GetType().Equals(GenericArguments[0])) { string xsiTypeName = Util.CreateXSITypeName(enumerator.Current.GetType()); s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName); } var hostResult = Host.Graph(s, (IGraphable)enumerator.Current); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); if (!enumerator.MoveNext()) break; // No further objects s.WriteEndElement(); count++; } }
/// <summary> /// Parse an object instance from <paramref name="s"/> /// </summary> public virtual object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { // Parse the base attributes ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Host = this.Host; baseFormatter.GenericArguments = this.GenericArguments; EN retVal = baseFormatter.Parse<EN>(s); // Use if (s.GetAttribute("use") != null) retVal.Use = Util.Convert<SET<CS<EntityNameUse>>>(s.GetAttribute("use")); // Process the parts #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 == "part") { var parseResult = Host.Parse(s, typeof(ENXP)); result.Code = parseResult.Code; result.AddResultDetail(parseResult.Details); retVal.Part.Add(parseResult.Structure as ENXP); } 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; }
/// <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; }
/// <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)); }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null ? BL instance = o as BL; if (instance.NullFlavor != null) return; // Format if (instance.Value != null) s.WriteAttributeString("value", string.Format("{0}", instance.Value).ToLower()); }
/// <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(); } }
/// <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(); } }
/// <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(); } } }
public override void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Want to control output of the value attribute ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); PQ instance = o as PQ; if (instance.NullFlavor != null) return; // Don't graph anymore if (instance.CodingRationale != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodingRationale", "PQ", s.ToString())); if (instance.Expression != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "PQ", s.ToString())); if (instance.OriginalText != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "PQ", s.ToString())); if (instance.Uncertainty != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "PQ", s.ToString())); if (instance.UncertaintyType != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "PQ", s.ToString())); if (instance.UncertainRange != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "PQ", s.ToString())); if (instance.Unit != null) s.WriteAttributeString("unit", instance.Unit); // Precision if (instance.Precision != null && instance.Precision != 0 && instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision)), DatatypeFormatter.FormatterCulture)); else if(instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString(DatatypeFormatter.FormatterCulture)); if (instance.Translation != null) foreach (var trans in instance.Translation) { s.WriteStartElement("translation", "urn:hl7-org:v3"); PQRFormatter pqrFormatter = new PQRFormatter(); pqrFormatter.Graph(s, trans, result); s.WriteEndElement(); } }
/// <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; }
/// <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); }
/// <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(); } }
/// <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)); } }
/// <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() )); }
/// <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; }
/// <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(); } }
/// <summary> /// Graph <paramref name="o"/> onto <paramref name="s"/> /// </summary> /// <param name="s">The stream to graph to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); REAL instance = o as REAL; if (instance.NullFlavor != null) return; // Don't graph anymore // Precision if (instance.Value.HasValue && instance.Precision != 0) s.WriteAttributeString("value", instance.Value.Value.ToString(String.Format("0.{0}", new String('0', instance.Precision)))); else if (instance.Value.HasValue) s.WriteAttributeString("value", instance.Value.Value.ToString()); // Unsupported properties if (instance.Expression != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "REAL", s.ToString())); if (instance.OriginalText != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "REAL", s.ToString())); if (instance.Uncertainty != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "REAL", s.ToString())); if (instance.UncertaintyType != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "REAL", s.ToString())); if (instance.UncertainRange != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "REAL", s.ToString())); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse from</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { PDVFormatter pdvFormatter = new PDVFormatter(); REAL retVal = pdvFormatter.Parse<REAL>(s, result); // Precision is not supported in R1, but is still useful to have so // we will report the precision of the data that was on the wire string valStr = s.GetAttribute("value"); if (valStr != null && valStr.Contains(".")) retVal.Precision = valStr.Length - valStr.IndexOf(".") - 1; else retVal.Precision = 0; // Validate ANYFormatter fmtr = new ANYFormatter(); string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; fmtr.Validate(retVal, pathName, result); return retVal; }
/// <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)); } }