@diana is the expert here and might have more details, but here is what I know:
First, I just want to recognize that moving contacts in the CHT is a huge pain point and we recognize that. (See this forum thread for additional brainstorming around this issue). The main reason moving contacts is so tricky is because the contact has historically been the backbone of our syncing algorithm (determining which documents the server sends to an “offline” user and which docs the server will accept from an “offline” user). So, anytime you want to move a contact in a way that it should become visible to a new user and disappear from an existing user’s data, it gets tricky. Hence the note in the move contacts docs about users needing to clear their cache. (See this issue for discussion around the additional complexities related to moving users’s contacts.)
The ray of hope, though, is this issue where we are exploring the possibility of changing how users are connected to the contact hierarchy (thereby affecting how the CHT determines which docs to sync for the user). My hope is that the outcome of that issue (and probably additional followup projects) might make it much more feasible to move contacts around without having to worry about causing syncing issues with with users.
Now, getting down to more of the specifics of your question, it is important to note that each contact contains a complete record of who its parents (and all their ancestors) are in the hierarchy (again, this has historically been used by the syncing algorithm). Reports, on the other hand, just contain a record of which person/place they are associated with (without additional information about that person/place’s parents). So, moving a PERSON via an edit contact form is possible because it is simply editing that person doc’s parent
data. This will automatically associate the person with the new parent place (*insert all the caveats about bad things happening if the move results in a user no longer having access to a person that they previously could see…).
However, moving a PLACE would require also updating all of the descendant contacts of the place (places/persons that exist below that place in the hierarchy). AFIK, there is not any logic in place in the CHT to do this kind of recursive update when editing a place. (Even adding logic like that would be sketchy at this point since an offline user might not even have access to all the descendant contacts (e.g. a supervisor with replication_depth
configured so they can see CHW Areas, but not Households or patients…). Hence why the move-contacts
action was implemented in cht-conf.
So, things are pretty bleak right now, but if we can decouple users syncing from the contact hierarchy then maybe we could avoid needing to de-normalize the entire ancestor hierarchy into each contact. This would get us to a place where moving PLACES would be much more feasible!