Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Operation ordering

Icon

Expressions in CommCare are evaluated left to right. The following example illustrates how this impacts expressions:

 

A and B or C

 

is equivalent to:

 

((A and B) or C)

 

Should you wish to evaluate expressions differently you must use parentheses to indicate which elements should be evaluated together e.g.:

 

A and (B or C)

 

 

Display Logic for Hidden Values

 

  • You can put a display condition in a hidden value
  • The hidden value will hold the null value '' until its display condition is met.  Once its display condition is met, it holds the calculated or loaded value.

  • If you update the case from a hidden value, it will only update the case if its display condition is met.

 

Examples

Simple Calculation Example

Icon

This is an example of a simple calculation where the Date of Birth is being calculated. The logic statement goes in the "Calculate Condition" of the Hidden Value.

Image Added



Complex Calculation Example

Icon

This is an example of a hidden value where the Estimated Date of Delivery (EDD) is being calculated. The logic statement goes in the "Calculation Condition" of the Hidden Value.

Image Added

 

For further guidance on doing calculations please see Hidden Values Tutorial Part 1: Adding Two Questions Using a Hidden Value and Hidden Values Tutorial Part 2: Calculations Using a Date.

Other calculations can be found on this page.

*EDD calculations: http://www.perinatology.com/calculators/Due-Date.htm and http://nrhm-mctsrpt.nic.in/MHFW/UI/FAQAnc.aspx