Assigning Cases to One of Multiple Locations

For mobile workers assigned to locations that can "View Child Data", they can sometimes be in more than one case sharing group. The user will be required to choose which location the case gets assigned to. For example, a clinic may be required to register clients and assign them to one of their CHWs.

This will add a multiple choice question in your application that allows you to choose which location a case will be assigned to.  

Step 1: Turn on the Add-On

When a mobile worker is registering a patient, you want to display a list of the case sharing groups so that they can assign the case to the appropriate location.  To do this, you need to turn on an Add-On called "Custom Single and Multiple Answer Questions".  This allows you to display custom choice lists in forms (i.e. a list of case sharing groups) instead of just items from a Lookup Table

Choose the Application Settings (the gear icon next to your application's name near the top left of the screen)

Navigate to the Add-Ons tab

Turn on the "Custom Single and Multiple Answer Questions" add-on under "Calculations" and hit Save

Step 2: Configure Your Application

In the application, you need to setup your Registration form so that it displays the list of case sharing groups in a single or multiple select question.  

Go to your form that is used to register a new case.  Choose the Choice dropdown and add a new Multiple Choice Lookup Table question. 

Set the question ID to owner_id (or whatever makes sense) and the label "What location do you want to assign the user to? (or whatever makes sense)".

Choose the "Lookup Table Data" item in the left tree, and then choose the "..." button to configure the list of choices.

Set the Query Expression to instance('locations')/locations/location[@type = 'TYPE OF LOCATION'] (note: be sure to change "TYPE OF LOCATION" to the specific type of location in your application. This will display the list of locations that are available to own the case.  Set the Instance ID to locations and the Instance URI to jr://fixture/locations.  Then click on the Save button. 

Back on the Lookup Table Data page, set the Value field to @id and the Display Text field to name.  Note that the Lookup Table dropdown should say "Lookup table not found in project".

Save your form, and then go to the Case Management section of the form and save the question to the case property called owner_id, which is a special property used to define the owner of the case.