From 4edddd108f5e113f33daa9fb8f6c9e78058444d6 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 26 Mar 2015 23:19:30 -0700 Subject: [PATCH 1/7] fix bug that caused raw to not be displayed durring startup when noise changes to 1 while sgv < 39 --- static/js/client.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index e11acd5c8..49874318e 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1569,10 +1569,13 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; var temp1 = [ ]; if (cal && isRawBGEnabled()) { temp1 = d[0].map(function (entry) { - var noise = entry.noise || 0; - var rawBg = noise < 2 && browserSettings.showRawbg != 'always' ? 0 : rawIsigToRawBg(entry, cal); - return { date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg'} - }).filter(function(entry) { return entry.y > 0}); + var rawBg = showRawBGs(entry.y, entry.noise, cal) ? rawIsigToRawBg(entry, cal) : 0; + if (rawBg > 0) { + return { date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg'} + } else { + return null + } + }).filter(function(entry) { return entry != null}); } var temp2 = d[0].map(function (obj) { return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), direction: obj.direction, color: sgvToColor(obj.y), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} From d8164d58e036262d0824bc725591afcfbda650eb Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 26 Mar 2015 23:19:55 -0700 Subject: [PATCH 2/7] removed debug --- static/js/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/js/client.js b/static/js/client.js index 49874318e..d2907c309 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1213,7 +1213,6 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; treatmentGlucose = scaleBg(treatment.glucose); } } else { - console.warn('found an VALID glucose value', treatment); treatmentGlucose = treatment.glucose; } } else if (treatment.glucose) { From 2bfa20c223d5d4c50910ad5addf7c1b872081426 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 28 Mar 2015 14:12:48 -0700 Subject: [PATCH 3/7] show bg (and rawbg/noise) even if there isn't a previous value --- static/js/client.js | 60 ++++++++++++++++------------------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index d2907c309..e96dfedff 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -369,28 +369,6 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; currentBG.toggleClass('bg-limit', value == 39 || value > 400); } - function updateCurrentNoise(entry) { - var noise = entry.noise - , noiseType; - - if (!showRawBGs(entry.y, noise, cal)) { - noiseType = null; - } else if (entry.y < 40) { - noiseType = 'error'; - } else if (noise == 2) { - noiseType = 'light'; - } else if (noise == 3) { - noiseType = 'medium'; - } else if (noise >= 4) { - noiseType = 'heavy'; - } - - bgButton.removeClass('noise-light noise-medium noise-heavy noise-error'); - if (noiseType) { - bgButton.addClass('noise-' + noiseType); - } - } - function updateBGDelta(prev, current) { var pill = currentDetails.find('span.pill.bgdelta'); @@ -400,21 +378,19 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; } if (prev === undefined || current == undefined || prev < 40 || prev > 400 || current < 40 || current > 400) { - pill.children('em').text('#'); + pill.children('em').hide(); } else { var bgDelta = scaleBg(current) - scaleBg(prev); if (browserSettings.units == 'mmol') { bgDelta = bgDelta.toFixed(1); + pill.children('label').text('mmol/L'); + } else { + pill.children('label').text('mg/dL'); } - pill.children('em').text((bgDelta >= 0 ? '+' : '') + bgDelta); + pill.children('em').text((bgDelta >= 0 ? '+' : '') + bgDelta).show(); } - if (browserSettings.units == 'mmol') { - pill.children('label').text('mmol/L'); - } else { - pill.children('label').text('mg/dL'); - } } @@ -445,7 +421,8 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; }); if (inRetroMode()) { - var time = new Date(brushExtent[1] - THIRTY_MINS_IN_MS); + var retroTime = new Date(brushExtent[1] - THIRTY_MINS_IN_MS); + // filter data for -12 and +5 minutes from reference time for retrospective focus data prediction var lookbackTime = (lookback + 2) * FIVE_MINS_IN_MS + 2 * ONE_MIN_IN_MS; nowData = nowData.filter(function(d) { @@ -461,17 +438,18 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; return ok; }); - if (nowData.length > lookback) { - var focusPoint = nowData[nowData.length - 1]; - var prevfocusPoint = nowData[nowData.length - 2]; - + var focusPoint = nowData.length > 0 ? nowData[nowData.length - 1] : null; + if (focusPoint) { updateCurrentSGV(focusPoint); - updateCurrentNoise(focusPoint); - - updateBGDelta(prevfocusPoint.y, focusPoint.y); - currentBG.css('text-decoration','line-through'); currentDirection.html(focusPoint.y < 39 ? '✖' : focusPoint.direction); + + var prevfocusPoint = nowData.length > lookback ? nowData[nowData.length - 2] : null; + if (prevfocusPoint) { + updateBGDelta(prevfocusPoint.y, focusPoint.y); + } else { + updateBGDelta(); + } } else { updateBGDelta(); currentBG.text('---'); @@ -480,10 +458,10 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; bgButton.removeClass('urgent warning inrange'); } - updateIOBIndicator(time); + updateIOBIndicator(retroTime); $('#currentTime') - .text(formatTime(time)) + .text(formatTime(retroTime)) .css('text-decoration','line-through'); updateTimeAgo(); @@ -493,7 +471,6 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; nowDate = new Date(now); updateCurrentSGV(latestSGV); - updateCurrentNoise(latestSGV); updateClockDisplay(); updateTimeAgo(); @@ -1191,7 +1168,6 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; var totalBG = 0; closeBGs.forEach(function(d) { totalBG += Number(d.y); - parseFloat() }); return totalBG > 0 ? (totalBG / closeBGs.length) : 450; From e1777e9f1092cb2c1374b80101360f3f220fa754 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 28 Mar 2015 14:32:46 -0700 Subject: [PATCH 4/7] some clean up --- static/js/client.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index e96dfedff..0ce37773e 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -1546,14 +1546,14 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; temp1 = d[0].map(function (entry) { var rawBg = showRawBGs(entry.y, entry.noise, cal) ? rawIsigToRawBg(entry, cal) : 0; if (rawBg > 0) { - return { date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg'} + return { date: new Date(entry.x - 2000), y: rawBg, sgv: scaleBg(rawBg), color: 'white', type: 'rawbg' }; } else { - return null + return null; } - }).filter(function(entry) { return entry != null}); + }).filter(function(entry) { return entry != null; }); } var temp2 = d[0].map(function (obj) { - return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), direction: obj.direction, color: sgvToColor(obj.y), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} + return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), direction: obj.direction, color: sgvToColor(obj.y), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered}; }); data = []; data = data.concat(temp1, temp2); From 406345411f53f05c24b189f87892f4fefd30b876 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 29 Mar 2015 00:17:24 -0700 Subject: [PATCH 5/7] always set the units even if we aren't going to show a delta --- static/js/client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index 0ce37773e..057c388c3 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -383,14 +383,17 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; var bgDelta = scaleBg(current) - scaleBg(prev); if (browserSettings.units == 'mmol') { bgDelta = bgDelta.toFixed(1); - pill.children('label').text('mmol/L'); - } else { - pill.children('label').text('mg/dL'); } pill.children('em').text((bgDelta >= 0 ? '+' : '') + bgDelta).show(); } + if (browserSettings.units == 'mmol') { + pill.children('label').text('mmol/L'); + } else { + pill.children('label').text('mg/dL'); + } + } From 6dd5c207fb16b47bf8a97b09b7d65857fe698c15 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 29 Mar 2015 10:20:01 -0700 Subject: [PATCH 6/7] anything that starts with dexcom should be treated the same (g4 with share is a new device) --- static/js/client.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/static/js/client.js b/static/js/client.js index 057c388c3..c726cd628 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -523,6 +523,10 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; return radius / focusRangeAdjustment; }; + function isDexcom(device) { + return device && device.toLowerCase().indexOf('dexcom') == 0; + } + function prepareFocusCircles(sel) { var badData = []; sel.attr('cx', function (d) { return xScale(d.date); }) @@ -539,7 +543,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .attr('stroke-width', function (d) { if (d.type == 'mbg') return 2; else return 0; }) .attr('stroke', function (d) { var device = d.device && d.device.toLowerCase(); - return (device == 'dexcom' ? 'white' : '#0099ff'); + return (isDexcom(d.device) ? 'white' : '#0099ff'); }) .attr('r', function (d) { return dotRadius(d.type); }); @@ -558,8 +562,7 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .on('mouseover', function (d) { if (d.type != 'sgv' && d.type != 'mbg') return; - var device = d.device && d.device.toLowerCase() - , bgType = (d.type == 'sgv' ? 'CGM' : (device == 'dexcom' ? 'Calibration' : 'Meter')) + var bgType = (d.type == 'sgv' ? 'CGM' : (isDexcom(d.device) ? 'Calibration' : 'Meter')) , rawBG = 0 , noiseLabel = ''; From dd54c58681f0bf2bc4cd9799c24ab373b49de9b0 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 29 Mar 2015 10:21:18 -0700 Subject: [PATCH 7/7] clean up --- static/js/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/js/client.js b/static/js/client.js index c726cd628..e702aea5c 100644 --- a/static/js/client.js +++ b/static/js/client.js @@ -542,7 +542,6 @@ var app = {}, browserSettings = {}, browserStorage = $.localStorage; .attr('opacity', function (d) { return futureOpacity(d.date.getTime() - latestSGV.x); }) .attr('stroke-width', function (d) { if (d.type == 'mbg') return 2; else return 0; }) .attr('stroke', function (d) { - var device = d.device && d.device.toLowerCase(); return (isDexcom(d.device) ? 'white' : '#0099ff'); }) .attr('r', function (d) { return dotRadius(d.type); });