public void ADXPCastADXPToStringTest() { ADXP ADXPToString = "Hamilton"; String strOut = ADXPToString; Assert.AreEqual("Hamilton", strOut); }
/// <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); } }
public void ADXPValueType2Test() { ADXP adxp = new ADXP("Canada", AddressPartType.County); adxp.NullFlavor = null; Assert.IsTrue(adxp.Validate()); }
public void ADXPCastStringToADXPTest() { ADXP StringToADXP = "Hamilton"; Assert.AreEqual("Hamilton", StringToADXP.Value); Assert.AreEqual(null, StringToADXP.Type); }
public void ADXPValue2Test() { ADXP adxp = new ADXP("96 White Water Dr."); adxp.NullFlavor = null; Assert.IsTrue(adxp.Validate()); }
public void ADXPTypeTest() { ADXP adxp = new ADXP(); adxp.Value = null; adxp.Type = AddressPartType.City; adxp.Code = null; adxp.CodeSystem = null; adxp.CodeSystemVersion = null; adxp.NullFlavor = null; Assert.IsFalse(adxp.Validate()); }
public void ADXPValueTest() { ADXP adxp = new ADXP(); adxp.Value = "Port Dover"; adxp.Type = null; adxp.Code = null; adxp.CodeSystem = null; adxp.CodeSystemVersion = null; adxp.NullFlavor = null; Assert.IsTrue(adxp.Validate()); }
public void ADXPValueTypeCodeCodeSystemCodeSystemVersionTest() { ADXP adxp = new ADXP(); adxp.Value = "Port Dover"; adxp.Type = AddressPartType.City; adxp.Code = "23.2487.35.12"; adxp.CodeSystem = "something"; adxp.CodeSystemVersion = "3"; adxp.NullFlavor = null; Assert.IsTrue(adxp.Validate()); }
public void ADXPValueTypeCodeTest() { ADXP adxp = new ADXP(); adxp.Value = "Port Dover"; adxp.Type = AddressPartType.City; adxp.Code = "23.2483.122"; adxp.CodeSystem = null; adxp.CodeSystemVersion = null; adxp.NullFlavor = null; Assert.IsFalse(adxp.Validate()); }
public void ADXPNullFlavorTest() { ADXP adxp = new ADXP(); adxp.Value = null; adxp.Type = null; adxp.Code = null; adxp.CodeSystem = null; adxp.CodeSystemVersion = null; adxp.NullFlavor = NullFlavor.NotApplicable; Assert.IsTrue(adxp.Validate()); }
/// <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> /// Parse an ADXP from stream <paramref name="s"/> /// </summary> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse CS ADXP retVal = baseFormatter.Parse <ADXP>(s, result); // Now parse our data out... if (!s.IsEmptyElement) { if (s.GetAttribute("code") != null && result.CompatibilityMode == DatatypeFormatterCompatibilityMode.Canadian) { retVal.Code = s.GetAttribute("code"); } else { result.AddResultDetail(new UnsupportedDatatypeR1PropertyResultDetail(ResultDetailType.Warning, "code", "ADXP", s.ToString())); } // Read next for text elemnt string sName = s.Name; s.Read(); while (!(s.NodeType == System.Xml.XmlNodeType.EndElement && sName == s.Name)) { if (s.NodeType == System.Xml.XmlNodeType.Text) { retVal.Value = s.Value; } s.Read(); } } // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; baseFormatter.Validate(retVal, pathName, result); return(retVal); }
/// <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> /// Parse an object from <paramref name="s"/> /// </summary> /// <param name="s">The stream to parse</param> /// <returns>The parsed object</returns> public object Parse(System.Xml.XmlReader s, DatatypeFormatterParseResult result) { // Parse the address parts // Parse base (ANY) from the stream ANYFormatter baseFormatter = new ANYFormatter(); // Parse CS AD retVal = baseFormatter.Parse <AD>(s, result); // Now parse our data out... Attributes if (s.GetAttribute("use") != null) { retVal.Use = (SET <CS <PostalAddressUse> >)Util.FromWireFormat(s.GetAttribute("use"), typeof(SET <CS <PostalAddressUse> >)); } if (s.GetAttribute("isNotOrdered") != null) { retVal.IsNotOrdered = (bool)Util.FromWireFormat(s.GetAttribute("isNotOrdered"), typeof(bool)); } // Loop through content // 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 { AddressPartType?adxpType; // Address part type // JF - This is a Canadian extension if (s.LocalName == "useablePeriod") // Usable Period, since this is an SXCM we'll need to read manually { // Useable period doesn't exist GTSFormatter sxcmFormatter = new GTSFormatter(); sxcmFormatter.Host = this.Host; retVal.UseablePeriod = sxcmFormatter.Parse(s, result) as GTS; } if (reverseMapping.TryGetValue(s.LocalName, out adxpType)) // Reverse map exists, so this is a part { ADXPFormatter adxpFormatter = new ADXPFormatter(); // ADXP Formatter adxpFormatter.Host = this.Host; ADXP part = (ADXP)adxpFormatter.Parse(s, result); // Parse part.Type = adxpType; retVal.Part.Add(part); // Add to AD } } catch (MessageValidationException e) { result.AddResultDetail(new ResultDetail(ResultDetailType.Error, e.Message, s.ToString(), e)); // Append details } finally { if (oldName == s.Name) { s.Read(); // Read if we need to } } } } #endregion // Validate string pathName = s is XmlStateReader ? (s as XmlStateReader).CurrentPath : s.Name; baseFormatter.Validate(retVal, pathName, result); return(retVal); }
public void ADXPToStringMethodTest() { ADXP ADXPToStringMethod = "Hamilton"; Assert.AreEqual("Hamilton", ADXPToStringMethod.ToString()); }