Resources validation

281 views
Skip to first unread message

Andrea Caloni

unread,
Aug 31, 2022, 8:31:30 AM8/31/22
to HAPI FHIR
Hi, I am developing a scenario where I have a plain server acting as a gateway, and "n" jpa server, acting as fhir repositories.
I need to validate resources on the basis of custom profiles, and I would prefer to validate it on the plain server, through an instance of the PrePopulatedValidationSupport class.
However, once the validation on the plain server has been passed, the jpa server does not persist the resource, because it differs from the basic profile, and it is not aware of the StructureDefinition corresponding to the profile.
For example, in my custom profile, the MedicationRequest resource has a reference to a SupplyRequest in the "basedOn" field.
The MedicationRequest base resource only allows a reference to CarePlan, MedicationRequest, ServiceRequest, ImmunizationRecommendation in the "basedOn" field. For this reason the jpa server does not persist the resource.
My question is: is it possible to completely disable resource validation on the jpa server, so that it accepts unknown profiles?
Otherwise I must necessarily relegate the validation to the jpa server, through an instance of a class that extends RepositoryValidatingInterceptor.

Thanks in advance
Andrea

James Agnew

unread,
Aug 31, 2022, 10:40:35 AM8/31/22
to Andrea Caloni, HAPI FHIR
It is definitely possible to have a JPA server that does not validate. What is the specific error message you're getting back? (ie. is this failure coming from the validator, from the storage layer, etc?)

Cheers,
James


--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/bfe81aec-4f1d-4cbf-820f-14d1702dc413n%40googlegroups.com.
Message has been deleted

Andrea Caloni

unread,
Sep 1, 2022, 3:37:44 AM9/1/22
to HAPI FHIR
Hi James, 

despite having configured the following parameters in application.yaml:
hapi:
  fhir:
    validation:
      requests_enabled: false
      responses_enabled: false
    enable_repository_validating_interceptor: false

when I try to post a MedicationRequest with following field:
"basedOn": [
        {
            "reference": "SupplyRequest/a25e965a-29fc-42b1-8767-1830032c20fc",
            "type": "SupplyRequest"
        }
    ]


I get the error:
"HAPI-0931: Invalid reference found at path 'MedicationRequest.basedOn'. Resource type 'SupplyRequest' is not valid for this path"

So it looks like the failure is coming from the validator.

Cheers,
Andrea

James Agnew

unread,
Sep 1, 2022, 3:00:21 PM9/1/22
to Andrea Caloni, HAPI FHIR
Ah, that validation is actually not the validator, it's the storage layer. It is disabled on the DaoConfig object via the "setEnforceReferenceTargetTypes" method.

I am not sure if we expose a setting in the YAML in the starter project for that setting yet - If not, one might need to be added (PR welcome to add it of course!)

Cheers,
James


Andrea Caloni

unread,
Sep 2, 2022, 7:51:22 AM9/2/22
to HAPI FHIR
Thank you James,
disabling it on the DaoConfig object, the validation disappear.

Cheers,
Andrea

Reply all
Reply to author
Forward
0 new messages