示例#1
0
        public virtual void TestIntervalWidth()
        {
            Interval <Int32?> ivl    = IntervalFactory.CreateWidth <Int32?>(new Diff <Int32?>(2));
            string            result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <Int32?>, Interval <Int32?> >(ivl));

            AssertXml("result", "<name><width value=\"2\"/></name>", result);
        }
示例#2
0
        public virtual void TestNullable()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(new DateDiff(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor
                                                                                                       .OTHER));
            string result = new IvlTsPropertyFormatter().Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate
                                                                                                                               > >(interval));

            AssertXml("result", "<name><width nullFlavor=\"OTH\"/></name>", result);
        }
示例#3
0
        public virtual void TestCustomUnit()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(new DateDiff(1, IvlTsFullDateTimePropertyFormatterTest.CustomUnit
                                                                                                       .SANDWICH));
            string result = new IvlTsPropertyFormatter().Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate
                                                                                                                               > >(interval));

            AssertXml("result", "<name><width unit=\"SANDWICH\" value=\"1\"/></name>", result);
        }
示例#4
0
        public virtual void TestIntervalWidth()
        {
            Interval <PhysicalQuantity> interval = IntervalFactory.CreateWidth <PhysicalQuantity>(new Diff <PhysicalQuantity>(PHYSICAL_QUANTITY_LOW
                                                                                                                              ));
            string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PhysicalQuantity>, Interval <PhysicalQuantity> >(
                                                      interval));

            AssertXml("result", "<name><width unit=\"mL\" value=\"1000\"/></name>", result);
        }
示例#5
0
        public virtual void TestIntervalWidth()
        {
            Diff <PlatformDate>     diff     = new Diff <PlatformDate>(new PlatformDate(15 * DateUtils.MILLIS_PER_DAY));
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(diff);
            string result = this.formatter.Format(GetContext("name", "IVL.WIDTH<TS.FULLDATE>", SpecificationVersion.R02_04_03), new IVLImpl
                                                  <QTY <PlatformDate>, Interval <PlatformDate> >(interval));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name><width unit=\"d\" value=\"15\"/></name>", result);
        }
示例#6
0
        public virtual void TestInvalidIntervalWidth()
        {
            Diff <PlatformDate>     diff     = new Diff <PlatformDate>(new PlatformDate(15 * DateUtils.MILLIS_PER_DAY));
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(diff);
            string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval
                                                                                                                                 ));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            AssertXml("result", "<name><width unit=\"d\" value=\"15\"/></name>", result);
        }
示例#7
0
        public virtual void TestIntervalWidthWithDecimals()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(new DateDiff(new PhysicalQuantity(new BigDecimal
                                                                                                                                ("1.5"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.MONTH)));
            string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval
                                                                                                                                 ));

            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
            // must have 2 of width/low/high
            AssertXml("result", "<name><width unit=\"mo\" value=\"1.5\"/></name>", result);
        }
示例#8
0
        public virtual void TestCustomUnit()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(new DateDiff(1, IvlTsR2PropertyFormatterTest.CustomUnit
                                                                                                       .SANDWICH));
            DateInterval dateInterval = new DateInterval(interval);
            IVL_TSImpl   hl7DataType  = new IVL_TSImpl(dateInterval);

            hl7DataType.DataType = StandardDataType.IVL_TS;
            string result = new IvlTsR2PropertyFormatter().Format(GetContext("name"), hl7DataType);

            AssertXml("result", "<name><width unit=\"SANDWICH\" value=\"1\"/></name>", result);
        }
示例#9
0
        public virtual void TestNullable()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateWidth <PlatformDate>(new DateDiff(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor
                                                                                                       .OTHER));
            DateInterval dateInterval = new DateInterval(interval);
            IVL_TSImpl   hl7DataType  = new IVL_TSImpl(dateInterval);

            hl7DataType.DataType = StandardDataType.IVL_TS;
            string result = new IvlTsR2PropertyFormatter().Format(GetContext("name"), hl7DataType);

            AssertXml("result", "<name><width nullFlavor=\"OTH\"/></name>", result);
        }
