How to display tasks in user level (example: Chw, Midwife)

Can anyone explain me how to display tasks in user level

example: few tasks should display only for chw and few should show up only for midwife

Display of tasks is controlled by the specifications in the appliesTo field and the return value of the appliesIf function. More details can be found in the task reference documentation.

If it’s possible to share details about the scenarios you’re working on, we can walk through configuration samples.

1 Like

Hello team,

How can I restrict tasks to appear for a CHW and not their supervisor? @Japheth_Kiprotich can share a snip of what the code looks like.

Sure @Esther_Moturi.

Here’s a simple task


  {
    name: 'assessment-after-registration',
    icon: 'icon-healthcare',
    title: 'CHW Consultation',
    appliesTo: 'contacts',
    appliesToType: ['person'],
    appliesIf: c => c.contact.role === 'patient', /*Todo: add check for CHW*/
    actions: [{ form: 'assessment' }],
    events: [
      {
        id: 'assessment-form',
        days: 7,
        start: 7,
        end: 2,
      }
    ],
    resolvedIf: function (contact, report, event, dueDate) {
      return Utils.isFormSubmittedInWindow(
        contact.reports,
        'assessment',
        Utils.addDate(dueDate, -event.start).getTime(),
        Utils.addDate(dueDate, event.end + 1).getTime()
      );
    }

  },

Found a workaround using the snippet below.

appliesIf: c => c.contact.role === 'patient' && user.role === 'chw'
1 Like