Can we cascade task to all lower levels when a form is submitted from higher level user

How can i cascade task from national levels to health center levels.

National-> Region-> District->Health center.

Example: A health center submits a alert form and a unique id is generated and we are passing that unique alert id to each higher level when ever a form is submitted unit national level.
So,when National level user verified the alert details and submits a action test result form for that alert id .It should trigger a task to the regional,district and health center level users whoever submitted the forms.

The Workflow i have done is as following:

  1. National level user submits a Test result form and a task will trigger to regional level user
  2. When regional level user submits the task. In task.js: I am filtering all the contact reports that district user submitted and fetch the unique “alert_id + report” from which i am capturing district details and passing the district_id in additional doc to trigger a task to the particular district from the alert_id is passed.
    3.Same as Regional level user, i am doing the same thing and when a district user submits a form then a task is getting triggered to health center level.

Instead of submitting the form and adding additional docs at each level. Is it possible to trigger a task to all lower level users when a national user submits a form/report.

Thanks in advance.

Hey @bindugowrig to answer your question let’s carefully consider your scenario.

  1. you are dealing with offline users (since you avail tasks at each level), each with a replication depth of 1
  2. you are working with both actions and tasks to capture data and cascade it down the hierarchy
  3. you want to match reports (not contacts) based on a report attribute that also exists in another report at a given hierarchy level.

What is the implication of the above aspects?

  1. for you to trigger a task a hierarchy level below (e.g. national to regional), you need a report to belong to the level (place for that matter). If the report is submitted as an action, you can easily put it at the lower level by either selecting the contact or submitting the report from the contact’s profile Action tab. The same will apply as you move down the hierarchy, for reports submitted as actions. Remember, in your case, you cannot use a report existing at a level above the hierarchy to trigger a task to a level below, because of the offline nature of the users and the replication depth.
  2. for tasks, let’s take a scenario whereby you have submitted an action report at the national level to the region level and you want another task at district level. First, the regional user has to complete the task, and to cascade the information to district level, you need to create an additional document with place_id pointing to the district. It is the latter report that will enable you trigger a task at district level. As you do so, you are making copies of the data and effectively cascading the data down the hierarchy.
  3. regarding matching of reports, you need to have an existing report for the contact that you want to do the match. This means that as you move data up the hierarchy, you must keep a record of relevant attributes. For example, if we have a report as follows for health_center with uuid hc-id
    {
        "_id": "uuid-1",
        "...": "...",
        "place_id": "hc-id",
        "alert_id": "2021-005-LOL-0003"
    }

a sample copy of the data at district level can take the format below.

     {
        "_id": "uuid-2",
        "...": "...",
        "hc_place_id": "hc-id",
        "place_id": "district-id",
        "alert_id": "2021-005-LOL-0003"
    }

To match reports at district level when a report is submitted from the region level (Region-> District as per your hierarchy) that looks like the sample below,

    {
        "_id": "uuid-3",
       "...": "...",
        "place_id": "district-id",
        "alert_id": "2021-005-LOL-0003"
    }

you simply use the matched attribute alert_id

Key things to note:

  • Ensure you capture all relevant attributes you need at each level as you move data up and down.
  • Utilize depth and needs_signoff where necessary.
  • resolvedIf using reports shall work if dealing with reports within the same context i.e. contact.reports
  • Utilize contactLabel to trigger tasks up the hierarchy.

Hi @kitsao ,

Yes, I am considering all the above points. Just want to confirm is there anyway to trigger a task to all lower levels when higher level(national user) submits a action form.

As of now, We are only able to submit a task to next lower level when a task is submitted.

@bindugowrig if you have access to all places IDs at the national level, then you can proceed by creating additional docs at all lower hierarchy levels to enable you trigger the tasks. The biggest catch is that you cannot retrieve the place IDs when submitting an action report, but can do it via a task’s modifyContent and reports matching using alert_id (the details of place IDs shall be available in the copies you make as you move data up the hierarchy. Remember you have the depth limit of 1.

@kitsao , I have two more questions:

1.Yes i am passing all the place ID’s to national level .As the test result is a action form and we cannot enable the tasks .So can we add multiple additional data-docs in regional level test result task so upon submitting regional level test result task to trigger a task at district and health center levels.

  1. Can we change the Action test result in national level user to task test result and create additional data-docs at National levels itself if above scenario works?

For 1, yes you can place reports (additional docs) at district and health center, since you have the relevant place_ids.

Regarding 2, you can do it. However, you need to have a definite window period for the task. Presumably, we have no knowledge of how soon a result shall be available. You can explore both action and task if there is design buy-in.