示例#1
0
        public virtual void TestDateFormatPrecedence()
        {
            VersionNumber version = SpecificationVersion.V02R02_AB;

            Runtime.ClearProperty(TsR2PropertyFormatter.DATE_FORMAT_OVERRIDE_BASE_PROPERTY_NAME + version.VersionLiteral);
            string                dateWithPatternPattern = "test1_mmddyy";
            string                overridePattern        = "test2_MMDDYY";
            PlatformDate          dateWithPattern        = new DateWithPattern(new PlatformDate(), dateWithPatternPattern);
            PlatformDate          normalDate             = new PlatformDate();
            TsR2PropertyFormatter formatter = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter();

            Assert.AreEqual(TsR2PropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(normalDate, version
                                                                                                                     ), "Should use default format if nothing else provided");
            Runtime.SetProperty(TsR2PropertyFormatter.DATE_FORMAT_OVERRIDE_BASE_PROPERTY_NAME + version.VersionLiteral, overridePattern
                                );
            Assert.AreEqual(overridePattern, formatter.DetermineDateFormat(normalDate, version), "Should use override format when provided"
                            );
            Assert.AreEqual(TsR2PropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(normalDate, SpecificationVersion
                                                                                                                     .V02R02), "Should always use override format when provided");
            Assert.AreEqual(TsR2PropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(normalDate, SpecificationVersion
                                                                                                                     .V01R04_3), "Should always use override format when provided");
            Assert.AreEqual(TsR2PropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(normalDate, SpecificationVersion
                                                                                                                     .V01R04_2_SK), "Should always use override format when provided");
            Assert.AreEqual(TsR2PropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(normalDate, SpecificationVersion
                                                                                                                     .R02_04_03), "Should always use override format when provided");
            Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(dateWithPattern, version), "Should use date with pattern always when provided"
                            );
            Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(dateWithPattern, SpecificationVersion.V01R04_3), "Should use date with pattern always when provided even if version is CeRx"
                            );
            Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(dateWithPattern, SpecificationVersion.V01R04_2_SK),
                            "Should use date with pattern always when provided even if version is SK CeRx");
            Runtime.ClearProperty(TsR2PropertyFormatter.DATE_FORMAT_OVERRIDE_BASE_PROPERTY_NAME + version.VersionLiteral);
        }
示例#2
0
        public virtual void TestIvlTsConstraintsInvalid()
        {
            XmlToModelResult    result      = new XmlToModelResult();
            XmlNode             node        = CreateNode("<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>");
            ConstrainedDatatype constraints = new ConstrainedDatatype("ivl", "IVL<TS>");

            constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0")));
            constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0")));
            ParseContext context = ParseContextImpl.Create("IVLTSCDAR1", null, SpecificationVersion.R02_04_03, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                           .MANDATORY, Cardinality.Create("1"), constraints, true);
            BareANY                 parseResult         = this.parser.Parse(context, Arrays.AsList(node), result);
            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> expectedIvl         = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                                        );

            Assert.IsFalse(result.IsValid());
            Assert.AreEqual(2, result.GetHl7Errors().Count);
            Assert.IsTrue(parseResult is IVLTSCDAR1);
            DateInterval ivl = (DateInterval)parseResult.BareValue;

            Assert.AreEqual(expectedIvl, ivl.Interval);
        }
示例#3
0
        public virtual void TestParseAll()
        {
            PlatformDate useable1 = DateUtil.GetDate(2008, 5, 25, 0, 0, 0, 0);
            PlatformDate useable2 = DateUtil.GetDate(2012, 8, 3, 0, 0, 0, 0);
            XmlNode      node     = CreateNode("<something isNotOrdered=\"true\"> " + "<city>city name</city>" + "freeform" + "<delimiter>,</delimiter>"
                                               + "\n" + "<state>Ontario</state>" + "<useablePeriod operator=\"P\" value=\"20080625\" />" + "<useablePeriod value=\"20120903\" />"
                                               + "</something>");
            AD ad = (AD) new AdR2ElementParser().Parse(CreateContext("AD", SpecificationVersion.V02R02), node, this.xmlResult);

            Assert.IsTrue(this.xmlResult.IsValid());
            PostalAddress postalAddress = ad.Value;

            Assert.AreEqual(0, postalAddress.Uses.Count, "number of name uses");
            Assert.AreEqual(4, postalAddress.Parts.Count, "number of name parts");
            Assert.AreEqual(2, postalAddress.UseablePeriods.Count, "number of useablePeriods");
            Assert.IsTrue((bool)ad.Value.IsNotOrdered);
            //cast for .NET translation
            AssertPostalAddressPartAsExpected("city", postalAddress.Parts[0], PostalAddressPartType.CITY, "city name");
            AssertPostalAddressPartAsExpected("free", postalAddress.Parts[1], null, "freeform");
            AssertPostalAddressPartAsExpected("delimiter comma", postalAddress.Parts[2], PostalAddressPartType.DELIMITER, ",");
            AssertPostalAddressPartAsExpected("state", postalAddress.Parts[3], PostalAddressPartType.STATE, "Ontario");
            Assert.IsTrue(postalAddress.UseablePeriods.ContainsKey(useable1));
            Assert.AreEqual(SetOperator.PERIODIC_HULL, postalAddress.UseablePeriods.SafeGet(useable1));
            Assert.IsTrue(postalAddress.UseablePeriods.ContainsKey(useable2));
            Assert.AreEqual(SetOperator.INCLUDE, postalAddress.UseablePeriods.SafeGet(useable2));
        }
