There are certain scenarios when you need to create more complex logic (than available in the built in logic builder (e.g. X statement is equal to Y value)) or more complex calculations. One option is to create a custom IF statement. An IF statement follows the construction, IF this, THEN this, OTHERWISE this. The format to express this kind of logic is the following: IF(evaluative statement, result if statement is true,result if statement is false).
For example, you could use an IF statement to conditionally store a value in a Hidden Value. Let's take an example where you register a client (a case) in a registration form and update the case property birth_facility. Later in the Follow Up form you want to update the case property birth_facility to the value of the question birth_facility_new IF the answer to change_facility is 'yes'; otherwise you want to leave it as the original value from the registration form. You would do the following:
For further guidance, please see the Hidden Values Tutorial Part 3: If Statements
You might have multiple conditions for an IF statement, where you need to use the OR or AND functions. Below are examples that demonstrate how you can write your expressions. Note that there is no need to enter IF twice for each argument.
Example with OR: if((#form/gender = "male" and #form/waist_circumference > 90) or (#form/gender = "female" and #form/waist_circumference > 85), 1, 0) where 1 refers to a high risk