Beispiel #1
0
        public virtual void TestIntervalLowWidth()
        {
            Diff <PlatformDate>     diff     = new Diff <PlatformDate>(new PlatformDate(15 * DateUtils.MILLIS_PER_DAY));
            Interval <PlatformDate> interval = IntervalFactory.CreateLowWidth <PlatformDate>(ParseDate("2007-02-20T15:34:22"), diff);
            string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval
                                                                                                                                 ));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name><low value=\"20070220\"/><width unit=\"d\" value=\"15\"/></name>", result);
        }
Beispiel #2
0
        public virtual void TestBasicFreq()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowWidth <PlatformDate>(DateUtil.GetDate
                                                                                                                              (1969, 11, 31), new DateDiff(CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY))), PeriodicIntervalTime
                                                                            .CreateFrequency(3, CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY)));
            string result = new GtsBoundedPivlFormatter().Format(GetContext("name"), new GTSImpl(gts));

            AssertXml("result", "<name specializationType=\"GTS.BOUNDEDPIVL\" xsi:type=\"SXPR_TS\">" + "<comp specializationType=\"IVL_TS.FULLDATE\" xsi:type=\"IVL_TS\">"
                      + "<low value=\"19691231\"/>" + "<width unit=\"d\" value=\"3\"/></comp>" + "<comp operator=\"I\" specializationType=\"PIVL_TS.DATETIME\" xsi:type=\"PIVL_TS\">"
                      + "<frequency><numerator specializationType=\"INT.NONNEG\" value=\"3\" xsi:type=\"INT\"/>" + "<denominator specializationType=\"PQ.TIME\" unit=\"d\" value=\"3\" xsi:type=\"PQ\"/>"
                      + "</frequency></comp></name>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Beispiel #3
0
        public virtual void TestIntervalLowWidthInvalidUnits()
        {
            PhysicalQuantity quantity = new PhysicalQuantity(new BigDecimal(15), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit
                                                             .MINUTE);
            Diff <PlatformDate>     diff     = new DateDiff(quantity);
            Interval <PlatformDate> interval = IntervalFactory.CreateLowWidth <PlatformDate>(ParseDate("2007-02-20T15:34:22"), 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><low value=\"20070220\"/><width unit=\"min\" value=\"15\"/></name>", result);
        }
Beispiel #4
0
        public virtual void TestBasicFreqAsCeRx()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowWidth <PlatformDate>(DateUtil.GetDate
                                                                                                                              (1969, 11, 31), new DateDiff(CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY))), PeriodicIntervalTime
                                                                            .CreateFrequency(3, CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY)));
            string result = new GtsBoundedPivlFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                     (this.result, null, "name", "GTS.BOUNDEDPIVL", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false
                                                                     ), new GTSImpl(gts));

            AssertXml("result", "<name xsi:type=\"SXPR_TS\">" + "<comp operator=\"I\" xsi:type=\"IVL_TS\">" + "<low value=\"19691231\"/>"
                      + "<width unit=\"d\" value=\"3\"/></comp>" + "<comp xsi:type=\"PIVL_TS\">" + "<frequency><numerator value=\"3\"/>" + "<denominator unit=\"d\" value=\"3\"/>"
                      + "</frequency></comp></name>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Beispiel #5
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);
        }
Beispiel #6
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);
        }