Assign value not functionning on android version

Good morning dear all,

I created 2 program rules in a tracker program to assign a 2 different value to a field according to the condition;
The first program rule condition is:
#{EMR_level_of_facility} ==‘DH’ and the action is asign the value A
The second program rule condition is
(#{EMR_SAM_Hospitalized} == ‘1’ && #{EMR_level_of_facility} == ‘DH’ ) || (#{EMR_SAM_Hospitalized_rg} == ‘1’ && #{EMR_level_of_facility} == ‘DH’) and the action is assign the value SAM

(#{EMR_SAM_Hospitalized} is a program rule variable on a data element with two options coded 1 and 0 same as {EMR_SAM_Hospitalized_rg}

#{EMR_level_of_facility} is a program rule variable on a data element with two options coded " PHC" and “DH”

Is checked use code for program rules.
the 2 programs rules function very well on the web version, but in the android version no matter the consdition it assign the value SAM

PS: on the first program i have also tried this condition :
(#{EMR_level_of_facility} ==‘DH’ && #{EMR_SAM_Hospitalized} == ’ ’ && #{EMR_SAM_Hospitalized_rg} == ’ ‘) || (#{EMR_level_of_facility} ==‘DH’ && #{EMR_SAM_Hospitalized} == ’ 0’ && #{EMR_SAM_Hospitalized_rg} == '0 ')

It woeks properly on web app but on the android it assigns the value SAM no matter what happens

thank you in advance for your answers

Have you set useCodeFor- OptionSet?
Are you trying to use TRUE_ONLY field or the DE option has value ‘1’? If not use true instead

All have options have option set:

#{EMR_level_of_facility} is a program rule variable on a data element with two options coded " PHC" and “DH”
(#{EMR_SAM_Hospitalized} is a program rule variable on a data element with two options coded 1 and 0 same as {EMR_SAM_Hospitalized_rg}

Use !d2:hasValue(‘EMR_SAM_Hospitalized’) instead of #{EMR_SAM_Hospitalized} == ’ ’ or any comparing for empty value

1 Like

Thank you very much. I changed the program rule to this but no change from now. Do you have any advice?
(d2:hasValue(#{EMR_level_of_facility}) && #{EMR_level_of_facility} ==‘DH’ && !d2:hasValue(‘EMR_SAM_Hospitalized’) && !d2:hasValue(‘EMR_SAM_Hospitalized_rg’) &&!d2:hasValue(‘EMR_Clhiv’)) || (d2:hasValue(#{EMR_level_of_facility}) && #{EMR_level_of_facility} ==‘DH’ && #{EMR_SAM_Hospitalized}==‘0’ && #{EMR_SAM_Hospitalized_rg}==‘0’ &&#{EMR_Clhiv}==‘0’)

I would suggest you trace your program.
What you should do:

  1. Open your TEI and add &verbose or &verbose=true to the end of the request string, in the address bar
  2. Open console with network part(press F12)
  3. Get your program rule id
  4. Enter it in console tab as filter value
  5. Check the program rule result

There you will be able to see what value you are getting and how they get processed.

okay thank you,
I deleted the first programs rules and started from scracht and it works better
thank you