Thank you @jaime.bosque - for right now I think it seems to be working, apparently the problem was that I had value type text for the option set instead of number, which caused the score to concatenate. Field testing is ongoing and will keep you posted.
@abdimohammed Do you have both program rules, to assign 0 or 1 based on yes or no? I’m not sure it will help, but I was having trouble if only assigning for yes.
Can you review this: Home - DHIS2 Documentation in case you are using the new version 2.2? Some changes were included in the RuleEngine and you might be affected by it.
Thank you @jaime.bosque , I was just looking up this post to figure out some new issues with program rules in the app. Will review that link and see if we can resolve them.
Do you know when the android and web will share the same rule engine?
My main issue is with the assign function, but I’m not assigning text, I’m assigning a numeric value that I then want to sum, not concatenate.
Rule 1 (priority 1)
Condition: #{occupation} ==5
Action: Assign value 3 to #{occupation_calculated}
Rule 2 (priority 1)
Condition: #{marital}==1
Action: Assign value 2 to #{marital_calculated}
Rule 3 (priority 2)
Condition: true
Action: Assign value #{occupation_calculated} + #{marital_calculated} to field “Final score”
In theory, if the user selects the option code 5 for occupation, it will assign a value of 3 to the calculated program variable, and then selects the option code 1 for marital status, it will assign a value of 2 to the calculated PV for marital status, and then the final score should be 5. This works fine on the web, but on the app (I think since 2.33.3), there’s no value. If you have a moment, let me know if you see anything off, thanks!
I am looking into this. I think there is a bug that has been included with the latest version of the RuleEngine… still trying to figure out but it seems that the Program Rule Variables cannot be used in the calculations.
However, I just tested that if you use directly the DataElements and not the PRV you will achieve what you want.
Rule 3 (priority 2)
Condition: true
Action: Assign value #{occupation} + #{marital} to field “Final score”
Will update here with further information, but just wanted to mention in case you are blocked somehow.
Regarding the alignment of RuleEngine between Web and Android I am not really sure. @marta, do you know maybe?
Thanks @jaime.bosque !
I think what you’re suggesting won’t work for calculating a score, unless the numeric value I want assigned to a certain option in an option set is the same as the code, right? Meaning, if I add the data elements themselves, am I not just adding up the option set codes (which are simply, 1, 2, 3, 4 and do not correspond to the “score” I want associated with each response)? I may not be understanding.
Thank you! Yes, apologies I wasn’t more clear that the issue is mainly where we are using option sets (or numeric values but where the “score value” differs from the code value).
@Natalie_Tibbels@jaime.bosque In my case I want to recode/convert ‘Male’ option to ‘1’. If option Male is selected then 1 will be assigned in another Track Entity Attribute. For this, I have created PRV