Stream: hapi
Topic: Finding the patient corresponding to a resource generically
Mohammad Jafari (Sep 02 2016 at 00:05):
Working on a Consent enforcement interceptor for HAPI, a problem I encounter is to find which patient a resource pertains to in order to find the Consents filed by that patient (or her/his behalf). Right now I have to loop over different resource types, cast the resource to the subtype and call the corresponding method for getting the patient. Since this seems to be a I'm wondering if there is a generic way of doing this without casting the resource. I am aware of the terser method which works directly on the XML of a resource but I think it is not guaranteed to always give the correct answer in this case. CC: @James Agnew
Grahame Grieve (Sep 02 2016 at 00:07):
what does 'pertain to' mean?
Mohammad Jafari (Sep 02 2016 at 00:11):
Generally, the patient whose consent would be effective and applicable to releasing of the resource but I hear your point. I'm thinking maybe a nice way to implement this in a configurable way is to have a mapping between resource names and the corresponding field which would refer to such patient and have it as part of the configuration of the interceptor
.
Grahame Grieve (Sep 02 2016 at 01:09):
well, sounds like a interface + class combination to contribute to HAPI, so that James an write the hook point, and people can use your default contribution, or implement their own....?
James Agnew (Sep 02 2016 at 13:42):
This sounds like a case for compartments to me!
You could do something like:
FhirTerser t = ctx.newTerser(); boolean pertains = t.isSourceInCompartmentForTarget("Patient", condidateResource, new IdType("Patient/123"));
Grahame Grieve (Sep 02 2016 at 20:49):
we don't make any promises about the relationship between the patient and the resource when we make the compartment link - we link for any reason at all; pertains is narrower
Mohammad Jafari (Sep 09 2016 at 22:57):
Thanks @James Agnew this seems an excellent place to start and definitely good enough for my demo. But I agree with Grahame that in the general case, this may be a more nuanced and perhaps jurisdiction-dependent matter.
Last updated: Apr 12 2022 at 19:14 UTC