Community Health Toolkit

What are different ways tasks can go in cancelled state?

In one of the instances I’m working on, larger amount of tasks went into Cancelled State in one particular month. I would like to know what are the different reasons tasks can go into Cancelled state.

Adding additional context on original issue, it looks like these tasks went from Draft state to Cancelled state. Does it mean tasks were never shown to CHWs? How can it happen ?

According to the docs, a task can go to “Cancelled” state if:

Task was not emitted when refreshing the requester’s data. Task has invalid partner emission.

The task was generated at least once but later in subsequent recalculation/refresh of tasks, it was no longer there, hence canceled.

This could be because:

  • appliesIf no longer returns true
  • or, the task definition is no longer there in the configuration
2 Likes

it looks like these tasks went from Draft state to Cancelled state. Does it mean tasks were never shown to CHWs?

Yes, it means these tasks were “scheduled” in the future (Draft) but the user never viewed them.

How can it happen ?

This can happen for several reasons - but in general, the task has become Cancelled which - as @binod points out correctly - this probably means appliesIf returned false. But there are a few more edge cases which may cause this:

  • Emissions that are more than 90 days old are discarded - so if you’re expecting to see a task “Failed” but you go too far into the future (like user not logging in for 3 months), it can become cancelled instead.
  • Some scenarios in which a user rewinds their system clock can result in cancelled docs. Specifically, if the “authoredOn” attribute of a taskDoc is in the future.
  • If you are working with emissions made via nools.rules, there are several “invalid emissions” which may cause a task to become cancelled. These should not be possible with the declarative system which guarantees well-formed emissions.
  • Maybe this is an obvious extension of what @binod has above “task definition is no longer there” – but if you rename a task definition, all existing task docs will be cancelled and new docs will be created.

Are you writing tests or investigating unexpected values in data?

5 Likes

Interesting question.

1 Like