示例#4
0
        /// <exception cref="Ca.Infoway.Messagebuilder.Marshalling.HL7.XmlToModelTransformationException"></exception>
        protected override MbDate ParseNonNullNode(ParseContext context, XmlNode node, BareANY bareAny, Type expectedReturnType,
                                                   XmlToModelResult xmlToModelResult)
        {
            XmlElement element      = (XmlElement)node;
            MbDate     result       = null;
            string     unparsedDate = GetAttributeValue(node, "value");

            if (StringUtils.IsBlank(unparsedDate))
            {
                xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, "Timestamp value must be non-blank.", element));
            }
            else
            {
                try
                {
                    PlatformDate parsedDate = ParseDate(unparsedDate, GetAllDateFormats(context), context);
                    result = (parsedDate == null ? null : new MbDate(parsedDate));
                }
                catch (ArgumentException)
                {
                    string message = "The timestamp " + unparsedDate + " in element " + XmlDescriber.DescribeSingleElement(element) + " cannot be parsed.";
                    xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.DATA_TYPE_ERROR, message, element));
                }
                this.sxcmHelper.HandleOperator(element, context, xmlToModelResult, (ANYMetaData)bareAny);
            }
            return(result);
        }
示例#5
0
        public virtual void TestParseValidValueAttributeWithTimeZoneMinus()
        {
            PlatformDate calendar      = DateUtil.GetDate(2008, 2, 31, 15, 58, 57, 862);
            string       expectedValue = "20080331155857.8620" + GetCurrentTimeZone(calendar);

            AssertValidValueAttribute(calendar, expectedValue);
        }
示例#6
0
        private Interval <PlatformDate> CreateLowHighInterval(bool hasLow, bool hasHigh)
        {
            PlatformDate low  = hasLow ? DateUtil.GetDate(2010, 2, 22) : null;
            PlatformDate high = hasHigh ? DateUtil.GetDate(2013, 7, 11) : null;

            return(IntervalFactory.CreateLowHigh(low, high));
        }
示例#7
0
        public virtual void TestIvlTsWithConstraintsInValid()
        {
            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> ivlTs = IntervalFactory.CreateLowHigh((PlatformDate)dateWithPatternLow, (PlatformDate)dateWithPatternHigh
                                                                          );
            DateInterval        dateInterval = new DateInterval(ivlTs);
            BareANY             dataType     = new IVLTSCDAR1Impl(dateInterval);
            ConstrainedDatatype constraints  = new ConstrainedDatatype("ivl", "IVL<TS>");

            constraints.Relationships.Add(new Relationship("low", "TS", Cardinality.Create("0")));
            constraints.Relationships.Add(new Relationship("high", "TS", Cardinality.Create("0")));
            FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty
                                                                                                                    , "ivl", "IVLTSCDAR1", null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.MANDATORY, Cardinality.Create("1"), false, SpecificationVersion
                                                                                                                    .R02_04_03, null, null, null, constraints, true);
            string xml = this.formatter.Format(formatContext, dataType);

            Assert.IsFalse(result.IsValid());
            Assert.AreEqual(2, result.GetHl7Errors().Count);
            string expected = "<ivl><low value=\"20120503\"/><high value=\"20120708\"/></ivl>";

            AssertXml("ivl output", expected, xml, true);
        }
示例#8
0
        public static int GetUTCOffset(string timeZoneId, PlatformDate date)
        {
            DateTimeOffset original  = new DateTimeOffset(date);
            DateTimeOffset converted = TimeZoneInfo.ConvertTime(original, GetTimeZone(timeZoneId));

            return((int)converted.Offset.TotalMilliseconds);
        }
