Closed rafinkanisa closed 2 years ago
To update script db.beneficiaries.find({ report_year: 2021, admin0pcode: "AF" }).forEach(function (beneficiary) { if ((beneficiary.boys + beneficiary.men + beneficiary.elderly_men + beneficiary.girls + beneficiary.women + beneficiary.elderly_women) !== beneficiary.total_beneficiaries){ beneficiary.total_male = 0; beneficiary.total_female = 0; beneficiary.total_beneficiaries = 0;
beneficiary.total_male += ((beneficiary.boys === null || beneficiary.boys === undefined || beneficiary.boys === NaN || beneficiary.boys < 0 || beneficiary.boys === '') ? 0 : beneficiary.boys) +
((beneficiary.men === null || beneficiary.men === undefined || beneficiary.men === NaN || beneficiary.men < 0 || beneficiary.men === '') ? 0 : beneficiary.men) +
((beneficiary.elderly_men === null || beneficiary.elderly_men === undefined || beneficiary.elderly_men === NaN || beneficiary.elderly_men < 0 || beneficiary.elderly_men === '') ? 0 : beneficiary.elderly_men);
beneficiary.total_female += ((beneficiary.girls === null || beneficiary.girls === undefined || beneficiary.girls === NaN || beneficiary.girls < 0 || beneficiary.girls === '') ? 0 : beneficiary.girls) +
((beneficiary.women === null || beneficiary.women === undefined || beneficiary.women === NaN || beneficiary.women < 0 || beneficiary.women === '') ? 0 : beneficiary.women) +
((beneficiary.elderly_women === null || beneficiary.elderly_women === undefined || beneficiary.elderly_women === NaN || beneficiary.elderly_women < 0 || beneficiary.elderly_women === '') ? 0 : beneficiary.elderly_women);
beneficiary.total_beneficiaries += beneficiary.total_male + beneficiary.total_female;
db.beneficiaries.save(beneficiary)
} })
and for preventive action before saving report , need to recalculate so this won't happen again
For prevention, we add a function to recalculate the beneficiaries before saving the report Link PR: iMMAP/ngm-reportHub#97
In the screenshots below, the SADD group has different total number with the total beneficiaries calculated automatically by the system
Link : https://reporthub.org/desk/#/cluster/projects/report/5faa586b399d8e9d34eeff5a/612edea27fd758f36030d1ff Location : Kunar, Dara-e-Pech, Senzia CHC
Not just this one, many other reports have the same issue Kindly identify the issue and fix