FHIR Chat · Custom profile validation · hapi

Stream: hapi

Topic: Custom profile validation


view this post on Zulip Jean Duteau (Aug 06 2019 at 13:58):

I am assisting a developer in implementing validation of a custom profile using HAPI. What I'd like to be able to do is validate a set of resources against a set of custom profiles, regardless of whether they actually declare conformance to the profile or not. He thought that starting with a FHIRInstanceValidator would do the trick but I don't see way to ask "is this resource conformant to this profile?". Is there a known way of doing this with HAPI?

view this post on Zulip Patrick Werner (Aug 06 2019 at 14:15):

hapi can do this as you can provide the profile to validate against in the $validate operation

view this post on Zulip Patrick Werner (Aug 06 2019 at 14:16):

https://www.hl7.org/fhir/resource-operation-validate.html

view this post on Zulip Jean Duteau (Aug 06 2019 at 14:19):

Yes, I know that it implements that function, so I know that it must have support on the server-side for calling the equivalent, but I can't see it. I've implemented a server operation and I want to call this validation to ensure my operation parameters conform to the proper profiles. I'll go look how the $validate operation works to see how we can implement this in our operation.

view this post on Zulip Jean Duteau (Aug 06 2019 at 15:09):

Hmm, do we know that the HAPI $validate function works when given a specific profile? I am about to test it, but the code would tell me otherwise.
This method:
public MethodOutcome validate(T theResource, IIdType theId, String theRawResource, EncodingEnum theEncoding, ValidationModeEnum theMode, String theProfile, RequestDetails theRequest)

in FhirResourceDaoR4 doesn't actually use the "String theProfile" parameter at all.

view this post on Zulip Patrick Werner (Aug 06 2019 at 17:00):

oh, you are right. In FhirResourceDaoR4.java the String containing the profile is never used.
@James Agnew is this a bug?

view this post on Zulip James Agnew (Aug 06 2019 at 18:41):

hmm yeah, i'd say that does sound like a bug :(

view this post on Zulip Jean Duteau (Aug 06 2019 at 18:43):

I looked at FhirResourceDaoSTU3 and it also doesn't use the profile string, so it's not a recent bug. I haven't tested the $validate call with the profile specified on the URL to see if that actually does work or not.

view this post on Zulip Patrick Werner (Aug 06 2019 at 19:01):

https://github.com/jamesagnew/hapi-fhir/issues/1414

view this post on Zulip Jean Duteau (Aug 06 2019 at 20:49):

Okay, notwithstanding the issue raised, is there a workaround? can I "inject" a profile into a resource and then validate it? I'm trying to read the HAPI code to see if it will validate a resource that declares it conforms to a profile.

view this post on Zulip Grahame Grieve (Aug 06 2019 at 20:59):

I'm not clear on the problem here. The core validator does do profile based validation...

view this post on Zulip James Agnew (Aug 06 2019 at 21:40):

The issue here is that there is a bug in HAPI's wrapper around the core validator where if you explicitly ask it to validate against a specific profile URI, it ignores that URI.

Jean- you could explicitly declare your profile URL in your Resource.meta.profile element- if that's populated, the validator will use it.

view this post on Zulip Grahame Grieve (Aug 06 2019 at 21:49):

except that he said at the beginning: he wants to enforce the validation irrespective of what the resource claims or not

view this post on Zulip James Agnew (Aug 06 2019 at 21:55):

yeah, that's the bug, I'm just proposing a temporary workaround while I fix that :)

view this post on Zulip James Agnew (Aug 07 2019 at 19:44):

This has been fixed in the latest 4.0.0-SNAPSHOT in Maven Central, and on hapi.fhir.org

Also of note, we are now using the R5 validator, and a bunch of new caching has been added to the default IValidationSupport implementation used by the JPA server. I'm seeing some decent performance gains in my smoke tests right now.

view this post on Zulip Grahame Grieve (Aug 07 2019 at 21:36):

The R5 validator is getting pretty solid now. I'm close to moving to asking for test cases with bug reports

view this post on Zulip Brian Kaney (Jan 03 2020 at 16:10):

Quick question folks -- using http://hapi.fhir.org/baseR4/Patient/$validate works as expected, but when I include ?profile=http://bogus/profile/url parameter it seems to ignore it, reporting 200 with "No issues detected during validation". Is this expected behavior for the test server?

view this post on Zulip Grahame Grieve (Jan 04 2020 at 05:38):

not from my pov

view this post on Zulip Brian Kaney (Jan 06 2020 at 22:25):

Hmm.. okay, it works-for-me now.


Last updated: Apr 12 2022 at 19:14 UTC