/// <summary> /// Graph <paramref name="o"/> onto <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result) { PDVFormatter qtyf = new PDVFormatter(); qtyf.Host = this.Host; qtyf.Graph(s, o, result); }
/// <summary> /// Parse an object from <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeR2FormatterParseResult result) { PDVFormatter qtyf = new PDVFormatter(); qtyf.Host = this.Host; return(qtyf.Parse <REAL>(s, result)); }
/// <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) { PDVFormatter baseFormatter = new PDVFormatter(); baseFormatter.Host = this.Host; var retVal = baseFormatter.ParseAttributes <CO>(s, result); // Process the parts #region Elements if (!s.IsEmptyElement) { int sDepth = s.Depth; string sName = s.Name; s.Read(); QTYFormatter qtyf = new QTYFormatter(); // 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 == "code" && retVal.Code == null) { var parseResult = Host.Parse(s, typeof(CD <String>)); result.Code = parseResult.Code; result.AddResultDetail(parseResult.Details); retVal.Code = parseResult.Structure as CD <String>; } else if (s.LocalName == "code") { result.AddResultDetail(new NotImplementedResultDetail(ResultDetailType.Warning, "Code can only be assigned once", s.ToString())); } else { qtyf.ParseElementsInline(s, retVal, result); } } catch (MessageValidationException e) { result.AddResultDetail(new ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, e)); } finally { if (s.Name == oldName) { s.Read(); } } } } #endregion // Validate new ANYFormatter().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) { PDVFormatter qtyf = new PDVFormatter(); qtyf.Host = this.Host; var retVal = qtyf.Parse <INT>(s, result); return(retVal); }
/// <summary> /// Graphs <paramref name="o"/> onto <paramref name="s"/> storing result /// in <paramref name="result"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result) { // Get a strongly typed instance of o PQ opq = o as PQ; // Output additional attributes // Since a PQ with null flavor derived can still have a unit // we only want to check for null flavors not derived if (opq.NullFlavor == null || opq.NullFlavor.Equals(NullFlavor.Derived)) { if (opq.Unit != null) { s.WriteAttributeString("unit", Util.ToWireFormat(opq.Unit)); } if (opq.CodingRationale != null) { s.WriteAttributeString("codingRationale", Util.ToWireFormat(opq.CodingRationale)); } } // Output the PDV and QTY formatter helper data PDVFormatter pdvFormatter = new PDVFormatter(); pdvFormatter.Host = this.Host; pdvFormatter.Graph(s, o, result); // Output the translations (if they exist) if (opq.Translation != null && (opq.NullFlavor == null || opq.NullFlavor.Equals(NullFlavor.Derived))) { foreach (var trans in opq.Translation) { s.WriteStartElement("translation", "urn:hl7-org:v3"); // Graph var hostResult = this.Host.Graph(s, trans); 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) { PDVFormatter qtyf = new PDVFormatter(); qtyf.Host = this.Host; qtyf.Graph(s, o, result); CO instance = o as CO; // Code property if (instance.NullFlavor != null) { return; } if (instance.Code != null) { s.WriteStartElement("code", "urn:hl7-org:v3"); var hostResult = this.Host.Graph(s, instance.Code); result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } }
/// <summary> /// Graphs <paramref name="o"/> onto <paramref name="s"/> storing result /// in <paramref name="result"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeR2FormatterGraphResult result) { // Get a strongly typed instance of o MO omo = o as MO; // Output additional attributes // Since a MO with null flavor derived can still have a currency // we only want to check for null flavors not derived if (omo.NullFlavor == null || omo.NullFlavor.Equals(NullFlavor.Derived)) { if (omo.Currency != null) { s.WriteAttributeString("currency", Util.ToWireFormat(omo.Currency)); } } // Output the PDV and QTY formatter helper data PDVFormatter pdvFormatter = new PDVFormatter(); pdvFormatter.Host = this.Host; pdvFormatter.Graph(s, o, result); }
/// <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 tUnit = null; if (s.GetAttribute("unit") != null) { tUnit = s.GetAttribute("unit"); } SET <CodingRationale> tRationale = null; if (s.GetAttribute("codingRationale") != null) { tRationale = Util.Convert <SET <CodingRationale> >(s.GetAttribute("codingRationale")); } // Parse PDV content (only attributes) var retVal = baseFormatter.ParseAttributes <PQ>(s, result); // Set PDV content retVal.Unit = tUnit; retVal.CodingRationale = tRationale; // Process elements // This requires a QTY formatter as QTY elements may be // in the stream as well #region Elements if (!s.IsEmptyElement) { // Prepare a formatter to process QTY elements QTYFormatter qtyFormatter = new QTYFormatter(); qtyFormatter.Host = this.Host; // Exit markers int sDepth = s.Depth; string sName = s.Name; // Translations SET <PQR> translations = new SET <PQR>(); // Read the next element s.Read(); // Read until exit condition is fulfilled while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && s.Depth == sDepth && s.Name == sName)) { string oldName = s.Name; // Name try { if (s.LocalName == "translation") // Format using ED { var hostResult = Host.Parse(s, typeof(PQR)); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); translations.Add(hostResult.Structure as PQR); } else { qtyFormatter.ParseElementsInline(s, retVal, result); } } catch (MessageValidationException e) { result.AddResultDetail(new MARC.Everest.Connectors.ResultDetail(MARC.Everest.Connectors.ResultDetailType.Error, e.Message, s.ToString(), e)); } finally { if (s.Name == oldName) { s.Read(); } } } // Set translations if (!translations.IsEmpty) { retVal.Translation = translations; } } #endregion // 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); }