Skip to content

Commit

Permalink
Support loading ISF and BG targets in mmol/L (#290)
Browse files Browse the repository at this point in the history
* Accept and convert ISF profile and BG targets in mmol/L

* BUG FIX

* another fix...
  • Loading branch information
sulkaharo authored and scottleibrand committed Dec 27, 2016
1 parent eb8cf37 commit be00420
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
18 changes: 12 additions & 6 deletions bin/oref0-detect-sensitivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,25 @@ if (!module.parent) {

var pumphistory_data = require(cwd + '/' + pumphistory_input);
var profile = require(cwd + '/' + profile_input);
//console.log(profile);
//var glucose_status = detectsensitivity.getLastGlucose(glucose_data);

var isf_data = require(cwd + '/' + isf_input);
if (isf_data.units !== 'mg/dL') {
console.log('ISF is expected to be expressed in mg/dL.'
, 'Found', isf_data.units, 'in', isf_input, '.');
process.exit(2);
if (isf_data.units == 'mmol/L') {
for (var i = 0, len = isf_data.sensitivities.length; i < len; i++) {
isf_data.sensitivities[i].sensitivity = isf_data.sensitivities[i].sensitivity * 18;
}
isf_data.units = 'mg/dL';
} else {
console.log('ISF is expected to be expressed in mg/dL or mmol/L.'
, 'Found', isf_data.units, 'in', isf_input, '.');
process.exit(2);
}
}
var basalprofile = require(cwd + '/' + basalprofile_input);

var iob_inputs = {
history: pumphistory_data
, profile: profile
, profile: profile
//, clock: clock_data
};
} catch (e) {
Expand Down
26 changes: 21 additions & 5 deletions bin/oref0-get-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,31 @@ if (!module.parent) {
var pumpsettings_data = require(cwd + '/' + pumpsettings_input);
var bgtargets_data = require(cwd + '/' + bgtargets_input);
if (bgtargets_data.units !== 'mg/dL') {
console.log('BG Target data is expected to be expressed in mg/dL.'
if (bgtargets_data.units == 'mmol/L') {
for (var i = 0, len = bgtargets_data.targets.length; i < len; i++) {
bgtargets_data.targets[i].high = bgtargets_data.targets[i].high * 18;
bgtargets_data.targets[i].low = bgtargets_data.targets[i].low * 18;
}
bgtargets_data.units = 'mg/dL';
} else {
console.log('BG Target data is expected to be expressed in mg/dL or mmol/L.'
, 'Found', bgtargets_data.units, 'in', bgtargets_input, '.');
process.exit(2);
process.exit(2);
}
}

var isf_data = require(cwd + '/' + isf_input);
if (isf_data.units !== 'mg/dL') {
console.log('ISF is expected to be expressed in mg/dL.'
, 'Found', isf_data.units, 'in', isf_input, '.');
process.exit(2);
if (isf_data.units == 'mmol/L') {
for (var i = 0, len = isf_data.sensitivities.length; i < len; i++) {
isf_data.sensitivities[i].sensitivity = isf_data.sensitivities[i].sensitivity * 18;
}
isf_data.units = 'mg/dL';
} else {
console.log('ISF is expected to be expressed in mg/dL or mmol/L.'
, 'Found', isf_data.units, 'in', isf_input, '.');
process.exit(2);
}
}
var basalprofile_data = require(cwd + '/' + basalprofile_input);

Expand Down

0 comments on commit be00420

Please sign in to comment.