示例#1
0
        public virtual void ShouldAdaptCorrectly()
        {
            IVLImpl <TS, Interval <PlatformDate> > ivl = new IVLImpl <TS, Interval <PlatformDate> >(IntervalFactory.CreateLow <PlatformDate>
                                                                                                        (new PlatformDate()));
            BareANY adapted = this.adapter.Adapt(typeof(TS), ivl);

            Assert.IsTrue(adapted is TS);
            Assert.AreEqual(((TS)adapted).Value, ivl.Value.Low, "low");
        }
示例#2
0
        public virtual void TestNullCaseMasked()
        {
            IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > dataType = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >();

            dataType.NullFlavor = Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.MASKED;
            string result = this.formatter.Format(GetContext("name"), dataType);

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name nullFlavor=\"MSK\"/>", result);
        }
示例#3
0
        private BareANY ConvertDataType(BareANY dataType)
        {
            object                  bareValue = dataType.BareValue;
            DateInterval            ivlTsR2   = (bareValue is DateInterval ? (DateInterval)bareValue : null);
            Interval <PlatformDate> ivlTsR1   = (ivlTsR2 == null ? null : ConvertIvlTs(ivlTsR2));
            BareANY                 result    = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >();

            result.DataType   = dataType.DataType;
            result.BareValue  = ivlTsR1;
            result.NullFlavor = dataType.NullFlavor;
            return(result);
        }
示例#4
0
        private IVLImpl <QTY <DateInterval>, DateInterval> createNewParsedValue(IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > oldParsedValue, DateInterval newValue)
        {
            IVLImpl <QTY <DateInterval>, DateInterval> newParsedValue = new IVLImpl <QTY <DateInterval>, DateInterval>();

            newParsedValue.BareValue   = newValue;
            newParsedValue.NullFlavor  = oldParsedValue.NullFlavor;
            newParsedValue.Language    = oldParsedValue.Language;
            newParsedValue.DisplayName = oldParsedValue.DisplayName;
            newParsedValue.Translations.AddAll(oldParsedValue.Translations);
            newParsedValue.OriginalText = oldParsedValue.OriginalText;
            newParsedValue.IsCdata      = oldParsedValue.IsCdata;
            newParsedValue.Unsorted     = oldParsedValue.Unsorted;
            newParsedValue.Operator     = oldParsedValue.Operator;
            return(newParsedValue);
        }
示例#5
0
        private void AppendSk(StringBuilder buffer, Int32?repetitions, Interval <PhysicalQuantity> quantity, int indentLevel, FormatContext
                              context)
        {
            INTImpl       intImpl       = new INTImpl(repetitions);
            FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("INT.NONNEG", context
                                                                                                                    .IsSpecializationType(), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), "numerator",
                                                                                                                    context);

            buffer.Append(this.intNonNegPropertyFormatter.Format(formatContext, intImpl, indentLevel));
            IVLImpl <PQ, Interval <PhysicalQuantity> > ivlImpl = new IVLImpl <PQ, Interval <PhysicalQuantity> >(quantity);

            formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("IVL<PQ.BASIC>", context.IsSpecializationType
                                                                                                          (), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), "denominator", context);
            buffer.Append(this.ivlPqPropertyFormatter.Format(formatContext, ivlImpl, indentLevel));
        }
示例#6
0
        private string HandleOffset(EventRelatedPeriodicIntervalTime value, FormatContext context, int indentLevel)
        {
            string result = string.Empty;

            if (value.Offset != null)
            {
                FormatContext newContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("IVL<PQ>", "offset",
                                                                                                                     context);
                IVL <QTY <PhysicalQuantity>, Interval <PhysicalQuantity> > ivlAny = new IVLImpl <QTY <PhysicalQuantity>, Interval <PhysicalQuantity
                                                                                                                                   > >();
                ivlAny.Value = value.Offset;
                result       = this.ivlPqR2PropertyFormatter.Format(newContext, ivlAny, indentLevel);
            }
            return(result);
        }
