public void IssueCategorization()
 {
     Assert.AreEqual(2, _report.ListErrors().Count());
     Assert.AreEqual(3, _report.Where(severity: OperationOutcome.IssueSeverity.Warning).Count());
     Assert.AreEqual(2, _report.Where(type: OperationOutcome.IssueType.BusinessRule).Count());
     Assert.AreEqual(1, _report.Where(issueCode: Issue.PROFILE_ELEMENTDEF_CARDINALITY_MISSING.Code).Count());
     Assert.AreEqual(1, _report.Where(severity: OperationOutcome.IssueSeverity.Warning, type: OperationOutcome.IssueType.BusinessRule, issueCode: 2008).Count());
     Assert.AreEqual(0, _report.Where(severity: OperationOutcome.IssueSeverity.Error, type: OperationOutcome.IssueType.BusinessRule, issueCode: 2008).Count());
 }
示例#2
0
        private OperationOutcome callService(string code, string system, string display, string uri, BindingStrength?strength, string path)
        {
            var outcome = new OperationOutcome();

            OperationOutcome validateResult = _service.ValidateCode(uri, code, system, display, abstractAllowed: false);
            var codeLabel = $"Code '{code}' from system '{system}'";

            if (display != null)
            {
                codeLabel += $" with display '{display}'";
            }

            if (validateResult.Where(type: OperationOutcome.IssueType.NotSupported).Any())
            {
                if (strength != BindingStrength.Example)
                {
                    outcome.AddIssue($"The terminology service is incapable of validating {codeLabel} (valueset '{uri}').", Issue.UNSUPPORTED_BINDING_NOT_SUPPORTED_BY_SERVICE, path);
                    validateResult.MakeInformational();
                    outcome.Include(validateResult);
                }
                return(outcome);
            }

            if (!validateResult.Success)
            {
                if (strength == BindingStrength.Required)
                {
                    outcome.AddIssue($"{codeLabel} is not valid for required binding to valueset '{uri}'", Issue.CONTENT_INVALID_FOR_REQUIRED_BINDING, path);
                }
                else if (strength != BindingStrength.Example)
                {
                    outcome.AddIssue($"{codeLabel} is not valid for non-required binding to valueset '{uri}'", Issue.CONTENT_INVALID_FOR_NON_REQUIRED_BINDING, path);
                }

                validateResult.MakeInformational();
            }

            outcome.Include(validateResult);
            return(outcome);
        }