Esempio n. 1
0
        protected virtual string CreatePivlTsElement(FormatContext context, PeriodicIntervalTime value, int indentLevel)
        {
            PivlTsPropertyFormatter formatter = new GtsBoundedPivlFormatter.CustomPivlTsPropertyFormatter(!RequiresOperatorOnFirstRepetition
                                                                                                              (context), RequiresSpecializationType(context));

            return(formatter.Format(context, new PIVLImpl(value), indentLevel));
        }
Esempio n. 2
0
        protected virtual GeneralTimingSpecification ParseNonNullNode(ParseContext context, XmlElement element, Type expectedReturnType
                                                                      , XmlToModelResult xmlResult)
        {
            GeneralTimingSpecification result     = null;
            IList <XmlElement>         components = FindComponents(element, xmlResult);

            if (components.Count == 2)
            {
                Interval <PlatformDate> duration  = ParseDuration(context, xmlResult, components[0]);
                PeriodicIntervalTime    frequency = ParseFrequency(context, xmlResult, components[1]);
                if (duration != null && frequency != null)
                {
                    result = new GeneralTimingSpecification(duration, frequency);
                }
                else
                {
                    if (duration == null)
                    {
                        xmlResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Could not parse the duration portion of the GTS.BOUNDEDPIVL"
                                                           , components[0]));
                    }
                    if (frequency == null)
                    {
                        xmlResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Could not parse the frequency portion of the GTS.BOUNDEDPIVL"
                                                           , components[1]));
                    }
                }
            }
            else
            {
                xmlResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, System.String.Format("Expected to find 2 <comp> sub-elements, but found {0}"
                                                                                                      , components.Count), element));
            }
            return(result);
        }
Esempio n. 3
0
        public virtual void TestMissingValues()
        {
            PeriodicIntervalTime frequency = PeriodicIntervalTime.CreateFrequency(null, null);
            string result = new PivlTsPropertyFormatter().Format(GetContext("periodicInterval", "PIVL<TS.DATETIME>"), new PIVLImpl(frequency
                                                                                                                                   ));

            AssertXml("result", "<periodicInterval></periodicInterval>", result);
            Assert.IsFalse(this.result.IsValid());
            Assert.AreEqual(1, this.result.GetHl7Errors().Count);
        }
Esempio n. 4
0
        public virtual void TestParseFailsWithMissingElements()
        {
            XmlNode node = CreateNode("<periodicInterval><frequency></frequency></periodicInterval>");
            PeriodicIntervalTime pivl = (PeriodicIntervalTime) new PivlTsDateTimeElementParser().Parse(CreateContext(), node, this.xmlResult
                                                                                                       ).BareValue;

            Assert.IsNull(pivl, "null");
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(2, this.xmlResult.GetHl7Errors().Count);
        }
Esempio n. 5
0
        private BareANY ConvertDataType(BareANY dataType)
        {
            object bareValue = dataType.BareValue;
            PeriodicIntervalTime   pivlR1 = (bareValue is PeriodicIntervalTime ? (PeriodicIntervalTime)bareValue : null);
            PeriodicIntervalTimeR2 pivlR2 = (pivlR1 == null ? null : ConvertPivl(pivlR1));
            BareANY result = new PIVLTSCDAR1Impl(pivlR2);

            result.DataType   = dataType.DataType;
            result.NullFlavor = dataType.NullFlavor;
            return(result);
        }
Esempio n. 6
0
        public virtual void TestBasicCase()
        {
            PhysicalQuantity quantity = new PhysicalQuantity(new BigDecimal(1), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit
                                                             .DAY);
            PeriodicIntervalTime frequency = PeriodicIntervalTime.CreateFrequency(3, quantity);
            string result = new PivlTsPropertyFormatter().Format(GetContext("periodicInterval", "PIVL<TS.DATETIME>"), new PIVLImpl(frequency
                                                                                                                                   ));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<periodicInterval><frequency><numerator value=\"3\"/><denominator unit=\"d\" value=\"1\"/></frequency></periodicInterval>"
                      , result);
        }
Esempio n. 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));
        }
