Exemplo n.º 1
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 AnyR2ElementParser().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");
        }
Exemplo n.º 2
0
        public virtual void TestParsePqWithNullFlavor()
        {
            XmlNode node = CreateNode("<something nullFlavor=\"ASKU\" xsi:type=\"PQ\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" />"
                                      );
            BareANY pqAny = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.R02_04_03
                                                                                   , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pqAny.BareValue);
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.ASKED_BUT_UNKNOWN, pqAny.NullFlavor);
        }
Exemplo n.º 3
0
        public virtual void ShouldParseStTextNodeAsCdata()
        {
            XmlNode node = CreateNode("<something xsi:type=\"ST\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><![CDATA[<cats think they're > humans & dogs 99% of the time/>]]></something>"
                                      );
            ParseContext context = ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, null, null, false);
            BareANY parseResult = new AnyR2ElementParser().Parse(context, node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(StandardDataType.ST, parseResult.DataType);
            Assert.IsTrue(((ANYMetaData)parseResult).IsCdata, "noted as cdata");
            Assert.AreEqual("<cats think they're > humans & dogs 99% of the time/>", parseResult.BareValue, "proper text returned");
        }
Exemplo n.º 4
0
        public virtual void TestParseWithMissingSpecializationType()
        {
            XmlNode node = CreateNode("<value xsi:type=\"PQ\" value=\"80\" unit=\"pg/mL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"
                                      );
            BareANY result = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY.LAB", typeof(object), null, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                                    .MANDATORY, null, null, false), node, this.xmlResult);

            Assert.IsNotNull(result);
            Assert.IsNull(result.BareValue);
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count, "has error");
            Assert.AreEqual("Cannot support properties of type \"PQ\" for \"ANY.LAB\"", this.xmlResult.GetHl7Errors()[0].GetMessage()
                            , "error message");
        }
Exemplo n.º 5
0
        public virtual void TestParseRetainsProperDatatype()
        {
            XmlNode node = CreateNode("<value xsi:type=\"PQ\" value=\"80\" unit=\"pg/mL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>"
                                      );
            BareANY result = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.V02R02
                                                                                    , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNotNull(result, "null");
            Assert.AreEqual(StandardDataType.PQ, result.DataType, "type");
            Assert.IsNotNull(result.BareValue, "null");
            Assert.AreEqual("pg/mL", ((PhysicalQuantity)result.BareValue).Unit.CodeValue, "unit");
            Assert.AreEqual(new BigDecimal(80), ((PhysicalQuantity)result.BareValue).Quantity, "unit");
        }
Exemplo n.º 6
0
        public virtual void TestParseStWithLanguage()
        {
            XmlNode node = CreateNode("<value xsi:type=\"ST\" language=\"fr-CA\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">some text</value>"
                                      );
            BareANY result = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.V02R02
                                                                                    , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNotNull(result, "null");
            Assert.AreEqual(StandardDataType.ST, result.DataType, "type");
            Assert.IsNotNull(result.BareValue, "null");
            Assert.AreEqual("some text", ((string)result.BareValue), "string");
            Assert.AreEqual("fr-CA", ((ANYImpl <object>)result).Language, "language");
        }
Exemplo n.º 7
0
        public virtual void TestParseRetainsProperDatatypeForSpecializationTypeWhenAnyOnlySpecifiesOkToUseAbstractType()
        {
            XmlNode node = CreateNode("<value xsi:type=\"IVL_PQ\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<low value=\"0.0\" unit=\"pg/mL\"/>"
                                      + "<high value=\"0.5\" unit=\"pg/mL\"/>" + "</value>");
            BareANY result = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.V02R02
                                                                                    , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, new XmlToModelResult()
                                                            );

            Assert.IsNotNull(result, "null");
            Assert.AreEqual(StandardDataType.IVL_PQ, result.DataType, "type");
            Assert.IsNotNull(result.BareValue, "null");
            Interval <PhysicalQuantity> interval = (Interval <PhysicalQuantity>)result.BareValue;

            Assert.AreEqual("pg/mL", interval.Low.Unit.CodeValue, "low unit");
            Assert.AreEqual(new BigDecimal(0).SetScale(1), interval.Low.Quantity, "low quantity");
            Assert.AreEqual("pg/mL", interval.High.Unit.CodeValue, "high unit");
            Assert.AreEqual(new BigDecimal(0.5), interval.High.Quantity, "high quantity");
        }
Exemplo n.º 8
0
        public virtual void TestParseAnyIvlTypeInInnerElements()
        {
            XmlNode node = CreateNode("<range xsi:type=\"IVL\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<low xsi:type=\"PQ\" value=\"123\" unit=\"kg\" />"
                                      + "<high xsi:type=\"PQ\" value=\"567\" unit=\"kg\" />" + "</range>");
            BareANY parseResult = new AnyR2ElementParser().Parse(ParseContextImpl.Create("ANY", typeof(object), SpecificationVersion.
                                                                                         R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, this.xmlResult
                                                                 );
            Interval <PhysicalQuantity> range = (Interval <PhysicalQuantity>)parseResult.BareValue;

            System.Console.Out.WriteLine(this.xmlResult.GetHl7Errors());
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNotNull(range, "null");
            Assert.AreEqual(StandardDataType.IVL_PQ, parseResult.DataType, "type");
            Assert.AreEqual(new BigDecimal("123"), range.Low.Quantity, "low");
            Assert.AreEqual(new BigDecimal("567"), range.High.Quantity, "high");
            Assert.AreEqual(new BigDecimal("345.0"), range.Centre.Quantity, "centre");
            Assert.AreEqual(new BigDecimal("444"), range.Width.Value.Quantity, "width");
            Assert.AreEqual(Representation.LOW_HIGH, range.Representation, "representation");
        }