Dear,
I am creating a task to have a follow up on a report (all the time). but I have 2 issues:
-
the task report has as contact the CHW not the patient
-
I cannot find a way to close the task if there is a single report submitted that was generated from that task
could you help ?
module.exports = [
{
name: 'tchad_form_pause',
icon: 'icon-healthcare-diagnosis',
title: 'diagnostic',
appliesTo: 'report',
appliesToType: IMCI_FORMS,
actions: [
{
type: 'report',
form: TASK_FORM,
modifyContent: generateIMCIContent
}
],
events: [
{
id: 'tchad_form_pause',
days: 0,
start: 1,
end: 0
}
],
resolvedIf: IMCIresolveIf
}
];
function IMCIresolveIf(contact, report, event) {
return isFormArrayHasSourceId(contact.reports, event.id, [TASK_FORM]);
}
function isFormArrayHasSourceId(reports,id, formArray) {
reports.forEach(function (report) {
if (formArray.includes(report.form)) {
if (report.source_id === id) {
return true;
}
}
});
return false;
}
var generateIMCIContent = function (content, contact, report){
//console.log('generateIMCIContent'+ content.source_id);
content.patient_uuid = getField(report, 'patient_uuid');
injectDataFromForm(content,'_case_',IMCI_CASE_DATA, IMCI_FORMS , [report]);
//console.log('generateIMCIContent Done');
};