Ejemplo n.º 1
0
        public virtual void TestParseUrgForBC()
        {
            ParseContext context = ParseContextImpl.Create("URG<PQ.LAB>", null, SpecificationVersion.V02R04_BC, null, null, null, null
                                                           , null, null, null, false);
            string xml = "<value specializationType=\"URG_PQ.LAB\" unit=\"1\" xsi:type=\"URG_PQ\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
                         + "<originalText mediaType=\"text/plain\" representation=\"TXT\">&lt;124</originalText>" + "<low inclusive=\"true\" nullFlavor=\"NI\" specializationType=\"PQ.LAB\" value=\"1\" />"
                         + "<high inclusive=\"false\" specializationType=\"PQ.LAB\" unit=\"g/L\" value=\"124\"/>" + "</value>";
            XmlNode node = CreateNode(xml);
            BareANY URG  = new UrgPqElementParser().Parse(context, node, this.xmlResult);
            UncertainRange <PhysicalQuantity> range = (UncertainRange <PhysicalQuantity>)URG.BareValue;

            Assert.IsNotNull(range, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(Representation.LOW_HIGH, range.Representation, "representation");
            Assert.AreEqual("<124", ((ANYMetaData)URG).OriginalText, "OT");
            Assert.IsTrue(range.LowInclusive.Value, "low inclusive");
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION, range.LowNullFlavor, "low NF"
                            );
            Assert.AreEqual(BigDecimal.ONE, range.Low.Quantity, "low value");
            Assert.IsNull(range.Low.Unit, "low unit");
            Assert.IsFalse(range.HighInclusive.Value, "high inclusive");
            Assert.IsNull(range.HighNullFlavor, "high NF");
            Assert.AreEqual(new BigDecimal("124"), range.High.Quantity, "high value");
            Assert.AreEqual("g/L", range.High.Unit.CodeValue, "high units");
            Assert.IsTrue(range.High.Unit is x_LabUnitsOfMeasure);
        }
Ejemplo n.º 2
0
        public virtual void TestBasic()
        {
            UncertainRange <PlatformDate> urg = UncertainRangeFactory.CreateLowHigh(DateUtil.GetDate(2010, 0, 20), DateUtil.GetDate(2011
                                                                                                                                    , 1, 21));
            string result = new UrgTsPropertyFormatter().Format(GetContext("name", "URG<TS.DATE>"), new URGImpl <TS, PlatformDate>(urg
                                                                                                                                   ));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name><low value=\"20100120\"/><high value=\"20110221\"/></name>", result);
        }
Ejemplo n.º 3
0
        private UncertainRange <V> ConvertIntervalToUncertainRange(Interval <V> parsedInterval, Boolean?lowInclusive, Boolean?highInclusive
                                                                   )
        {
            UncertainRange <V> urg = null;

            if (parsedInterval != null)
            {
                urg = new UncertainRange <V>(parsedInterval, lowInclusive, highInclusive);
            }
            return(urg);
        }
Ejemplo n.º 4
0
        protected override UncertainRange <V> ParseNonNullNode(ParseContext context, XmlNode node, BareANY result, Type expectedReturnType
                                                               , XmlToModelResult xmlToModelResult)
        {
            // URGs are almost identical in function to IVLs; use IVL parser
            BareANY            bareAny        = GetIvlParser().Parse(ConvertContext(context), Arrays.AsList(node), xmlToModelResult);
            Interval <V>       parsedInterval = (Interval <V>)bareAny.BareValue;
            Boolean?           lowInclusive   = GetInclusiveValue("low", context, node, xmlToModelResult);
            Boolean?           highInclusive  = GetInclusiveValue("high", context, node, xmlToModelResult);
            UncertainRange <V> urg            = ConvertIntervalToUncertainRange(parsedInterval, lowInclusive, highInclusive);

            return(urg);
        }
Ejemplo n.º 5
0
        public virtual void TestUrg()
        {
            UncertainRange <PhysicalQuantity> urg = UncertainRangeFactory.CreateLowHigh(CreateQuantity("55", Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                                                       .MILLIMETER), CreateQuantity("60", Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.MILLIMETER));
            ANYImpl <object> urgImpl = new ANYImpl <object>(urg, null, StandardDataType.URG_PQ_BASIC);
            string           result  = new AnyPropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                             (new ModelToXmlResult(), null, "name", "ANY.LAB", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false
                                                                             ), urgImpl, 0);

            AssertXml("result", "<name specializationType=\"URG_PQ.BASIC\" xsi:type=\"URG_PQ\"><low unit=\"mm\" value=\"55\"/><high unit=\"mm\" value=\"60\"/></name>"
                      , result);
        }
