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 7 forks source link

Allow requiring form's fields using "Depending on" value #608

Closed bnygren closed 1 month ago

bnygren commented 5 months ago

Situation: Some fields are revealed when a preceding field value matches a value range using the "depending on" attribute. The subsequent (dependent) field would typically be required (i.e., user must make a selection to save the form). Currently the user can skip any field with a 'depending on' attribute, leading to poor data quality.

A proposed workaround with having a default value in the dependent field is infeasible because 1) it is functionally no different than not being required since the user could just leave the field as is; 2) Having a default value (e.g., NA, or " ") in the dependent field confuses the uses as it is not in the source form, and introduces incorrect values into the data that must be cleaned before utilizing the data.

Proposed solution: Add new JSON attribute that allows for requiring a dependent field. This was discussed as being technically challenging but solutions should be thoroughly investigated as the data system appears functionally limited compared to common data collection tools in its current state.

{ "type": "yes-no", "id": "FMH1", "caption": "Is finger marked for OPV?", "important": "true" },{ "type": "dropdown", "id": "ReasonsH1", "caption": "Reason if finger is not marked", "dependingOn": "FMH1", "dependingOnValues": ["false"], "important": "true", "options":[ {"key":"NoTeam","caption":"No team","order":"1"}, {"key":"Absent","caption":"Absent","order":"2"}, {"key":"NewBorn","caption":"New Born","order":"3"}, {"key":"Sick","caption":"Sick","order":"4"}, {"key":"Sleep","caption":"Sleep","order":"5"}, {"key":"Refuse","caption":"Refuse","order":"6"}, {"key":"Other","caption":"Other","order":"7"}] },

RaziaMahmodi commented 4 months ago

When the Yes-No condition is not met, user is still able to select a value from dropdown and save the record.

RaziaMahmodi commented 2 months ago

As I checked, I don't see any improvement for this issue on Test server. The miner part that doesn't work is that when the new form is opened, the Dependingon field is visible. It should be hidden. If the DependingValueon is met, it should be shown.