jakxz
08/22/2023, 3:47 PM_tag
parameter as expected (and the bundle response is correctly filtered) but we're wondering about the read operation: this may not be a medplum question, it might be a FHIR question in general - is it possible to scope a read request in a similar way?
What are some alternatives we could consider if not?rahul1
08/22/2023, 5:48 PMrahul1
09/07/2023, 9:06 PMjakxz
09/08/2023, 10:41 PMrahul1
09/08/2023, 10:45 PMjakxz
09/09/2023, 6:42 AMphishin
09/19/2023, 6:09 PMmedplum-server
)
Some background:
- We use Client Credentials Login, this works because its server -> server and we bulk save all resources that belong to a Patient
- We never actually get a Patient’s credentials when they login to their health plan. So we don’t want to create Users in Medplum if we don’t have to (we don’t have a credential to store)
- There is this world of Compartments that may be beneficial also, but we’re a bit unsure how to leverage it.phishin
09/19/2023, 6:10 PMrahul1
09/19/2023, 6:46 PMrahul1
09/19/2023, 6:49 PMrahul1
09/19/2023, 6:49 PMphishin
09/19/2023, 6:51 PMGET http://our.medplum.com/Coverage?_tag=our-fake-tag|123
phishin
09/19/2023, 6:52 PMrahul1
09/19/2023, 7:00 PM_compartment
, to find all resources of a given type associacted with a patient.
e.g. http://our.medplum.com/Coverage?_compartment=Patient/1234.
The compartment is associated with the Coverage resource automatically by the server, using the compartment specification (https://www.hl7.org/fhir/compartmentdefinition.html)
- If the goal is to block access to the server for some patients, then an access policy would be appropriate. However, this typically isn't done on a request-by-request basis, but more on session basis. If the medplum client is on the server, it doesn't seem like you'd want to actually block access from any patient data within the lifetime of the client's sessionjakxz
09/19/2023, 7:17 PMrahul1
09/19/2023, 8:14 PMid
field of the resource in Medplum?
That would just be a GET [base]/Coverage/67890
http://hl7.org/fhir/R4/http.html#readrahul1
09/19/2023, 8:37 PMjakxz
09/20/2023, 2:00 PMsearch
in this statement for `read`:
> If the goal is just to perform a search in medplum for all resources, of a certain type related to a Patient, you can do this using compartments.
vs
> If the goal is just to perform a read
in medplum for a specific resource
, of a certain type related to a Patient, you can do this using _____
.
Would the answer just be compartments again? 😮jakxz
09/20/2023, 2:46 PMjakxz
09/20/2023, 2:53 PMread
requests?phishin
09/20/2023, 4:07 PMpatient.id
to fix all of the references accross their resoruces (i.e. update all "reference": "Patient/old-id" to point to the newly generated ID)
- We also tag each resource with the patient ID, this was our hacky way of achieveing access control on Search's, but not Reads.
We make Search's like this:
GET our.medplum.com/Coverage?_tag=newly-created-patient-id|123
This works for Searches because we've tagged all Coverage resources that belong to this Patient with that tag. (Note: We know that this also works: GET our.medplum.com/Coverage?patient=Patient/new-patient-id
)
We make Reads like this:
GET our.medplum.com/Location/456
.
The reason why the above isn't great, is because Reads are not access controlled at all. As far as we know, Reads don't allow a _tag
param so we don't know for sure if this Location belongs to that Patient. (Or is accessible to that Patient) If a user starts guessing IDs, they can query for random Locations (or read any FHIR resource by ID) and see some PHI they shouldn't be able to see.
So our problem:
We want to make sure when we make a request to our Medplum instance for a given patient, we never return a resource that is shouldn't be seen by that patient. Is compartments the way to go here?
Hope this helps 🙂 Happy to jump on a voice call if thats helpful too.rahul1
09/21/2023, 3:55 PMour.medplum.com/Location/456
, it seems like you're basically proxying those requests straight to medplum from your server.
So for server-to-server communication, (where each user doesn't have their own access token), using AccessPolicies doesn't seem to make sense. That's because AccessPolicies are generally used to restrict access to a specific accessToken, not on a per-request basis. We've had some speculative conversations about have the MedplumClient
act "on behalf of" a user per-request, but are still working on the design.
For your immediate use-case, you can convert your "read" requests into a search via the _id
parameter (http://hl7.org/fhir/R4/search.html#id)
This means you could perform a search:
[base]/Location?_id=456&_compartment=Patient/new-patient
phishin
09/21/2023, 6:09 PMjakxz
09/21/2023, 8:31 PMrahul1
09/21/2023, 10:08 PMrahul1
02/13/2024, 9:38 PM