Centre d'assistance Gustav

Parcourez ou recherchez nos rubriques d'aide.

Calculation-Number

S’abonner

Number calculations can be integrated in various formats: as a list, number, text, date, duration, as well as within a table or a tracking grid.

The result of the calculation is updated when a variable used in the formula is entered, and it can be imported into another form or displayed in the summary view.

 

For a calculation to be valid, it must include a formula as well as "variable observations" from the same form.
In the example below, the BMI calculation includes the variables "current weight" and "current height."

 

Observations included in a calculation must have a unique variable name:

 

 

Here are the elements to consider in a calculation:

  • A calculation can include hidden observations that are not visible during editing or printing

  • Variables used in the calculation can be located at any level within the document

  • A calculation can include the result of another calculation

  • Calculations cannot have child observations

  • Variables can have default values

Here is a link to a formula validation tool:

https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/eval 

 

Formula Examples

Formula with exponentiation:

Math.pow(Weight / Height, 2) + Test

Formula with conditions: if()

if (VIFA == 1) {
  VarA * 1000;
} else {
  VarB * 2000;
}
if (UserGender == 0) {
  2.11 * currentHeight - (5.78 * patientAge) - (2.29 * currentWeight) + 667;
} else {
  if (UserGender == 1) {
    (7.57 * currentHeight - (5.02 * patientAge) - (1.76 * currentWeight)) - 309;
  }
}
if (UserGenderCalc == 1) {
  662 - (9.53 * patientAge) + PhysicalActivityCoef * (15.91 * usedWeight) + (539 * currentHeight);
} else {
  if (UserGenderCalc == 0) {
    354 - (6.91 * patientAge) + PhysicalActivityCoef * (9.36 * usedWeight) + (726 * currentHeight);
  }
}

Ternary operator (for inline conditional expressions):
If an if result is used directly in a calculation, use the format:

(condition) ? (then) : (else)

Example:

(Age > 60 ? 1000 : 2000) * 4

Equivalent if/else:

if (Age > 60) {
  1000 * 4;
} else {
  2000 * 4;
}

Aggregators (Function + $ + variable name):

  • TOTAL$variable_name

  • AVG$variable_name

  • FIRST$variable_name

  • LAST$variable_name

Example:

TOTAL$MultiCalc

Note: The keywords if and else must be written in lowercase.