示例#10
0
        protected override Interval <T> ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType
                                                         , XmlToModelResult xmlToModelResult)
        {
            // go back and revert TS.FULLDATEWITHTIME validation check? (is there anything to revert?)
            context = HandleSpecializationType(context, node, xmlToModelResult);
            Interval <T> result = null;
            XmlElement   low    = (XmlElement)GetNamedChildNode(node, "low");
            XmlElement   high   = (XmlElement)GetNamedChildNode(node, "high");
            XmlElement   center = (XmlElement)GetNamedChildNode(node, "center");
            XmlElement   width  = (XmlElement)GetNamedChildNode(node, "width");

            ValidateCorrectElementsProvided(low != null, high != null, center != null, width != null, (XmlElement)node, context, xmlToModelResult
                                            );
            BareANY  lowAny     = low == null ? null : CreateType(context, low, xmlToModelResult);
            object   lowType    = lowAny == null ? null : lowAny.BareValue;
            BareANY  highAny    = high == null ? null : CreateType(context, high, xmlToModelResult);
            object   highType   = highAny == null ? null : highAny.BareValue;
            BareANY  centerAny  = center == null ? null : CreateType(context, center, xmlToModelResult);
            object   centerType = centerAny == null ? null : centerAny.BareValue;
            BareDiff widthType  = width == null ? null : CreateDiffType(context, width, xmlToModelResult);

            DoOtherValidations(lowAny, highAny, centerAny, widthType, (XmlElement)node, context, xmlToModelResult);
            if (lowAny != null && highAny != null)
            {
                result = IntervalFactory.CreateLowHigh <T>((T)lowType, (T)highType, lowAny.NullFlavor, highAny.NullFlavor);
            }
            else
            {
                if (lowAny != null && widthType != null)
                {
                    result = IntervalFactory.CreateLowWidth <T>((T)lowType, (Diff <T>)widthType, lowAny.NullFlavor);
                }
                else
                {
                    if (highAny != null && widthType != null)
                    {
                        result = IntervalFactory.CreateWidthHigh <T>((Diff <T>)widthType, (T)highType, highAny.NullFlavor);
                    }
                    else
                    {
                        if (centerAny != null && widthType != null)
                        {
                            result = IntervalFactory.CreateCentreWidth <T>((T)centerType, (Diff <T>)widthType, centerAny.NullFlavor);
                        }
                        else
                        {
                            if (centerAny != null && lowAny != null)
                            {
                                result = IntervalFactory.CreateLowCentre <T>((T)lowType, (T)centerType, lowAny.NullFlavor, centerAny.NullFlavor);
                            }
                            else
                            {
                                if (centerAny != null && highAny != null)
                                {
                                    result = IntervalFactory.CreateCentreHigh <T>((T)centerType, (T)highType, centerAny.NullFlavor, highAny.NullFlavor);
                                }
                                else
                                {
                                    if (lowAny != null)
                                    {
                                        result = IntervalFactory.CreateLow <T>((T)lowType, lowAny.NullFlavor);
                                    }
                                    else
                                    {
                                        if (highAny != null)
                                        {
                                            result = IntervalFactory.CreateHigh <T>((T)highType, highAny.NullFlavor);
                                        }
                                        else
                                        {
                                            if (centerAny != null)
                                            {
                                                result = IntervalFactory.CreateCentre <T>((T)centerType, centerAny.NullFlavor);
                                            }
                                            else
                                            {
                                                if (widthType != null)
                                                {
                                                    result = IntervalFactory.CreateWidth <T>((Diff <T>)widthType);
                                                }
                                                else
                                                {
                                                    if (low == null && high == null && center == null && width == null)
                                                    {
                                                        // only treat this as a "simple" interval if no other interval elements were provided (even if they were in error)
                                                        // try to parse a "simple" interval; this does not seem a valid approach for MR2009, MR2007, or CeRx (perhaps allowed within the XSDs?)
                                                        object type = CreateType(context, (XmlElement)node, xmlToModelResult).BareValue;
                                                        if (type == null)
                                                        {
                                                            xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.SYNTAX_ERROR, "\"Simple interval node: " + XmlDescriber.DescribePath
                                                                                                          (node) + " does not allow a null value\"", (XmlElement)node));
                                                        }
                                                        else
                                                        {
                                                            result = IntervalFactory.CreateSimple <T>((T)type);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(result);
        }
示例#11
0
        protected override Interval <T> ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType
                                                         , XmlToModelResult xmlToModelResult)
        {
            Interval <T> result = null;
            XmlElement   low    = (XmlElement)GetNamedChildNode(node, "low");
            XmlElement   high   = (XmlElement)GetNamedChildNode(node, "high");
            XmlElement   center = (XmlElement)GetNamedChildNode(node, "center");
            XmlElement   width  = (XmlElement)GetNamedChildNode(node, "width");

            ValidateCorrectElementsProvided(low != null, high != null, center != null, width != null, (XmlElement)node, context, xmlToModelResult
                                            );
            BareANY  lowAny        = low == null ? null : CreateType(context, low, xmlToModelResult, false);
            object   lowType       = ExtractValue(lowAny);
            Boolean? lowInclusive  = ExtractInclusive(context, low, xmlToModelResult);
            BareANY  highAny       = high == null ? null : CreateType(context, high, xmlToModelResult, false);
            object   highType      = ExtractValue(highAny);
            Boolean? highInclusive = ExtractInclusive(context, high, xmlToModelResult);
            BareANY  centerAny     = center == null ? null : CreateType(context, center, xmlToModelResult, false);
            object   centerType    = ExtractValue(centerAny);
            BareDiff widthType     = width == null ? null : CreateDiffType(context, width, xmlToModelResult);

            if (lowAny != null && highAny != null)
            {
                result = IntervalFactory.CreateLowHigh <T>((T)lowType, (T)highType, lowAny.NullFlavor, highAny.NullFlavor);
            }
            else
            {
                if (lowAny != null && widthType != null)
                {
                    result = IntervalFactory.CreateLowWidth <T>((T)lowType, (Diff <T>)widthType, lowAny.NullFlavor);
                }
                else
                {
                    if (highAny != null && widthType != null)
                    {
                        result = IntervalFactory.CreateWidthHigh <T>((Diff <T>)widthType, (T)highType, highAny.NullFlavor);
                    }
                    else
                    {
                        if (centerAny != null && widthType != null)
                        {
                            result = IntervalFactory.CreateCentreWidth <T>((T)centerType, (Diff <T>)widthType, centerAny.NullFlavor);
                        }
                        else
                        {
                            if (centerAny != null && lowAny != null)
                            {
                                result = IntervalFactory.CreateLowCentre <T>((T)lowType, (T)centerType, lowAny.NullFlavor, centerAny.NullFlavor);
                            }
                            else
                            {
                                if (centerAny != null && highAny != null)
                                {
                                    result = IntervalFactory.CreateCentreHigh <T>((T)centerType, (T)highType, centerAny.NullFlavor, highAny.NullFlavor);
                                }
                                else
                                {
                                    if (lowAny != null)
                                    {
                                        result = IntervalFactory.CreateLow <T>((T)lowType, lowAny.NullFlavor);
                                    }
                                    else
                                    {
                                        if (highAny != null)
                                        {
                                            result = IntervalFactory.CreateHigh <T>((T)highType, highAny.NullFlavor);
                                        }
                                        else
                                        {
                                            if (centerAny != null)
                                            {
                                                result = IntervalFactory.CreateCentre <T>((T)centerType, centerAny.NullFlavor);
                                            }
                                            else
                                            {
                                                if (widthType != null)
                                                {
                                                    result = IntervalFactory.CreateWidth <T>((Diff <T>)widthType);
                                                }
                                                else
                                                {
                                                    if (low == null && high == null && center == null && width == null)
                                                    {
                                                        // only treat this as a "simple" interval if no other interval elements were provided (even if they were in error)
                                                        // try to parse a "simple" interval
                                                        BareANY simpleAny = CreateType(context, (XmlElement)node, xmlToModelResult, true);
                                                        object  type      = ExtractValue(simpleAny);
                                                        if (type == null)
                                                        {
                                                            xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.SYNTAX_ERROR, "\"Simple interval node: " + XmlDescriber.DescribePath
                                                                                                          (node) + " does not allow a null value\"", (XmlElement)node));
                                                        }
                                                        else
                                                        {
                                                            result = IntervalFactory.CreateSimple <T>((T)type, ((ANYMetaData)simpleAny).Operator);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (result != null)
            {
                result.LowInclusive  = lowInclusive;
                result.HighInclusive = highInclusive;
            }
            return(result);
        }