Skip to content

Instantly share code, notes, and snippets.

@mgranberry
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgranberry/7f208d3fd35c1a185df3 to your computer and use it in GitHub Desktop.
Save mgranberry/7f208d3fd35c1a185df3 to your computer and use it in GitHub Desktop.
function iobCalc(treatment, time) {
var dia=profile.dia;
var scalefactor = 1;
var peak;
if (dia == 3) {
peak=75;
} else {
// console.warn('DIA of ' + dia + ' not supported');
peak = 75;
scalefactor = 3.0/dia;
}
var sens=profile.sens;
if (typeof time === 'undefined') {
var time = new Date();
}
if (treatment.insulin) {
var bolusTime=new Date(treatment.created_at);
var minAgo=scalefactor*(time-bolusTime)/1000/60;
if (minAgo < 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment