Community Health Toolkit

Flexible Hierarchies - Fetching new places in the XFORMS

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

Describe the Bug
After successfully configuring a new place level, getting an error when attempting to load the UUID of this level on a contact creation form. E.g When creating a Health Center (now a child of a Supervisor Area level of contact_type supervisor_area and type contact).

ERROR
pyxform.errors.PyXFormError: Unknown question type ‘db:contact’.

How To Reproduce The Issue

  1. Create a Supervisor Area level
  2. Modify the health_center-create workflow to have the question “In which Supervisor Area will this CHW Belong”?
  3. Set the question type to db:contact since the supervisor_area contact type has “type”: “contact”
  4. See error when uploading the form to the server.

Expected Behavior
I expect to attach CHW Areas to the new level using the health_center-create workflow.

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

Hey @sheila_abby with configurable hierarchy, use db:<contact_type> instead of db:<type>. In your case, db:supervisor_area should work just fine.

Hi @kitsao
I have tried adding db:supervisor_area on the type column of the form.
Getting
pyxform.errors.PyXFormError: Unknown question type ‘db:supervisor_area’.

Hey @sheila_abby I see. It goes back to contact selector, which would be easy to handle in versions 3.10 +. However, since you’re on version 3.7, you’ll have to modify Pyxforms question_type_dictionary.py, in my case located on /usr/local/lib/python2.7/dist-packages/pyxform/question_type_dictionary.py to include the type you’re working with i.e.

QUESTION_TYPE_DICT = \
    {
        ...,
        "db:<contact_type>": {
            "control": {
                "tag": "input"
            },
            "bind": {
                "type": "db:<contact_type>"
            }
        }
    }

Then proceed to convert your forms.

1 Like

Thank you @kitsao This works!!

1 Like