private void HandleConstraints(string type, ICollection <BareANY> parsedItems, ConstrainedDatatype constraints, IList <XmlNode > nodes, XmlToModelResult xmlToModelResult) { IiCollectionConstraintHandler.ConstraintResult constraintResult = this.constraintHandler.CheckConstraints(type, constraints , parsedItems); if (constraintResult != null) { bool isTemplateId = constraintResult.IsTemplateId(); if (constraintResult.IsFoundMatch()) { if (isTemplateId) { string msg = System.String.Format("Found match for templateId fixed constraint: {0}", constraintResult.GetIdentifer()); xmlToModelResult.AddHl7Error(new Hl7Error(Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MATCH, ErrorLevel.INFO, msg, nodes .Count > 0 ? nodes[0] : null)); } } else { Hl7ErrorCode errorCode = (isTemplateId ? Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING : Hl7ErrorCode.CDA_FIXED_CONSTRAINT_MISSING ); string msg = "Expected to find an identifier with: " + constraintResult.GetIdentifer(); xmlToModelResult.AddHl7Error(new Hl7Error(errorCode, ErrorLevel.WARNING, msg, nodes.Count > 0 ? nodes[0] : null)); } } }
public void LogError(Hl7ErrorCode errorCode, ErrorLevel errorLevel, string errorMessage) { Hl7Errors errors = context.GetModelToXmlResult(); string propertyPath = context.GetPropertyPath(); errors.AddHl7Error(new Hl7Error(errorCode, errorLevel, errorMessage, propertyPath)); }
private void LogFixedConstraintError(string name, string value, string fixedConstraint, string type, ErrorLogger errorLogger , bool isSingletonTemplateIdRoot) { string message = System.String.Format("Property {0} of type {1} is constrained to a fixed value of {2} but was {3}", name , type, fixedConstraint, value); Hl7ErrorCode error = (isSingletonTemplateIdRoot ? Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING : Hl7ErrorCode.CDA_FIXED_CONSTRAINT_MISSING ); errorLogger.LogError(error, ErrorLevel.ERROR, message); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 13, Configuration.FieldSeparator), Id, ErrorCodeAndLocation, ErrorLocation != null ? string.Join(Configuration.FieldRepeatSeparator, ErrorLocation.Select(x => x.ToDelimitedString())) : null, Hl7ErrorCode?.ToDelimitedString(), Severity, ApplicationErrorCode?.ToDelimitedString(), ApplicationErrorParameter != null ? string.Join(Configuration.FieldRepeatSeparator, ApplicationErrorParameter) : null, DiagnosticInformation?.ToDelimitedString(), UserMessage?.ToDelimitedString(), InformPersonIndicator != null ? string.Join(Configuration.FieldRepeatSeparator, InformPersonIndicator.Select(x => x.ToDelimitedString())) : null, OverrideType?.ToDelimitedString(), OverrideReasonCode != null ? string.Join(Configuration.FieldRepeatSeparator, OverrideReasonCode.Select(x => x.ToDelimitedString())) : null, HelpDeskContactPoint != null ? string.Join(Configuration.FieldRepeatSeparator, HelpDeskContactPoint.Select(x => x.ToDelimitedString())) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
private void ValidateMissingMandatoryNonStructuralRelationships(Hl7Source source, IDictionary <string, string> resolvedRelationshipNames ) { // compare xml provided elements with all known mandatory relationships (watch for nested) IList <Relationship> allRelationships = source.GetAllRelationships(); foreach (Relationship relationship in allRelationships) { // ignore structural - this has been checked elsewhere (and isn't contained in the resolved relationships anyway) if (!relationship.Structural && relationship.Cardinality.Min > 0) { if (!resolvedRelationshipNames.ContainsKey(GenerateRelationshipKey(relationship))) { Hl7Error error = new Hl7Error(relationship.Association ? Hl7ErrorCode.MANDATORY_ASSOCIATION_NOT_PROVIDED : Hl7ErrorCode.MANDATORY_FIELD_NOT_PROVIDED , "Relationship '" + relationship.Name + "' has a minimum cardinality greater than zero, but no value was provided.", source .GetCurrentElement()); source.GetResult().AddHl7Error(error); // check for missing fixed constraints ConstrainedDatatype constraints = source.GetService().GetConstraints(source.GetVersion(), relationship.ConstrainedType); if (constraints != null) { bool isTemplateId = constraints.Name.EndsWith("templateId"); foreach (Relationship constraint in constraints.Relationships) { if (constraint.HasFixedValue()) { string msg = System.String.Format("{0}.{1} property constrained to {2} but no value was provided.", relationship.Name, constraint .Name, constraint.FixedValue); Hl7ErrorCode errorCode = (isTemplateId ? Hl7ErrorCode.CDA_TEMPLATEID_FIXED_CONSTRAINT_MISSING : Hl7ErrorCode.CDA_FIXED_CONSTRAINT_MISSING ); source.GetResult().AddHl7Error(new Hl7Error(errorCode, ErrorLevel.WARNING, msg, source.GetCurrentElement())); } } } } } } }
public void LogError(Hl7ErrorCode errorCode, ErrorLevel errorLevel, string errorMessage) { errors.AddHl7Error(new Hl7Error(errorCode, errorLevel, errorMessage, element)); }
public void LogError(Hl7ErrorCode errorCode, ErrorLevel errorLevel, string errorMessage) { errors.AddHl7Error(new Hl7Error(errorCode, errorLevel, errorMessage, propertyPath)); }
public void LogError(Hl7ErrorCode errorCode, ErrorLevel errorLevel, string message) { this._enclosing.errors.Add(new Hl7Error(errorCode, errorLevel, message, string.Empty)); }