Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

de:userguide:formeditor:functions:getbmi

getBMI

/* Calculates the BMI out of the given values
 * 
 * tfHeight:
 * The numeric textfield containing the patient's height in cm
 * 
 * tfWeight:
 * The numeric textfield containing the patient's weight in kg
 * 
 * return;
 * This function returns the calculated BMI
 */
function getBMI (tfHeight, tfWeight) {
   /* ======================================== */
   // IMPORTS
   importPackage(java.awt);
   importPackage(java.lang);
 
   /* Get the patient's size and weight and 
    * allocate it to the variables height and weight.
    */
   var height = new Float(tfHeight.getValue());
   var weight = new Float(tfWeight.getValue());
 
   /* The patient's size must be greater than 0,
    * to avoid deviding by 0.
    */
   if (height <= 0) {
      return 0;
   }
 
   /* IF THE HEIGHT IS GIVEN IN METER:
    * Convert the patient's height from cm to m
    * ELSE: delete or outcomment this line
    */
   height = height / 100;
 
   // calculate the BMI
   // (rounded on one decimal place)
   return Math.round(100 * (weight / (height * height))) / 100;
   /* ======================================== */
}
de/userguide/formeditor/functions/getbmi.txt · Zuletzt geändert: 2019/12/09 10:19 (Externe Bearbeitung)

Seiten-Werkzeuge