Exemple #1
0
        public virtual void TestParse()
        {
            XmlNode node = CreateNode("<top xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"urn:hl7-org:v3\" " + "xmlns:cda=\"urn:hl7-org:v3\" xmlns:sdtc=\"urn:hl7-org:sdtc\">"
                                      + "<effectiveTime xsi:type=\"IVL_TS\"><low value=\"20120512\"/><high value=\"20120512\"/></effectiveTime>" + "<effectiveTime xsi:type=\"PIVL_TS\" institutionSpecified=\"true\" operator=\"A\"><period value=\"1\" unit=\"h\"/></effectiveTime>"
                                      + "</top>");
            ParseContext parseContext = ParseContextImpl.Create("LIST<SXCM<TS>>", null, SpecificationVersion.CCDA_R1_1, null, null, null
                                                                , Cardinality.Create("0-4"), null, true);
            BareANY result = new ListR2ElementParser(this.parserR2Registry).Parse(parseContext, AsList(node.ChildNodes), this.xmlResult
                                                                                  );

            Assert.IsTrue(this.xmlResult.IsValid());
            IList <MbDate> list = ((LIST <SXCM_R2 <MbDate>, MbDate>)result).RawList();

            Assert.IsNotNull(list, "null");
            Assert.AreEqual(2, list.Count, "size");
            DateInterval firstValue = (DateInterval)list[0];

            AssertDateEquals("low", "yyyyMMdd", ParseDate("2012-05-12"), firstValue.Interval.Low);
            AssertDateEquals("high", "yyyyMMdd", ParseDate("2012-05-12"), firstValue.Interval.High);
            PeriodicIntervalTimeR2 secondValue = (PeriodicIntervalTimeR2)list[1];

            Assert.AreEqual(true, secondValue.InstitutionSpecified);
            Assert.AreEqual(new BigDecimal("1"), secondValue.Period.Quantity);
            Assert.AreEqual("h", secondValue.Period.Unit.CodeValue);
        }
Exemple #2
0
        public virtual void TestPivlPhasePeriod()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><period unit=\"d\" value=\"1\"/><phase><low value=\"20120503\"/><high value=\"20120708\"/></phase></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult    = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedPeriod = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                   .DAY);
            PlatformDate            dateLow             = DateUtil.GetDate(2012, 4, 3);
            DateWithPattern         dateWithPatternLow  = new DateWithPattern(dateLow, "yyyyMMdd");
            PlatformDate            dateHigh            = DateUtil.GetDate(2012, 6, 8);
            DateWithPattern         dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd");
            Interval <PlatformDate> expectedPhase       = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedPeriod.Quantity, pivl.Period.Quantity);
            Assert.AreEqual(expectedPeriod.Unit.CodeValue, pivl.Period.Unit.CodeValue);
            Assert.AreEqual(expectedPhase, pivl.Phase);
            Assert.IsNull(pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.FrequencyQuantity);
        }
Exemple #3
0
        public virtual void TestMissingValues()
        {
            PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2((Interval <PlatformDate>)null, (PhysicalQuantity)null);
            string result = new PivlTsR2PropertyFormatter().Format(GetContext("periodicInterval", "PIVL<TS>"), new PIVL_R2Impl(pivl));

            // from a strict reading of the schema, this is a perfectly valid PIVL_TS
            AssertXml("result", "<periodicInterval></periodicInterval>", result);
            Assert.IsTrue(this.result.IsValid());
        }
Exemple #4
0
        public virtual void TestParseNullFlavor()
        {
            XmlNode node                = CreateNode("<periodicInterval nullFlavor=\"NAV\"/>");
            BareANY pivlTsAny           = new PivlTsR2ElementParser().Parse(CreateContext(), node, this.xmlResult);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)pivlTsAny.BareValue;

            Assert.IsNull(pivl);
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.TEMPORARILY_UNAVAILABLE, pivlTsAny.NullFlavor
                            );
        }
Exemple #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);
        }
