protected virtual PeriodicIntervalTime ParseFrequency(ParseContext context, XmlElement element, Type expectedReturnType, XmlToModelResult xmlToModelResult) { XmlElement numerator = (XmlElement)GetNamedChildNode(element, "numerator"); XmlElement denominator = (XmlElement)GetNamedChildNode(element, "denominator"); if (numerator != null && denominator != null) { Int32?repetitions = ParseNumerator(context, numerator, xmlToModelResult); if (SpecificationVersion.IsExactVersion(SpecificationVersion.V01R04_2_SK, context.GetVersion())) { Interval <PhysicalQuantity> quantityInterval = ParseDenominatorSk(context, denominator, xmlToModelResult); return(PeriodicIntervalTimeSk.CreateFrequencySk(repetitions, quantityInterval == null ? null : quantityInterval.Low, quantityInterval == null ? null : quantityInterval.High)); } else { PhysicalQuantity quantity = ParseDenominator(context, denominator, xmlToModelResult); return(PeriodicIntervalTime.CreateFrequency(repetitions, quantity)); } } else { if (numerator == null) { CreateMandatoryChildElementHl7Error(element, "numerator", xmlToModelResult); } if (denominator == null) { CreateMandatoryChildElementHl7Error(element, "denominator", xmlToModelResult); } return(null); } }
public virtual void TestMissingQuantitiesSk() { PeriodicIntervalTimeSk frequencySk = PeriodicIntervalTimeSk.CreateFrequencySk(2, null, null); string result = new PivlTsPropertyFormatter().Format(GetContextSk("periodicInterval", "PIVL<TS.DATETIME>"), new PIVLImpl( frequencySk)); AssertXml("result", "<periodicInterval></periodicInterval>", result); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(1, this.result.GetHl7Errors().Count); }
public virtual void TestBasicCaseForSk() { PhysicalQuantity lowQuantity = new PhysicalQuantity(new BigDecimal(1), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit .DAY); PhysicalQuantity highQuantity = new PhysicalQuantity(new BigDecimal(4), Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit .DAY); PeriodicIntervalTimeSk frequencySk = PeriodicIntervalTimeSk.CreateFrequencySk(3, lowQuantity, highQuantity); string result = new PivlTsPropertyFormatter().Format(GetContextSk("periodicInterval", "PIVL<TS.DATETIME>"), new PIVLImpl( frequencySk)); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<periodicInterval><frequency><numerator value=\"3\"/><denominator><low unit=\"d\" value=\"1\"/><high unit=\"d\" value=\"4\"/></denominator></frequency></periodicInterval>" , result); }
public virtual void TestBasicFreqAsCeRxAndSask() { GeneralTimingSpecification gts = new GeneralTimingSpecification(IntervalFactory.CreateLowWidth <PlatformDate>(DateUtil.GetDate (1969, 11, 31), new DateDiff(CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY))), PeriodicIntervalTimeSk .CreateFrequencySk(3, CreateQuantity("3", Ca.Infoway.Messagebuilder.Domainvalue.Basic.DefaultTimeUnit.DAY), CreateQuantity ("10", 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_2_SK, null, null, null, false ), new GTSImpl(gts)); AssertXml("result", "<name xsi:type=\"SXPR_TS\">" + "<comp operator=\"I\" xsi:type=\"IVL_TS\">" + "<low value=\"19691231\"/>" + "<width unit=\"d\" value=\"3\"/></comp>" + "<comp xsi:type=\"PIVL_TS\">" + "<frequency><numerator value=\"3\"/>" + "<denominator>" + "<low unit=\"d\" value=\"3\"/>" + "<high unit=\"d\" value=\"10\"/>" + "</denominator>" + "</frequency></comp></name>" , result); Assert.IsTrue(this.result.IsValid()); }