Access Policy for Multi-Organization Practice
# support
e
Hello, We are experiencing some difficulties with access policies for our project. Attached is the use case we wish to implement. Currently, we can access organizations and PractitionerRoles, but we can't access the Practitioners themselves. Here's what we have at the moment: { "resourceType": "AccessPolicy", "name": "Admin Access Policy", "id": "ad9e4f2a-c50f-492f-b9e6-743f89ec7bb9", "resource": [ { "resourceType": "Practitioner", "criteria": "Practitioner?_id=%practitioner" }, { "resourceType": "PractitionerRole", "criteria": "PractitionerRole?organization=%provider_organization" }, { "resourceType": "Organization", "criteria": "Organization?_id=%provider_organization" } ] } We'd like to be able to apply a criterion such as Practitioner?_id=PractitionerRole?practitioner, but only when PractitionerRole?organization=%provider_organization. How can we achieve this? Thanks for your help.
t
Hello @rahul1 , do you have any idea about this ? It is kind of blocking on our end 🙂 Thanks
r
HI @thomabig and @Estelle , thank you for your patience
What you're describing would essentially use a chained search (https://www.medplum.com/docs/search/chained-search#reverse-chained-search)
Practitioner?_has:PractitionerRole:organization=%organization_id
Unfortunately, for performance reasons, we can't support these kinds of chained searches in access policies, as we perform these checks on every read / write https://www.medplum.com/docs/access/access-policies#criteria-based-access-control
Most of our customers solve this problem by using a Bot to update
AccessPolicies
up to date as
Practitioners
enter / leave an organization
t
To understand it correctly, what you mean is when practitionner is added to Organization A, a bot will add it automatically to Organization 1 ? I'm not fully sure to understand the process, if we update the access policies, would it be one specific access policy per user ?
r
My apologies, let me give a bit more of a robust solution: We would use the
meta.account
property described here: https://www.medplum.com/docs/access/access-policies#healthcare-partnerships
The workflow would be: - Practitioner 1 is assigned to Org A and Orga C via PractitionerRole - A bot would listen for changes to PractitionerRoles. - It would crawl the Org hierarchy to the root - It assigns Practitioner 1's
meta.account
property to be a reference to
Organization 1
- Admin 1's access policy allows
Practitioner?_compartment=Organization/org-1-id
t
Thanks you @rahul1 It looks like we have something working 🙂
r
That's great @thomabig ! Would you mind sharing the solution you came up with? We love to add the useful patterns as "recipes" in our public documentation
t
Hi @rahul1 , I may have spoken to quickly. Indeed as meta.account does not take an array of Organization we cannot assign to practitionner 1 the organization 1 and the organization 2. such as admin 1 and admin2 have access to Practitioner 1 So we are actually still searching
e
Indeed, here's what we've done, but as Thoma pointed out, we can't assign two referent organizations to a practitioner.
r
@Estelle sorry for the delay. Yes unfortunately right now we don't support an array of
meta.account
. This feature is on our backlog, but unfortunately we don't have a timeline estimate at this point: https://github.com/medplum/medplum/issues/3668
180 Views