Exemple #6
0
        public virtual void TestParseEmpty()
        {
            XmlNode node = CreateNode("<periodicInterval/>");
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2) new PivlTsR2ElementParser().Parse(CreateContext(), node, this.xmlResult
                                                                                                     ).BareValue;

            Assert.IsNotNull(pivl, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.IsNull(pivl.Alignment);
            Assert.IsFalse((bool)pivl.InstitutionSpecified);
            //Cast for .NET translation
            Assert.IsNull(pivl.Phase);
            Assert.IsNull(pivl.Period);
        }
Exemple #7
0
        public virtual void TestFullPivl()
        {
            PlatformDate            lowDate             = DateUtil.GetDate(1999, 0, 23);
            PlatformDate            lowDateWithPattern  = new DateWithPattern(lowDate, "yyyyMMdd");
            PlatformDate            highDate            = DateUtil.GetDate(2013, 4, 7);
            PlatformDate            highDateWithPattern = new DateWithPattern(highDate, "yyyyMMdd");
            Interval <PlatformDate> phase  = IntervalFactory.CreateLowHigh(lowDateWithPattern, highDateWithPattern);
            PhysicalQuantity        period = new PhysicalQuantity(new BigDecimal(11), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit
                                                                  .DAY);
            PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2(phase, period, CalendarCycle.DAY_OF_THE_MONTH, true, null, null);
            string result = new PivlTsR2PropertyFormatter().Format(GetContext("periodicInterval", "PIVL<TS>"), new PIVL_R2Impl(pivl));

            Assert.IsTrue(this.result.IsValid());
            AssertXml("result", "<periodicInterval alignment=\"D\" institutionSpecified=\"true\"><phase><low value=\"19990123\"/><high value=\"20130507\"/></phase><period unit=\"d\" value=\"11\"/></periodicInterval>"
                      , result);
        }
Exemple #8
0
        public virtual void TestParseFailsInvalidAlignment()
        {
            XmlNode node = CreateNode("<periodicInterval alignment=\"INVALIDVALUE\"/>");
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2) new PivlTsR2ElementParser().Parse(CreateContext(), node, this.xmlResult
                                                                                                     ).BareValue;

            Assert.IsNotNull(pivl, "null");
            Assert.IsFalse(this.xmlResult.IsValid());
            Assert.AreEqual(1, this.xmlResult.GetHl7Errors().Count);
            Assert.IsTrue(this.xmlResult.GetHl7Errors()[0].GetMessage().Contains("CalendarCycle"));
            Assert.IsNull(pivl.Alignment);
            Assert.IsFalse((bool)pivl.InstitutionSpecified);
            //Cast for .NET translation
            Assert.IsNull(pivl.Phase);
            Assert.IsNull(pivl.Period);
        }
Exemple #9
0
        public virtual void TestPivlFrequency()
        {
            ModelToXmlResult result            = new ModelToXmlResult();
            PhysicalQuantity frequencyQuantity = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                      .DAY);
            PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2(4, frequencyQuantity);
            BareANY       dataType      = new PIVLTSCDAR1Impl(pivl);
            FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty
                                                                                                                    , "pivl", "PIVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false,
                                                                                                                    SpecificationVersion.R02_04_03, null, null, null, null, true);
            string xml = this.formatter.Format(formatContext, dataType);

            Assert.IsTrue(result.IsValid());
            string expected = "<pivl><frequency><numerator value=\"4\"/><denominator unit=\"d\" value=\"1\"/></frequency></pivl>";

            AssertXml("pivl output", expected, xml, true);
        }
