コード例 #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 TestReportErrorForMissingSpecializationType()
        {
            XmlToModelResult xmlResult = new XmlToModelResult();
            XmlNode          node      = CreateNode("<range><low value=\"123\" unit=\"m\" /><high value=\"567\" unit=\"HOUR\" /></range>");
            object           range     = new AnyElementParser().Parse(null, node, xmlResult).BareValue;

            Assert.IsNull(range, "null");
            Assert.IsFalse(xmlResult.GetHl7Errors().IsEmpty(), "has error");
            Assert.AreEqual(Hl7ErrorCode.MANDATORY_FIELD_NOT_PROVIDED, xmlResult.GetHl7Errors()[0].GetHl7ErrorCode(), "error");
        }
コード例 #3
0
        public virtual void ShouldCatchXsiNilAttributeErrorForAssociation()
        {
            XmlNode          node      = CreateNode("<patient nullFlavor=\"NI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>");
            XmlToModelResult xmlResult = new XmlToModelResult();

            new NullFlavorHelper(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, node, xmlResult, true).ParseNullNode();
            Assert.IsFalse(xmlResult.GetHl7Errors().IsEmpty());
            Assert.AreEqual(1, xmlResult.GetHl7Errors().Count);
            Assert.IsTrue(xmlResult.GetHl7Errors()[0].GetMessage().Contains("does not specify xsi:nil=\"true\""));
        }
コード例 #4
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");
        }
コード例 #5
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);
        }
コード例 #6
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);
            }
        }
コード例 #7
0
 internal XmlToCdaModelResult(XmlToModelResult result)
 {
     this.delegate_ = result;
     foreach (Hl7Error error in result.GetHl7Errors())
     {
         errors.Add(new TransformError(error));
     }
 }
コード例 #8
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestInvalidNode(XmlNode invalidNode)
        {
            XmlToModelResult xmlResult   = new XmlToModelResult();
            string           parseResult = (string)new EdSignatureElementParser().Parse(CreateEdContext(), invalidNode, xmlResult).BareValue;

            Assert.IsNull(parseResult, "parse result");
            Assert.AreEqual(2, xmlResult.GetHl7Errors().Count, "HL7 error count");
            Hl7Error hl7Error = xmlResult.GetHl7Errors()[0];

            Assert.AreEqual("Attribute mediaType must be included with a value of \"text/xml\" for ED.SIGNATURE", hl7Error.GetMessage
                                (), "error message");
            Assert.AreEqual(Hl7ErrorCode.DATA_TYPE_ERROR, hl7Error.GetHl7ErrorCode(), "error message code");
            hl7Error = xmlResult.GetHl7Errors()[1];
            Assert.AreEqual("Expected ED.SIGNATURE node to have a child element named signature", hl7Error.GetMessage(), "error message"
                            );
            Assert.AreEqual(Hl7ErrorCode.DATA_TYPE_ERROR, hl7Error.GetHl7ErrorCode(), "error message code");
        }
コード例 #9
0
        public virtual MessageValidatorResult Validate(XmlDocument message, VersionNumber version, GenericCodeResolverRegistry codeResolverRegistryOverride
                                                       )
        {
            XmlToModelResult transformResults = this.messageTransformer.TransformFromHl7(version, message, codeResolverRegistryOverride
                                                                                         );

            return(new MessageValidatorResult(transformResults.GetHl7Errors()));
        }
コード例 #10
0
        /// <exception cref="Platform.Xml.Sax.SAXException"></exception>
        private void AssertConformance(object[] arguments)
        {
            XmlNode          node      = CreateNode("<effectiveTime><low nullFlavor=\"NI\"/></effectiveTime>");
            XmlToModelResult xmlResult = new XmlToModelResult();

            new NullFlavorHelper((Ca.Infoway.Messagebuilder.Xml.ConformanceLevel)arguments[0], node, xmlResult, false).ParseNullNode(
                );
            Assert.AreEqual(arguments[1], xmlResult.GetHl7Errors().IsEmpty());
        }
コード例 #11
0
 private void CreateBeanPathOnErrorMessages(XmlToModelResult result, object messageBean)
 {
     // would be nice to push this entire method into XmlToModelResult, but BeanUtil not visible from XmlToModelResult
     // (and moving classes or adding a dependency causes all sorts of problems)
     foreach (Hl7Error hl7Error in result.GetHl7Errors())
     {
         string beanPath = BeanUtil.DescribeBeanPath(messageBean, hl7Error.GetPath());
         hl7Error.SetBeanPath(beanPath);
     }
 }
コード例 #12
0
        public virtual void ShouldAllowXsiNilAttributeErrorForAssociationWhenSystemPropertySet()
        {
            XmlNode          node      = CreateNode("<patient nullFlavor=\"NI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>");
            XmlToModelResult xmlResult = new XmlToModelResult();

            Runtime.SetProperty(NullFlavorHelper.MB_SUPPRESS_XSI_NIL_ON_NULLFLAVOR, "true");
            new NullFlavorHelper(Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, node, xmlResult, true).ParseNullNode();
            Runtime.ClearProperty(NullFlavorHelper.MB_SUPPRESS_XSI_NIL_ON_NULLFLAVOR);
            Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty());
        }
コード例 #13
0
        public virtual void ShouldMapObservationAttributes()
        {
            XmlDocument      document2   = GetSourceDocument(XML2);
            XmlElement       element2    = document2.DocumentElement;
            Hl7MessageSource rootSource2 = new Hl7MessageSource(MockVersionNumber.MOCK_NEWFOUNDLAND, document2, null, null, this.service
                                                                );
            Hl7PartSource partSource2 = rootSource2.CreatePartSource(CreateRelationship("PORX_MT010120CA.QuantityObservationEvent"),
                                                                     element2);
            QuantityObservationEventBean teal = (QuantityObservationEventBean) new Hl7SourceMapper().MapPartSourceToTeal(partSource2,
                                                                                                                         null);

            Assert.IsNotNull(teal, "teal");
            Assert.IsNotNull(teal.PatientMeasurementType, "code1");
            Assert.IsNotNull(teal.PatientMeasuredValue, "code2");
            XmlToModelResult result = partSource2.GetResult();

            Assert.IsNotNull(result, "result");
            Assert.AreEqual(3, result.GetHl7Errors().Count);
            Assert.AreEqual(Hl7ErrorCode.UNSUPPORTED_INTERACTION, result.GetHl7Errors()[0].GetHl7ErrorCode());
            Assert.AreEqual(Hl7ErrorCode.MANDATORY_FIELD_NOT_PROVIDED, result.GetHl7Errors()[1].GetHl7ErrorCode());
            Assert.AreEqual(Hl7ErrorCode.MANDATORY_FIELD_NOT_PROVIDED, result.GetHl7Errors()[2].GetHl7ErrorCode());
        }
コード例 #14
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);
            }
        }
コード例 #15
0
        private void HandleContent(EncapsulatedData ed, XmlElement element, XmlToModelResult result, ParseContext context)
        {
            IList <XmlNode> allContentNodes = DetermineAllContentNodes(element);

            foreach (XmlNode node in allContentNodes)
            {
                try
                {
                    ed.AddContent(node);
                }
                catch (TransformerException e)
                {
                    result.GetHl7Errors().Add(new Hl7Error(Hl7ErrorCode.INTERNAL_ERROR, "An error occurred trying to parse ED content. Some or all of the content may not have been processed: "
                                                           + e.Message, element));
                }
            }
            ed.TrimContent();
        }