public static OperationOutcome AddValidationProblems(this OperationOutcome outcome, Type resourceType, HttpStatusCode code, ValidationProblemDetails validationProblems)
        {
            if (resourceType == null)
            {
                throw new ArgumentNullException(nameof(resourceType));
            }
            if (validationProblems == null)
            {
                throw new ArgumentNullException(nameof(ValidationProblemDetails));
            }

            OperationOutcome.IssueSeverity severity = IssueSeverityOf(code);
            foreach (var error in validationProblems.Errors)
            {
                outcome.Issue.Add(new OperationOutcome.IssueComponent
                {
                    Severity    = severity,
                    Code        = OperationOutcome.IssueType.Required,
                    Diagnostics = error.Value.FirstOrDefault(),
                    Location    = new[] { FhirPathUtil.ConvertToXPathExpression(FhirPathUtil.ResolveToFhirPathExpression(resourceType, error.Key)) }
                });
            }

            return(outcome);
        }
Beispiel #2
0
        public void Can_Convert_FhirPathExpression_To_XPathExpression_Test()
        {
            var fhirPathExpression = "Patient.name[0].family";
            var expected           = "f:Patient/f:name[0]/f:family";

            var actual = FhirPathUtil.ConvertToXPathExpression(fhirPathExpression);

            Assert.Equal(expected, actual);
        }