Ejemplo n.º 6
0
        public virtual void TestBasic()
        {
            UncertainRange <PhysicalQuantity> urg = UncertainRangeFactory.CreateLowHigh(CreateQuantity("55", CeRxDomainTestValues.MILLIMETER
                                                                                                       ), CreateQuantity("60", CeRxDomainTestValues.MILLIMETER));

            urg.HighInclusive = true;
            urg.LowInclusive  = false;
            string result = new UrgPqPropertyFormatter().Format(GetContext("name", "URG<PQ.BASIC>"), new URGImpl <PQ, PhysicalQuantity
                                                                                                                  >(urg));

            AssertXml("result", "<name><low inclusive=\"false\" unit=\"mm\" value=\"55\"/><high inclusive=\"true\" unit=\"mm\" value=\"60\"/></name>"
                      , result);
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 7
0
        public virtual void TestBasicWithInvalidInclusiveUsage()
        {
            UncertainRange <PlatformDate> urg = UncertainRangeFactory.CreateLowHigh(DateUtil.GetDate(2010, 0, 20), DateUtil.GetDate(2011
                                                                                                                                    , 1, 21));

            urg.HighInclusive = true;
            string result = new UrgTsPropertyFormatter().Format(GetContext("name", "URG<TS.DATE>"), new URGImpl <TS, PlatformDate>(urg
                                                                                                                                   ));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            // should not use inclusive fields with this datatype
            AssertXml("result", "<name><low value=\"20100120\"/><high value=\"20110221\"/></name>", result);
        }
Ejemplo n.º 8
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<range><low value=\"123\" unit=\"kg\" /><high value=\"567\" unit=\"kg\" /></range>");
            UncertainRange <PhysicalQuantity> range = (UncertainRange <PhysicalQuantity>) new UrgPqElementParser().Parse(CreateContext()
                                                                                                                         , node, this.xmlResult).BareValue;

            Assert.IsNotNull(range, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            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");
            Assert.IsNull(range.LowInclusive);
            Assert.IsNull(range.HighInclusive);
        }
