Skip to main content

Patient $set-accounts Operation

Medplum implements a custom $set-accounts operation for Patient resources to manage account references. This is the recommended way to manage account references for patients.

This operation sets the Patient's meta.accounts references and propogates them to the resources in that patient's compartment. This is useful when you need to ensure consistent meta.accounts access across all resources related to a patient.

warning

This operation will only update the first 1,000 resources in the patient's compartment.

For example, when this operation is used to add a new organization to a patient's meta.accounts, it will update both the patient and all resources in the patient's compartment to include that organization in each of their meta.accounts list. Then, by updating the references in meta.accounts, each resource's meta.compartment will also be refreshed to include the references in meta.accounts.

note

Resources in a patient's compartment are defined by the FHIR Patient CompartmentDefinition. This includes resources where the patient is the subject, as well as resources that are directly linked to the patient through specific references (performer, author, participant, etc.).

Invoke the $set-accounts operation

POST [base]/R4/Patient/<id>/$set-accounts

Input

The input is a FHIR Parameters resource containing:

  • accounts a reference to set in each resource's meta.accounts

Example request payload:

{
"resourceType": "Parameters",
"parameter": [
{
"name": "accounts",
"valueReference": {
"reference": "Organization/<organization-id>"
}
},
{
"name": "accounts",
"valueReference": {
"reference": "Practitioner/<practitioner-id>"
}
}
]
}

Output

The output is a FHIR Parameters resource containing:

  • resourcesUpdated The number of resources that were updated

Example response if patient has 3 resources in their compartment:

{
"resourceType": "Parameters",
"parameter": [
{
"name": "resourcesUpdated",
"valueInteger": 3
}
]
}