From 828c62ef285d4df4c3af243396baff96868cae48 Mon Sep 17 00:00:00 2001 From: Gerrit Niezen Date: Fri, 20 May 2016 14:56:42 +0100 Subject: [PATCH 1/2] dropping incomplete bolus due to time change; dropping new-day event if followed by time change --- lib/drivers/tandemDriver.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/drivers/tandemDriver.js b/lib/drivers/tandemDriver.js index a77b3eef9f..a6d406acb4 100644 --- a/lib/drivers/tandemDriver.js +++ b/lib/drivers/tandemDriver.js @@ -1547,8 +1547,14 @@ module.exports = function (config) { .with_expectedExtended(bolus.bolex_insulin_requested); } record = record.set('index', bolus.index); - cfg.tzoUtil.fillInUTCInfo(record, bolus.jsDate); - records.push(record.done()); + + if(record.subType === 'normal' && bolus.insulin_delivered === undefined) { + debug('Only part of a bolus received, dropping:', bolus); + } + else{ + cfg.tzoUtil.fillInUTCInfo(record, bolus.jsDate); + records.push(record.done()); + } // wizard records if (_.includes(['standard', 'extended'], bolus.bolus_option) && @@ -1709,6 +1715,14 @@ module.exports = function (config) { for (var b = 0; b < newDayRecords.length; ++b) { var event = newDayRecords[b]; + + var nextEvent = data.log_records[data.log_records.indexOf(event) + 1 ]; + if( nextEvent.header_id === PUMP_LOG_RECORDS.LID_TIME_CHANGED.value || + nextEvent.header_id === PUMP_LOG_RECORDS.LID_DATE_CHANGED.value) { + debug('Dropping new-day event (',event.deviceTime,') followed by date/time change (', nextEvent.deviceTime,')'); + continue; + }; + var rate = event.commanded_basal_rate; if ((rate !== null) && (rate > 0)) { // new day event; breaks up flat-rate basals From 881f7bdc9a929b2a9204d7a683fcf2b368fa3e37 Mon Sep 17 00:00:00 2001 From: Gerrit Niezen Date: Wed, 25 May 2016 10:06:29 +0100 Subject: [PATCH 2/2] set duration to 0 for final temp basal if not available --- lib/tandem/tandemSimulator.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/tandem/tandemSimulator.js b/lib/tandem/tandemSimulator.js index ec54b67b4a..3915d75e93 100644 --- a/lib/tandem/tandemSimulator.js +++ b/lib/tandem/tandemSimulator.js @@ -166,11 +166,17 @@ exports.make = function(config){ if (currBasal.deliveryType === 'temp') { if(!currBasal.isAssigned('duration')) { - if(currTempBasal && currTempBasal.time_left) { - // temp basal was cancelled - currBasal.duration = currTempBasal.duration - currTempBasal.time_left; - }else{ - currBasal.duration = currTempBasal.duration; + if(currTempBasal != null) { + if (currTempBasal.time_left) { + // temp basal was cancelled + currBasal.duration = currTempBasal.duration - currTempBasal.time_left; + }else{ + currBasal.duration = currTempBasal.duration; + } + } + else { + currBasal.duration = 0; + annotate.annotateEvent(currBasal, 'basal/unknown-duration'); } } currBasal = currBasal.done();