예제 #1
0
        public virtual void TestParseMissingFixedtemplateIdConstraint()
        {
            XmlNode             node           = CreateNode("<top>" + "<something root=\"1.2.3.4\" extension=\"5678\" />" + "</top>");
            ConstrainedDatatype constraints    = new ConstrainedDatatype("constraintName.templateId", "II");
            Relationship        rootConstraint = new Relationship();

            rootConstraint.Name       = "root";
            rootConstraint.FixedValue = "a_fixed_value";
            constraints.Relationships.Add(rootConstraint);
            XmlToModelResult xmlToModelResult = new XmlToModelResult();
            BareANY          result           = new SetR2ElementParser(this.parserR2Registry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion
                                                                                                                            .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), constraints, false
                                                                                                                            ), AsList(node.ChildNodes), xmlToModelResult);
            ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet();

            Assert.IsFalse(xmlToModelResult.IsValid());
            Assert.AreEqual(1, xmlToModelResult.GetHl7Errors().Count, "size");
            Assert.AreEqual("Expected to find an identifier with: root={a_fixed_value},extension={null}", xmlToModelResult.GetHl7Errors
                                ()[0].GetMessage());
            Assert.AreEqual(Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING, xmlToModelResult.GetHl7Errors()[0].GetHl7ErrorCode(
                                ));
            Assert.AreEqual(ErrorLevel.WARNING, xmlToModelResult.GetHl7Errors()[0].GetHl7ErrorLevel());
            Assert.IsNotNull(rawSet, "null");
            Assert.AreEqual(1, rawSet.Count, "size");
            IEnumerator <Identifier> iterator = rawSet.GetEnumerator();

            if (iterator.MoveNext())
            {
                Assert.AreEqual(new Identifier("1.2.3.4", "5678"), iterator.Current);
            }
        }
예제 #2
0
        public virtual void TestParseMatchingFixedNonTemplateIdConstraint()
        {
            XmlNode             node           = CreateNode("<top>" + "<something root=\"1.2.3.4\"/>" + "</top>");
            ConstrainedDatatype constraints    = new ConstrainedDatatype("constraintName.somethingElse", "II");
            Relationship        rootConstraint = new Relationship();

            rootConstraint.Name       = "root";
            rootConstraint.FixedValue = "1.2.3.4";
            constraints.Relationships.Add(rootConstraint);
            XmlToModelResult xmlToModelResult = new XmlToModelResult();
            BareANY          result           = new SetR2ElementParser(this.parserR2Registry).Parse(ParseContextImpl.Create("SET<II>", null, SpecificationVersion
                                                                                                                            .V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1-5"), constraints, false
                                                                                                                            ), AsList(node.ChildNodes), xmlToModelResult);
            ICollection <Identifier> rawSet = ((SET <II, Identifier>)result).RawSet();

            Assert.IsTrue(xmlToModelResult.IsValid());
            // only has an info message
            Assert.IsTrue(xmlToModelResult.GetHl7Errors().IsEmpty());
            Assert.IsNotNull(rawSet, "null");
            Assert.AreEqual(1, rawSet.Count, "size");
            IEnumerator <Identifier> iterator = rawSet.GetEnumerator();

            if (iterator.MoveNext())
            {
                Assert.AreEqual(new Identifier("1.2.3.4"), iterator.Current);
            }
        }
예제 #3
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top>" + "<something>Fred</something>" + "<something>Wilma</something>" + "<something>Betty</something>"
                                      + "</top>");
            BareANY result = new SetR2ElementParser(ParserR2Registry.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");
        }