AFG-Polio-Data / APMIS-Project

APMIS (Afghanistan Polio Management Information System) is an supplemental Immunization Activities management system to manage the vaccination activities in the country.
https://test.afghanistan-apmis.com
GNU General Public License v3.0
4 stars 8 forks source link

Error in form data: calculated fields not re-calculating consistently after data edits #739

Open lbaertlein1 opened 1 week ago

lbaertlein1 commented 1 week ago

Bug Description

There are forms in the database where the value stored in a calculated field does not match the calculation and input fields. It is not clear exactly what is causing this, but could be that re-calculation of calculated fields are not triggered consistently when form data are edited. It could also be that some users are able to manually input values into a calculated field, that are not properly overwritten by the calculation.

The incorrect values can be seen in the Campaign Data page as well as in the database.

Steps to Reproduce

Review the below forms, for Oct SIA 2024, DC Daily Compilation H2H, in the Campaign Data page or in the database: • East/Nangarhar/Chaparhar/Shoaib Kaly (Cluster 25): The calculated field “Number Remaining Absent Day 3” is incorrect. 32 were recorded absent, 0 found vaccinated, and 7 vaccinated by the team. The total remaining absent for the day should be 32-0-7=25, but it is recorded as 24. • East/Laghman/Mehtarlam/Maidani (Cluster 4): The calculated field “Number Remaining Absent Day 3” is incorrect. 27 were recorded absent, 0 found vaccinated, and 30 vaccinated by the team. This should have been flagged as a validation error, as 30 > 27. However, the number remaining absent is recorded as 23. • East/Nangarhar/Behsud/Cluster 31: In the Grand Total section, ‘Number of children Remaining Absent (return during campaign) [Days 1-3]’ is 103, with 0 ‘found vaccinated’ and 0 ‘Revaccinated’, yet the total ‘Number of children Remaining Absent (return during campaign) [Day 4]’ is 100 instead of 103.

This error is not limited to the Oct SIA. Examples can be found in all SIAs.

Expected Behavior

Calculated fields should always be based on the current values of input fields - i.e. if input fields are edited, the calculated fields should recalculate. If a user somehow manually inputs a value in a calculated field, it should be over-ridden by the calculation.