public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Format the UVP to the wire UVPFormatter uvpFormatter = new UVPFormatter(); uvpFormatter.Host = this.Host; uvpFormatter.Graph(s, o, result); if ((o as ANY).NullFlavor != null) return; // Get the value of the elements, since it is a generic type Type ivlType = o.GetType(); object 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); // Warn the developer if there are any properties that can't be represented in R1 if (originalTextValue != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "URG", s.ToString())); if (lowClosedValue != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "LowClosed", "URG", s.ToString())); if (highClosedValue != null) result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "HighClosed", "URG", s.ToString())); if (lowValue != null && highValue != null) // low & high { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("high", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, high, value can't be represented together in an URG data type in R1. Only formatting low and high", s.ToString(), null)); if (widthValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, high, width can't be represented together in an URG data type in R1. Only formatting low and high", s.ToString(), null)); #endregion } else if (lowValue != null && widthValue != null) // Low & width { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("width", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, width, value can't be represented together in an URG data type in R1. Only formatting low and width", s.ToString(), null)); if (highValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, width, high can't be represented together in an URG data type in R1. Only formatting low and width", s.ToString(), null)); #endregion } else if (highValue != null && widthValue != null) // high & width { s.WriteStartElement("width", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("high", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "high, width, value can't be represented together in an URG data type in R1. Only formatting width and high", s.ToString(), null)); if (lowValue != null) result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "high, width, low can't be represented together in an URG data type in R1. Only formatting width and high", s.ToString(), null)); #endregion } else if (lowValue != null) // low only { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (highValue != null) // High only { s.WriteStartElement("high", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (widthValue != null) // width only { s.WriteStartElement("width", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (valueValue != null) ; //DOC: The next comment makes no sence, further documentation required. // No need for this ; else result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Can't create a valid representation of URG using the supplied data for data types R1. Valid IVL must have [low & [high | width]] | [high & width] | high | value to satisfy data type R1 constraints", s.ToString(), null)); }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Format the UVP to the wire UVPFormatter uvpFormatter = new UVPFormatter(); uvpFormatter.Host = this.Host; uvpFormatter.Graph(s, o, result); if ((o as ANY).NullFlavor != null) { return; } // Get the value of the elements, since it is a generic type Type ivlType = o.GetType(); object 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); // Warn the developer if there are any properties that can't be represented in R1 if (originalTextValue != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "URG", s.ToString())); } if (lowClosedValue != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "LowClosed", "URG", s.ToString())); } if (highClosedValue != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "HighClosed", "URG", s.ToString())); } if (lowValue != null && highValue != null) // low & high { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("high", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, high, value can't be represented together in an URG data type in R1. Only formatting low and high", s.ToString(), null)); } if (widthValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, high, width can't be represented together in an URG data type in R1. Only formatting low and high", s.ToString(), null)); } #endregion } else if (lowValue != null && widthValue != null) // Low & width { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("width", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, width, value can't be represented together in an URG data type in R1. Only formatting low and width", s.ToString(), null)); } if (highValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "low, width, high can't be represented together in an URG data type in R1. Only formatting low and width", s.ToString(), null)); } #endregion } else if (highValue != null && widthValue != null) // high & width { s.WriteStartElement("width", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); s.WriteStartElement("high", "urn:hl7-org:v3"); hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); #region Warnings if (valueValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "high, width, value can't be represented together in an URG data type in R1. Only formatting width and high", s.ToString(), null)); } if (lowValue != null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Warning, "high, width, low can't be represented together in an URG data type in R1. Only formatting width and high", s.ToString(), null)); } #endregion } else if (lowValue != null) // low only { s.WriteStartElement("low", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)lowValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (highValue != null) // High only { s.WriteStartElement("high", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)highValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (widthValue != null) // width only { s.WriteStartElement("width", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)widthValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } else if (valueValue != null) { ; } //DOC: The next comment makes no sence, further documentation required. // No need for this ; else { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Can't create a valid representation of URG using the supplied data for data types R1. Valid IVL must have [low & [high | width]] | [high & width] | high | value to satisfy data type R1 constraints", s.ToString(), null)); } }