diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 21d5213e9c9..515c47d5964 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -405,11 +405,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s GVIIdeal_Time += timeDelta / (1000 * 60); glucoseTotal += entry.bgValue; - if (entry.bgValue < options.targetLow) { - RMSTotal += Math.pow(options.targetLow - entry.bgValue, 2); + if (entry.sgv < options.targetLow) { + RMSTotal += Math.pow(options.targetLow - entry.sgv, 2); } - if (entry.bgValue > options.targetHigh) { - RMSTotal += Math.pow(entry.bgValue - options.targetHigh, 2); + if (entry.sgv > options.targetHigh) { + RMSTotal += Math.pow(entry.sgv - options.targetHigh, 2); } } @@ -443,7 +443,7 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s TDCHourly = TDCHourly / consts.MMOL_TO_MGDL; unitString = ' mmol/L'; - RMS = Math.sqrt(RMSTotal / events) / consts.MMOL_TO_MGDL; + // RMSTotal is already in display units (mmol/L) because entry.sgv is used above } TDC = Math.round(TDC * 100) / 100;