示例#1
0
        public virtual void TestIsValid()
        {
            XmlToModelResult xmlResult = new XmlToModelResult();

            Assert.IsTrue(xmlResult.IsValid(), "is valid");
            xmlResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "monkey", "a.property.path"));
            Assert.IsFalse(xmlResult.IsValid(), "is not valid");
        }
示例#2
0
        public virtual void TestParseEmptyNode()
        {
            XmlNode node = CreateNode("<something/>");

            new MoElementParser().Parse(CreateContext(), node, result);
            Assert.IsFalse(result.IsValid(), "valid");
            Assert.AreEqual(2, this.result.GetHl7Errors().Count);
        }
示例#3
0
        public virtual void TestParseEmptyNode()
        {
            // error should be: root is mandatory
            XmlNode node = CreateNode("<something/>");

            new IiR2ElementParser().Parse(CreateContext("II"), node, this.result);
            Assert.IsFalse(result.IsValid(), "result");
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
示例#4
0
        public virtual void TestParseInvalidCurrency()
        {
            XmlNode node        = CreateNode("<something value=\"12.00\" currency=\"XXX\" />");
            Money   parseResult = (Money) new MoR2ElementParser().Parse(CreateContext(), node, this.result).BareValue;

            Assert.IsFalse(result.IsValid(), "result");
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            AssertResultAsExpected(parseResult, new BigDecimal("12.00"), null);
        }
示例#5
0
        public virtual void TestPivlPhasePeriod()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><period unit=\"d\" value=\"1\"/><phase><low value=\"20120503\"/><high value=\"20120708\"/></phase></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult    = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedPeriod = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                   .DAY);
            PlatformDate            dateLow             = DateUtil.GetDate(2012, 4, 3);
            DateWithPattern         dateWithPatternLow  = new DateWithPattern(dateLow, "yyyyMMdd");
            PlatformDate            dateHigh            = DateUtil.GetDate(2012, 6, 8);
            DateWithPattern         dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd");
            Interval <PlatformDate> expectedPhase       = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedPeriod.Quantity, pivl.Period.Quantity);
            Assert.AreEqual(expectedPeriod.Unit.CodeValue, pivl.Period.Unit.CodeValue);
            Assert.AreEqual(expectedPhase, pivl.Phase);
            Assert.IsNull(pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.FrequencyQuantity);
        }
示例#6
0
        public virtual void TestIvlTsConstraintsInvalid()
        {
            XmlToModelResult    result      = new XmlToModelResult();
            XmlNode             node        = CreateNode("<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>");
            ConstrainedDatatype constraints = new ConstrainedDatatype("ivl", "IVL<TS>");

            constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0")));
            constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0")));
            ParseContext context = ParseContextImpl.Create("IVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), constraints, true);
            BareANY                 parseResult         = this.parser.Parse(context, Arrays.AsList(node), result);
            PlatformDate            dateLow             = DateUtil.GetDate(2012, 4, 3);
            DateWithPattern         dateWithPatternLow  = new DateWithPattern(dateLow, "yyyyMMdd");
            PlatformDate            dateHigh            = DateUtil.GetDate(2012, 6, 8);
            DateWithPattern         dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd");
            Interval <PlatformDate> expectedIvl         = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsFalse(result.IsValid());
            Assert.AreEqual(2, result.GetHl7Errors().Count);
            Assert.IsTrue(parseResult is IVLTSCDAR1);
            DateInterval ivl = (DateInterval)parseResult.BareValue;

            Assert.AreEqual(expectedIvl, ivl.Interval);
        }
示例#7
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);
            }
        }
示例#8
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);
            }
        }
示例#9
0
        public virtual void ShouldReportUnsupportedInteraction()
        {
            XmlToModelResult result = this.transformer.TransformFromHl7(MockVersionNumber.MOCK_NEWFOUNDLAND, this.factory.CreateFromString
                                                                            (UNSUPPORTED_MESSAGE_XML));

            Assert.IsNotNull(result, "result");
            Assert.IsFalse(result.IsValid(), "bean");
        }
示例#10
0
        public virtual void TestParseInvalidValueAttribute()
        {
            XmlNode          node   = CreateNode("<something value=\"19990355\" />");
            XmlToModelResult result = new XmlToModelResult();

            new TsElementParser().Parse(new TrivialContext("TS.DATETIME"), node, result);
            Assert.IsFalse(result.IsValid(), "valid date");
            Assert.AreEqual(1, result.GetHl7Errors().Count, "one error");
            Hl7Error hl7Error = result.GetHl7Errors()[0];

            Assert.AreEqual("The timestamp 19990355 in element <something value=\"19990355\"/> cannot be parsed.", hl7Error.GetMessage
                                (), "error message");
            Assert.AreEqual(Hl7ErrorCode.DATA_TYPE_ERROR, hl7Error.GetHl7ErrorCode(), "error message type");
        }
示例#11
0
        public virtual void TestParse()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<top><name>Fred</name>" + "<name>Flinstone</name></top>");

            new ListElementParser(ParserRegistry.GetInstance()).Parse(ParseContextImpl.Create("LIST<ABCDEFGHIJKLMNOPQRSTUVWXYZ>", null
                                                                                              , SpecificationVersion.V02R02, null, null, null, Cardinality.Create("1-5"), null, false), AsList(node.ChildNodes), result
                                                                      );
            Assert.IsFalse(result.IsValid(), "valid");
            foreach (Hl7Error error in result.GetHl7Errors())
            {
                System.Console.Out.WriteLine(error);
            }
        }
示例#12
0
        public virtual void TestPivlFrequency()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><frequency><numerator value=\"4\"/><denominator unit=\"d\" value=\"1\"/></frequency></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedFrequencyQuantity = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                              .DAY);

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedFrequencyQuantity.Quantity, pivl.FrequencyQuantity.Quantity);
            Assert.AreEqual(expectedFrequencyQuantity.Unit.CodeValue, pivl.FrequencyQuantity.Unit.CodeValue);
            Assert.AreEqual((Int32?)4, pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.Period);
            Assert.IsNull(pivl.Phase);
        }