Skip to content

Commit cb67da5

Browse files
authored
Merge pull request #8454 from luborjurena/fix/rms-mmol-conversion
Fix Out of Range RMS not converting from mg/dl to mmol/l
2 parents cdef1e7 + 2f896c6 commit cb67da5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/report_plugins/glucosedistribution.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,11 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s
405405
GVIIdeal_Time += timeDelta / (1000 * 60);
406406
glucoseTotal += entry.bgValue;
407407

408-
if (entry.bgValue < options.targetLow) {
409-
RMSTotal += Math.pow(options.targetLow - entry.bgValue, 2);
408+
if (entry.sgv < options.targetLow) {
409+
RMSTotal += Math.pow(options.targetLow - entry.sgv, 2);
410410
}
411-
if (entry.bgValue > options.targetHigh) {
412-
RMSTotal += Math.pow(entry.bgValue - options.targetHigh, 2);
411+
if (entry.sgv > options.targetHigh) {
412+
RMSTotal += Math.pow(entry.sgv - options.targetHigh, 2);
413413
}
414414
}
415415

@@ -443,7 +443,7 @@ glucosedistribution.report = function report_glucosedistribution (datastorage, s
443443
TDCHourly = TDCHourly / consts.MMOL_TO_MGDL;
444444
unitString = ' mmol/L';
445445

446-
RMS = Math.sqrt(RMSTotal / events) / consts.MMOL_TO_MGDL;
446+
// RMSTotal is already in display units (mmol/L) because entry.sgv is used above
447447
}
448448

449449
TDC = Math.round(TDC * 100) / 100;

0 commit comments

Comments
 (0)