Closed ShruJo closed 4 years ago
Hi, Could anyone let me know how to solve this or, if there's some other way to do this?
Hi @ShruJo - Please see https://github.com/jamesagnew/hapi-fhir/wiki/Getting-Help for details on where to ask for help with HAPI FHIR.
In this case it sounds like you are probably missing DefaultProfileValidationSupport from your chain.
The issue: Trying to validate terminologies of the resources in FHIR. Following are the steps followed while trying to reproduce the issue:
Create a HAPI FHIR Server locally by extending "RestfulServer". Inside the initialize() method setting FHIR context(R4) and adding a hardcoded serverbase. Setting all the ResourceProviders using setResourceProviders method.
Adding a @Validate method for all the ResourceProviders which sets the structure definition. that defines all the resource related cardinalities, snapshots, differentials with all the binding and valueset URLs.
Binding for the elements in differential and snapshot is kept as "REQUIRED". (say for Patient Resource patient.gender binding is set as REQUIRED). As we want to get the codes from the URL specified only.
Using the PrePopulatedSupport add the structure definition and add it in ValidationSupportChain. Using FHIRInstanceValidator set the validationSupportChain object.
Using ValidateResult validate the resource using FhirValidator object (validator.validateWithResult(input);)
On Running the service and calling the following Postman URL it shown the below response(considering the Patient resource with gender as male.): URL: http://localhost:8080/Patient/1/$validate **Response:
** { "resourceType": "OperationOutcome", "issue": [ { "severity": "information", "code": "processing", "diagnostics": "The value provided ('male') is not in the value set http://hl7.org/fhir/ValueSet/administrative-gender (http://hl7.org/fhir/ValueSet/administrative-gender, and a code is recommended to come from this value set) (error message = Unknown code[male] in system[(none)])", "location": [ "Patient.gender", "Line 30, Col 2" ] } ] }
ENVIRONMENT
Additional context
pom.xml:
patientProfile.json: { "resourceType": "StructureDefinition", "id": "123", "meta": { "lastUpdated": "2019-11-01T09:29:23.356+11:00" }, "text": { "status": "generated", "div": "
{ "resourceType": "Patient",
"name": [ { "fhir_comments": [ " Peter James Chalmers, but called \"Jim\" " ],
], "gender":"male" }
..