-
Notifications
You must be signed in to change notification settings - Fork 71.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wip/bwp improvements #959
Merged
Merged
Wip/bwp improvements #959
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
var _ = require('lodash'); | ||
var levels = require('../levels'); | ||
var times = require('../times'); | ||
var CONST_60_MINUTES_IN_MS = 3600000; | ||
|
||
function init() { | ||
|
||
|
@@ -124,7 +125,20 @@ function init() { | |
results.effect = iob * profile.getSensitivity(sbx.time); | ||
results.outcome = scaled - results.effect; | ||
var delta = 0; | ||
|
||
var timeSinceLastMeal = 1000000000; | ||
var now = (new Date).getTime(); | ||
|
||
for (var i = 0; i < sbx.data.treatments.length; i++) { | ||
var treatment = sbx.data.treatments[i]; | ||
var delta = now - treatment.mills; | ||
if (delta < timeSinceLastMeal) { timeSinceLastMeal = delta;} | ||
} | ||
|
||
results.timeSinceLastMeal = timeSinceLastMeal; | ||
results.mealEatenRecently = false; | ||
if (timeSinceLastMeal < CONST_60_MINUTES_IN_MS) { results.mealEatenRecently = true; } | ||
|
||
var target_high = profile.getHighBGTarget(sbx.time); | ||
var sens = profile.getSensitivity(sbx.time); | ||
|
||
|
@@ -137,6 +151,11 @@ function init() { | |
|
||
var target_low = profile.getLowBGTarget(sbx.time); | ||
|
||
results.belowLowTarget = false; | ||
if (scaled < target_low) { | ||
results.belowLowTarget = true; | ||
} | ||
|
||
if (results.outcome < target_low) { | ||
delta = Math.abs(results.outcome - target_low); | ||
results.bolusEstimate = delta / sens * -1; | ||
|
@@ -197,6 +216,7 @@ function pushInfo(prop, info, sbx) { | |
}); | ||
} else if (prop) { | ||
info.push({label: 'Insulin on Board', value: prop.displayIOB + 'U'}); | ||
info.push({label: 'Current target', value: 'Low: '+sbx.data.profile.getLowBGTarget(sbx.time) + ' High: ' + sbx.data.profile.getHighBGTarget(sbx.time)}); | ||
info.push({label: 'Sensitivity', value: '-' + sbx.data.profile.getSensitivity(sbx.time) + ' ' + sbx.settings.units + '/U'}); | ||
info.push({label: 'Expected effect', value: prop.displayIOB + ' x -' + sbx.data.profile.getSensitivity(sbx.time) + ' = -' + prop.effectDisplay + ' ' + sbx.settings.units}); | ||
info.push({label: 'Expected outcome', value: sbx.lastScaledSGV() + '-' + prop.effectDisplay + ' = ' + prop.outcomeDisplay + ' ' + sbx.settings.units}); | ||
|
@@ -205,7 +225,20 @@ function pushInfo(prop, info, sbx) { | |
var carbEquivalent = Math.ceil(Math.abs(sbx.data.profile.getCarbRatio() * prop.bolusEstimateDisplay)); | ||
info.unshift({label: 'Carb Equivalent', value: prop.bolusEstimateDisplay + 'U * ' + sbx.data.profile.getCarbRatio() + ' = ' + carbEquivalent + 'g'}); | ||
info.unshift({label: 'Current Carb Ratio', value: '1U / ' + sbx.data.profile.getCarbRatio() + ' g'}); | ||
info.unshift({label: '-BWP', value: prop.bolusEstimateDisplay + 'U, maybe covered by carbs?'}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue found: Expected '{' and instead saw 'info'. |
||
if (prop.mealEatenRecently) info.unshift({label: 'Meal eaten recently', value: 'excess IOB is probably your meal bolus?'}); | ||
|
||
if (!prop.belowLowTarget) { | ||
info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, not account for carbs'}); | ||
} | ||
|
||
if (prop.belowLowTarget) { | ||
if (prop.iob > 0) { | ||
info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, MAKE SURE IOB IS COVERED BY CARBS'}); | ||
} else { | ||
info.unshift({label: '-BWP', value: prop.bolusEstimateDisplay + 'U reduction needed in active insulin to reach low target, too much basal?'}); | ||
} | ||
} | ||
} | ||
} else { | ||
info.push({label: 'Notice', value: 'required info missing'}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Variable 'delta' is already declared in line 127.