Okay, I am working with HAPI FHIR APi's and I am trying to figure out how to validate and object/ against a custom StructureDefinition json or resourcetext.
I have no problems creating a default validator and validating against the default structural definitions etc... but how do I tell HAPI/API to validate against my XML or JSON instead of the defaults?
I see the documentation at the bottom of this page that says "supplying your own structure definitions" http://hapifhir.io/doc_validation.html but I really am lost on what exactly is expected... I have taken the code snippet and gotten it to compile, and I know I must overload these routines, though I am not really sure how... to tell it, hey go load this XML or JSON file ...
I also never see any of these overridden routines actually get called when I pass in a resourcetext for a resource not found in the default FHIR definitions.. Which I would expect based on the documentation at least something to get called since its not found in the DefaultProfileValidationSupport...
So, can anyone point me to an example, or something else that shows HOW to actually do this? Basically I have a custom structuredefinition and I want it to be validated against it... how the heck do I set this up?
Have a look at what I have done here - https://github.com/sylwestergryzio/fhir-connectathon-2017-devices.
At the bare minimum you will have to implement the following methods:
public List<StructureDefinition> fetchAllStructureDefinitions(FhirContext theContext)
and public <T extends IBaseResource> T fetchResource(FhirContext theContext, Class<T> theClass, String theUri)
.
You could also look at the implementation of the org.hl7.fhir.dstu3.hapi.validation.DefaultProfileValidationSupport
: https://github.com/jamesagnew/hapi-fhir/blob/master/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/validation/DefaultProfileValidationSupport.java
It shows even how to load custom structure definitions from a file on a classpath.