Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions lib/report_plugins/glucosedistribution.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ glucosedistribution.html = function html(client) {
translate('Time in fluctuation and Time in rapid fluctuation measure the % of time during the examined period, during which the blood glucose has been changing relatively fast or rapidly. Lower values are better.') + '<br/><br/>' +
translate('Mean Total Daily Change is a sum of the absolute value of all glucose excursions for the examined period, divided by the number of days. Lower is better.')+ '<br/><br/>' +
translate('Mean Hourly Change is a sum of the absolute value of all glucose excursions for the examined period, divided by the number of hours in the period. Lower is better.')+ '<br/><br/>' +
translate('GVI and PGS are measures developed by Dexcom, detailed <a href="http://www.healthline.com/diabetesmine/a-new-view-of-glycemic-variability-how-long-is-your-line#2">here</a>.')+
translate('Out of Range RMS is calculated by squaring the distance out of range for all glucose readings for the examined period, summing them, dividing by the count and taking the square root. This metric is similar to in-range percentage but weights readings far out of range higher. Lower values are better.')+ '<br/><br/>' +
translate('GVI and PGS are measures developed by Dexcom, detailed <a href="http://www.healthline.com/diabetesmine/a-new-view-of-glycemic-variability-how-long-is-your-line#2">here</a>.')+
'</div><br/><br/>' +
translate('Filter by hours') + ':' +
'<br/>' +
Expand Down Expand Up @@ -327,6 +328,8 @@ glucosedistribution.report = function report_glucosedistribution(datastorage, so
var GVITotal = 0;
var GVIIdeal = 0;

var RMSTotal = 0;

var usedRecords = 0;
var glucoseTotal = 0;
var deltaTotal = 0;
Expand Down Expand Up @@ -362,7 +365,17 @@ glucosedistribution.report = function report_glucosedistribution(datastorage, so

GVITotal += Math.sqrt(25 + Math.pow(delta, 2));
glucoseTotal += entry.bgValue;


var x = entry.bgValue;
var rangeMin = options.targetLow;
var rangeMax = options.targetHigh;
if (x < rangeMin) {
RMSTotal += Math.pow(rangeMin - x, 2);
}
if (x > rangeMax) {
RMSTotal += Math.pow(x - rangeMax, 2);
}

}

var GVIDelta = Math.floor(glucose_data[0].bgValue,glucose_data[glucose_data.length-1].bgValue);
Expand All @@ -385,7 +398,9 @@ glucosedistribution.report = function report_glucosedistribution(datastorage, so

var TDC = deltaTotal / days;
var TDCHourly = TDC / 24.0;


var RMS = Math.sqrt(RMSTotal / events);

// console.log('TADC',TDC,'days',days);

var timeInT1 = Math.round(100 * t1count / events).toFixed(1);
Expand Down Expand Up @@ -420,7 +435,10 @@ glucosedistribution.report = function report_glucosedistribution(datastorage, so

$('<tr><th>' + translate('Mean Hourly Change') + '</th><th>GVI</th><th>PGS</th></tr>').appendTo(stabilitytable);
$('<tr><td class="tdborder">' + TDCHourly + unitString + '</td><td class="tdborder">' + GVI + '</td><td class="tdborder">' + PGS + '</td></tr>').appendTo(stabilitytable);


$('<tr><th>Out of Range RMS</th></tr>').appendTo(stabilitytable);
$('<tr><td class="tdborder">' + Math.round(RMS * 100) / 100 + unitString + '</td></tr>').appendTo(stabilitytable);

stabilitytable.appendTo(stability);

setTimeout(function() {
Expand Down