Hello,
We're using access policies to assign organizations to the meta.accounts and meta.compartment field. When the resource is created with a properly scoped access policy, the organization is added to both of these.
However, when a resource is updated the organization reference is removed from the accounts and compartment. Our understanding is that the expected behavior is that the organization is retained in updates and cannot be changed/replaced/removed.
Are we misunderstanding this functionality? Or is it possible there is a bug here? For reference, we believe we've traced the issue here
https://github.com/medplum/medplum/blob/8bffe8d686b93753ac1a9c72c6227533f049f50c/packages/server/src/fhir/repo.ts#L2016
the getAccounts method doesn't appear to build accounts on update for resources that aren't part of a patient compartment.
Thanks for looking.