Access Policies
# support
a
Hi, I have 3 different accessPolicies for a relatedPerson namely
Caregiver
Family Member
and
Legal Guardian
. I am attaching these policies to user while Inviting. Question: Is there a way after a user logs in (invited user) check what category does he belongs to? Like(
Caregiver
Family Member
or the
Legal Guardian
? Is there a way i can get assigned access-policy name? Thanks in Advance for the help!
r
You can get the user's
Patient
resource by using the
useMedplumProfile()
hook
a
Hey Rahul, have added
ProjectMemmbership
in my access-policies and tried hitting the API. It still gave me
forbidden
error. Tried with all the 3 objects below:
Copy code
{
      "resourceType": "ProjectMembership",
      "compartment": {
        "reference": "%patient"
      }
    },
    {
      "resourceType": "ProjectMembership",
      "compartment": {
        "reference": "%patient"
      },
      "readonly": true
    },
    {
      "resourceType": "ProjectMembership",
      "readonly": true
    },
The CURL request i am hitting:
Copy code
curl 'https://api.foodemo.xyz/fhir/R4/ProjectMembership?profile=Patient%2Ffa0850c7-2e6e-40cd-8aff-21fb92170e9c' \
  -H 'Accept: */*' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjAzYzBiOWIyLWY3YTMtNGEyYi04MjlhLTMwYjg1MDYxOTkxZSIsInR5cCI6IkpXVCJ9.eyJsb2dpbl9pZCI6IjNkMGFjY2ViLTY0OGItNGUxNy1hMTUwLWU4NzU1NmIwMzI3YSIsInN1YiI6ImM3OGFkNzRiLTJjYTMtNDhjNC04OTczLTVlMzA0ZGYxZjk4NCIsInVzZXJuYW1lIjoiYzc4YWQ3NGItMmNhMy00OGM0LTg5NzMtNWUzMDRkZjFmOTg0Iiwic2NvcGUiOiJvcGVuaWQiLCJwcm9maWxlIjoiUGF0aWVudC9mYTA4NTBjNy0yZTZlLTQwY2QtOGFmZi0yMWZiOTIxNzBlOWMiLCJpYXQiOjE2ODEzNjUxMTMsImlzcyI6Imh0dHBzOi8vYXBpLmZvb2RlbW8ueHl6LyIsImV4cCI6MTY4MTM2ODcxM30.aKNWr4Ciet4W9PWtFQpiKWdW2KHa7lF_eSnvlr-EjomlYnIm_dZ0A8iJzH5Pj1sD1ii_A-vaFEF-8yqi3JXqioBiduBmRqBj67rM2TAC6IV5PWfeg4V9TC8ofA9vgKV_x3an3LpAU6mM3NwbT5SCD6c7AZyKGRpmDomcnDiRycXcFpQ6EOUxxsao8CWgyJQZVvH-ZlYrwp-zku-BjVv2_uwZJzkGrJYB5GouRZHoIcQr5gbNcPRJ0k02NGnhvPQ1a6m_2_S_27ScMaOibX_mwxVjD2yJ9PnacXv3i_7NZB4P-Foru0nQ6_yfPuvi0oOtSeg0PvavLWSr7p2X3Pz7QQ' \
  -H 'Cache-Control: max-age=0' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/fhir+json' \
  -H 'Origin: http://localhost:3001' \
  -H 'Referer: http://localhost:3001/' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Site: cross-site' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' \
  -H 'X-Medplum: extended' \
  -H 'sec-ch-ua: "Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  --compressed
@rahul1 if you can help me out in this?
r
@ahmedsakri sorry for the delay. I mispoke slightly in my earlier response. Certain resources, such as
ProjectMembership
are only accessible by project administrators, so the patient login won't be able to access them
I've researched an alternative that I actually believe is more "correct"
The
RelatedPerson.relationship
field is an array, precisely for this reason. I would suggest that for every
RelatedPerson
, in addition to storing their family relationship (e.g. "mother", "father", etc.), you also store a second element that indicates whether they are a "Caregiver Family Member or the Legal Guardian". This field will then also be a Search parameter, making it easier to perform searches such as "find all legal guardians for Patient X"
156 Views