public virtual void TestParseValidFull() { TimeZoneInfo timeZone = TimeZoneUtil.GetTimeZone("America/Toronto"); Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate(2006, 11, 25, 11, 12, 13, 0, timeZone), DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone)); XmlNode node = CreateNode("<something code=\"FRED\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\">" + " <originalText>some original text</originalText>" + " <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />" + " <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />" + " <validTime><low value=\"20061225121213.0000-0400\"/><high value=\"20070102111112.0000-0400\"/></validTime>" + "</something>"); HXIT <MockCharacters> ce = (HXIT <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("HXIT<CE>", typeof(MockCharacters ), SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult); Assert.IsTrue(this.xmlResult.IsValid(), "valid"); Assert.AreEqual(MockEnum.FRED, ce.Value.Code, "enum found properly"); Assert.AreEqual("aCsName", ce.Value.CodeSystemName); Assert.AreEqual("aCsVersion", ce.Value.CodeSystemVersion); Assert.AreEqual("aDisplayName", ce.Value.DisplayName); Assert.AreEqual("some original text", ce.Value.OriginalText.Content); Assert.AreEqual(2, ce.Value.Translation.Count); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeValue, ce.Value.Translation[0 ].Code.CodeValue); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeSystem, ce.Value.Translation[ 0].Code.CodeSystem); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeValue, ce.Value.Translation [1].Code.CodeValue); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, ce.Value.Translation [1].Code.CodeSystem); Assert.AreEqual(interval.Low, ce.Value.ValidTime.Low); Assert.AreEqual(interval.High, ce.Value.ValidTime.High); }
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); }
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)); }
public virtual void TestBasic() { Interval <Int32?> ivl = IntervalFactory.CreateLowHigh <Int32?>(1, 3); string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <Int32?>, Interval <Int32?> >(ivl)); AssertXml("result", "<name><low value=\"1\"/><high value=\"3\"/></name>", result); }
public virtual void TestValidFull() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(new DateWithPattern(DateUtil.GetDate(2006, 11, 25), "yyyyMMdd"), new DateWithPattern(DateUtil.GetDate(2007, 0, 2), "yyyyMMdd")); CodedTypeR2 <Code> translation1 = new CodedTypeR2 <Code>(); translation1.Code = CeRxDomainTestValues.KILOGRAM; CodedTypeR2 <Code> translation2 = new CodedTypeR2 <Code>(); translation2.Code = CeRxDomainTestValues.FLUID_OUNCE; CodedTypeR2 <Code> codedType = new CodedTypeR2 <Code>(); codedType.Code = CeRxDomainTestValues.CENTIMETRE; codedType.CodeSystemName = "aCodeSystemName"; codedType.CodeSystemVersion = "aCodeSystemVersion"; codedType.DisplayName = "aDisplayName"; codedType.Translation.Add(translation1); codedType.Translation.Add(translation2); codedType.ValidTime = interval; EncapsulatedData originalText = new EncapsulatedData(); originalText.Content = "some original text"; codedType.OriginalText = originalText; string result = new HxitCeR2PropertyFormatter().Format(GetContext("name", "HXIT<CE>"), new CE_R2Impl <Code>(codedType)); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name code=\"cm\" codeSystem=\"1.2.3.4\" codeSystemName=\"aCodeSystemName\" codeSystemVersion=\"aCodeSystemVersion\" displayName=\"aDisplayName\">" + "<originalText>some original text</originalText>" + "<translation code=\"kg\" codeSystem=\"1.2.3.4\"/>" + "<translation code=\"[foz_br]\" codeSystem=\"1.2.3.4\"/>" + "<validTime><low value=\"20061225\"/><high value=\"20070102\"/></validTime>" + "</name>", StringUtils.Trim(result), true ); }
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 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 TestBasic() { Interval <PhysicalQuantity> interval = IntervalFactory.CreateLowHigh <PhysicalQuantity>(PHYSICAL_QUANTITY_LOW, PHYSICAL_QUANTITY_HIGH ); string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PhysicalQuantity>, Interval <PhysicalQuantity> >( interval)); AssertXml("result", "<name><low unit=\"mL\" value=\"1000\"/><high unit=\"mL\" value=\"2000\"/></name>", result); }
public virtual void TestBasicWithInclusive() { Interval <Int32?> ivl = IntervalFactory.CreateLowHigh <Int32?>(1, 3); ivl.LowInclusive = true; ivl.HighInclusive = false; string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <Int32?>, Interval <Int32?> >(ivl)); AssertXml("result", "<name><low inclusive=\"true\" value=\"1\"/><high inclusive=\"false\" value=\"3\"/></name>", result); }
public virtual void TestBasic() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(ParseDate("2006-12-25"), ParseDate("2007-01-02" )); string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval )); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name><low value=\"20061225\"/><high value=\"20070102\"/></name>", result); }
public virtual void TestIntervalLowHighWithNullFlavor() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(ParseDate("2007-02-20T15:34:22"), null, null , Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.MASKED); string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval )); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name><low value=\"20070220\"/><high nullFlavor=\"MSK\"/></name>", result); }
public virtual void TestIntervalLowHighWithInvalidNullFlavor2() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(ParseDate("2007-02-20T15:34:22"), null, null , Ca.Infoway.Messagebuilder.Domainvalue.Nullflavor.NullFlavor.NEGATIVE_INFINITY); string result = this.formatter.Format(GetContext("name"), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval )); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); AssertXml("result", "<name><low value=\"20070220\"/><high nullFlavor=\"NINF\"/></name>", result); }
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()); }
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()); }
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()); }
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()); }
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 TestEivlTsFull() { PhysicalQuantity low = new PhysicalQuantity(new BigDecimal("120"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CENTIMETRE); PhysicalQuantity high = new PhysicalQuantity(new BigDecimal("170"), Ca.Infoway.Messagebuilder.Domainvalue.Basic.UnitsOfMeasureCaseSensitive .CENTIMETRE); Interval <PhysicalQuantity> ivl = IntervalFactory.CreateLowHigh(low, high); TimingEvent timingEvent = Ca.Infoway.Messagebuilder.Domainvalue.Basic.TimingEvent.ACM; EventRelatedPeriodicIntervalTime @event = new EventRelatedPeriodicIntervalTime(ivl, timingEvent); string result = new EivlTsR2PropertyFormatter().Format(CreateContext("EIVL<TS>"), new EIVLImpl <EventRelatedPeriodicIntervalTime >(@event)); Assert.IsTrue(this.result.IsValid()); AssertXml("xml output", "<eventRelatedPeriod><event code=\"ACM\" codeSystem=\"2.16.840.1.113883.5.139\" codeSystemName=\"TimingEvent\" displayName=\"Acm\"/><offset><low unit=\"cm\" value=\"120\"/><high unit=\"cm\" value=\"170\"/></offset></eventRelatedPeriod>" , result, true); }
public virtual void TestBasicAbstract() { Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(ParseDate("2006-12-25"), ParseDate("2007-01-02" )); IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > hl7DataType = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval ); hl7DataType.DataType = StandardDataType.IVL_FULL_DATE; string result = this.formatter.Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(this.result , null, "name", "IVL<TS.FULLDATEWITHTIME>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, false, SpecificationVersion .R02_04_03, null, null, null, false), hl7DataType); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name specializationType=\"IVL_TS.FULLDATE\" xsi:type=\"IVL_TS\"><low value=\"20061225\"/><high value=\"20070102\"/></name>" , result); }
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 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 TestBasicAbstract() { TimeZoneInfo timeZone = TimeZoneUtil.GetTimeZone("America/Toronto"); Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate(2006, 11, 25, 11, 12, 13, 0, timeZone), DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone)); IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> > hl7DataType = new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval ); hl7DataType.DataType = StandardDataType.IVL_FULL_DATE_TIME; string result = new IvlTsPropertyFormatter().Format(new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl (this.result, null, "name", "IVL<TS.FULLDATEWITHTIME>", Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.POPULATED, null, false, SpecificationVersion.V02R02, timeZone, timeZone, null, false), hl7DataType); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name specializationType=\"IVL_TS.FULLDATETIME\" xsi:type=\"IVL_TS\"><low value=\"20061225111213.0000-0500\"/><high value=\"20070102101112.0000-0500\"/></name>" , result); }
public virtual void TestParseFull() { TimeZoneInfo timeZone = TimeZoneUtil.GetTimeZone("America/Toronto"); Interval <PlatformDate> interval = IntervalFactory.CreateLowHigh <PlatformDate>(DateUtil.GetDate(2006, 11, 25, 11, 12, 13, 0, timeZone), DateUtil.GetDate(2007, 0, 2, 10, 11, 12, 0, timeZone)); XmlNode node = CreateNode("<something code=\"BARNEY\" codeSystem=\"1.2.3.4.5\" codeSystemName=\"aCsName\" codeSystemVersion=\"aCsVersion\" displayName=\"aDisplayName\" value=\"1.2\" operator=\"P\">" + " some freeform text" + " <originalText>some original text</originalText>" + " <qualifier inverted=\"true\"><name code=\"cm\" codeSystem=\"1.2.3.4\"/><value code=\"normal\" codeSystem=\"2.16.840.1.113883.5.14\"/></qualifier>" + " <qualifier inverted=\"true\"><name code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\"/><value code=\"ACT\" codeSystem=\"2.16.840.1.113883.5.6\"/></qualifier>" + " <translation code=\"M\" codeSystem=\"2.16.840.1.113883.5.1\" />" + " <translation code=\"F\" codeSystem=\"2.16.840.1.113883.5.1\" />" + " <validTime><low value=\"20061225121213.0000-0400\"/><high value=\"20070102111112.0000-0400\"/></validTime>" + "</something>" ); HXIT <MockCharacters> ce = (HXIT <MockCharacters>) this.parser.Parse(ParseContextImpl.Create("HXIT<CE>", typeof(MockCharacters ), SpecificationVersion.V02R02, null, null, Ca.Infoway.Messagebuilder.Xml.ConformanceLevel.OPTIONAL, null, null, false), node, this.xmlResult); Assert.IsFalse(this.xmlResult.IsValid()); Assert.AreEqual(4, this.xmlResult.GetHl7Errors().Count, "error message count"); Assert.IsNotNull(ce.Value, "main enum found"); Assert.AreEqual("BARNEY", ce.Value.GetCodeValue(), "main code"); Assert.AreEqual("1.2.3.4.5", ce.Value.GetCodeSystem(), "main code"); Assert.AreEqual("aCsName", ce.Value.CodeSystemName); Assert.AreEqual("aCsVersion", ce.Value.CodeSystemVersion); Assert.AreEqual("aDisplayName", ce.Value.DisplayName); Assert.IsNull(ce.Value.Operator); Assert.IsNull(ce.Value.Value); Assert.IsNull(ce.Value.SimpleValue); Assert.AreEqual("some original text", ce.Value.OriginalText.Content); Assert.AreEqual(2, ce.Value.Translation.Count); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeValue, ce.Value.Translation[0 ].Code.CodeValue); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.MALE.CodeSystem, ce.Value.Translation[ 0].Code.CodeSystem); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeValue, ce.Value.Translation [1].Code.CodeValue); Assert.AreEqual(Ca.Infoway.Messagebuilder.Domainvalue.Payload.AdministrativeGender.FEMALE.CodeSystem, ce.Value.Translation [1].Code.CodeSystem); Assert.AreEqual(0, ce.Value.Qualifier.Count); Assert.AreEqual(interval.Low, ce.Value.ValidTime.Low); Assert.AreEqual(interval.High, ce.Value.ValidTime.High); }
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); }
public virtual BareANY Adapt(string toDataTypeName, BareANY any) { return(new DataTypeAdapterHelper().CopyAndReturnAdapted(any, (BareANY) new IVLImpl <TS, Interval <PlatformDate> >(), any.BareValue != null ? IntervalFactory.CreateLowHigh <PlatformDate>((PlatformDate)any.BareValue, (PlatformDate)any.BareValue) : null)); }
protected override Interval <T> ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType , XmlToModelResult xmlToModelResult) { Interval <T> result = null; XmlElement low = (XmlElement)GetNamedChildNode(node, "low"); XmlElement high = (XmlElement)GetNamedChildNode(node, "high"); XmlElement center = (XmlElement)GetNamedChildNode(node, "center"); XmlElement width = (XmlElement)GetNamedChildNode(node, "width"); ValidateCorrectElementsProvided(low != null, high != null, center != null, width != null, (XmlElement)node, context, xmlToModelResult ); BareANY lowAny = low == null ? null : CreateType(context, low, xmlToModelResult, false); object lowType = ExtractValue(lowAny); Boolean? lowInclusive = ExtractInclusive(context, low, xmlToModelResult); BareANY highAny = high == null ? null : CreateType(context, high, xmlToModelResult, false); object highType = ExtractValue(highAny); Boolean? highInclusive = ExtractInclusive(context, high, xmlToModelResult); BareANY centerAny = center == null ? null : CreateType(context, center, xmlToModelResult, false); object centerType = ExtractValue(centerAny); BareDiff widthType = width == null ? null : CreateDiffType(context, width, xmlToModelResult); if (lowAny != null && highAny != null) { result = IntervalFactory.CreateLowHigh <T>((T)lowType, (T)highType, lowAny.NullFlavor, highAny.NullFlavor); } else { if (lowAny != null && widthType != null) { result = IntervalFactory.CreateLowWidth <T>((T)lowType, (Diff <T>)widthType, lowAny.NullFlavor); } else { if (highAny != null && widthType != null) { result = IntervalFactory.CreateWidthHigh <T>((Diff <T>)widthType, (T)highType, highAny.NullFlavor); } else { if (centerAny != null && widthType != null) { result = IntervalFactory.CreateCentreWidth <T>((T)centerType, (Diff <T>)widthType, centerAny.NullFlavor); } else { if (centerAny != null && lowAny != null) { result = IntervalFactory.CreateLowCentre <T>((T)lowType, (T)centerType, lowAny.NullFlavor, centerAny.NullFlavor); } else { if (centerAny != null && highAny != null) { result = IntervalFactory.CreateCentreHigh <T>((T)centerType, (T)highType, centerAny.NullFlavor, highAny.NullFlavor); } else { if (lowAny != null) { result = IntervalFactory.CreateLow <T>((T)lowType, lowAny.NullFlavor); } else { if (highAny != null) { result = IntervalFactory.CreateHigh <T>((T)highType, highAny.NullFlavor); } else { if (centerAny != null) { result = IntervalFactory.CreateCentre <T>((T)centerType, centerAny.NullFlavor); } else { if (widthType != null) { result = IntervalFactory.CreateWidth <T>((Diff <T>)widthType); } else { if (low == null && high == null && center == null && width == null) { // only treat this as a "simple" interval if no other interval elements were provided (even if they were in error) // try to parse a "simple" interval BareANY simpleAny = CreateType(context, (XmlElement)node, xmlToModelResult, true); object type = ExtractValue(simpleAny); if (type == null) { xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.SYNTAX_ERROR, "\"Simple interval node: " + XmlDescriber.DescribePath (node) + " does not allow a null value\"", (XmlElement)node)); } else { result = IntervalFactory.CreateSimple <T>((T)type, ((ANYMetaData)simpleAny).Operator); } } } } } } } } } } } } if (result != null) { result.LowInclusive = lowInclusive; result.HighInclusive = highInclusive; } return(result); }
protected override Interval <T> ParseNonNullNode(ParseContext context, XmlNode node, BareANY parseResult, Type expectedReturnType , XmlToModelResult xmlToModelResult) { // go back and revert TS.FULLDATEWITHTIME validation check? (is there anything to revert?) context = HandleSpecializationType(context, node, xmlToModelResult); Interval <T> result = null; XmlElement low = (XmlElement)GetNamedChildNode(node, "low"); XmlElement high = (XmlElement)GetNamedChildNode(node, "high"); XmlElement center = (XmlElement)GetNamedChildNode(node, "center"); XmlElement width = (XmlElement)GetNamedChildNode(node, "width"); ValidateCorrectElementsProvided(low != null, high != null, center != null, width != null, (XmlElement)node, context, xmlToModelResult ); BareANY lowAny = low == null ? null : CreateType(context, low, xmlToModelResult); object lowType = lowAny == null ? null : lowAny.BareValue; BareANY highAny = high == null ? null : CreateType(context, high, xmlToModelResult); object highType = highAny == null ? null : highAny.BareValue; BareANY centerAny = center == null ? null : CreateType(context, center, xmlToModelResult); object centerType = centerAny == null ? null : centerAny.BareValue; BareDiff widthType = width == null ? null : CreateDiffType(context, width, xmlToModelResult); DoOtherValidations(lowAny, highAny, centerAny, widthType, (XmlElement)node, context, xmlToModelResult); if (lowAny != null && highAny != null) { result = IntervalFactory.CreateLowHigh <T>((T)lowType, (T)highType, lowAny.NullFlavor, highAny.NullFlavor); } else { if (lowAny != null && widthType != null) { result = IntervalFactory.CreateLowWidth <T>((T)lowType, (Diff <T>)widthType, lowAny.NullFlavor); } else { if (highAny != null && widthType != null) { result = IntervalFactory.CreateWidthHigh <T>((Diff <T>)widthType, (T)highType, highAny.NullFlavor); } else { if (centerAny != null && widthType != null) { result = IntervalFactory.CreateCentreWidth <T>((T)centerType, (Diff <T>)widthType, centerAny.NullFlavor); } else { if (centerAny != null && lowAny != null) { result = IntervalFactory.CreateLowCentre <T>((T)lowType, (T)centerType, lowAny.NullFlavor, centerAny.NullFlavor); } else { if (centerAny != null && highAny != null) { result = IntervalFactory.CreateCentreHigh <T>((T)centerType, (T)highType, centerAny.NullFlavor, highAny.NullFlavor); } else { if (lowAny != null) { result = IntervalFactory.CreateLow <T>((T)lowType, lowAny.NullFlavor); } else { if (highAny != null) { result = IntervalFactory.CreateHigh <T>((T)highType, highAny.NullFlavor); } else { if (centerAny != null) { result = IntervalFactory.CreateCentre <T>((T)centerType, centerAny.NullFlavor); } else { if (widthType != null) { result = IntervalFactory.CreateWidth <T>((Diff <T>)widthType); } else { if (low == null && high == null && center == null && width == null) { // only treat this as a "simple" interval if no other interval elements were provided (even if they were in error) // try to parse a "simple" interval; this does not seem a valid approach for MR2009, MR2007, or CeRx (perhaps allowed within the XSDs?) object type = CreateType(context, (XmlElement)node, xmlToModelResult).BareValue; if (type == null) { xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.SYNTAX_ERROR, "\"Simple interval node: " + XmlDescriber.DescribePath (node) + " does not allow a null value\"", (XmlElement)node)); } else { result = IntervalFactory.CreateSimple <T>((T)type); } } } } } } } } } } } } return(result); }