I’ve a code that works as expected but I do not undestand why, so I need your help to figure out what is doing this code
With a task that appliesTo reports of type ‘patient_assessment’ , the patient_assessment form doesn’t have a field follow_up_count, the task action is defined as:
actions: [{
form: 'referral_followup,
modifyContent: (content, contact, report) => {
const followUpCount = parseInt(getField(report, 'follow_up_count'), 10) || 0;
content.t_follow_up_count = followUpCount + 1;
}],
if referral_followup form doesn’t have a follow_up_count field, the t_follow_up_count variable passed to the form has always the value 1, and this is clear, but if the referral_followup has the follow_up_count, the t_follow_up_count variable passed to the form has incremental values as expected, 1,2,3…
In my understanding in the user device the reports will be processed one by one and only patient_assessment reports will be processed, since patient_assessment report has never the field follow_up_count the const followUpCount
will be 0 and the content.t_follow_up_count = followUpCount + 1
will be allways 1 but this is not happening