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); }
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); }
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); }
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); }
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); }
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"); }
public virtual void TestTs() { ModelToXmlResult result = new ModelToXmlResult(); PlatformDate date = DateUtil.GetDate(2012, 4, 3); DateWithPattern dateWithPattern = new DateWithPattern(date, "yyyyMMdd"); BareANY dataType = new TSCDAR1Impl(new MbDate(dateWithPattern)); FormatContext formatContext = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(result, string.Empty , "date", "TSCDAR1", 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()); Assert.AreEqual("<date value=\"20120503\"/>", xml.Trim()); }
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"); }
public virtual void TestDateFormatPrecedence() { VersionNumber version = SpecificationVersion.V02R02_AB; Runtime.ClearProperty(TsFullDateTimePropertyFormatter.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(); TsFullDateTimePropertyFormatter formatter = new TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter (); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, version), "Should use default format if nothing else provided"); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, SpecificationVersion.V01R04_3), "Should use old default format if nothing else provided and version is CeRx" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, SpecificationVersion.V01R04_2_SK), "Should use old default format if nothing else provided and version is SK CeRx" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, NEWFOUNDLAND_LEGACY_VERSION_HACK), "Should NOW use default format if nothing else provided and version is NFLD" ); Runtime.SetProperty(TsFullDateTimePropertyFormatter.DATE_FORMAT_OVERRIDE_BASE_PROPERTY_NAME + version.VersionLiteral, overridePattern ); Assert.AreEqual(overridePattern, formatter.DetermineDateFormat(StandardDataType.TS_FULLDATETIME, normalDate, version), "Should use override format when provided" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, SpecificationVersion.V02R02), "Should not use override format when provided version is only the base version of provided version" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, SpecificationVersion.V01R04_3), "Should not use override format when provided version does not match" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, SpecificationVersion.V01R04_2_SK), "Should not use override format when provided version does not match" ); Assert.AreEqual(TsFullDateTimePropertyFormatter.DATE_FORMAT_YYYYMMDDHHMMSS_SSSZZZZZ, formatter.DetermineDateFormat(StandardDataType .TS_FULLDATETIME, normalDate, NEWFOUNDLAND_LEGACY_VERSION_HACK), "Should not use override format when provided version does not match" ); Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(StandardDataType.TS_FULLDATETIME, dateWithPattern, version), "Should use date with pattern always when provided"); Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(StandardDataType.TS_FULLDATETIME, dateWithPattern, SpecificationVersion.V01R04_3), "Should use date with pattern always when provided even if version is CeRx"); Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(StandardDataType.TS_FULLDATETIME, dateWithPattern, SpecificationVersion.V01R04_2_SK), "Should use date with pattern always when provided even if version is SK CeRx"); Assert.AreEqual(dateWithPatternPattern, formatter.DetermineDateFormat(StandardDataType.TS_FULLDATETIME, dateWithPattern, NEWFOUNDLAND_LEGACY_VERSION_HACK), "Should use date with pattern always when provided even if version is NFLD"); Runtime.ClearProperty(TsFullDateTimePropertyFormatter.DATE_FORMAT_OVERRIDE_BASE_PROPERTY_NAME + version.VersionLiteral); }
public virtual void TestGetAttributeNameValuePairsInvalidDatePattern() { // 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, "yyyyMMMdd"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATE", null, null , false, SpecificationVersion.R02_04_02, null, null, null, false), dateWithInvalidPattern, null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("1999Apr23", result.SafeGet("value"), "value as expected (even though invalid)"); Assert.AreEqual(1, xmlResult.GetHl7Errors().Count); }
public virtual void TestFormatValueNonNullWithValidTime() { PlatformDate lowDate = new DateWithPattern(DateUtil.GetDate(2006, 11, 25), "yyyyMMdd"); PlatformDate highDate = new DateWithPattern(DateUtil.GetDate(2014, 3, 12), "yyyyMMdd"); Interval <PlatformDate> validTime = IntervalFactory.CreateLowHigh(lowDate, highDate); EnR2PropertyFormatter formatter = new EnR2PropertyFormatter(); TrivialName trivialName = new TrivialName("something"); trivialName.ValidTime = validTime; string result = formatter.Format(GetContext("name", "TN"), new TNImpl(trivialName)); Assert.IsTrue(this.result.IsValid()); AssertXml("something in text node", "<name>something<validTime><low value=\"20061225\"/><high value=\"20140412\"/></validTime></name>" , result, true); }
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); }
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()); }
public virtual void TestBasicPartTime() { TimeZoneInfo timeZone = TimeZoneUtil.GetTimeZone("America/Toronto"); PlatformDate lowDate = new DateWithPattern(DateUtil.GetDate(2006, 11, 25, 11, 12, 13, 0, timeZone), "yyyyMMddHHZZZZZ"); PlatformDate highDate = new DateWithPattern(DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone), "yyyyMMddHHZZZZZ"); Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(lowDate, highDate); DateInterval dateInterval = new DateInterval(interval); IVL_TSImpl hl7DataType = new IVL_TSImpl(dateInterval); hl7DataType.DataType = StandardDataType.IVL_TS; string result = new IvlTsR2PropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "name", "IVL<TS>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, false, SpecificationVersion .V02R02, timeZone, timeZone, null, false), hl7DataType); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name><low value=\"2006122511-0500\"/><high value=\"2007010210-0500\"/></name>", result); }
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 TsFullDateTimePropertyFormatterTest.TestableTsFullDateTimePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATETIME", null, null, false, SpecificationVersion.V01R04_3, null, null, null, false), 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()); }
public virtual void TestGetAttributeNameValuePairsUsingPartTimePattern() { // 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, "yyyyMM"); 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(dateWithInvalidPattern), null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); string expectedValue = "199904"; Assert.AreEqual(expectedValue, result.SafeGet("value"), "value as expected"); Assert.IsTrue(xmlResult.IsValid()); }
public virtual void TestGetAttributeNameValuePairsForDateWithPattern() { // 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, "yyyyMM"); // note that a Date and a DateWithPattern only work for equals() because the // Java implementation we are using uses "instanceof" instead of "getClass()" for its preliminary comparison Assert.AreEqual(calendar, dateWithPattern, "same dates should be equal"); ModelToXmlResult xmlResult = new ModelToXmlResult(); IDictionary <string, string> result = new TsFullDatePropertyFormatterTest.TestableTsFullDatePropertyFormatter().GetAttributeNameValuePairsForTest (new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(xmlResult, null, "name", "TS.DATE", null, null , false, SpecificationVersion.R02_04_02, null, null, null, false), dateWithPattern, null); Assert.AreEqual(1, result.Count, "map size"); Assert.IsTrue(result.ContainsKey("value"), "key as expected"); Assert.AreEqual("199904", result.SafeGet("value"), "value as expected"); Assert.IsTrue(xmlResult.GetHl7Errors().IsEmpty()); }
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); }