How do I handle Multiple if statements

Hie

I would like to set 3 results based on 3 separate conditions.

I have written my if statement as follows in the expression editor for :

if((#form/Health_Statistics/adm_oedema = ‘yes’), ‘Oedema’,
if(#form/Health_Statistics/adm_MUAC < 125 and #form/Health_Statistics/age

= 6), ‘MUAC_less_125mm’, if((#form/Health_Statistics/adm_WH_score < -2 and
#form/Health_Statistics/adm_MUAC >= 125) or
(#form/Health_Statistics/adm_WH_score < -2 and
#form/Health_Statistics/adm_MUAC = 0), ‘WH_score_less_-2’))

basically i am trying to classify the reason for admission into a child
health monitoring program.

if the child has oedema the primary reason for admission is ’ Oedema’
if the child is 6months or older and MUAC is less than 25 then primary
reason for admission is 'MUAC_less_125mm’
if the child has zscore that is less than -2 but MUAC higher than 125, then
primary reason for admission is ‘WH_zscore_less_-2’

Where have I gone wrong as I am getting an error stating that my if
statement should have 3 arguments and not 1.

Eva

Hi Eva,

The bracket at the end of this ‘if’ statement:

if(#form/Health_Statistics/adm_MUAC < 125 and #form/Health_Statistics/age

= 6)

comes too early, hence that if() functions only has one argument.

Cheers,
Will

··· On Thu, Oct 12, 2017 at 6:32 AM, Eva wrote:

Hie

I would like to set 3 results based on 3 separate conditions.

I have written my if statement as follows in the expression editor for :

if((#form/Health_Statistics/adm_oedema = ‘yes’), ‘Oedema’,
if(#form/Health_Statistics/adm_MUAC < 125 and #form/Health_Statistics/age

= 6), ‘MUAC_less_125mm’, if((#form/Health_Statistics/adm_WH_score < -2
and #form/Health_Statistics/adm_MUAC >= 125) or
(#form/Health_Statistics/adm_WH_score < -2 and
#form/Health_Statistics/adm_MUAC = 0), ‘WH_score_less_-2’))

basically i am trying to classify the reason for admission into a child
health monitoring program.

if the child has oedema the primary reason for admission is ’ Oedema’
if the child is 6months or older and MUAC is less than 25 then primary
reason for admission is 'MUAC_less_125mm’
if the child has zscore that is less than -2 but MUAC higher than 125,
then primary reason for admission is ‘WH_zscore_less_-2’

Where have I gone wrong as I am getting an error stating that my if
statement should have 3 arguments and not 1.

Eva


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.