Complex Case Sharing


I have a complex case sharing requirement that I need help with.

Our company is in the field of health research. Our location structure is Country > Province > District > Facility(Clinic/Hospital). The issue though is that we have our ‘own’ teams (multiple mobile workers) that are required to capture patient details, and we also have independent service providers that capture patient details.

Ideally, I do not want the independent service provider to be able to access the case details of the patients captured by our ‘own’ teams or by other independent service providers. Yet, at the same time, I need our ‘own’ teams to be able to access and update patient cases captured by other members of the same team (each district has one team).

Another issue adding to this, is that I need the all mobile workers to be assigned to a district to ensure they only capture in their respective district and due to the large number of facilities, it would not be feasible to remove the location settings as this will make the app slower and take up device space…

I would really appreciate a solution to this… Thanks in advance !


Hi @Clayton_Sims

Sorry to bother you, but maybe you could guide me here with the above - it’s a related problem to Case Sharing: Unrecoverable Error

If there’s no solution to this, then I’m thinking of removing the locations and using the Groups instead. Just means I will have add LookUp tables for the locations and change the questions around to reflect this…


A few thoughts on your workflows:

I think you should be able to get a structure like the one you outlined to work.

One option would be to configure the “Facility” level location to not share cases, but to configure a “Team” level underneath the Facility level which does share cases. Independent providers would then need to be added into Teams of One, which contains only their user. In that configuration, “Mobile Worker 1, 2, 3” would be assigned to the same “Team” while Independent Provider 1 would be on the “Independent Provider 1” team. It will mean an extra, non-semantic location, but is the most straightforward option.

Since you are trying to configure a fairly specific / custom sharing profile, an alternative recommendation I have is exploring performing the case assignments manually rather than automatically. If you disable the “Case Sharing” flag from your app (I know it’s counter-intuitive), you can instead directly control where cases are assigned by setting the owner_id property of the case to be either a User ID (which you can retrieve manually from the CommCare Session, but is also the default for new cases), or to be the Location ID of a location which has case ownership enabled.

One example of doing this is documented on the wiki, for allowing users to choose an assignment from a list. In your case, though, it sounds like the assignment is deterministic: A case is owned directly by the Provider’s User for independent providers, but by the Facility (or another location) for the Shared workers.


Hi Clayton

Thank you for your suggestions.

I have turned off “Own Cases” under the Organization Levels and assigned the Mobile Workers to the their Case Sharing Groups . This seems to be working now. In the process of testing it out so looking forward to the outcome.

Thank you for your assistance