Community Health Toolkit

Flexible Hierarchies - Moving Contacts Error

NOTE: This is a public repository. Images or logs containing protected health information (PHI) must be fully-redacted.

Describe the Bug
After adding a new place level(Supervisor Area), I attempt to move contacts (CHW Areas) to be the children of this new place.
However, I get a hierarchy constraint error…
ERROR Error: Hierarchy Constraints: contacts of type ‘health_center’ cannot have parent of type 'contact’

The medic docs recommend we have the new place type with properties
“type” set to contact
“contact_type” set to the custom_place_name

Here is a sample doc
{

  • _id: “746bd4b2-7902-4914-b822-f1aaa2558407”,

  • _rev: “1-f2fce26d7635201acf882e0e34e7d0bc”,

  • parent: {

    • _id: “27a70730-eba6-4409-9cbe-4934a50c02fa”},
  • type: “contact”,

  • contact_type: “supervisor_area”,

  • contact: {

    • _id: “029be058-aae5-48bd-85c3-9ee4419da7ac”},
  • name: “Supervisor Abby Supervisor Area”,

  • geolocation: “”,

  • peer_group_notes: “”,

  • reported_date: 1632995571188

}

How To Reproduce The Issue

  1. Creat a Supervisor Area place
  2. Get a list of CHW Areas you need to migrate to the new Level
  3. Use the medic-conf move-contacts command
  4. See error

Expected Behavior
I expect to migrate contacts in the new hierarchy without errors.

Environment

  • Instance: (eg: alpha.dev.medicmobile.org, etc)
  • Browser: (eg: Firefox, Chrome, incognito mode, etc, which worked, which didn’t)
  • Client platform: (eg: Windows, MacOS, Linux)
  • App: (eg: webapp, admin, sentinel, api, couch2pg, medic-conf, etc)
  • Version: 3.7

Additional Context
The workaround was to edit the “type” property to have the value "custom_place_name’
e.g “type”: “supervisor_area”. But will need to later change it back to “type”:“contact” after a successful migration.

Hello.

Can you please share which version of medic-conf you are using?
This issue should be fixed in the latest version: Hierarchy error prevents "move-contacts" action from working with parents using contact_type · Issue #286 · medic/cht-conf · GitHub . Do you see this error if you install cht-conf (medic-conf is now deprecated).

medic-conf version 3.1.0

Okay, let me try installing cht-conf. Thanks

Ok, looking at the commit that fixed this (Move-contact action should support use of contact_type (#286) · medic/cht-conf@15235c9 · GitHub) it looks like you need at least v3.2.0.
I still highly recommend installing cht-conf, which is regularly updated.

Thanks!

This works! No more errors…
Now using cht-conf version 3.8.0
Thanks @diana

2 Likes