Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
db6658c
Use endsWith from Lodash
edwingustafson Aug 10, 2018
56d122d
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 16, 2018
0425235
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 21, 2018
7dff7a2
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 22, 2018
f8fd86e
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 24, 2018
d17ca20
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 27, 2018
94b024f
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 30, 2018
5268a1b
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Aug 31, 2018
e0a228c
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 2, 2018
72549f0
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 5, 2018
eb6b49b
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 6, 2018
a7bc42e
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 14, 2018
8492a69
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 15, 2018
a1e0078
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Sep 29, 2018
a7a8e76
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 7, 2018
aa1c3d4
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 12, 2018
de43b76
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 15, 2018
868cb4d
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 21, 2018
a02c9f0
Return function results directly (without trivial local variable)
edwingustafson Oct 27, 2018
599c0bc
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 27, 2018
b7d1a3b
Eliminate another case of function returning trivial local variable
edwingustafson Oct 29, 2018
07967f3
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Oct 30, 2018
d9b616d
Another opportunity to directly return function result without a triv…
edwingustafson Oct 30, 2018
46e97ad
Consolidate redundant functions "percentile"; remove unused function …
edwingustafson Nov 15, 2018
d154a1f
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 18, 2018
77386d5
Import percentile with var not const
edwingustafson Nov 18, 2018
666d97c
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 18, 2018
631c34f
basalGlucose spelling
edwingustafson Nov 18, 2018
2fa6652
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 18, 2018
fb9357d
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 25, 2018
8b9ac41
ESLint configured for JavaScript 5 on Node
edwingustafson Nov 25, 2018
0d1b6d8
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 25, 2018
14b7125
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 26, 2018
c80aea2
ESLint configuration files (for editor hints) (not installed in project)
edwingustafson Nov 26, 2018
5b89003
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 27, 2018
d3103d7
Use var, not const, for JavaScript 5 compatibility
edwingustafson Nov 28, 2018
a8ec659
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 29, 2018
d3b98d8
Malformed typeof checks
edwingustafson Nov 29, 2018
cb84669
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Nov 30, 2018
41f9048
Non-breaking spaces (ESLint rule no-irregular-whitespace)
edwingustafson Dec 1, 2018
d7ef9bb
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 1, 2018
2748a98
Superfluous semicolons found with ESLint's no-extra-semi rule
edwingustafson Dec 1, 2018
fab4755
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 1, 2018
2ff85f1
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 2, 2018
c5948fc
Unnecessary escape characters in regular expressions
edwingustafson Dec 3, 2018
348a54b
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 3, 2018
4224cc9
Triple equals
edwingustafson Dec 4, 2018
f08d18d
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 9, 2018
13d9760
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 10, 2018
71dfef9
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 11, 2018
d8e3590
Unused imports
edwingustafson Dec 11, 2018
43225dd
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 11, 2018
80c02b1
Unused callback function parameter "index"
edwingustafson Dec 11, 2018
6ef6875
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 11, 2018
eac16de
Don't redeclare function parameter when providing default value
edwingustafson Dec 11, 2018
5f18e99
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 12, 2018
25339b6
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 12, 2018
5ba5528
Declare loop variables once and only once
edwingustafson Dec 13, 2018
a591872
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 13, 2018
96a7f95
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 14, 2018
110503d
Missing and redundant variable declarations
edwingustafson Dec 16, 2018
c013628
Revert changes in lib/iob that may be causing failure of Travis CI te…
edwingustafson Dec 17, 2018
11e2dbc
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Dec 27, 2018
c4e887d
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Jan 1, 2019
24fe3d0
Merge remote-tracking branch 'upstream/dev' into dev
edwingustafson Jan 8, 2019
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
6 changes: 3 additions & 3 deletions bin/oref0-autosens-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ if (!module.parent) {


if (typeof profile.isfProfile === "undefined") {
for (prop in profile[0].store) {
profilename = prop;
for (var prop in profile[0].store) {
var profilename = prop;
}
//console.error(profilename);
//console.error(profile[0].store[profilename].basal);
Expand Down Expand Up @@ -89,7 +89,7 @@ if (!module.parent) {
"autosens_max": 2.0,
"autosens_min": 0.5
};
var inputs = { "basals": profile.basalprofile };
inputs = { "basals": profile.basalprofile };
profile.max_daily_basal = basal.maxDailyBasal(inputs);
//console.error(profile);
}
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-autotune-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ if (!module.parent) {
previous_autotune_data.insulinPeakTime = pumpprofile_data.insulinPeakTime;
}

var inputs = {
inputs = {
preppedGlucose: prepped_glucose_data
, previousAutotune: previous_autotune_data
, pumpProfile: pumpprofile_data
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-autotune-prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ if (!module.parent) {
}
}

var inputs = {
inputs = {
history: pumphistory_data
, profile: profile_data
, pumpprofile: pumpprofile_data
Expand Down
6 changes: 3 additions & 3 deletions bin/oref0-calculate-iob.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ if (!module.parent) {
var autosens_data = null;
if (autosens_input) {
try {
var autosens_data = require(cwd + '/' + autosens_input);
autosens_data = require(cwd + '/' + autosens_input);
} catch (e) {}
//console.error(autosens_input, JSON.stringify(autosens_data));
}
var pumphistory_24_data = null;
if (pumphistory_24_input) {
try {
var pumphistory_24_data = require(cwd + '/' + pumphistory_24_input);
pumphistory_24_data = require(cwd + '/' + pumphistory_24_input);
} catch (e) {}
}

// pumphistory_data.sort(function (a, b) { return a.date > b.date });

var inputs = {
inputs = {
history: pumphistory_data
, history24: pumphistory_24_data
, profile: profile_data
Expand Down
8 changes: 4 additions & 4 deletions bin/oref0-detect-sensitivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ if (!module.parent) {
console.error("Calculating sensitivity using 8h of non-exluded data");
detection_inputs.deviations = 96;
detect(detection_inputs);
ratio8h = ratio;
newisf8h = newisf;
var ratio8h = ratio;
var newisf8h = newisf;
console.error("Calculating sensitivity using all non-exluded data (up to 24h)");
detection_inputs.deviations = 288;
detect(detection_inputs);
ratio24h = ratio;
newisf24h = newisf;
var ratio24h = ratio;
var newisf24h = newisf;
if ( ratio8h < ratio24h ) {
console.error("Using 8h autosens ratio of",ratio8h,"(ISF",newisf8h+")");
} else {
Expand Down
8 changes: 4 additions & 4 deletions bin/oref0-determine-basal.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ if (!module.parent) {
autosens_data = JSON.parse(fs.readFileSync(autosens_input, 'utf8'));
//console.error(JSON.stringify(autosens_data));
} catch (e) {
var msg = {
msg = {
msg: "Optional feature Auto Sensitivity enabled. Could not find specified auto-sens: " + autosens_input
, error: e
};
Expand All @@ -168,7 +168,7 @@ if (!module.parent) {
reservoir_data = fs.readFileSync(reservoir_input, 'utf8');
//console.error(reservoir_data);
} catch (e) {
var msg = {
msg = {
msg: "Warning: Could not read required reservoir data from "+reservoir_input+"."
, file: reservoir_input
, error: e
Expand All @@ -183,7 +183,7 @@ if (!module.parent) {
currentTime = new Date(currentTime_input);
console.error(currentTime);
} catch (e) {
var msg = {
msg = {
msg: "Warning: Could not parse current time: "+currentTime_input+"."
, error: e
};
Expand Down Expand Up @@ -212,7 +212,7 @@ if (!module.parent) {

var tempBasalFunctions = require('../lib/basal-set-temp');

rT = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, params['microbolus'], reservoir_data, currentTime);
var rT = determine_basal(glucose_status, currenttemp, iob_data, profile, autosens_data, meal_data, tempBasalFunctions, params['microbolus'], reservoir_data, currentTime);

if(typeof rT.error === 'undefined') {
console.log(JSON.stringify(rT));
Expand Down
10 changes: 5 additions & 5 deletions bin/oref0-get-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if (!module.parent) {
var model_input = params.model;
var autotune_input = params.autotune;

var cwd = process.cwd()
cwd = process.cwd()
var pumpsettings_data = require(cwd + '/' + pumpsettings_input);
var bgtargets_data = require(cwd + '/' + bgtargets_input);
if (bgtargets_data.units !== 'mg/dL') {
Expand Down Expand Up @@ -130,7 +130,7 @@ if (!module.parent) {
}
var basalprofile_data = require(cwd + '/' + basalprofile_input);

var preferences = {};
preferences = {};
if (typeof preferences_input !== 'undefined') {
preferences = require(cwd + '/' + preferences_input);
}
Expand All @@ -139,7 +139,7 @@ if (!module.parent) {
var model_data = { }
if (params.model) {
try {
model_string = fs.readFileSync(model_input, 'utf8');
var model_string = fs.readFileSync(model_input, 'utf8');
model_data = model_string.replace(/"/gi, '');
} catch (e) {
var msg = { error: e, msg: "Could not parse model_data", file: model_input};
Expand All @@ -154,7 +154,7 @@ if (!module.parent) {
autotune_data = JSON.parse(fs.readFileSync(autotune_input, 'utf8'));

} catch (e) {
var msg = { error: e, msg: "Could not parse autotune_data", file: autotune_input};
msg = { error: e, msg: "Could not parse autotune_data", file: autotune_input};
console.error(msg.msg);
// Continue and output a non-autotuned profile if we don't have autotune_data
//console.log(JSON.stringify(msg));
Expand All @@ -169,7 +169,7 @@ if (!module.parent) {
carbratio_data = JSON.parse(fs.readFileSync(carbratio_input, 'utf8'));

} catch (e) {
var msg = { error: e, msg: "Could not parse carbratio_data. Feature Meal Assist enabled but cannot find required carb_ratios.", file: carbratio_input };
msg = { error: e, msg: "Could not parse carbratio_data. Feature Meal Assist enabled but cannot find required carb_ratios.", file: carbratio_input };
console.error(msg.msg);
console.log(JSON.stringify(msg));
process.exit(1);
Expand Down
6 changes: 3 additions & 3 deletions bin/oref0-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if (!module.parent) {
var tick = delta;
if (delta >= 0) { tick = "+" + delta; }
var iob_data = require(cwd + '/' + iob_input);
iob = iob_data[0].iob.toFixed(1);
var iob = iob_data[0].iob.toFixed(1);
var basalprofile_data = require(cwd + '/' + basalprofile_input);
var basalRate;
basalLookup();
Expand Down Expand Up @@ -124,15 +124,15 @@ if (!module.parent) {
//} else {
//enactedstring = enactedtemp.duration + "m@" + enactedtemp.rate.toFixed(1) + "U";
//}
tz = new Date().toString().match(/([-+][0-9]+)\s/)[1]
var tz = new Date().toString().match(/([-+][0-9]+)\s/)[1]
//enactedDate = new Date(enactedtemp.timestamp.concat(tz));
//enactedHMS = enactedDate.toLocaleTimeString().split(":")
//enactedat = enactedHMS[0].concat(":", enactedHMS[1]);

var mealCOB = "???";
if (typeof meal_input !== 'undefined') {
try {
meal_data = JSON.parse(fs.readFileSync(meal_input, 'utf8'));
var meal_data = JSON.parse(fs.readFileSync(meal_input, 'utf8'));
//console.error(JSON.stringify(meal_data));
if (typeof meal_data.mealCOB !== 'undefined') {
mealCOB = meal_data.mealCOB;
Expand Down
2 changes: 1 addition & 1 deletion bin/oref0-meal.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if (!module.parent) {
basalprofile_data = temp;
}

var inputs = {
inputs = {
history: pumphistory_data
, profile: profile_data
, basalprofile: basalprofile_data
Expand Down
14 changes: 7 additions & 7 deletions bin/oref0-pebble.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ if (!module.parent) {

var bgnow = glucose_data[0].glucose;
var iob_data = require(cwd + '/' + iob_input);
iob = iob_data[0].iob.toFixed(1);
var iob = iob_data[0].iob.toFixed(1);
var basalprofile_data = require(cwd + '/' + basalprofile_input);
var basalRate;
basalLookup();
Expand Down Expand Up @@ -116,19 +116,19 @@ if (!module.parent) {
}
var enactedtemp = require(cwd + '/' + enactedtemp_input);
if (enactedtemp.duration < 1) {
enactedstring = "Cancel";
var enactedstring = "Cancel";
} else {
enactedstring = enactedtemp.duration + "m@" + enactedtemp.rate.toFixed(1) + "U";
}
tz = new Date().toString().match(/([-+][0-9]+)\s/)[1]
enactedDate = new Date(enactedtemp.timestamp.concat(tz));
enactedHMS = enactedDate.toLocaleTimeString().split(":")
enactedat = enactedHMS[0].concat(":", enactedHMS[1]);
var tz = new Date().toString().match(/([-+][0-9]+)\s/)[1]
var enactedDate = new Date(enactedtemp.timestamp.concat(tz));
var enactedHMS = enactedDate.toLocaleTimeString().split(":")
var enactedat = enactedHMS[0].concat(":", enactedHMS[1]);

var mealCOB = "???";
if (typeof meal_input !== 'undefined') {
try {
meal_data = JSON.parse(fs.readFileSync(meal_input, 'utf8'));
var meal_data = JSON.parse(fs.readFileSync(meal_input, 'utf8'));
//console.error(JSON.stringify(meal_data));
if (typeof meal_data.mealCOB !== 'undefined') {
mealCOB = meal_data.mealCOB;
Expand Down
62 changes: 31 additions & 31 deletions lib/autotune-prep/categorize.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function categorizeBGDatums(opts) {

var bucketedData = [];
bucketedData[0] = glucoseData[0];
j=0;
var j=0;
//for loop to validate and bucket the data
for (var i=1; i < glucoseData.length; ++i) {
var BGTime;
Expand Down Expand Up @@ -107,7 +107,7 @@ function categorizeBGDatums(opts) {
//console.error(glucoseDatum);
if (glucoseDatum) {
var BGDate = new Date(glucoseDatum.date);
var BGTime = BGDate.getTime();
BGTime = BGDate.getTime();
if ( treatmentTime < BGTime ) {
treatments.splice(i,1);
}
Expand All @@ -125,17 +125,17 @@ function categorizeBGDatums(opts) {
// main for loop
var fullHistory = IOBInputs.history;
for (i=bucketedData.length-5; i > 0; --i) {
var glucoseDatum = bucketedData[i];
glucoseDatum = bucketedData[i];
//console.error(glucoseDatum);
var BGDate = new Date(glucoseDatum.date);
var BGTime = BGDate.getTime();
BGDate = new Date(glucoseDatum.date);
BGTime = BGDate.getTime();
// As we're processing each data point, go through the treatment.carbs and see if any of them are older than
// the current BG data point. If so, add those carbs to COB.
var treatment = treatments[treatments.length-1];
treatment = treatments[treatments.length-1];
var myCarbs = 0;
if (treatment) {
var treatmentDate = new Date(tz(treatment.timestamp));
var treatmentTime = treatmentDate.getTime();
treatmentDate = new Date(tz(treatment.timestamp));
treatmentTime = treatmentDate.getTime();
//console.error(treatmentDate);
if ( treatmentTime < BGTime ) {
if (treatment.carbs >= 1) {
Expand Down Expand Up @@ -192,22 +192,22 @@ function categorizeBGDatums(opts) {
// for IOB calculations, use the average of the last 4 hours' basals to help convergence;
// this helps since the basal this hour could be different from previous, especially if with autotune they start to diverge.
// use the pumpbasalprofile to properly calculate IOB during periods where no temp basal is set
currentPumpBasal = basal.basalLookup(opts.pumpbasalprofile, BGDate);
BGDate1hAgo = new Date(BGTime-1*60*60*1000);
BGDate2hAgo = new Date(BGTime-2*60*60*1000);
BGDate3hAgo = new Date(BGTime-3*60*60*1000);
basal1hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate1hAgo);
basal2hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate2hAgo);
basal3hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate3hAgo);
var currentPumpBasal = basal.basalLookup(opts.pumpbasalprofile, BGDate);
var BGDate1hAgo = new Date(BGTime-1*60*60*1000);
var BGDate2hAgo = new Date(BGTime-2*60*60*1000);
var BGDate3hAgo = new Date(BGTime-3*60*60*1000);
var basal1hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate1hAgo);
var basal2hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate2hAgo);
var basal3hAgo = basal.basalLookup(opts.pumpbasalprofile, BGDate3hAgo);
var sum = [currentPumpBasal,basal1hAgo,basal2hAgo,basal3hAgo].reduce(function(a, b) { return a + b; });
IOBInputs.profile.currentBasal = Math.round((sum/4)*1000)/1000;

// this is the current autotuned basal, used for everything else besides IOB calculations
currentBasal = basal.basalLookup(opts.basalprofile, BGDate);
var currentBasal = basal.basalLookup(opts.basalprofile, BGDate);

//console.error(currentBasal,basal1hAgo,basal2hAgo,basal3hAgo,IOBInputs.profile.currentBasal);
// basalBGI is BGI of basal insulin activity.
basalBGI = Math.round(( currentBasal * sens / 60 * 5 )*100)/100; // U/hr * mg/dL/U * 1 hr / 60 minutes * 5 = mg/dL/5m
var basalBGI = Math.round(( currentBasal * sens / 60 * 5 )*100)/100; // U/hr * mg/dL/U * 1 hr / 60 minutes * 5 = mg/dL/5m
//console.log(JSON.stringify(IOBInputs.profile));
// call iob since calculated elsewhere
var iob = getIOB(IOBInputs)[0];
Expand All @@ -218,7 +218,7 @@ function categorizeBGDatums(opts) {
// datum = one glucose data point (being prepped to store in output)
glucoseDatum.BGI = BGI;
// calculating deviation
deviation = avgDelta-BGI;
var deviation = avgDelta-BGI;
//console.error(deviation,avgDelta,BG,bucketedData[i].glucose);

// set positive deviations to zero if BG is below 80
Expand All @@ -234,8 +234,8 @@ function categorizeBGDatums(opts) {
// Then, calculate carb absorption for that 5m interval using the deviation.
if ( mealCOB > 0 ) {
var profile = profileData;
ci = Math.max(deviation, profile.min_5m_carbimpact);
absorbed = ci * profile.carb_ratio / sens;
var ci = Math.max(deviation, profile.min_5m_carbimpact);
var absorbed = ci * profile.carb_ratio / sens;
// Store the COB, and use it as the starting point for the next data point.
mealCOB = Math.max(0, mealCOB-absorbed);
}
Expand All @@ -251,9 +251,9 @@ function categorizeBGDatums(opts) {
// set initial values when we first see COB
CRCarbs += myCarbs;
if (!calculatingCR) {
CRInitialIOB = iob.iob;
CRInitialBG = glucoseDatum.glucose;
CRInitialCarbTime = new Date(glucoseDatum.date);
var CRInitialIOB = iob.iob;
var CRInitialBG = glucoseDatum.glucose;
var CRInitialCarbTime = new Date(glucoseDatum.date);
console.error("CRInitialIOB:",CRInitialIOB,"CRInitialBG:",CRInitialBG,"CRInitialCarbTime:",CRInitialCarbTime);
}
// keep calculatingCR as long as we have COB or enough IOB
Expand All @@ -263,9 +263,9 @@ function categorizeBGDatums(opts) {
calculatingCR = true;
// when COB=0 and IOB drops low enough, record end values and be done calculatingCR
} else {
CREndIOB = iob.iob;
CREndBG = glucoseDatum.glucose;
CREndTime = new Date(glucoseDatum.date);
var CREndIOB = iob.iob;
var CREndBG = glucoseDatum.glucose;
var CREndTime = new Date(glucoseDatum.date);
console.error("CREndIOB:",CREndIOB,"CREndBG:",CREndBG,"CREndTime:",CREndTime);
var CRDatum = {
CRInitialIOB: CRInitialIOB
Expand Down Expand Up @@ -363,16 +363,16 @@ function categorizeBGDatums(opts) {
}
}
// debug line to print out all the things
BGDateArray = BGDate.toString().split(" ");
var BGDateArray = BGDate.toString().split(" ");
BGTime = BGDateArray[4];
console.error(absorbing.toString(),"mealCOB:",mealCOB.toFixed(1),"mealCarbs:",mealCarbs,"basalBGI:",basalBGI.toFixed(1),"BGI:",BGI.toFixed(1),"IOB:",iob.iob.toFixed(1),"at",BGTime,"dev:",deviation,"avgDelta:",avgDelta,type);
}

var IOBInputs = {
IOBInputs = {
profile: profileData
, history: opts.pumpHistory
};
var treatments = find_insulin(IOBInputs);
treatments = find_insulin(IOBInputs);
CRData.forEach(function(CRDatum) {
var dosedOpts = {
treatments: treatments
Expand Down Expand Up @@ -424,8 +424,8 @@ function categorizeBGDatums(opts) {
//console.error(ISFGlucoseData.length, UAMLength);
}
}
var basalLength = basalGlucoseData.length;
var ISFLength = ISFGlucoseData.length;
basalLength = basalGlucoseData.length;
ISFLength = ISFGlucoseData.length;
if ( 4*basalLength + ISFLength < CSFLength && ISFLength < 10 ) {
console.error("Warning: too many deviations categorized as meals");
//console.error("Adding",CSFLength,"CSF deviations to",basalLength,"basal ones");
Expand Down
Loading