Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public virtual void TestGetValueGeneratesDifferentStringsForDifferentTimeZones()
        {
            PlatformDate calendar    = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            string       gmtSixValue = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetValueForTest(new MbDate(calendar),
                                                                                                                     CreateFormatContextWithTimeZone(TimeZoneUtil.GetTimeZone("GMT-6")), null);
            string gmtFiveValue = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetValueForTest(new MbDate(calendar),
                                                                                                                CreateFormatContextWithTimeZone(TimeZoneUtil.GetTimeZone("GMT-5")), null);

            Assert.IsFalse(StringUtils.Equals(gmtSixValue, gmtFiveValue));
        }
Ejemplo n.º 3
0
        public virtual void TestGetAttributeNameValuePairsNullValue()
        {
            IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null
                                                                                                                                 , null, false), null, new TS_R2Impl());

            // a null value for TS elements results in a nullFlavor attribute
            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("nullFlavor"), "key as expected");
            Assert.AreEqual(AbstractPropertyFormatter.NULL_FLAVOR_NO_INFORMATION, result.SafeGet("nullFlavor"), "value as expected");
        }
Ejemplo n.º 4
0
        public virtual void TestGetAttributeNameValuePairsDateWithMillisAndTimezone()
        {
            // used as expected: a date object is passed in
            PlatformDate calendar  = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            string       resultXml = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl
                                                                                                              (new ModelToXmlResult(), null, "name", null, null, null, false, SpecificationVersion.R02_04_02, null, null, null, false)
                                                                                                          , new TS_R2Impl(new MbDate(calendar)));
            string result = Ca.Infoway.Messagebuilder.StringUtils.Substring(resultXml, "<name value=\"".Length, resultXml.IndexOf("\"/>"
                                                                                                                                  ));

            Assert.AreEqual("yyyyMMddHHmmss.SSS0ZZZZZ".Length, result.Length, "value length as expected");
            Assert.IsTrue(result.StartsWith("19990423101112.000"), "value as expected");
        }
Ejemplo n.º 5
0
        public virtual void TestGetAttributeNameValuePairsDateWithDatePatternInformation()
        {
            // used as expected: a date object is passed in
            PlatformDate    calendar1           = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            DateWithPattern dateWithPattern     = new DateWithPattern(calendar1, "yyyyMMddHHmmss");
            IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null
                                                                                                                                 , null, false), new MbDate(dateWithPattern), null);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("19990423101112", result.SafeGet("value"), "value as expected");
        }
Ejemplo n.º 6
0
        private void HandleVersion(SpecificationVersion version, string expected, bool withTimeZone)
        {
            // used as expected: a date object is passed in
            PlatformDate calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null
                                                                                                                                 , null, false, version, null, null, null, false), new MbDate(calendar), null);

            Assert.AreEqual(1, result.Count, "map size");
            string expectedValue = withTimeZone ? expected + GetCurrentTimeZone(calendar) : expected;

            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected");
        }
Ejemplo n.º 7
0
        public virtual void TestGetAttributeNameValuePairsDateWithMillisAndTimezoneDatePatternInformation()
        {
            // used as expected: a date object is passed in
            PlatformDate    calendar            = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            DateWithPattern dateWithPattern     = new DateWithPattern(calendar, "yyyyMMddHHmmss.SSSZZZZZ");
            IDictionary <string, string> result = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                      (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(new ModelToXmlResult(), null, "name", null, null
                                                                                                                                 , null, false, SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(dateWithPattern), null);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            // SPD: hard to verify result date string since it is timezone dependent. we check length instead
            Assert.AreEqual("yyyyMMddHHmmss.SSSZZZZZ".Length, result.SafeGet("value").Length, "value length as expected");
        }
Ejemplo n.º 8
0
        public virtual void TestGetAttributeNameValuePairsValidDatePatternMissingTimezone()
        {
            // used as expected: a date object is passed in
            PlatformDate                 calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            DateWithPattern              dateWithValidPatternMissingTZ = new DateWithPattern(calendar, "yyyyMMddHH");
            ModelToXmlResult             xmlResult = new ModelToXmlResult();
            IDictionary <string, string> result    = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS", null, null, false
                                                                                                                                    , SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(dateWithValidPatternMissingTZ), null);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            Assert.AreEqual("1999042310", result.SafeGet("value"), "value as expected");
            // non-R2 formatter would complain about missing TZ; R2 schema does not explicitly state this is true
            Assert.IsTrue(xmlResult.IsValid());
        }
Ejemplo n.º 9
0
        public virtual void TestGetAttributeNameValuePairsValidDatePatternForCeRxMissingTimezone()
        {
            // used as expected: a date object is passed in
            PlatformDate                 calendar = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            DateWithPattern              dateWithInvalidPattern = new DateWithPattern(calendar, "yyyyMMddHH");
            ModelToXmlResult             xmlResult = new ModelToXmlResult();
            IDictionary <string, string> result    = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS", null, null, false
                                                                                                                                    , SpecificationVersion.V01R04_3, null, null, null, false), new MbDate(dateWithInvalidPattern), null);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            string expectedValue = "1999042310";

            Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected");
            Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty());
        }
Ejemplo n.º 10
0
        public virtual void TestSxcmGetAttributeNameValuePairsDateWithNoOperator()
        {
            // used as expected: a date object is passed in
            PlatformDate                 calendar1 = DateUtil.GetDate(1999, 3, 23, 10, 11, 12, 0);
            TS_R2                        ts        = new TS_R2Impl(new MbDate(calendar1));
            ModelToXmlResult             xmlResult = new ModelToXmlResult();
            IDictionary <string, string> result    = new TsR2PropertyFormatterTest.TestableTsR2PropertyFormatter().GetAttributeNameValuePairsForTest
                                                         (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "SXCM<TS>", null, null
                                                                                                                                    , false, SpecificationVersion.R02_04_02, null, null, null, false), new MbDate(calendar1), ts);

            Assert.AreEqual(1, result.Count, "map size");
            Assert.IsTrue(xmlResult.IsValid());
            Assert.IsTrue(result.ContainsKey("value"), "key as expected");
            string expectedValue = "19990423101112.0000" + GetCurrentTimeZone(calendar1);

            Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected");
        }