Exemple #10
0
        public virtual void TestParseFull()
        {
            PlatformDate lowDate  = DateUtil.GetDate(1999, 0, 23);
            PlatformDate highDate = DateUtil.GetDate(2013, 4, 7);
            XmlNode      node     = CreateNode("<periodicInterval alignment=\"D\" institutionSpecified=\"true\"><phase><low value=\"19990123\"/><high value=\"20130507\"/></phase><period unit=\"d\" value=\"11\"/></periodicInterval>"
                                               );
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2) new PivlTsR2ElementParser().Parse(CreateContext(), node, this.xmlResult
                                                                                                     ).BareValue;

            Assert.IsNotNull(pivl, "null");
            Assert.IsTrue(this.xmlResult.IsValid());
            Assert.AreEqual(CalendarCycle.DAY_OF_THE_MONTH, pivl.Alignment);
            Assert.IsTrue((bool)pivl.InstitutionSpecified);
            //Cast for .NET translation
            Assert.AreEqual(lowDate, pivl.Phase.Low);
            Assert.AreEqual(highDate, pivl.Phase.High);
            Assert.AreEqual(new BigDecimal(11), pivl.Period.Quantity);
            Assert.AreEqual("d", pivl.Period.Unit.CodeValue);
        }
Exemple #11
0
        public virtual void TestPivlFrequency()
        {
            XmlToModelResult result = new XmlToModelResult();
            XmlNode          node   = CreateNode("<pivl><frequency><numerator value=\"4\"/><denominator unit=\"d\" value=\"1\"/></frequency></pivl>"
                                                 );
            ParseContext context = ParseContextImpl.Create("PIVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), null, true);
            BareANY          parseResult = this.parser.Parse(context, Arrays.AsList(node), result);
            PhysicalQuantity expectedFrequencyQuantity = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                                              .DAY);

            Assert.IsTrue(result.IsValid());
            Assert.IsTrue(parseResult is PIVLTSCDAR1);
            PeriodicIntervalTimeR2 pivl = (PeriodicIntervalTimeR2)parseResult.BareValue;

            Assert.AreEqual(expectedFrequencyQuantity.Quantity, pivl.FrequencyQuantity.Quantity);
            Assert.AreEqual(expectedFrequencyQuantity.Unit.CodeValue, pivl.FrequencyQuantity.Unit.CodeValue);
            Assert.AreEqual((Int32?)4, pivl.FrequencyRepetitions);
            Assert.IsNull(pivl.Period);
            Assert.IsNull(pivl.Phase);
        }
Exemple #12
0
        public virtual void TestPivlPhasePeriod()
        {
            ModelToXmlResult        result              = new ModelToXmlResult();
            PlatformDate            dateLow             = DateUtil.GetDate(2012, 4, 3);
            DateWithPattern         dateWithPatternLow  = new DateWithPattern(dateLow, "yyyyMMdd");
            PlatformDate            dateHigh            = DateUtil.GetDate(2012, 6, 8);
            DateWithPattern         dateWithPatternHigh = new DateWithPattern(dateHigh, "yyyyMMdd");
            Interval <PlatformDate> phase = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                          );
            PhysicalQuantity period = new PhysicalQuantity(BigDecimal.ONE, Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive
                                                           .DAY);
            PeriodicIntervalTimeR2 pivl = new PeriodicIntervalTimeR2(phase, period);
            BareANY       dataType      = new PIVLTSCDAR1Impl(pivl);
            FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty
                                                                                                                    , "pivl", "PIVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false,
                                                                                                                    SpecificationVersion.R02_04_03, null, null, null, null, true);
            string xml = this.formatter.Format(formatContext, dataType);

            Assert.IsTrue(result.IsValid());
            string expected = "<pivl><period unit=\"d\" value=\"1\"/><phase><low value=\"20120503\"/><high value=\"20120708\"/></phase></pivl>";

            AssertXml("pivl output", expected, xml, true);
        }
Exemple #13
0
 private PeriodicIntervalTimeR2 ConvertPivl(PeriodicIntervalTime pivlR1)
 {
     return(PeriodicIntervalTimeR2.CreateFromPivlR1(pivlR1));
 }
Exemple #14
0
 private PeriodicIntervalTime ConvertPivl(PeriodicIntervalTimeR2 pivlR2)
 {
     return(PeriodicIntervalTime.CreateFromPivlR2(pivlR2));
 }