Hi everyone,
One question regarding tasks triggered from a location instead of patient. We have a form on location level (to anonymize the patient), that can be filled in by a CHW. When the form is filled in, it triggers a task which can later be finished by the CHW. If multiple Forms are filled in at location level, multiple tasks are triggered per form (let’s say three for simplicity). Having these three tasks, and assessing just one, will resolve all of the others. I assume this is because of the resolvedIf. Is there a way to construct the resolvedIf in a way that only one task is resolved? Ideally the one that was just clicked?
Currently I am working with this:
resolvedIf: function(contact, report, event, dueDate) {
const startTime = Math.max(addDays(dueDate, -event.start).getTime(), report.reported_date);
const endTime = addDays(dueDate, event.end + 1).getTime();
let found;
let forms = ['young_infant_afterlab'];
contact.reports.forEach(function (c_report) {
if (!forms.includes(c_report.form)) { return; }
if (c_report._id === report._id) {
found = true;
}
});
return isFormArraySubmittedInWindow(
contact.reports, ['young_infant_afterlab'], startTime, endTime
) ;
}
_afterlab being the task and young_infant the form that triggers the task (for completeness). I was trying to work with the report ID but doesn’t work, I assume because it goes through all reports in the location and all tasks and it will find matches for each.
Any help would be appreciated.