示例#9
0
        public virtual void TestDateEquals()
        {
            PlatformDate date1 = new PlatformDate(12345);
            PlatformDate date2 = new PlatformDate(12345);

            Assert.AreEqual(date1, date2);
        }
示例#10
0
        /// <exception cref="System.Exception"></exception>
        private void AssertValidValueAttribute(PlatformDate expectedResult, string value)
        {
            XmlNode node = CreateNode("<something value=\"" + value + "\" />");

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE_TIME, expectedResult, (PlatformDate)(new
                                                                                                                                   TsElementParser()).Parse(CreateContext(), node, this.xmlResult).BareValue);
        }
示例#11
0
        protected virtual void AssertDateEquals(string description, string pattern, PlatformDate expected, PlatformDate actual)
        {
            Assert.IsNotNull(actual, description + " not null");
            DateFormat format = DateUtil.Instance(pattern);

            Assert.AreEqual(format.Format(expected), format.Format(actual), description);
        }
示例#12
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);
        }
示例#13
0
        /// <summary>
        /// Convenience method for adding a period and inclusive operator.
        /// </summary>
        /// <param name="periodInTime"></param>
        /// <param name="setOperator"></param>
        /// <returns>whether the added period replaced an existing period</returns>
        public bool AddUseablePeriod(PlatformDate periodInTime, SetOperator setOperator)
        {
            // leave it up to the user to worry about a given time replacing an existing one
            SetOperator previousValue = UseablePeriods.ContainsKey(periodInTime) ? UseablePeriods[periodInTime] : null;

            UseablePeriods.Add(periodInTime, setOperator == null ? SetOperator.INCLUDE : setOperator);
            return(previousValue != null);
        }
示例#14
0
        /*
         *      private String Date {
         *        set {
         *                      try {
         *                              Date = ((Int64?)Int64.Parse(value,System.Globalization.NumberStyles.Integer)).Value;
         *                      } catch (FormatException e) {
         *                      }
         *              }
         *      }
         *
         *
         *      private void setDate(long time) {
         *              this.date.Time = time;
         *      }
         *
         *      public Date getDate() {
         *              return this.date;
         *      }
         */

        private void setDate(String datestr)
        {
            try {
                this.date = DateUtils.ParseDate(datestr, new string[] { "yyyy-MM-dd" });
            }
            catch (FormatException e) {
            }
        }
示例#15
0
        public virtual void TestParseValidValueAttributePlusExtraAttribute()
        {
            PlatformDate calendar = DateUtil.GetDate(1999, 2, 3, 0, 0, 0, 0);
            XmlNode      node     = CreateNode("<something extra=\"extra\" value=\"19990303\" />");

            AssertDateEquals("correct value returned", MarshallingTestCase.FULL_DATE, calendar, (PlatformDate) new TsElementParser().Parse
                                 (CreateContext(), node, this.xmlResult).BareValue);
        }
示例#16
0
 private string GetPatternFromDateWithPattern(PlatformDate date)
 {
     if (date is DateWithPattern)
     {
         return(((DateWithPattern)date).DatePattern);
     }
     return(null);
 }
示例#17
0
        public virtual void TestParseValidValueAttributeWithTimeZonePlus()
        {
            PlatformDate expectedCalendar = DateUtil.GetDate(2008, 2, 31, 10, 58, 57, 862, TimeZoneUtil.GetTimeZone("America/New_York"
                                                                                                                    ));
            XmlNode node = CreateNode("<something extra=\"extra\" value=\"20080331155857.8620+0100\" />");

            AssertDateEquals("correct value returned", MarshallingTestCase.FULL_DATE_TIME, expectedCalendar, (PlatformDate) new TsElementParser
                                 ().Parse(CreateContext(), node, this.xmlResult).BareValue);
        }
示例#18
0
        public virtual void TestParseValidValueAttributeWithTimeZoneMinus()
        {
            PlatformDate calendar = DateUtil.GetDate(2008, 2, 31, 15, 58, 57, 862);
            string       value    = "20080331155857.8620" + GetCurrentTimeZone(calendar);
            XmlNode      node     = CreateNode("<something extra=\"extra\" value=\"" + value + "\" />");

            AssertDateEquals("correct value returned", MarshallingTestCase.FULL_DATE_TIME, calendar, (PlatformDate) new TsElementParser
                                 ().Parse(CreateContext(), node, this.xmlResult).BareValue);
        }