Ejemplo n.º 9
0
        public virtual void TestParseAnyWithSpecializationTypeInOuterElementWithAlternativeDesignation()
        {
            XmlNode node = CreateNode("<range xsi:type=\"URG_PQ\" specializationType=\"URG&lt;PQ.BASIC&gt;\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
                                      + "<low value=\"123\" unit=\"kg\" />" + "<high value=\"567\" unit=\"kg\" />" + "</range>");
            UncertainRange <PhysicalQuantity> range = (UncertainRange <PhysicalQuantity>) new AnyElementParser().Parse(ParseContextImpl.
                                                                                                                       Create("ANY.LAB", typeof(object), SpecificationVersion.R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                                                                              .MANDATORY, null, null, false), node, this.xmlResult).BareValue;

            Assert.IsNotNull(range, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            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");
        }
Ejemplo n.º 10
0
        public virtual void TestBasicForBC()
        {
            UncertainRange <PhysicalQuantity> urg = new UncertainRange <PhysicalQuantity>(new PhysicalQuantity(new BigDecimal(1), null)
                                                                                          , new PhysicalQuantity(new BigDecimal(124), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.GRAMS_PER_LITRE
                                                                                                                 ), null, null, Representation.LOW_HIGH, Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION, null
                                                                                          , null, true, false);
            URGImpl <PQ, PhysicalQuantity> dataType = new URGImpl <PQ, PhysicalQuantity>(urg);

            dataType.OriginalText = "<124";
            string result = new UrgPqPropertyFormatter().Format(GetContext("name", "URG<PQ.LAB>", SpecificationVersion.V02R04_BC), dataType
                                                                );

            AssertXml("result", "<name><originalText>&lt;124</originalText><low inclusive=\"true\" nullFlavor=\"NI\" value=\"1\"/><high inclusive=\"false\" unit=\"g/L\" value=\"124\"/></name>"
                      , result);
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 11
0
        public virtual void TestReportError()
        {
            XmlNode node = CreateNode("<range><low value=\"123\" unit=\"m\" /><high value=\"567\" unit=\"h\" /></range>");
            UncertainRange <PhysicalQuantity> range = null;

            try
            {
                range = (UncertainRange <PhysicalQuantity>) new UrgPqElementParser().Parse(CreateContext(), node, this.xmlResult).BareValue;
                Assert.Fail("Should fail trying to add quantities of different units");
            }
            catch (ArgumentException e)
            {
                // expected
                Assert.AreEqual("Can't add two quantities of different units: m and h", e.Message, "syntax error");
            }
            Assert.IsNull(range, "null");
        }
Ejemplo n.º 12
0
        public virtual void TestUrgPqLabForBC()
        {
            UncertainRange <PhysicalQuantity> urg = new UncertainRange <PhysicalQuantity>(new PhysicalQuantity(new BigDecimal(1), null)
                                                                                          , new PhysicalQuantity(new BigDecimal(124), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.GRAMS_PER_LITRE
                                                                                                                 ), null, null, Representation.LOW_HIGH, Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NO_INFORMATION, null
                                                                                          , null, true, false);
            AnyPropertyFormatter formatter = new AnyPropertyFormatter();
            FormatContext        context   = GetContext("name", "ANY", SpecificationVersion.V02R04_BC);
            ANYImpl <object>     any       = new ANYImpl <object>(urg, null, StandardDataType.URG_PQ_LAB);

            any.OriginalText = "<124";
            string result = formatter.Format(context, any);

            AssertXml("result", "<name specializationType=\"URG_PQ.LAB\" xsi:type=\"URG_PQ\"><originalText>&lt;124</originalText><low inclusive=\"true\" nullFlavor=\"NI\" value=\"1\"/><high inclusive=\"false\" unit=\"g/L\" value=\"124\"/></name>"
                      , result);
            Assert.IsTrue(this.result.IsValid());
        }
Ejemplo n.º 13
0
        protected override string FormatNonNullValue(FormatContext context, UncertainRange <PlatformDate> value, int indentLevel)
        {
            // convert URG to an IVL and use IVL formatter
            Interval <PlatformDate> convertedInterval = IntervalFactory.CreateFromUncertainRange(value);
            IVLImpl <TS, Interval <PlatformDate> > convertedHl7Interval = new IVLImpl <TS, Interval <PlatformDate> >(convertedInterval);
            FormatContext ivlContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(context.Type.Replace
                                                                                                                     ("URG", "IVL"), context.IsSpecializationType(), context);
            string xml = this.formatter.Format(ivlContext, convertedHl7Interval, indentLevel);

            xml = ChangeAnyIvlRemnants(xml);
            // inclusive attributes not allowed for URG<TS>
            if (value.LowInclusive != null || value.HighInclusive != null)
            {
                context.GetModelToXmlResult().AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "High/Low inclusive fields should not be set; these attributes are not allowed for "
                                                                       + context.Type + " types", context.GetPropertyPath()));
            }
            return(xml);
        }
Ejemplo n.º 14
0
        public virtual void TestParseAnyUrgExampleFromChiDocsWithSpecializationTypeInInnerElements()
        {
            XmlNode node = CreateNode("<range xsi:type=\"URG_PQ\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + "<low xsi:type=\"PQ\" specializationType=\"PQ.HEIGHTWEIGHT\" value=\"123\" unit=\"kg\" />"
                                      + "<high xsi:type=\"PQ\" specializationType=\"PQ.HEIGHTWEIGHT\" value=\"567\" unit=\"kg\" />" + "</range>");
            BareANY parseResult = new AnyElementParser().Parse(ParseContextImpl.Create("ANY.LAB", typeof(object), SpecificationVersion
                                                                                       .R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, null, null, false), node, this.xmlResult
                                                               );
            UncertainRange <PhysicalQuantity> range = (UncertainRange <PhysicalQuantity>)parseResult.BareValue;

            System.Console.Out.WriteLine(this.xmlResult.GetHl7Errors());
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNotNull(range, "null");
            Assert.AreEqual(StandardDataType.URG_PQ_HEIGHTWEIGHT, 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");
        }
Ejemplo n.º 15
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<effectiveTime xsi:type=\"URG_TS\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
                                      "<center xsi:type=\"TS\" specializationType=\"TS.DATE\" value=\"200404\"/>" + "<width xsi:type=\"PQ\" specializationType=\"PQ.TIME\" value=\"4\" unit=\"mo\"/>"
                                      + "</effectiveTime>");
            UncertainRange <PlatformDate> range = (UncertainRange <PlatformDate>) new UrgTsElementParser().Parse(CreateContext(), node,
                                                                                                                 this.xmlResult).BareValue;

            Assert.IsNotNull(range, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(DateUtil.GetDate(2004, 1, 1), range.Low, "low");
            Assert.AreEqual(DateUtil.GetDate(2004, 3, 1), range.Centre, "centre");
            Assert.AreEqual(DateUtil.GetDate(2004, 5, 1), range.High, "high");
            Assert.AreEqual(new BigDecimal("4"), ((DateDiff)range.Width).ValueAsPhysicalQuantity.Quantity, "width");
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.MONTH.CodeValue, ((DateDiff)range.Width).ValueAsPhysicalQuantity
                            .Unit.CodeValue, "width units");
            Assert.AreEqual(Representation.CENTRE_WIDTH, range.Representation, "representation");
            Assert.IsNull(range.LowInclusive);
            Assert.IsNull(range.HighInclusive);
        }
