//set up global variables/objects function Echo() { this.height = 0; this.weight = 0; this.bsa = 0; this.aao = 0; this.aov = 0; } var myAAO = new Echo(); function calculateAAO(form) { myAAO.height = parseFloat(form.height.value); myAAO.weight = parseFloat(form.weight.value); myAAO.bsa = calcAAOBSA(); myAAO.aao = calcHMean(); myAAO.aov = calcHAOV(); form.bsa.value = myAAO.bsa.toFixed(2); form.HalifaxAOVMean.value = (Math.exp(myAAO.aov) / 10).toFixed(2); form.HalifaxMean.value = (Math.exp(myAAO.aao) / 10).toFixed(2); form.HalifaxRange.value = calcHRange(); form.HalifaxRatio.value = (Math.exp(myAAO.aao) / Math.exp(myAAO.aov)).toFixed(2); form.DerivedAOV.value = (1.55 * Math.pow(myAAO.bsa, 0.5)).toFixed(2); form.DerivedMean.value = calcDerivedMean().toFixed(2); form.DerivedRange.value = calcDerivedRange(); form.UCLAMean.value = calcUCLA().toFixed(2); }// end main function //calcBSA function calcAAOBSA() { if (isNaN(myAAO.height) || myAAO.height === 0) { return 0.1 * Math.pow(myAAO.weight, (2 / 3)); } else { return 0.024265 * Math.pow(myAAO.height, 0.3964) * Math.pow(myAAO.weight, 0.5378); } } //calculate the Halifax mean, range function calcHMean() { var lnbsa = Math.log(myAAO.bsa); return lnbsa * 0.421 + 2.898; } function calcHRange() { var lower = myAAO.aao - (1.96 * 0.09111); var upper = myAAO.aao + (1.96 * 0.09111); lower = Math.exp(lower); upper = Math.exp(upper); lower = lower / 10; upper = upper / 10; return lower.toFixed(2) + " - " + upper.toFixed(2); } //calculate the Boston AOV and the AAO diameter based on Boston AOV function calcDerivedMean() { var avaMean = 1.55 * Math.pow(myAAO.bsa, 0.5); return 1.16 * avaMean; } function calcDerivedRange() { var avaMean = 1.55 * Math.pow(myAAO.bsa, 0.5); var lower = 0.97 * avaMean; var upper = 1.35 * avaMean; return lower.toFixed(2) + " - " + upper.toFixed(2); } function calcHAOV() { var lnbsa = Math.log(myAAO.bsa); return lnbsa * 0.426 + 2.732; } function calcUCLA() { return (1.60 + 0.13 * myAAO.height) / 10; }