Tenant Assignment and Access
Use the Tenancy Design Decision Guide to choose your tenant boundary, Patient model, and account experience. This page implements tenant access within one project using assignments in meta.accounts and the computed meta.compartment field.
Represent your tenants, assign their records, then grant users access. References in meta.compartment can also support finer permissions within a tenant, such as care-team access. For a separate project per tenant, see Projects.
The enrollment examples below assign a Patient and the resources in its FHIR compartment, such as Observations and Tasks, to the same tenants. They support tenant-specific Patients and intentional chart sharing. A shared Patient with isolated clinical records needs the resource-specific rules described in the Patient-records guide.
Overview
What is a tenant?
A tenant is a customer organization or organizational unit that your application treats as a distinct operating context, with defined rules for its data, users, and administration. The resource representing that group describes its meaning; access policies and membership grants enforce access. References in meta.compartment can also represent smaller access groups within a tenant, or care-team assignments in an application with no multi-tenant design.
This guide configures the tenant resources, assignments, and permissions for the selected model. Here is an overview of the steps you will take:
- Model your tenants: Choose the FHIR resources representing your tenant boundaries.
- Assign data to tenants: Set the account references used by your access rules.
- Grant users access: Configure policies and membership grants for the approved records.
Step 1: Model your tenants
Choose the resource that represents your tenant in the operating model. An Organization fits a customer practice or organizational unit. A HealthcareService can anchor access for a service offering when that service corresponds to the separately governed unit you selected.
| Your boundary | Resource | Example |
|---|---|---|
| A customer practice or organizational unit | Organization | Each member practice in an MSO. |
| A separately governed service offering | HealthcareService | Cardiology and oncology services with independent data-governance requirements. |
Use Organization for a department as an organizational unit, and HealthcareService for the services it provides. See Modeling Provider Organizations for the clinical relationships. Choosing a resource type does not itself establish the access boundary; the assignments and grants below enforce it.
Other FHIR resource types can also anchor account-based groups when their meaning fits your model. Use the chosen representation consistently; project boundaries are configured separately.
The diagrams show how the membership grant and Patient assignment refer to the same group. Boxes are FHIR resources. Solid arrows follow reference fields; dashed arrows show permitted access. Care-team permissions are an additional access layer within a tenant.
Scroll horizontally to view the full diagram.
Scroll horizontally to view the full diagram.
The membership supplies the group reference to its policy; the Patient carries the matching assignment in meta.accounts. Creating the group or setting Patient.managingOrganization alone does not establish these grants.
Optional: Add care-team restrictions
A CareTeam represents participants in care. Use the pattern below when the API must restrict clinicians to their care team's patients. For a focused worklist within broader permitted access, UI filters can use existing fields and relationships without tenant or care-team assignments in meta.compartment. See UI filtering versus API restrictions.
If a team operates as a separately governed business unit, model that unit with an Organization and its care participants with CareTeam.
For patient-specific teams, one pattern is a CareTeam per Patient, with CareTeam.subject referencing that Patient. Give each clinician one access grant per assigned team, or per practice/team pair when both restrictions apply. Keep those grants synchronized with care assignments; updating CareTeam.participant alone does not update permissions.
Scroll horizontally to view the full diagram.
The membership supplies this policy with the approved practice and care-team parameters. The Patient must match both assignments. CareTeam participation alone does not grant access.
You can preserve the practice boundary while limiting clinicians to their assigned care teams:
- One project per practice: The project provides the outer boundary. Use care-team criteria within that project for clinicians who must only access their assigned patients.
- Several practices in one project: Enforce the practice and care-team conditions together. Separate practice-wide and team-only grants combine access; the team grant does not narrow the practice-wide grant.
For tenant-specific Patients whose charts share one team audience, assign both the practice and approved CareTeam references with $set-accounts. A resource can have several tenant or care-team references in meta.compartment; those assignments form a set, with no automatic parent-child containment. CareTeam.managingOrganization describes the responsible organization and does not create an authorization hierarchy.
This read-only example requires both the practice and care-team references in meta.compartment for Patient and Encounter access:
export const practiceCareTeamPolicy: AccessPolicy = {
resourceType: 'AccessPolicy',
name: 'Practice and care-team reads',
resource: [
{
resourceType: 'Patient',
criteria: 'Patient?_compartment=%organization&_compartment=%care_team',
readonly: true,
},
{
resourceType: 'Encounter',
criteria: 'Encounter?_compartment=%organization&_compartment=%care_team',
readonly: true,
},
],
};Supply organization and care_team as reference parameters in the same ProjectMembership.access entry. Verify that the team belongs to the intended practice and that the member is authorized for it. Repeat the combined grant for each approved practice/team pair. Repeated _compartment parameters require both matches; comma-separated values would match either.
The example grants only Patient and Encounter reads. Add explicit rules for other needed types and keep broader grants off memberships that need this restriction. Maintain the assignments when teams change. Patient-wide assignment and propagation apply to the Patient and the resources in its FHIR compartment, such as Observations and Tasks; if a shared Patient has different clinical audiences, use resource-specific clinical rules.
Tenant hierarchies
For a hierarchy such as region → clinic, one approach is to grant access through the lowest-level tenants:
- Assign each Patient only to the lowest-level clinic or clinics it belongs to within that hierarchy. Keep any separate care-team assignments required by your policies.
- For staff authorized at a region or higher level, expand its descendants into one
ProjectMembership.accessgrant per approved clinic, preserving any care-team conditions. - When a clinic is added, moved, or removed, update every affected membership with access at an ancestor level.
Organization.partOf describes the hierarchy; it does not automatically grant access to descendants. Use patient-wide propagation only when the Patient and its clinical records have the same intended audience.
Shared directories and automation
For a shared practitioner directory, explicitly grant the permitted Practitioner reads. If practitioner records must be tenant-specific, assign tenant accounts to them and apply corresponding criteria. Make the same choice for Questionnaires, terminology, PlanDefinitions, and ActivityDefinitions. Include the CodeSystem and ValueSet reads needed by terminology-backed UI controls. Projects covers exported reference data and read-only access across linked projects.
For shared Bots, configure permission to invoke the Bot separately from its execution permissions. A Bot normally uses its own ProjectMembership policy; runAsUser selects the caller's permissions instead.
Step 2: Assign data to tenants
Assign the chosen group references with $set-accounts, which updates meta.accounts and the computed meta.compartment field, then configure policies to match them. The Organization and HealthcareService examples assign tenant scope. The Care-team access tabs apply the same mechanism to finer groups; combine those assignments with the tenant scope when both restrictions are required.
FHIR compartments and meta.compartment
The Patient's FHIR compartment is the collection of resources related to that Patient through the relationships in the Patient CompartmentDefinition, such as Observations, Tasks, and DiagnosticReports. For example, an Observation whose subject references Patient/alice belongs to Alice's FHIR Patient compartment.
The Patient's meta.compartment field is server-computed metadata describing the Patient resource's membership in Patient, Project, and account-based groups. For example, it can contain Organization/clinic-a to record the Patient's tenant assignment. It contains compartment references, rather than a list of the Patient's clinical records.
Tenant assignments are stored in meta.accounts and included in the server-computed meta.compartment. AccessPolicy and ProjectMembership grants determine who can access the assigned resources.
Assigning account references
The server computes meta.compartment. Use $set-accounts to set the resource’s tenant or care-team account references, which the server includes in its meta.compartment field. Supply the complete intended account list, including existing accounts you want to retain. The operation requires project-admin or super-admin authority and checks access to the target resource.
The IDs below are illustrative. Substitute the actual resource IDs returned by OpenOrchid before running the examples.
When a Patient and the resources in its FHIR compartment, such as Observations and Tasks, have the same intended tenant audience, assign the Patient to those tenants and use propagation for existing resources. For tenant-specific Patients, assign each Patient only to its intended tenant. For a shared Patient with different clinical audiences, follow Clinical-record isolation.
Tenant assignment controls which tenant-scoped policies can match the Patient. Portal permissions come from the User’s membership and policy. See Patient login and memberships.
Example Method: Assigning a Patient to an Organization Tenant
/**
* Enrolls a patient in an organization. This is done by adding a reference to the organization to the patient using the $set-accounts operation.
*
* 1. Get the patient's pre-existing accounts
* 2. Check if already enrolled, and if so, return
* 3. Construct the Parameters resource with the existing accounts and the new organization
* 4. Call the $set-accounts operation with the Parameters resource. It will update the Patient and eligible resources in its FHIR compartment, such as Observations and Tasks.
* See docs: https://www.medplum.com/docs/api/fhir/operations/patient-set-accounts
*
* @param medplum - The Medplum client.
* @param patient - The patient to enroll.
* @param organization - The organization to enroll the patient in.
*/
export async function enrollPatient(
medplum: MedplumClient,
patient: Patient,
organization: Organization
): Promise<void> {
// 1. Get the patient's pre-existing accounts
const accounts = patient.meta?.accounts || [];
const orgReference = getReferenceString(organization);
// 2. Check if already enrolled, and if so, return
if (accounts.some((a: Reference) => a.reference === orgReference)) {
return;
}
// 3. Construct the Parameters resource with the existing accounts and the new organization
const parameters: Parameters = {
resourceType: 'Parameters',
parameter: [
// Include all existing accounts
...accounts.map((account) => ({
name: 'accounts',
valueReference: {
reference: account.reference,
},
})),
// Add the new organization
{
name: 'accounts',
valueReference: createReference(organization),
},
// Propagate changes to resources in the Patient's FHIR compartment, such as Observations and Tasks
{
name: 'propagate',
valueBoolean: true,
},
],
};
try {
// 4. Call the $set-accounts operation with the Parameters resource. It will update the Patient and eligible resources in its FHIR compartment, such as Observations and Tasks.
await medplum.post(`fhir/R4/Patient/${patient.id}/$set-accounts`, parameters);
} catch (error) {
throw new Error(normalizeErrorString(error));
}
}Find other example enrollment methods here.
//Assigning a specific Patient to the clinic-a tenant
const medplum1: MedplumClient = {} as MedplumClient;
const patientId1 = 'patient-id';
await medplum1.post(`fhir/R4/Patient/${patientId1}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'Organization/clinic-a' },
},
],
});This will update the meta.compartment field of the Patient resource to include the reference to the Organization. This excerpt shows the account assignment; other metadata and compartment references are omitted:
{
"resourceType": "Patient",
"meta": {
"accounts": [{ "reference": "Organization/clinic-a" }],
"compartment": [{ "reference": "Organization/clinic-a" }]
}
}
//Assigning a specific Patient to the cardiology-service tenant
const medplum2: MedplumClient = {} as MedplumClient;
const patientId2 = 'patient-id';
await medplum2.post(`fhir/R4/Patient/${patientId2}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'HealthcareService/cardiology-service' },
},
],
});This will update the meta.compartment field of the Patient resource to include the reference to the HealthcareService. This excerpt shows the account assignment; other metadata and compartment references are omitted:
{
"resourceType": "Patient",
"meta": {
"accounts": [{ "reference": "HealthcareService/cardiology-service" }],
"compartment": [{ "reference": "HealthcareService/cardiology-service" }]
}
}
//Assigning a specific Patient to the diabetes-care-team access group
const medplum3: MedplumClient = {} as MedplumClient;
const patientId3 = 'patient-id';
await medplum3.post(`fhir/R4/Patient/${patientId3}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'CareTeam/diabetes-care-team' },
},
],
});This will update the meta.compartment field of the Patient resource to include the reference to the CareTeam. This excerpt shows the account assignment; other metadata and compartment references are omitted:
{
"resourceType": "Patient",
"meta": {
"accounts": [{ "reference": "CareTeam/diabetes-care-team" }],
"compartment": [{ "reference": "CareTeam/diabetes-care-team" }]
}
}
Resources that support access rules based on meta.compartment can be assigned to tenants with this model. Binary uses securityContext instead. For example, you could also assign a Questionnaire to a tenant by calling the $set-accounts operation on that specific resource.
//Assigning a specific Questionnaire to the clinic-a tenant
const medplum4: MedplumClient = {} as MedplumClient;
const questionnaireId1 = 'questionnaire-id';
await medplum4.post(`fhir/R4/Questionnaire/${questionnaireId1}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'Organization/clinic-a' },
},
],
});//Assigning a specific Questionnaire to the cardiology-service tenant
const medplum5: MedplumClient = {} as MedplumClient;
const questionnaireId2 = 'questionnaire-id';
await medplum5.post(`fhir/R4/Questionnaire/${questionnaireId2}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'HealthcareService/cardiology-service' },
},
],
});//Assigning a specific Questionnaire to the diabetes-care-team access group
const medplum6: MedplumClient = {} as MedplumClient;
const questionnaireId3 = 'questionnaire-id';
await medplum6.post(`fhir/R4/Questionnaire/${questionnaireId3}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'CareTeam/diabetes-care-team' },
},
],
});Why is Patient a special case?
Patient supports propagation to existing resources in its FHIR compartment, such as Observations and Tasks. Ordinary writes of resources referring to the Patient can also inherit the Patient’s tenant accounts. These behaviors are useful when the Patient and its clinical records share a tenant audience. A resource is determined to "belong" to a Patient based on the resource relationships defined by the Patient CompartmentDefinition.
For example, a QuestionnaireResponse belongs to a Patient if it has a reference to the Patient in the subject or author field, a Communication belongs to a Patient if it has a reference to the Patient in the subject, recipient, or sender field, etc.
To apply account changes to existing resources in the Patient's FHIR compartment, such as Observations and Tasks, call $set-accounts with propagate: true. Propagation updates resources in the target project that the caller can read and update; verify the resulting assignments before treating a transfer as complete.
//Assigning a specific Patient to the clinic-a tenant and propagating to all resources that _"belong"_ to that Patient
const medplum7: MedplumClient = {} as MedplumClient;
const patientId4 = 'patient-id';
await medplum7.post(`fhir/R4/Patient/${patientId4}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'Organization/clinic-a' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});//Assigning a specific Patient to the cardiology-service tenant and propagating to all resources that _"belong"_ to that Patient
const medplum8: MedplumClient = {} as MedplumClient;
const patientId5 = 'patient-id';
await medplum8.post(`fhir/R4/Patient/${patientId5}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'HealthcareService/cardiology-service' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});//Assigning a specific Patient to the diabetes-care-team access group and propagating to all resources that _"belong"_ to that Patient
const medplum9: MedplumClient = {} as MedplumClient;
const patientId6 = 'patient-id';
await medplum9.post(`fhir/R4/Patient/${patientId6}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'CareTeam/diabetes-care-team' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});With this Patient-based assignment model, ordinary writes of resources in the Patient's FHIR compartment inherit the Patient’s account references in meta.accounts; the server includes those references in meta.compartment. Propagation follows each resource’s own FHIR Patient compartment references, such as subject, rather than arbitrary links like Communication.partOf. propagate: false skips the existing-resource sweep; it does not turn off inheritance on future writes.
Assigning a Patient to multiple tenants or teams
Use the examples below when the organizations, services, or care teams intentionally share the Patient and the resources in its FHIR compartment, such as Observations and Tasks. They call $set-accounts with multiple account references and propagation. Matching policies can then grant access to the assigned resources.
For independent Patient information, provision tenant-specific Patients. For shared Patient information with separate clinical records, use resource-specific clinical rules.
//Assigning a specific Patient to the clinic-a and clinic-b tenants
const medplum10: MedplumClient = {} as MedplumClient;
const patientId7 = 'patient-id';
await medplum10.post(`fhir/R4/Patient/${patientId7}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'Organization/clinic-a' },
},
{
name: 'accounts',
valueReference: { reference: 'Organization/clinic-b' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});//Assigning a specific Patient to the cardiology-service and neurology-service tenants
const medplum11: MedplumClient = {} as MedplumClient;
const patientId8 = 'patient-id';
await medplum11.post(`fhir/R4/Patient/${patientId8}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'HealthcareService/cardiology-service' },
},
{
name: 'accounts',
valueReference: { reference: 'HealthcareService/neurology-service' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});//Assigning a specific Patient to the diabetes-care-team and hypertension-care-team access groups
const medplum12: MedplumClient = {} as MedplumClient;
const patientId9 = 'patient-id';
await medplum12.post(`fhir/R4/Patient/${patientId9}/$set-accounts`, {
resourceType: 'Parameters',
parameter: [
{
name: 'accounts',
valueReference: { reference: 'CareTeam/diabetes-care-team' },
},
{
name: 'accounts',
valueReference: { reference: 'CareTeam/hypertension-care-team' },
},
{
name: 'propagate',
valueBoolean: true,
},
],
});Step 3: Grant users access
Once you've modeled your tenants and associated data with them, you also need to give your Practitioner Users access to those tenants. This is done through AccessPolicies and ProjectMembership configuration.
Use Parameterized Access Policies to supply the tenant references in each membership grant.
Create AccessPolicies with Parameterized Variables
Your AccessPolicy uses parameterized variables (like %organization, %healthcare_service, or %care_team) that get replaced at runtime with tenant or care-team references from the user's ProjectMembership. Use these variables in _compartment policy criteria to match the tenant or care-team references in each resource's meta.compartment field. See Criteria-based Access Control.
For new multi-tenant policies, prefer resource-level criteria with parameterized values instead of legacy top-level AccessPolicy.compartment rules. This makes each resource rule explicit and lets one policy template be reused across many ProjectMembership.access entries.
In your design, you should decide which resource types you want to restrict access to within your tenants versus which resource types you want to allow access to.
export const _accessPolicyOrg = {
resourceType: 'AccessPolicy',
name: 'Organization Based Access Policy',
resource: [
{
resourceType: 'Patient',
criteria: 'Patient?_compartment=%organization',
},
{
resourceType: 'Observation',
criteria: 'Observation?_compartment=%organization',
},
{
resourceType: 'Encounter',
criteria: 'Encounter?_compartment=%organization',
},
{
resourceType: 'Communication',
criteria: 'Communication?_compartment=%organization',
},
//...
],
} as const;export const _accessPolicyHS = {
resourceType: 'AccessPolicy',
name: 'HealthcareService Based Access Policy',
resource: [
{
resourceType: 'Patient',
criteria: 'Patient?_compartment=%healthcare_service',
},
{
resourceType: 'Observation',
criteria: 'Observation?_compartment=%healthcare_service',
},
{
resourceType: 'Encounter',
criteria: 'Encounter?_compartment=%healthcare_service',
},
{
resourceType: 'Communication',
criteria: 'Communication?_compartment=%healthcare_service',
},
//...
],
} as const;export const _accessPolicyCT = {
resourceType: 'AccessPolicy',
name: 'Care Team Access Policy',
resource: [
{
resourceType: 'Patient',
criteria: 'Patient?_compartment=%care_team',
},
{
resourceType: 'CarePlan',
criteria: 'CarePlan?_compartment=%care_team',
},
{
resourceType: 'Encounter',
criteria: 'Encounter?_compartment=%care_team',
},
{
resourceType: 'Communication',
criteria: 'Communication?_compartment=%care_team',
},
//...
],
} as const;Configure membership grants
In this pattern, the User's ProjectMembership supplies its approved tenant or care-team references through access.parameter. This is a permission grant; it does not assign the User's profile or clinical records to a tenant. Each parameter name must match the variable name used in the AccessPolicy (e.g., if your AccessPolicy uses %organization, the User's ProjectMembership access.parameter should be named "organization").
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/mso-policy" },
"parameter": [
{
"name": "organization",
"valueReference": { "reference": "Organization/clinic-a" }
}
]
}
]
}
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/service-policy" },
"parameter": [
{
"name": "healthcare_service",
"valueReference": { "reference": "HealthcareService/cardiology-service" }
}
]
}
]
}
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/careteam-policy" },
"parameter": [
{
"name": "care_team",
"valueReference": { "reference": "CareTeam/diabetes-care-team" }
}
]
}
]
}
When should you assign a User to a tenant?
You can assign a User to a tenant at invite time or after they have been invited.
Invite Practitioner Users at Invite Time
Invite Practitioner Users associated with their respective tenants via the /admin/invite endpoint:
Example: Inviting a Practitioner User with Tenant Access
const medplum13: MedplumClient = {} as MedplumClient;
await medplum13.post('admin/projects/:projectId/invite', {
resourceType: 'Practitioner',
firstName: 'Jane',
lastName: 'Smith',
email: 'dr.smith@example.com',
membership: {
access: [
{
policy: { reference: 'AccessPolicy/careteam-policy' },
parameter: [
{
name: 'care_team',
valueReference: { reference: 'CareTeam/hypertension-care-team' },
},
],
},
],
},
});Assign Practitioner Users to a Tenant After Invite
The helper below assumes the Practitioner has one membership in the project. If you provision multiple memberships for that profile, select the intended membership by ID before updating its grants.
Example Method: Enrolling a Practitioner in an Organization Tenant After Invite
/**
* Enrolls a practitioner in an organization by adding the organization to the access array of the practitioner's project membership.
*
* 1. Search for the practitioner's project membership, if there is no project membership, throw an error
* 2. Check if the organization reference already exists in any access array
* 3. If the organization reference does not exist, add the organization to the ProjectMembership.access array
* 4. Update the ProjectMembership resource
*
* @param medplum - The Medplum client.
* @param practitioner - The practitioner to enroll.
* @param organization - The organization to enroll the practitioner in.
* @returns The updated project membership resource
*/
export async function enrollPractitioner(
medplum: MedplumClient,
practitioner: Practitioner,
organization: Organization
): Promise<ProjectMembership> {
// 1. Search for the practitioner's project membership, if there is no project membership, throw an error
const projectMembershipSearch = await medplum.searchOne('ProjectMembership', {
profile: getReferenceString(practitioner),
});
if (projectMembershipSearch) {
const membershipResource = projectMembershipSearch;
const existingAccess = membershipResource.access || [];
// 2. Check if this organization reference already exists in any access array
const organizationExists = existingAccess.some((access) =>
access.parameter?.some(
(param) => param.name === 'organization' && param.valueReference?.reference === getReferenceString(organization)
)
);
// 3. If the organization reference does not exist, add the organization to the ProjectMembership.access array
if (!organizationExists) {
const policy = await medplum.searchOne('AccessPolicy', {
name: 'Your Access Policy Name',
});
if (!policy) {
throw new Error('Access policy not found');
}
if (existingAccess.length > 0) {
existingAccess.push({
parameter: [{ name: 'organization', valueReference: createReference(organization) }],
policy: { reference: getReferenceString(policy) },
});
} else {
membershipResource.access = [
{
parameter: [{ name: 'organization', valueReference: createReference(organization) }],
policy: { reference: getReferenceString(policy) },
},
];
}
}
// 4. Update the ProjectMembership resource
try {
const updatedResource = await medplum.updateResource(membershipResource);
return updatedResource;
} catch (error) {
throw new Error(normalizeErrorString(error));
}
}
throw new Error(`No project membership found for practitioner ${practitioner.id}`);
}Granting access to multiple tenants or teams
To grant access to multiple groups, include multiple entries in the access array with the approved parameters. The standalone CareTeam example below uses one entry per team. Where practice and team conditions must both apply, repeat the combined grant instead. The resulting session can access the combined grants. Use separate authenticated sessions when each session must be limited to one tenant.
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/mso-policy" },
"parameter": [
{
"name": "organization",
"valueReference": { "reference": "Organization/clinic-a" }
}
]
},
{
"policy": { "reference": "AccessPolicy/mso-policy" },
"parameter": [
{
"name": "organization",
"valueReference": { "reference": "Organization/clinic-b" }
}
]
}
]
}
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/service-policy" },
"parameter": [
{
"name": "healthcare_service",
"valueReference": { "reference": "HealthcareService/cardiology-service" }
}
]
},
{
"policy": { "reference": "AccessPolicy/service-policy" },
"parameter": [
{
"name": "healthcare_service",
"valueReference": { "reference": "HealthcareService/neurology-service" }
}
]
}
]
}
{
"resourceType": "ProjectMembership",
"access": [
{
"policy": { "reference": "AccessPolicy/careteam-policy" },
"parameter": [
{
"name": "care_team",
"valueReference": { "reference": "CareTeam/alice-smith" }
}
]
},
{
"policy": { "reference": "AccessPolicy/careteam-policy" },
"parameter": [
{
"name": "care_team",
"valueReference": { "reference": "CareTeam/bob-jones" }
}
]
}
// ... one entry per patient CareTeam the user is assigned to
]
}
Can some resource types still be accessed by Users, regardless of the tenant(s) they are assigned to?
A good thing to consider is that your application may need to allow some resource types to be accessed by Users, regardless of the tenant(s) they are assigned to. For example, you may want to allow Questionnaires to be accessed by Users, regardless of the tenant(s) they are assigned to because you want one single Patient Onboarding Questionnaire or you want Practitioners to be able to view each other's profiles, even if they are not assigned to the same tenant.
For a resource type intentionally shared in full, grant reads without the tenant criterion. If only some resources are shared, use criteria that match those designated shared resources alongside the tenant rules. An unfiltered rule for that resource type would also expose other tenants’ resources.
export const _accessPolicyMixed = {
resourceType: 'AccessPolicy',
name: 'Questionnaire Access Policy',
resource: [
//Non tenant level restricted resources
{
resourceType: 'Questionnaire',
readonly: true,
},
{
resourceType: 'Practitioner',
readonly: true,
},
//...
//Tenant level restricted resources
{
resourceType: 'Patient',
criteria: 'Patient?_compartment=%organization',
},
{
resourceType: 'Observation',
criteria: 'Observation?_compartment=%organization',
},
{
resourceType: 'Encounter',
criteria: 'Encounter?_compartment=%organization',
},
{
resourceType: 'Communication',
criteria: 'Communication?_compartment=%organization',
},
//...
],
} as const;Tenant selection and sessions
Choose whether staff work in one authenticated tenant context or combine authorized tenant access. A tenant selector can narrow the visible records within combined access. Keep any care-team restrictions in effect within the selected practice or service.
See Identity, Memberships, and Sessions.
Verify and continue
Test each tenant’s direct reads, searches, and writes, including files and records created by Bots or imports. Check Patient-record behavior and transfers with the chosen shared or tenant-specific Patient model.
Use Access Policies for resource and field permissions and Identity, Memberships, and Sessions for authenticated context. If the application’s sharing requirements change, revisit the Tenancy Design Decision Guide.