public virtual void HandleConstraints(ConstrainedDatatype constraints, EncapsulatedData ed, ErrorLogger logger) { if (ed == null || constraints == null) { return; } TelecommunicationAddress reference = ed.ReferenceObj; // ignoring any fixed value returned from reference constraints checking this.constraintsHandler.ValidateConstraint("reference", reference == null ? null : "reference", constraints, logger); // just checks if reference provided if (reference != null) { // only check this constraint if a reference has been provided (whether the reference was mandatory or not) string referenceValue = reference.ToString(); this.constraintsHandler.ValidateConstraint("reference.value", referenceValue, constraints, logger); } // checks for actual value string mediaType = ed.MediaType == null ? null : ed.MediaType.CodeValue; string newMediaType = this.constraintsHandler.ValidateConstraint("mediaType", mediaType, constraints, logger); if (!StringUtils.Equals(mediaType, newMediaType)) { x_DocumentMediaType newMediaTypeEnum = Ca.Infoway.Messagebuilder.Domainvalue.Basic.X_DocumentMediaType.Get(newMediaType); if (newMediaTypeEnum != null) { ed.MediaType = newMediaTypeEnum; } } }
private void ValidateTelecomAddressValue(TelecommunicationAddress telecomAddress, string type, VersionNumber version, XmlElement element, string propertyPath, Hl7Errors errors) { Hl7BaseVersion baseVersion = version.GetBaseVersion(); string address = telecomAddress.Address; int schemePlusAddressLength = telecomAddress.ToString().Length; if (StringUtils.IsBlank(address)) { CreateError("TelecomAddress must have a value for the actual address", element, propertyPath, errors); } else { if (StandardDataType.TEL_EMAIL.Type.Equals(type) && schemePlusAddressLength > MAX_VALUE_LENGTH_EMAIL) { CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_EMAIL, type, baseVersion, element, propertyPath, errors); } else { if (StandardDataType.TEL_URI.Type.Equals(type) && schemePlusAddressLength > MAX_VALUE_LENGTH_URI) { CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_URI, type, baseVersion, element, propertyPath, errors); } else { if (StandardDataType.TEL_PHONE.Type.Equals(type)) { if (IsMr2007(baseVersion) || IsCeRxOrNewfoundland(version)) { if (schemePlusAddressLength > MAX_VALUE_LENGTH_PHONE_MR2007_CERX) { CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_PHONE_MR2007_CERX, type, baseVersion, element, propertyPath , errors); } } else { if (schemePlusAddressLength > MAX_VALUE_LENGTH_PHONE_MR2009) { CreateMaxLengthError(schemePlusAddressLength, MAX_VALUE_LENGTH_PHONE_MR2009, type, baseVersion, element, propertyPath, errors ); } } } } } } }