public virtual void TestIntervalHigh() { Interval <PlatformDate> interval = IntervalFactory.CreateHigh <PlatformDate>(ParseDate("2006-12-25")); string result = this.formatter.Format(GetContext("name", "IVL.HIGH<TS.FULLDATE>", SpecificationVersion.R02_04_03), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval)); Assert.IsTrue(this.result.IsValid()); AssertXml("result", "<name><high value=\"20061225\"/></name>", result); }
public virtual void TestInvalidIntervalHigh() { Interval <PlatformDate> interval = IntervalFactory.CreateHigh <PlatformDate>(ParseDate("2006-12-25")); string result = this.formatter.Format(GetContext("name", "IVL.WIDTH<TS.FULLDATE>", SpecificationVersion.R02_04_02), new IVLImpl <QTY <PlatformDate>, Interval <PlatformDate> >(interval)); Assert.IsFalse(this.result.IsValid()); Assert.AreEqual(2, this.result.GetHl7Errors().Count); // high invalid; must supply width AssertXml("result", "<name><high value=\"20061225\"/></name>", 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); }
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); }