示例#19
0
        public virtual void DateInterpretedAsSaskShouldBeGreaterThanSameTimeInterpretedAsOntario()
        {
            XmlNode      node     = CreateNode("<something value=\"19990303000000\" />");
            PlatformDate saskDate = ((PlatformDate) new TsElementParser().Parse(CreateContextWithTimeZone(TimeZoneUtil.GetTimeZone("Canada/Saskatchewan"
                                                                                                                                   )), node, this.xmlResult).BareValue);
            PlatformDate ontarioDate = ((PlatformDate) new TsElementParser().Parse(CreateContextWithTimeZone(TimeZoneUtil.GetTimeZone(
                                                                                                                 "Canada/Ontario")), node, this.xmlResult).BareValue);

            Assert.IsTrue(saskDate.CompareTo(ontarioDate) > 0);
        }
示例#20
0
        public virtual void TestGetValueGeneratesDifferentStringsForDifferentTimeZones()
        {
            PlatformDate calendar    = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            string       gmtSixValue = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetValueForTest(calendar
                                                                                                                                         , CreateFormatContextWithTimeZone(TimeZoneUtil.GetTimeZone("GMT-6")), null);
            string gmtFiveValue = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetValueForTest(calendar
                                                                                                                                    , CreateFormatContextWithTimeZone(TimeZoneUtil.GetTimeZone("GMT-5")), null);

            Assert.IsFalse(StringUtils.Equals(gmtSixValue, gmtFiveValue));
        }
示例#21
0
        public virtual void TestGetValueGeneratesDifferentStringsForDifferentTimeZones()
        {
            PlatformDate date        = DateUtil.GetDate(1992, 1, 1, 0, 0, 0, 0, TimeZoneUtil.GetTimeZone("Canada/Ontario"));
            string       gmtSixValue = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetValueForTest(date, CreateFormatContextWithTimeZone
                                                                                                                                     (TimeZoneUtil.GetTimeZone("Canada/Saskatchewan")), null);
            string gmtFiveValue = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetValueForTest(date, CreateFormatContextWithTimeZone
                                                                                                                                (TimeZoneUtil.GetTimeZone("Canada/Ontario")), null);

            Assert.IsFalse(StringUtils.Equals(gmtSixValue, gmtFiveValue));
        }
示例#22
0
        private void AppendUseablePeriod(StringBuilder buffer, PlatformDate date, SetOperator @operator, int indentLevel, FormatContext
                                         outerContext)
        {
            FormatContext context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl("SXCM<TS>", "useablePeriod"
                                                                                                              , outerContext);
            MbDate mbDate = (date == null ? null : new MbDate(date));
            TS_R2  tsAny  = new TS_R2Impl(mbDate, @operator);

            buffer.Append(this.tsFormatter.Format(context, tsAny, indentLevel));
        }
示例#23
0
        public virtual void TestTs()
        {
            PlatformDate     date            = DateUtil.GetDate(2003, 2, 27);
            DateWithPattern  dateWithPattern = new DateWithPattern(date, "yyyyMMdd");
            ANYImpl <object> tsImpl          = new ANYImpl <object>(new MbDate(dateWithPattern), null, StandardDataType.TS);
            string           result          = new AnyR2PropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                       (this.result, null, "name", "ANY", null, null, false, SpecificationVersion.R02_04_02, null, null, null, false), tsImpl,
                                                                                   0);

            AssertXml("result", "<name value=\"20030327\" xsi:type=\"TS\"/>", result);
        }
示例#24
0
        public virtual void TestParseValidValueAttribute()
        {
            PlatformDate calendar = DateUtil.GetDate(1999, 2, 3, 9, 11, 10, 867);

            AssertValidValueAttribute(calendar, "19990303091110.867");
            AssertValidValueAttribute(DateUtil.GetDate(1999, 2, 3, 9, 11, 10, 0), "19990303091110");
            AssertValidValueAttribute(DateUtil.GetDate(1999, 2, 3, 9, 11, 0, 0), "199903030911");
            AssertValidValueAttribute(DateUtil.GetDate(1999, 2, 3, 18, 11, 0, 0), "199903031811");
            AssertValidValueAttribute(DateUtil.GetDate(1999, 2, 3, 9, 0, 0, 0), "1999030309");
            AssertValidValueAttribute(DateUtil.GetDate(1999, 2, 3, 0, 0, 0, 0), "19990303");
        }