Ejemplo n.º 16
0
        public virtual void TestParseWithLowHighInclusiveAttributes()
        {
            XmlNode node = CreateNode("<effectiveTime>" + "<low inclusive=\"true\" value=\"20040101\"/>" + "<high inclusive=\"true\" value=\"20040501\"/>"
                                      + "</effectiveTime>");
            UncertainRange <PlatformDate> range = (UncertainRange <PlatformDate>) new UrgTsElementParser().Parse(CreateContext(), node,
                                                                                                                 this.xmlResult).BareValue;
            PlatformDate lowDate  = DateUtil.GetDate(2004, 0, 1);
            PlatformDate highDate = DateUtil.GetDate(2004, 4, 1);

            // inclusive usage is not allowed in this case as per pan-Canadian specs
            Assert.IsNotNull(range, "null");
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(2, this.xmlResult.GetHl7Errors().Count);
            Assert.AreEqual(lowDate, range.Low, "low");
            Assert.AreEqual(new PlatformDate(lowDate.Time + (highDate.Time - lowDate.Time) / 2), range.Centre, "centre");
            Assert.AreEqual(highDate, range.High, "high");
            Assert.AreEqual(highDate.Time - lowDate.Time, range.Width.Value.Time, "width");
            Assert.AreEqual(Representation.LOW_HIGH, range.Representation, "representation");
            Assert.IsTrue(range.LowInclusive.Value);
            Assert.IsTrue(range.HighInclusive.Value);
        }
Ejemplo n.º 17
0
        protected override string FormatNonNullDataType(FormatContext context, BareANY dataType, int indentLevel)
        {
            UncertainRange <PhysicalQuantity> value = (UncertainRange <PhysicalQuantity>)dataType.BareValue;
            // convert URG to an IVL and use IVL formatter (loses any inclusive info; we'll pull that out later)
            Interval <PhysicalQuantity> convertedInterval = IntervalFactory.CreateFromUncertainRange(value);
            IVLImpl <PQ, Interval <PhysicalQuantity> > convertedHl7Interval = new IVLImpl <PQ, Interval <PhysicalQuantity> >(convertedInterval
                                                                                                                             );
            FormatContext ivlContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(context.Type.Replace
                                                                                                                     ("URG", "IVL"), context.IsSpecializationType(), context);
            string xml = this.formatter.Format(ivlContext, convertedHl7Interval, indentLevel);

            xml = ChangeAnyIvlRemnants(xml);
            xml = AddOriginalText(xml, dataType, indentLevel);
            // add in inclusive attributes if necessary
            if (value.LowInclusive != null)
            {
                xml = AddInclusiveAttribute(xml, "low", value.LowInclusive);
            }
            if (value.HighInclusive != null)
            {
                xml = AddInclusiveAttribute(xml, "high", value.HighInclusive);
            }
            return(xml);
        }
Ejemplo n.º 18
0
 public virtual void SetDosagePreconditionValue(UncertainRange <PhysicalQuantity> dosagePreconditionValue)
 {
     this.dosagePreconditionValue = dosagePreconditionValue;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructs an uncertain range HL7 datatype using a given UncertainRange datatype.
 /// </summary>
 ///
 /// <param name="defaultValue">the starting value for the uncertain range</param>
 public URGImpl(UncertainRange <V> defaultValue) : base(typeof(UncertainRange <V>), defaultValue, null, Ca.Infoway.Messagebuilder.Datatype.StandardDataType.URG)
 {
 }
Ejemplo n.º 20
0
 protected override string FormatNonNullValue(FormatContext context, UncertainRange <PhysicalQuantity> value, int indentLevel
                                              )
 {
     // unused
     throw new NotSupportedException();
 }
Ejemplo n.º 21
0
 public virtual void SetDosageRange(UncertainRange <PhysicalQuantity> dosageRange)
 {
     this.dosageRange = dosageRange;
 }