I want to be able to hide or show some areas of a Tracker form. The user selects one or other option which in turn shows or hides a section of the form. I want to incorporate mandatory fields within the areas that are unhidden. I am able to achieve this using program rules to apply a ‘mandatory field’ flag to the appropriate fields as they are unhidden. The trouble comes where the user unselects that item or changes their choice and I want to hide the section again - it seems there’s no option to undo the mandatory flag on the fields that need to be hidden and they can’t be hidden as a result.
Am I missing something or is this not possible?
I think this issue can be handled by making the program rule , which is for making filed mandatory, conditional to skip logic program rule variable.
Let me know if an example is needed on play.dhis2.org.
Please, if you have time to provide an example on play.dhis2.org, that would be very helpful Dr Sahib. It’s been a while, I hope you are well!
Yeah long time, I am good thank you and I hope you are well also.
You can work around this issue in two ways as below:
The simplest way would be to make the fields COMPULSORY in the configuration from the beginning and while hiding the section, they will be hidden with raising no issue.
If you are looking to manage it manually: See the example in
Link: DHIS 2 Demo - Sierra Leone
Program : Malaria case diagnosis, treatment and investigation
Program rule: Mic/RDT/PCR : test result is Positive
Program rule: Mic/RDT/PCR : test result is negative
Program rule variable: MalariaTestResult
Fields which shows/hides the section: Malaria Test Result , in first stage
Explanation: Both rules are dependent on same program rule variable but evaluating the condition differently. For example one rule evaluates as ‘Yes’ while the other evaluates as ‘No’.
Note : I hope you could catch the example before the play.dhis2.org renews the backup.
Thank you Dr, I managed to get it in time.
For some reason I had trouble with the same setup on my system, but perhaps there’s another reason for it. I will try again and report back. The only difference is that I was clearing the hidden fields before hiding them, but otherwise the rule is much the same. I will test again.