ysael
03/12/2025, 8:13 PMysael
03/12/2025, 8:20 PMTypeScript
function handleAuthResponse(response: LoginAuthenticationResponse): void {
if (response.code) {
medplum.processCode(response.code).catch(console.error);
}
if (response.memberships) {
// TODO: Handle multiple memberships
// In a real app, you would present a list of memberships to the user
// For this example, just use the first membership
medplum
.post('auth/profile', {
login: response.login,
profile: response.memberships[0].id,
})
.then(handleAuthResponse)
.catch(console.error);
}
@https://github.com/medplum/medplum/blob/550d4d4745de99ccd22096fa3866a5211d635d1e/examples/medplum-react-native-example/src/Home.tsx
but in the context of @https://next-auth.js.org/configuration/providers/oauth#using-a-custom-providerreshma
03/12/2025, 11:47 PMysael
03/13/2025, 12:22 PM/signin to select the correct membership instead of back to my application. I would like to be able to handle that on my side so I can either attach the first membership or prompt the user to select one.
ps: I am using self hosted applicationysael
03/13/2025, 1:07 PMTypeScript
if (login.membership && body.redirectUri && client?.redirectUri) {
And my redirectUrl gets set using appBaseUrl
TypeScript
const redirectUrl = new URL(signInPage, getConfig().appBaseUrl);ysael
03/13/2025, 7:16 PMrahul1
03/17/2025, 10:09 AMysael
03/17/2025, 1:05 PMJSON
{
"resourceType": "AccessPolicy",
"id": "123",
"name": "Parameterized Access Policy",
"resource": [
{
"resourceType": "Patient",
"criteria": "Patient?organization=%provider_organization"
},
{
"resourceType": "DiagnosticReport",
"criteria": "DiagnosticReport?performer=%provider_organization"
}
]
}ysael
03/17/2025, 1:06 PMysael
03/17/2025, 1:19 PMrahul1
03/18/2025, 4:45 PMrahul1
03/18/2025, 4:45 PMysael
03/18/2025, 8:10 PM_compartment to restrict access to resources within an organization, and indeed we could call our project a "Managed Service Organization."
I just read the code from the PR and have a few questions:
- For a non-admin Practitioner who can view and select patients from multiple organizations:
- What is the best way to determine the organizations they have access to? (For now, I was thinking of using the auth/me endpoint and deriving those from the AccessPolicy.resource array.)
- We are also considering adding _compartment as a search parameter to our request depending on the organization that the user has selected. Is this the best way to do it?finnbergquist
03/19/2025, 6:18 PMysael
03/19/2025, 8:18 PMYes, that is one way to do it. Or you could get the ProjectMembership for that non-admin Practitioner and look at the Organization references in the access array.
Good to hear!
Not sure if I understand. Is this search for Organizations? Can you send what you have for the request now?
as a non-admin that have access to multiple organization once the organization is selected I do:
bash
curl 'https://api.medplum.com/fhir/R4/Patient?_compartment=Organization/[SelectedOrganization]' \
-H 'authorization: Bearer $ACCESS_TOKEN' \
-H 'content-type: application/fhir+json'ysael
03/19/2025, 8:19 PMfinnbergquist
03/21/2025, 4:09 PM