Hi everyone,
I’m experiencing an issue with a DHIS2 Program Rule that I’d appreciate some insight on from the community.
I have a Tracker program with a multiple-choice data element. Based on the selection of a specific option (in this case, “Other – specify”), another data element should become visible.
I initially configured the program rule using the following expression:
!d2:validatePattern( #{4.1 Why are new ANC attendees _ receiving MMS _ IFA}, '.*\\b4\\b.*' )
This expression worked perfectly during our previous use of the form in July. However, when the same form was used again yesterday, the program rule stopped working during data entry on the Android/mobile app. The field that should have been revealed remained hidden.
This was particularly problematic because the form had previously worked as expected, so I had no reason to anticipate the issue during data collection.
I had to troubleshoot the issue with the help of Claude AI and eventually changed the expression to:
!d2:validatePattern( #{4.2 Why are new ANC attendees _ receiving MMS}, '^(.*,)?4(,.*)?$' )
With this revised expression, the program rule is now working correctly on the mobile app.
My questions to the DHIS2 community
- Why would the original expression stop working when it previously worked correctly with the same form?
- Could there have been a change in how DHIS2 evaluates
d2:validatePattern()or multiple-choice option values, particularly in the Android Capture app? - Is the new expression:
'^(.*,)?4(,.*)?$'
a reliable approach for checking whether option 4 is selected in a multiple-choice field?
4. Are there any potential edge cases with this new expression that I should be aware of?
5. Has anyone else experienced similar behaviour where a program rule works in one period/version of data collection and then unexpectedly stops working later?
I’m mainly trying to determine whether I can sleep easy with the new expression
, or whether I’ve simply found a workaround that could cause another problem later.
Any explanation from the DHIS2 developers or experienced implementers would be greatly appreciated.
