Skip to content

Commit

Permalink
make current basal available as a property
Browse files Browse the repository at this point in the history
  • Loading branch information
jasoncalabrese committed Sep 7, 2016
1 parent d86a0c1 commit f37bfdf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/plugins/basalprofile.js
Expand Up @@ -9,6 +9,18 @@ function init() {
, pluginType: 'pill-minor'
};

basal.setProperties = function setProperties (sbx) {
if (hasRequiredInfo(sbx)) {
sbx.offerProperty('basalprofile', function setBasal() {
var profile = sbx.data.profile;
return {
current: profile.getTempBasal(sbx.time)
};
});
}
};


function hasRequiredInfo (sbx) {

if (!sbx.data.profile) { return false; }
Expand All @@ -33,8 +45,8 @@ function init() {
}

var profile = sbx.data.profile;

var basalValue = profile.getTempBasal(sbx.time);
var prop = sbx.properties.basalprofile;
var basalValue = prop && prop.current;
var tempMark = '';
tempMark += basalValue.treatment ? 'T' : '';
tempMark += basalValue.combobolustreatment ? 'C' : '';
Expand Down
1 change: 1 addition & 0 deletions lib/plugins/index.js
Expand Up @@ -58,6 +58,7 @@ function init() {
, require('./insulinage')()
, require('./treatmentnotify')()
, require('./timeago')()
, require('./basalprofile')()
];

plugins.registerServerDefaults = function registerServerDefaults() {
Expand Down
1 change: 1 addition & 0 deletions lib/sandbox.js
Expand Up @@ -52,6 +52,7 @@ function init ( ) {
var profile = require('./profilefunctions')();
//Plugins will expect the right profile based on time
profile.loadData(ctx.ddata.profiles);
profile.updateTreatments(ctx.ddata.profileTreatments, ctx.ddata.tempbasalTreatments, ctx.ddata.combobolusTreatments);
sbx.data.profile = profile;
delete sbx.data.profiles;

Expand Down

0 comments on commit f37bfdf

Please sign in to comment.