public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something>" + "<numerator unit=\"mg\" value=\"1000\" />" + "<denominator unit=\"d\" value=\"1\" />" + "</something>" + "<something>" + "<numerator unit=\"mg\" value=\"1001\" />" + "<denominator unit=\"d\" value=\"2\" />" + "</something>" + "</top>"); BareANY result = new SetElementParser(ParserRegistry.GetInstance()).Parse(ParseContextImpl.Create("SET<RTO<PQ.DRUG,PQ.TIME>>" , null, SpecificationVersion.V01R04_2_SK, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality .Create("1-5"), null, false), AsList(node.ChildNodes), null); ICollection <Ratio <PhysicalQuantity, PhysicalQuantity> > set = ((SET <RTO <PhysicalQuantity, PhysicalQuantity>, Ratio <PhysicalQuantity , PhysicalQuantity> >)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(2, set.Count, "size"); bool foundFirst = false; bool foundSecond = false; foreach (Ratio <PhysicalQuantity, PhysicalQuantity> ratio in set) { if (ratio.Numerator.Quantity.Value == 1000 && ratio.Denominator.Quantity.Value == 1) { foundFirst = true; } else { if (ratio.Numerator.Quantity.Value == 1001 && ratio.Denominator.Quantity.Value == 2) { foundSecond = true; } } } Assert.IsTrue(foundFirst); Assert.IsTrue(foundSecond); }
public virtual void RawValueCanBeAddedToParsedValue() { XmlNode node = CreateNode("<top>" + "<something root=\"1.1\" extension=\"fred\" use=\"BUS\"/>" + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />" + "</top>"); BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II.BUS>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), null); ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet(); rawSet.Add(new Identifier("3.3", "newExtension")); Assert.AreEqual(3, rawSet.Count, "size"); Assert.IsTrue(rawSet.Contains(new Identifier("3.3", "newExtension"))); }
public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something root=\"rootValue\" extension=\"fred\" />" + "<something root=\"rootValue2\" extension=\"extensionValue\" />" + "</top>"); BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), new XmlToModelResult()); ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet(); Assert.IsNotNull(rawSet, "null"); Assert.AreEqual(2, rawSet.Count, "size"); Assert.IsTrue(rawSet.Contains(new Identifier("rootValue", "fred"))); Assert.IsTrue(rawSet.Contains(new Identifier("rootValue2", "extensionValue"))); }
public virtual void DuplicatesShouldLogValidationError() { XmlNode node = CreateNode("<top>" + "<something root=\"1.1\" extension=\"fred\" use=\"BUS\"/>" + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />" + "<something root=\"2.2\" extension=\"extensionValue\" use=\"BUS\" />" + "</top>"); BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<II.BUS>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), this.xmlResult); ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet(); Assert.AreEqual(2, rawSet.Count, "size"); Assert.IsTrue(rawSet.Contains(new Identifier("1.1", "fred"))); Assert.IsTrue(rawSet.Contains(new Identifier("2.2", "extensionValue"))); Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count, "errors"); Assert.AreEqual("Duplicate value not allowed for SET", this.xmlResult.GetHl7Errors()[0].GetMessage(), "message"); }
public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something>Fred</something>" + "<something>Wilma</something>" + "<something>Betty</something>" + "</top>"); BareANY result = new SetElementParser(ParserRegistry.GetInstance()).Parse(ParseContextImpl.Create("SET<ST>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), null); ICollection <string> set = ((SET <ST, string>)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(3, set.Count, "size"); Assert.IsTrue(set.Contains("Fred"), "Fred"); Assert.IsTrue(set.Contains("Wilma"), "Wilma"); Assert.IsTrue(set.Contains("Betty"), "Betty"); }
public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something value=\"20000407123059\" />" + "<something value=\"20020628010101\" />" + "</top>"); BareANY result = new SetElementParser(ParserRegistry.GetInstance()).Parse(ParseContextImpl.Create("SET<TS>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), new XmlToModelResult()); ICollection <PlatformDate> set = ((SET <TS, PlatformDate>)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(2, set.Count, "size"); PlatformDate expectedCalendar = DateUtil.GetDate(2000, 3, 7, 12, 30, 59, 0); Assert.IsTrue(set.Contains(expectedCalendar), "first date"); expectedCalendar = DateUtil.GetDate(2002, 5, 28, 1, 1, 1, 0); Assert.IsTrue(set.Contains(expectedCalendar), "second date"); }
public virtual void TestParseWithDuplicates() { XmlNode node = CreateNode("<top>" + "<telecom specializationType=\"TEL.EMAIL\" value=\"mailto:[email protected]\"/>" + "<telecom specializationType=\"TEL.EMAIL\" value=\"mailto:[email protected]\"/>" + "</top>"); BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<TEL.PHONEMAIL>", null, SpecificationVersion .V01R04_3, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false) , AsList(node.ChildNodes), this.xmlResult); ICollection <TelecommunicationAddress> set = ((SET <TEL, TelecommunicationAddress>)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(1, set.Count, "size"); foreach (TelecommunicationAddress address in set) { Assert.AreEqual(CeRxDomainTestValues.MAILTO.CodeValue, address.UrlScheme.CodeValue, "urlscheme"); Assert.AreEqual("*****@*****.**", address.Address, "address"); } Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count); Assert.AreEqual("Duplicate value not allowed for SET", this.xmlResult.GetHl7Errors()[0].GetMessage()); }
public virtual void TestParse() { XmlNode node = CreateNode("<top>" + "<something specializationType=\"TEL.EMAIL\" value=\"mailto://Fred\"/>" + "<something specializationType=\"TEL.EMAIL\" value=\"mailto://Wilma\"/>" + "</top>"); BareANY result = new SetElementParser(this.parserRegistry).Parse(ParseContextImpl.Create("SET<TEL.PHONEMAIL>", null, SpecificationVersion .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), null); ICollection <TelecommunicationAddress> set = ((SET <TEL, TelecommunicationAddress>)result).RawSet(); Assert.IsNotNull(set, "null"); Assert.AreEqual(2, set.Count, "size"); ICollection <string> expectedStrings = new HashSet <string>(); expectedStrings.Add("Fred"); expectedStrings.Add("Wilma"); foreach (TelecommunicationAddress address in set) { Assert.AreEqual(CeRxDomainTestValues.MAILTO.CodeValue, address.UrlScheme.CodeValue, "urlscheme"); Assert.IsTrue(expectedStrings.Contains(address.Address), "expected set contains address"); expectedStrings.Remove(address.Address); } }