public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult 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)); } //if ((o is CS<String> || o.GetType().GetGenericTypeDefinition() == typeof(CS<>))) //{ // if (instance_ics.CodeSystem != null) // Warn if there is no way to represent this in R1 // result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystem", "CS", s.ToString())); // else if (instance_ics.CodeSystemName != null) // result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemName", "CS", s.ToString())); // else if (instance_ics.CodeSystemVersion != null) // result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemVersion", "CS", s.ToString())); //} }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Represent the ST as an ED and serialize the ED ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); ST instance = o as ST; // Get rid of these attributes if (result.CompatibilityMode != DatatypeFormatterCompatibilityMode.ClinicalDocumentArchitecture) { // In R1 data types an ST is a restriction of an ED with these attributes fixed s.WriteAttributeString("mediaType", "text/plain"); s.WriteAttributeString("representation", "TXT"); } // Language if (instance.Language != null) { s.WriteAttributeString("language", instance.Language); } // Content s.WriteString(instance.Value); // Translation if (instance.Translation != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Translation", "ST", s.ToString())); } }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { AD instance = o as AD; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o as ANY, result); // Null flavor if (instance.NullFlavor != null) { return; } // use if (instance.Use != null) { s.WriteAttributeString("use", Util.ToWireFormat(instance.Use)); } if (instance.IsNotOrdered != null) { s.WriteAttributeString("isNotOrdered", instance.IsNotOrdered.ToString().ToLower()); } // parts if (instance.Part != null) { foreach (ADXP part in instance.Part) { if (mapping.ContainsKey(part.Type ?? AddressPartType.AddressLine)) { s.WriteStartElement(mapping[part.Type ?? AddressPartType.AddressLine], "urn:hl7-org:v3"); } else { throw new MessageValidationException(string.Format("Can't represent address part '{0}' in datatypes R1 at '{1}'", part.Type, (s as XmlStateWriter).CurrentPath)); } 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> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to graph object to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TEL instance_tel = (TEL)o; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) { return; } // Attributes if (instance_tel.Value != null) { s.WriteAttributeString("value", instance_tel.Value); } if (instance_tel.Use != null && instance_tel.Use.Items != null && instance_tel.Use.Items.Count > 0) { s.WriteAttributeString("use", Util.ToWireFormat(instance_tel.Use)); } if (instance_tel.Capabilities != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail( ResultDetailType.Warning, "Capabilities", "TEL", s.ToString())); } // Elements if (instance_tel.UseablePeriod != null) { s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); GTSFormatter formatterHelper = new GTSFormatter(); formatterHelper.Host = this.Host; formatterHelper.Graph(s, instance_tel.UseablePeriod, result); s.WriteEndElement(); // usable period } //foreach (SXCM<TS> up in instance_tel.UseablePeriod) //{ // // Start element // s.WriteStartElement("useablePeriod", "urn:hl7-org:v3"); // // Attributes for SXCM // if(up.Operator != null) // s.WriteAttributeString("operator", Util.ToWireFormat(up.Operator)); // // Timestamp portion // TSFormatter tsFormatter = new TSFormatter(); // tsFormatter.Graph(s, (TS)up, result); // s.WriteEndElement(); // end usablePeriod //} }
/// <summary> /// Graph the object <paramref name="o"/> to <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Cast the object to GTS GTS instance = o as GTS; // Hull instance corrections if (instance.Hull != null) { if (instance.Hull.NullFlavor != null) { instance.NullFlavor = instance.NullFlavor ?? instance.Hull.NullFlavor; instance.Hull.NullFlavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.NullFlavor", "NullFlavor", instance.NullFlavor, s.ToString())); } if (instance.Hull.Flavor != null) { instance.Flavor = instance.Flavor ?? instance.Hull.Flavor; instance.Hull.Flavor = null; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Hull.Flavor", "Flavor", instance.Flavor, s.ToString())); } } ANYFormatter anyFormatter = new ANYFormatter(); // Graph the base anyFormatter.Graph(s, o as ANY, result); // Determine what type of hull we have if (instance.NullFlavor != null) // Null flavor specified, no hull will be graphed { return; } else if (instance.Hull == null) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, "Cannot graph a GTS with a Null Hull", s.ToString())); return; } object instanceHull = instance.Hull; if (instanceHull.GetType().Name.StartsWith("QS")) { instanceHull = instanceHull.GetType().GetMethod("TranslateToSXPR").Invoke(instanceHull, null); } string xsiTypeName = Util.CreateXSITypeName(instanceHull.GetType()); s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, xsiTypeName); // Output the formatting var hostResult = this.Host.Graph(s, (IGraphable)instanceHull); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); }
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> /// Graphs the object <paramref name="o"/> onto the stream. /// </summary> /// <param name="s">The XmlWriter stream to write to.</param> /// <param name="o">The object to graph.</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { TN tn = (TN)o; ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); if (tn.Part.Count > 0 && tn.NullFlavor == null) { s.WriteString(tn.Part[0].Value); } if (tn.Part.Count > 1) { result.AddResultDetail(new InsufficientRepetionsResultDetail(ResultDetailType.Warning, "TN is only permitted to have one part", s.ToString())); } }
/// <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())); } }
public void Graph(XmlWriter xw, object o, DatatypeFormatterGraphResult result) { // Graph this object to the stream ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(xw, o, result); // Graph the any part of this if (o.GetType().GetProperty("NullFlavor").GetValue(o, null) != null) { return; // No further graphing } // Now comes the fun part .. we'll need to graph the Value property onto the stream, object valueValue = o.GetType().GetProperty("Value").GetValue(o, null); if (valueValue != null) { xw.WriteAttributeString("value", Util.ToWireFormat(valueValue)); } }
/// <summary> /// Grap the object to a stream /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ADXP instance = o as ADXP; // Start with part type and code attributes ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); if (instance.NullFlavor != null) { return; } // Now format our data if (instance.Type != null && result.CompatibilityMode != DatatypeFormatterCompatibilityMode.ClinicalDocumentArchitecture) { s.WriteAttributeString("partType", Util.ToWireFormat(instance.Type)); } if (instance.Code != null) { if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { s.WriteAttributeString("code", instance.Code); } else { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Code", "ADXP", s.ToString())); } } if (instance.Value != null) { s.WriteValue(instance.Value); } if (instance.CodeSystem != null) // Warn if there is no way to represent this in R1 { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystem", "ADXP", s.ToString())); } if (instance.CodeSystemVersion != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "CodeSystemVersion", "ADXP", s.ToString())); } }
/// <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())); } }
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 the object <paramref name="o"/> onto <paramref name="s"/> /// </summary> /// <param name="s">The xmlwriter to write to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref TS instance_ts = (TS)o; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) { return; } // Timestamp if (instance_ts.Value != null) { s.WriteAttributeString("value", o.ToString()); } }
/// <summary> /// Graph object <paramref name="o"/> onto stream <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); // Graph the base data // If there is no null flavor then graph the rest of the object object invertedValue = o.GetType().GetProperty("Inverted").GetValue(o, null), nameValue = o.GetType().GetProperty("Name").GetValue(o, null), valueValue = o.GetType().GetProperty("Value").GetValue(o, null); // Graph the structural attributes s.WriteAttributeString("inverted", Util.ToWireFormat(invertedValue)); // Graph the non-structural elements if (nameValue != null) { s.WriteStartElement("name"); CVFormatter cdFormatter = new CVFormatter(); cdFormatter.Host = this.Host; cdFormatter.GenericArguments = this.GenericArguments; cdFormatter.Graph(s, nameValue, result); s.WriteEndElement(); // end name } if (valueValue != null) { s.WriteStartElement("value"); CDFormatter cdFormatter = new CDFormatter(); cdFormatter.Host = this.Host; cdFormatter.GenericArguments = this.GenericArguments; cdFormatter.Graph(s, valueValue, result); s.WriteEndElement(); // end value } }
/// <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) { // Graph this UVP to the stream ANYFormatter pdvFormatter = new ANYFormatter(); pdvFormatter.Graph(s, o, result); // Add probability if ((o as ANY).NullFlavor != null) { return; // No need for this } object probValue = o.GetType().GetProperty("Probability").GetValue(o, null), valueValue = o.GetType().GetProperty("Value").GetValue(o, null); // Output XSI:TYPE s.WriteAttributeString("xsi", "type", DatatypeFormatter.NS_XSI, Util.CreateXSITypeName(o.GetType())); if (probValue != null) { s.WriteAttributeString("probability", Util.ToWireFormat(probValue)); } // Graph the value ANY anyValue = valueValue as ANY; if (anyValue == null) { return; } var hostResult = this.Host.Graph(s, anyValue); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); }
/// <summary> /// Graph object <paramref name="o"/> onto <paramref name="s"/> /// </summary> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter anyFormatter = new ANYFormatter(); anyFormatter.Graph(s, o, result); // Now graph the attributes Type eivlType = o.GetType(); object eventValue = eivlType.GetProperty("Event").GetValue(o, null), offsetValue = eivlType.GetProperty("Offset").GetValue(o, null), operatorValue = eivlType.GetProperty("Operator").GetValue(o, null); // Append the attributes to the writer if ((o as ANY).NullFlavor != null) { return; // Nothing to report } if (operatorValue != null) { s.WriteAttributeString("operator", Util.ToWireFormat(operatorValue)); } // Write elements if (eventValue != null) { s.WriteStartElement("event", "urn:hl7-org:v3"); Host.GraphObject(s, (IGraphable)eventValue); s.WriteEndElement(); } if (offsetValue != null) { s.WriteStartElement("offset", "urn:hl7-org:v3"); Host.GraphObject(s, (IGraphable)offsetValue); 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++; } }
public void Graph(XmlWriter s, object o, DatatypeFormatterGraphResult result) { II instance = o as II; // Base graph ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o as ANY, result); IResultDetail[] useDetails = new IResultDetail[0]; // Handle II graphing if (instance.Root != null) // root { s.WriteAttributeString("root", instance.Root); } if (instance.Extension != null) // extension { s.WriteAttributeString("extension", instance.Extension); } if (instance.AssigningAuthorityName != null) // assigning authority { s.WriteAttributeString("assigningAuthorityName", instance.AssigningAuthorityName); } // NHS Extension : Start if (instance.PatientIdStatus != null) // assigning authority { s.WriteAttributeString("patientIdStatus", instance.PatientIdStatus); } // NHS Extension : Finish if (instance.Displayable != null) { s.WriteAttributeString("displayable", instance.Displayable.ToString().ToLower()); } // JF - Use is not permitted if (instance.Scope != null && instance.Scope.HasValue) { if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { switch (instance.Scope.Value) { case IdentifierScope.VersionIdentifier: s.WriteAttributeString("use", "VER"); break; case IdentifierScope.BusinessIdentifier: s.WriteAttributeString("use", "BUS"); break; default: result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "scope", "II", s.ToString())); break; } } else { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Scope", "II", s.ToString())); } } // Non supported features if (instance.IdentifierName != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "IdentifierName", "II", s.ToString())); } if (instance.Reliability != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Reliability", "II", s.ToString())); } }
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> /// Graph the object <paramref name="o"/> onto stream <paramref name="s"/> /// </summary> /// <param name="s">The XmlWriter to write the object to</param> /// <param name="o">The object to graph</param> public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { // Get an instance ref ED instance_ed = (ED)o; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Null flavor if (((ANY)o).NullFlavor != null) { return; } // Attributes s.WriteAttributeString("representation", Util.ToWireFormat(instance_ed.Representation)); if (instance_ed.MediaType != null) { s.WriteAttributeString("mediaType", Util.ToWireFormat(instance_ed.MediaType)); } if (instance_ed.Language != null) { s.WriteAttributeString("language", instance_ed.Language); } if (instance_ed.Compression != null) { s.WriteAttributeString("compression", Util.ToWireFormat(instance_ed.Compression)); } if (instance_ed.IntegrityCheck != null) { s.WriteAttributeString("integrityCheck", Convert.ToBase64String(instance_ed.IntegrityCheck)); } if (instance_ed.Description != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Description", "ED", s.ToString())); } if (instance_ed.IntegrityCheckAlgorithm != null) { // Incorrect representation of the SHA1 and SHA256 names in r1 switch ((EncapsulatedDataIntegrityAlgorithm)instance_ed.IntegrityCheckAlgorithm) { case EncapsulatedDataIntegrityAlgorithm.SHA1: s.WriteAttributeString("integrityCheckAlgorithm", "SHA-1"); break; case EncapsulatedDataIntegrityAlgorithm.SHA256: s.WriteAttributeString("integrityCheckAlgorithm", "SHA-256"); break; } } // Elements if (instance_ed.Reference != null) { TELFormatter refFormatter = new TELFormatter(); s.WriteStartElement("reference", "urn:hl7-org:v3"); refFormatter.Graph(s, instance_ed.Reference, result); s.WriteEndElement(); } if (instance_ed.Thumbnail != null) { EDFormatter thumbFormatter = new EDFormatter(); s.WriteStartElement("thumbnail", "urn:hl7-org:v3"); thumbFormatter.Graph(s, instance_ed.Thumbnail, result); s.WriteEndElement(); } if (instance_ed.Translation != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Translation", "ED", s.ToString())); } Encoding textEncoding = System.Text.Encoding.UTF8; // Value if (instance_ed.Data != null && instance_ed.Data.Length > 0) { if (instance_ed.Representation == EncapsulatedDataRepresentation.B64) { s.WriteBase64(instance_ed.Data, 0, instance_ed.Data.Length); } else if (instance_ed.Representation == EncapsulatedDataRepresentation.TXT) { s.WriteString(textEncoding.GetString(instance_ed.Data)); } else { char[] charBuffer = textEncoding.GetChars(instance_ed.Data); s.WriteRaw(charBuffer, 0, charBuffer.Length); } } }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter anyFormatter = new ANYFormatter(); anyFormatter.Graph(s, o, result); // Now graph the attributes 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); // Append the attributes to the writer if ((o as ANY).NullFlavor != null) { return; // Nothing to report } if (valueValue != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Value", "PIVL", s.ToString())); } //s.WriteAttributeString("value", Util.ToWireFormat(valueValue)); if (operatorValue != null) { s.WriteAttributeString("operator", Util.ToWireFormat(operatorValue)); } if (alignmentValue != null) { s.WriteAttributeString("alignment", Util.ToWireFormat(alignmentValue)); } if (institutionSpecifiedValue != null) { s.WriteAttributeString("institutionSpecified", Util.ToWireFormat(institutionSpecifiedValue)); } if (countValue != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Count", "PIVL", s.ToString())); } // Write elements if (phaseValue != null) { s.WriteStartElement("phase", "urn:hl7-org:v3"); Host.GraphObject(s, (IGraphable)phaseValue); s.WriteEndElement(); } if (frequencyValue != null) { // JF - Frequency is not supported by UV R1 if (result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { s.WriteStartElement("frequency", "urn:hl7-org:v3"); var hostResult = this.Host.Graph(s, (IGraphable)frequencyValue); result.AddResultDetail(hostResult.Details); result.Code = hostResult.Code; s.WriteEndElement(); } else { RTO <INT, PQ> rto = frequencyValue as RTO <INT, PQ>; periodValue = rto.Denominator / rto.Numerator; result.AddResultDetail(new PropertyValuePropagatedResultDetail(ResultDetailType.Warning, "Frequency", "Period", periodValue, s.ToString())); s.WriteStartElement("period", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)periodValue); result.AddResultDetail(hostResult.Details); result.Code = hostResult.Code; s.WriteEndElement(); } } else if (periodValue != null) { s.WriteStartElement("period", "urn:hl7-org:v3"); var hostResult = Host.Graph(s, (IGraphable)periodValue); result.AddResultDetail(hostResult.Details); result.Code = hostResult.Code; s.WriteEndElement(); } }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { EN instance = o as EN; // Do a base format ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o as ANY, result); // Null flavor if (instance.NullFlavor != null) { return; } // use if (instance.Use != null) { s.WriteAttributeString("use", Util.ToWireFormat(instance.Use)); } // parts if (instance.Part != null) { foreach (ENXP part in instance.Part) { EntityNamePartType?pt = part.Type; SET <CS <EntityNamePartQualifier> > qualifiers = new SET <CS <EntityNamePartQualifier> >(); if (part.Qualifier != null) { foreach (var qlf in part.Qualifier) { qualifiers.Add(qlf.Clone() as CS <EntityNamePartQualifier>); } } // Title part type? if (pt == EntityNamePartType.Title) { part.Qualifier.Add(new CS <EntityNamePartQualifier>() { Code = CodeValue <EntityNamePartQualifier> .Parse("TITLE") } ); pt = null; } // Possible to match qualifier to a part tpye if none specified! if (!qualifiers.IsEmpty) { CS <EntityNamePartQualifier> pfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Prefix)), sfx = qualifiers.Find(a => a.Code.Equals(EntityNamePartQualifier.Suffix)); if (pfx != null) { pt = EntityNamePartType.Prefix; qualifiers.Remove(pfx); } else if (sfx != null) { pt = EntityNamePartType.Suffix; qualifiers.Remove(sfx); } } // Part type is not set so do it inline if (pt == null) { if (!qualifiers.IsEmpty) { result.AddResultDetail(new NotSupportedChoiceResultDetail(ResultDetailType.Warning, "Part has qualifier but is not being rendered as a type element, qualifier will be dropped", s.ToString(), null)); } s.WriteString(part.Value); } else if (mapping.ContainsKey(pt)) { var prt = part.Clone() as ENXP; prt.Type = pt; prt.Qualifier = qualifiers; s.WriteStartElement(mapping[pt], "urn:hl7-org:v3"); ENXPFormatter enFormatter = new ENXPFormatter(); enFormatter.Graph(s, prt, result); s.WriteEndElement(); } else { throw new MessageValidationException(string.Format("Can't represent entity name part '{0}' in datatypes R1 at '{1}'", pt, (s as XmlStateWriter).CurrentPath)); } } } // base details }
/// <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++; } } }
public void Graph(System.Xml.XmlWriter s, object o, DatatypeFormatterGraphResult result) { ANYFormatter baseFormatter = new ANYFormatter(); baseFormatter.Graph(s, o, result); // Since this is a generic type, we'll need to get the values we're interested in // for the formatting operation Type oType = o.GetType(); object numerator = oType.GetProperty("Numerator").GetValue(o, null), denominator = oType.GetProperty("Denominator").GetValue(o, null); // Check for the QTY members QTY <Nullable <Double> > qtyPortion = o as QTY <Nullable <Double> >; // Check for non-representable properties if (qtyPortion.Expression != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Expression", "RTO", s.ToString())); } if (qtyPortion.OriginalText != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "OriginalText", "RTO", s.ToString())); } if (qtyPortion.Uncertainty != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Uncertainty", "RTO", s.ToString())); } if (qtyPortion.UncertaintyType != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertaintyType", "RTO", s.ToString())); } if (qtyPortion.UncertainRange != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "UncertainRange", "RTO", s.ToString())); } if (qtyPortion.Value != null) { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "Value", "RTO", s.ToString())); } IXmlStructureFormatter serFormatter = Host; // Serialize the data-type if (numerator != null) { s.WriteStartElement("numerator", "urn:hl7-org:v3"); // Write the XSI type string xsiTypeName = Util.CreateXSITypeName(numerator.GetType()); // 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()); } var hostResult = serFormatter.Graph(s, (IGraphable)numerator); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } if (denominator != null) { s.WriteStartElement("denominator", "urn:hl7-org:v3"); // Write the XSI type string xsiTypeName = Util.CreateXSITypeName(denominator.GetType()); // 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()); } var hostResult = serFormatter.Graph(s, (IGraphable)denominator); result.Code = hostResult.Code; result.AddResultDetail(hostResult.Details); s.WriteEndElement(); } // Append details //details.AddRange(serFormatter.Details); }