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);
        }
Example #2
0
        public void Resolve_Patient_Communication_Language_Test()
        {
            var resourceType = typeof(Patient);
            var expression   = "Communication[0].Language";

            var resolvedExpression = FhirPathUtil.ResolveToFhirPathExpression(resourceType, expression);

            Assert.Equal("Patient.communication[0].language", resolvedExpression);
        }
Example #3
0
        public void Resolve_Patient_FamilyElement_Test()
        {
            var resourceType = typeof(Patient);
            var expression   = "Name[0].FamilyElement";
            var expected     = "Patient.name[0].family";

            var actual = FhirPathUtil.ResolveToFhirPathExpression(resourceType, expression);

            Assert.Equal(expected, actual);
        }
Example #4
0
        public void Resolve_Questionnaire_RequriedElement_In_ItemElement_Hierarchy_Test()
        {
            var resourceType = typeof(Questionnaire);
            var expression   = ModelInfo.Version == "1.0.2"
                ? "Group.Question[3].Group[0].Question[3].RequiredElement"
                : "Item[0].Item[3].Item[0].Item[3].RequiredElement";
            var expected = ModelInfo.Version == "1.0.2"
                ? "Questionnaire.group.question[3].group[0].question[3].required"
                : "Questionnaire.item[0].item[3].item[0].item[3].required";

            var resolvedExpression = FhirPathUtil.ResolveToFhirPathExpression(resourceType, expression);

            Assert.Equal(expected, resolvedExpression);
        }
Example #5
0
        public void Resolve_Questionnaire_Initial_In_ItemElement_Hierarchy_Test()
        {
            var resourceType = typeof(Questionnaire);
            // NOTE: Initial does not exist in DSTU2
            var expression = ModelInfo.Version == "1.0.2"
                ? "Group.Question[3].Group[0].Question[3].TextElement"
                : "Item[0].Item[3].Item[0].Item[3].Initial";
            var expected = ModelInfo.Version == "1.0.2"
                ? "Questionnaire.group.question[3].group[0].question[3].text"
                : "Questionnaire.item[0].item[3].item[0].item[3].initial";

            var resolvedExpression = FhirPathUtil.ResolveToFhirPathExpression(resourceType, expression);

            Assert.Equal(expected, resolvedExpression);
        }