PR to assign value to a tracked entity and data element not working in Android

Dear all,

I’ve been having issues trying to assign the value of the age to the TEA, calculated from the year of birth in the Tracker Program - Android Version. No any reaction to the program rule.
Note: It works well in the Web Version.

Could anyone assist, please?


I’m using DHIS2 2.33.5 (web version) and DHIS2 Capture V2.2.1

Any input, idea, or recommendation is very much welcomed!


HI @Josue.

It seems there is a program with the Program Rule Variables that are of type “Calculated Value” as it can be seen in this JIRA ticket: [ANDROAPP-3295] - Jira

Sorry for the inconvenience.

Thank you, @jaime.bosque for the response.

Let’s wait for the issue to be fixed. Thanks to the team too.


Hi all,
The JIRA ticket referenced here (3295) was closed, but I’m not able to get PRVs with calculated values working on android. Does anyone see an issue with this rule? It’s working on the browser so I think I’m missing something, maybe with the later releases with quotes? I’m trying to set it up so the boolean data element (er_bouton) has no value or is “no”, the PRV is assigned a value 0 (and later added into a score). If yes, assign value 3.
Let me know if you see what I’m doing wrong here, thanks!
PS This is follow up on this post Program rule, assign value by summing boolean data elements - #20 by abdimohammed


Hi @Natalie_Tibbels. Thanks for the message.

Are you sure you updated the version to 2.2.2? It was fixed there.

Yep, we are on 2.2.2. Just tested again, it’s ok on browser and the non-boolean calculated values are working, but on the app, not working. I cant tell if it’s failing to assign the score to the calculated PRV, or if the score field is failing to add the calculated values up. It just remains blank.

I synchronized and when I opened the record in the browser, it calculated correctly. Even after sychronizing, when I re-open in the app, that field is still blank. It’s a mystery. It allows us to have the data but prevents us from using the score as a decision-making tool in the moment, which is the primary use.
Screen Shot 2020-10-05 at 3.11.47 PM

HI @Natalie_Tibbels. Could you provide access to the server via private message? Or share the program JSON?


Hey @Natalie_Tibbels. Me again! So I tested and the assignation is working in both 2.2.2 and the new future release 2.3

I am having very simple PR which mimic yours:




So I would say that is correct. I am just thinking if as you are making some calculations afterwards (it seems you are adding) it might be that there are other program rules that affect this?

Let me know. The JSON would help.


Thanks so much for continuing to look into it!!! To lay my cards on the table, I’m just trying to figure out how to extract the JSON file (not a programmer). I’ve used the metadata export app to export all the programs and PRs and PRVs in our system, but we have almost 20 tracker and event programs so once I open the file in visual studio code, it’s hard for me to figure out what to keep and delete…
In the example above, “months pregnant” is a calculated PRV, right? So that’s the same setup, but we don’t display the calculated PRV, we add the calculated PRVs at the end. Each boolean has a score of 3, so Score C is the total if you add up all the “yes” answers (14*3). The final score is then adding on top of it scores A and B which are non-boolean answers (option set code combinations that produce different scores and seem to be working properly).
I guess one test I could do is to create a data element for the calculated PRV to display and see if the assignment is working correctly, which I expect it will based on your test above. So then what I may not have correct is the rule to add all the calculated PRVs (the 3s) up for score C.

Hi @Natalie_Tibbels,

If you are using calculated values make sure the asigment is performed before using that variable in a program rule expression or action.
You can test the value in android if you also add a display Key/Value Pair action along side the assign one. This way you won’t need to create a new data element.


Bonjour Natalie,

I think I have found your issue. The logic of some Program Rules is not correct… the funny thing is that some are OK and some are wrong so in some cases you could have got a proper calculated value.

For example, I am checking and your assignation of values to a PRV for “plaie in mouth” is correct:
PR er_assign_plaie-0-non
PR er_assign_plaie-3-oui

However, if I go to another one, for example for the bouton
PR er_assign_bouton-0-non
PR er_assign_bouton-5-oui

As you can see, the logic to calculate the 0 when “NO” is selected is not valid. You should have used the OR operator (II) and not the AND (&&) . As your expression now is something like “If the ER_button Data Element has no value AND it is choosen the option NO” assign a zero. Which will never happen.

I believe that if you fix those program rules you will get the proper result.

A tip, you can probably use the following API call to quickly identify your Program Rules that might be wrong:,condition&filter=condition:like:&&filter=condition:like:!

The %26 is the URL translation of && and the %21 is the URL translation of !. So basically you will retrieve all those Program Rules which contain the && and the ! .

Hope it helps!

1 Like