示例#25
0
        public virtual void DateShouldBeAffectedByDateTimeZone()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 24, 23, 0, 0, 0, TimeZoneUtil.GetTimeZone("America/New_York"));
            string       value          = "20080625";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" specializationType=\"TS.FULLDATE\" />");
            ParseContext context        = ParseContextImpl.Create("TS.FULLDATE", typeof(PlatformDate), SpecificationVersion.R02_04_02, TimeZoneUtil
                                                                  .GetTimeZone("GMT-3"), null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, null, null, false);
            PlatformDate date = (PlatformDate) new TsElementParser().Parse(context, node, this.xmlResult).BareValue;

            AssertDateEquals("should not be different even though different time zone", MarshallingTestCase.FULL_DATE, expectedResult
                             , date);
        }
示例#26
0
        public virtual void TestParseValidFullDateTimeSpecificationTypeForAbstractFullDateWithTime()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 14, 16, 10, 0);
            string       value          = "20080625141610" + GetCurrentTimeZone(expectedResult);
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" specializationType=\"TS.FULLDATETIME\" />");
            ParseContext context        = ParseContextImpl.Create("TS.FULLDATEWITHTIME", typeof(PlatformDate), SpecificationVersion.R02_04_02
                                                                  , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, false);

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE_TIME, expectedResult, (PlatformDate)(new
                                                                                                                                   TsElementParser()).Parse(context, node, this.xmlResult).BareValue);
            Assert.IsTrue(this.xmlResult.GetHl7Errors().IsEmpty(), "no errors");
        }
示例#27
0
        public virtual void TestParseFullDatePartTimeWithMissingTimezoneForCeRx()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 14, 16, 00, 0);
            string       value          = "200806251416";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            ParseContext context        = ParseContextImpl.Create("TS.FULLDATEPARTTIME", typeof(PlatformDate), SpecificationVersion.V01R04_3
                                                                  , null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, null, false);

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE_TIME, expectedResult, (PlatformDate)(new
                                                                                                                                   TsElementParser()).Parse(context, node, this.xmlResult).BareValue);
            Assert.AreEqual(0, this.xmlResult.GetHl7Errors().Count, "no timezone missing error");
        }
示例#28
0
        public virtual void TestParseValidValueAttributeWithTimeZonePlusHasCorrectDatePattern()
        {
            PlatformDate calendar = DateUtil.GetDate(2008, 2, 31, 10, 58, 57, 862, TimeZoneUtil.GetTimeZone("America/New_York"));
            string       value    = "20080331155857.8620+0100";

            AssertValidValueAttribute(calendar, value);
            XmlNode      node       = CreateNode("<something value=\"" + value + "\" />");
            PlatformDate parsedDate = (PlatformDate)(new TsElementParser()).Parse(CreateContext(), node, this.xmlResult).BareValue;

            Assert.IsTrue(parsedDate is DateWithPattern, "is messagebuilder date");
            Assert.AreEqual("yyyyMMddHHmmss.SSS0ZZZZZ", ((DateWithPattern)parsedDate).DatePattern, "correct date pattern");
        }
示例#29
0
        public virtual void TestParseLowFullDateTime()
        {
            PlatformDate            expectedResultlow = DateUtil.GetDate(2005, 7, 10, 23, 3, 27, 0, TimeZoneUtil.GetTimeZone("America/Toronto"));
            XmlNode                 node     = CreateNode("<effectiveTime><low value=\"20050810230327\" /></effectiveTime>");
            Interval <PlatformDate> interval = Parse(node, "IVL<TS>");

            Assert.IsNotNull(interval, "null");
            AssertDateEquals("low", MarshallingTestCase.FULL_DATE_TIME, expectedResultlow, interval.Low);
            Assert.IsNull(interval.High, "high");
            Assert.IsNull(interval.Centre, "centre");
            Assert.IsNull(interval.Width, "width");
        }
示例#30
0
        public virtual void TestParseDate()
        {
            PlatformDate expectedResult = DateUtil.GetDate(2008, 5, 25, 0, 0, 0, 0);
            string       value          = "20080625";
            XmlNode      node           = CreateNode("<something value=\"" + value + "\" />");
            ParseContext context        = ParseContextImpl.Create("TS", typeof(PlatformDate), SpecificationVersion.R02_04_02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel
                                                                  .POPULATED, null, null, false);
            MbDate mbDate = (MbDate) new TsR2ElementParser().Parse(context, node, this.xmlResult).BareValue;

            AssertDateEquals("correct value returned " + value, MarshallingTestCase.FULL_DATE, expectedResult, mbDate.Value);
            Assert.IsTrue(this.xmlResult.IsValid());
        }