示例#7
0
        private void AppendValues(StringBuilder buffer, GeneralTimingSpecification value, int indentLevel, FormatContext context)
        {
            Interval <PlatformDate>            duration    = value.Duration;
            IVL <TS, Interval <PlatformDate> > ivlDuration = new IVLImpl <TS, Interval <PlatformDate> >(duration);
            IvlTsPropertyFormatter             formatter   = new GtsBoundedPivlFormatter.CustomIvlTsPropertyFormatter(RequiresOperatorOnFirstRepetition
                                                                                                                          (context), RequiresSpecializationType(context));
            PeriodicIntervalTime frequency = value.Frequency;

            buffer.Append(formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("IVL<TS.FULLDATE>"
                                                                                                                     , RequiresSpecializationType(context), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1")
                                                                                                                     , "comp", context), ivlDuration, indentLevel + 1));
            // constraints not passed down
            buffer.Append(CreatePivlTsElement(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("PIVL<TS.DATETIME>"
                                                                                                                        , RequiresSpecializationType(context), Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1")
                                                                                                                        , "comp", context), frequency, indentLevel + 1));
        }
示例#8
0
        public virtual void TestBasicAbstract()
        {
            Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(ParseDate("2006-12-25"), ParseDate("2007-01-02"
                                                                                                                               ));
            IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > hl7DataType = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval
                                                                                                                                            );

            hl7DataType.DataType = StandardDataType.IVL_FULL_DATE;
            string result = this.formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(this.result
                                                                                                                            , null, "name", "IVL<TS.FULLDATEWITHTIME>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, false, SpecificationVersion
                                                                                                                            .R02_04_03, null, null, null, false), hl7DataType);

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name specializationType=\"IVL_TS.FULLDATE\" xsi:type=\"IVL_TS\"><low value=\"20061225\"/><high value=\"20070102\"/></name>"
                      , result);
        }
示例#9
0
        public virtual void TestBasicAbstract()
        {
            TimeZoneInfo            timeZone = TimeZoneUtil.GetTimeZone("America/Toronto");
            Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate(2006, 11, 25, 11, 12, 13,
                                                                                                             0, timeZone), DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone));
            IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > hl7DataType = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval
                                                                                                                                            );

            hl7DataType.DataType = StandardDataType.IVL_FULL_DATE_TIME;
            string result = new IvlTsPropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                    (this.result, null, "name", "IVL<TS.FULLDATEWITHTIME>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null,
                                                                    false, SpecificationVersion.V02R02, timeZone, timeZone, null, false), hl7DataType);

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<name specializationType=\"IVL_TS.FULLDATETIME\" xsi:type=\"IVL_TS\"><low value=\"20061225111213.0000-0500\"/><high value=\"20070102101112.0000-0500\"/></name>"
                      , result);
        }
示例#10
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);
        }
示例#11
0
        public virtual string Format(FormatContext context, BareANY value, int indentLevel)
        {
            if (value == null)
            {
                return(string.Empty);
            }
            object bareValue = value.BareValue;
            Interval <PlatformDate> innerDateInterval   = null;
            Interval <MbDate>       innerMbDateInterval = null;

            if (bareValue != null && bareValue is DateInterval)
            {
                DateInterval dateInterval = (DateInterval)bareValue;
                HandleConstraints(context, context.GetModelToXmlResult(), context.GetPropertyPath(), dateInterval);
                innerDateInterval   = dateInterval.Interval;
                innerMbDateInterval = IntervalFactory.CreateMbDateInterval(innerDateInterval);
            }
            BareANY newValue = new IVLImpl <TS, Interval <MbDate> >(typeof(Interval <object>), innerMbDateInterval, value.NullFlavor, value
                                                                    .DataType);

            return(actualFormatter.Format(context, newValue, indentLevel));
        }
示例#12
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);
        }