Esempio n. 8
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<periodicInterval><frequency><numerator value=\"3\"/><denominator value=\"1\" unit=\"d\"/></frequency></periodicInterval>"
                                      );
            PeriodicIntervalTime pivl = (PeriodicIntervalTime) new PivlTsDateTimeElementParser().Parse(CreateContext(), node, this.xmlResult
                                                                                                       ).BareValue;

            Assert.IsNotNull(pivl, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pivl.Operator);
            Assert.IsNull(pivl.Period);
            Assert.IsNull(pivl.Phase);
            Assert.IsNull(pivl.Value);
            Assert.AreEqual(Representation.FREQUENCY, pivl.Representation);
            Assert.AreEqual(new BigDecimal("1"), pivl.Quantity.Quantity, "qty");
            Assert.AreEqual("d", pivl.Quantity.Unit.CodeValue, "units");
            Assert.AreEqual((Int32?)3, pivl.Repetitions, "reps");
        }
Esempio n. 9
0
        public virtual void TestBasicFreqAsMR2009()
        {
            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.R02_04_02, null, null, null, false
                                                                     ), 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());
        }
Esempio n. 10
0
        public virtual void TestBasicAsCeRx()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate
                                                                                                                             (1969, 11, 31), DateUtil.GetDate(1969, 11, 31)), PeriodicIntervalTime.CreatePeriod(new DateDiff(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\"/>"
                      + "<high value=\"19691231\"/>" + "</comp>" + "<comp xsi:type=\"PIVL_TS\">" + "<period unit=\"d\" value=\"3\"/>" + "</comp>"
                      + "</name>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Esempio n. 11
0
        public virtual void TimeZoneHandling()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate
                                                                                                                             (1969, 11, 31), DateUtil.GetDate(1969, 11, 31)), PeriodicIntervalTime.CreateFrequency(2, new PhysicalQuantity(BigDecimal
                                                                                                                                                                                                                                           .TEN, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive.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, TimeZoneUtil.GetTimeZone
                                                                         ("GMT-7"), null, null, false), new GTSImpl(gts));

            AssertXml("result", "<name xsi:type=\"SXPR_TS\">" + "<comp operator=\"I\" xsi:type=\"IVL_TS\">" + "<low value=\"19691230\"/>"
                      + "<high value=\"19691230\"/></comp>" + "<comp xsi:type=\"PIVL_TS\">" + "<frequency><numerator value=\"2\"/><denominator unit=\"d\" value=\"10\"/></frequency></comp></name>"
                      , result);
            Assert.IsTrue(this.result.IsValid());
        }
Esempio n. 12
0
        public virtual void TestBasicPhaseAsMR2009()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate
                                                                                                                             (1969, 11, 31), DateUtil.GetDate(1969, 11, 31)), PeriodicIntervalTime.CreatePhase(IntervalFactory.CreateLowHigh <PlatformDate
                                                                                                                                                                                                                                              >(DateUtil.GetDate(1969, 11, 31), DateUtil.GetDate(1969, 11, 31))));
            string result = new GtsBoundedPivlFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                     (this.result, null, "name", "GTS.BOUNDEDPIVL", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false
                                                                     ), 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\"/>" + "<high value=\"19691231\"/></comp>" + "<comp operator=\"I\" specializationType=\"PIVL_TS.DATETIME\" xsi:type=\"PIVL_TS\">"
                      + "<phase><low value=\"19691231\"/><high value=\"19691231\"/></phase></comp></name>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Esempio n. 13
0
        public virtual void TestBasicPhase()
        {
            GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate
                                                                                                                             (1969, 11, 31), DateUtil.GetDate(1969, 11, 31)), PeriodicIntervalTime.CreatePhase(IntervalFactory.CreateLowHigh <PlatformDate
                                                                                                                                                                                                                                              >(DateUtil.GetDate(1969, 11, 31), DateUtil.GetDate(1969, 11, 31))));
            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\"/>" + "<high value=\"19691231\"/></comp>" + "<comp operator=\"I\" specializationType=\"PIVL_TS.DATETIME\" xsi:type=\"PIVL_TS\">"
                      + "<phase><low value=\"19691231\"/><high value=\"19691231\"/></phase></comp></name>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Esempio n. 14
0
 private PeriodicIntervalTimeR2 ConvertPivl(PeriodicIntervalTime pivlR1)
 {
     return(PeriodicIntervalTimeR2.CreateFromPivlR1(pivlR1));
 }
Esempio n. 15
0
 private PeriodicIntervalTime ConvertPivl(PeriodicIntervalTimeR2 pivlR2)
 {
     return(PeriodicIntervalTime.CreateFromPivlR2(pivlR2));
 }