private FormatContext ValidateInterval(Interval <T> value, BareANY bareAny, FormatContext context) { string type = context.Type; IList <string> errors = new List <string>(); string specializationType = bareAny.DataType == null ? null : bareAny.DataType.Type; string newType = this.ivlValidationUtils.ValidateSpecializationType(type, specializationType, errors); RecordAnyErrors(errors, context); if (!StringUtils.Equals(type, newType)) { // replace the context with one using the specialization type context = new Ca.Infoway.Messagebuilder.Marshalling.HL7.Formatter.FormatContextImpl(newType, true, context); } bool lowProvided = RepresentationUtil.HasLow(value.Representation) && (value.Low != null || value.LowNullFlavor != null); bool highProvided = RepresentationUtil.HasHigh(value.Representation) && (value.High != null || value.HighNullFlavor != null ); bool centerProvided = RepresentationUtil.HasCentre(value.Representation) && (value.Centre != null || value.CentreNullFlavor != null); bool widthProvided = RepresentationUtil.HasWidth(value.Representation) && (value.Width != null && (value.Width.Value != null || value.Width.NullFlavor != null)); errors = this.ivlValidationUtils.ValidateCorrectElementsProvided(type, context.GetVersion(), lowProvided, highProvided, centerProvided , widthProvided); RecordAnyErrors(errors, context); errors = this.ivlValidationUtils.DoOtherValidations(type, lowProvided ? value.LowNullFlavor : null, centerProvided ? value .CentreNullFlavor : null, highProvided ? value.HighNullFlavor : null, widthProvided ? value.Width.NullFlavor : null, (widthProvided && value.Width is DateDiff) ? (DateDiff.ConvertDiff(value.Width)).Unit : null); RecordAnyErrors(errors, context); return(context); }
private FormatContext ValidateInterval(Interval <T> value, BareANY bareAny, FormatContext context) { bool lowProvided = RepresentationUtil.HasLow(value.Representation) && (value.Low != null || value.LowNullFlavor != null); bool highProvided = RepresentationUtil.HasHigh(value.Representation) && (value.High != null || value.HighNullFlavor != null ); bool centerProvided = RepresentationUtil.HasCentre(value.Representation) && (value.Centre != null || value.CentreNullFlavor != null); bool widthProvided = RepresentationUtil.HasWidth(value.Representation) && (value.Width != null && (value.Width.Value != null || value.Width.NullFlavor != null)); IList <string> errors = this.ivlValidationUtils.ValidateCorrectElementsProvidedForR2(lowProvided, highProvided, centerProvided , widthProvided); RecordAnyErrors(errors, context); return(context); }
private void AppendIntervalBounds(FormatContext context, Interval <T> value, StringBuilder buffer, int indentLevel) { Representation rep = value.Representation; string low = RepresentationUtil.HasLow(rep) ? CreateElement(context, IvlPropertyFormatter <T> .LOW, CreateQTY(value.Low, value .LowNullFlavor), indentLevel) : null; string high = RepresentationUtil.HasHigh(rep) ? CreateElement(context, IvlPropertyFormatter <T> .HIGH, CreateQTY(value.High , value.HighNullFlavor), indentLevel) : null; string centre = RepresentationUtil.HasCentre(rep) ? CreateElement(context, IvlPropertyFormatter <T> .CENTRE, CreateQTY(value .Centre, value.CentreNullFlavor), indentLevel) : null; string width = RepresentationUtil.HasWidth(rep) ? CreateWidthElement(context, IvlPropertyFormatter <T> .WIDTH, value.Width, indentLevel) : null; switch (rep) { case Representation.LOW_HIGH: { buffer.Append(low); buffer.Append(high); break; } case Representation.CENTRE: { buffer.Append(centre); break; } case Representation.HIGH: { buffer.Append(high); break; } case Representation.LOW: { buffer.Append(low); break; } case Representation.WIDTH: { buffer.Append(width); break; } case Representation.LOW_WIDTH: { buffer.Append(low); buffer.Append(width); break; } case Representation.LOW_CENTER: { buffer.Append(low); buffer.Append(centre); break; } case Representation.WIDTH_HIGH: { buffer.Append(width); buffer.Append(high); break; } case Representation.CENTRE_WIDTH: { buffer.Append(centre); buffer.Append(width); break; } case Representation.CENTRE_HIGH: { buffer.Append(centre); buffer.Append(high); break; } default: { break; } } }