Skip to content

mxklb/boluscalculator

Repository files navigation

Insulin Bolus Calculator

IBC - An Insulin Bolus Calculator - A HTML5 WebApp. Build Status

A simple and transparent calculator app for the intensive/flexible insulin therapy.

This app is deployed using gh-pages. Check it out here: insulinboluscalculator.org

Feel free to simply use it and/or contribute to the develpoment ..

About this App

This is a bolus calculator app to estimate a single insulin dose based on personalized therapy settings, the actual blood glucose level and a meal. I wrote this app because I could not find any free web/mobile app that let one calculate an insulin bolus using the formulas I knew. Most of the apps I found did not clearly point out the formulas they use to perform the calculations. So this is the result ...

This app comes with absolutely no warranty and may only be used at your own risk!

All app settings are always stored in your browsers local storage.

How is the Bolus calculated

The equations used to calculate the resulting insulin dose are simple ...

Final Bolus

The Final Bolus is defined as the sum of the Effective Meal and a Correction.

The Correction and the Effective Meal are provisional results. These results depend on personal therapy settings, which could vary during the day (indicated by the index i). All three values are always displayed in insulin units [U].

Provisional Results

The Effective Meal is simply defined as the product of the Amount of Meal and a Meal Factor.

The Correction is defined as the difference of the actual Glucose Level and the aspired Glucose Aim divided by a correction. The Corr. Factor is the personal insulin sensitivity. It indicates how many units the blood glucose level gets lowered by injecting one unit of insulin.

Note: The Correction could be negative, which indicates that the resulting amount of bread units is missing to hit the Glucose Aim. If it is possitive insulin is needed to reduce the blood glucose level to reach the Glucose Aim.

How to use it

This app is developed for actual versions of firefox and webkit based browsers like chrome and safari. It is designed for mobile screen resolutions above 320x480.

However:

  1. Open insulinboluscalculator.org in a modern web browser
  2. Make sure the therapy settings are displayed according to your needs
  3. Enter the actual Glucose Level (soberly measured) --> Correction
  4. Enter the Amount of Meal to be eaten --> Effective Meal
  5. Catch up the resulting insulin units [U] immediately

All results are always recalculated if any input value got changed. Red colored bolus numbers indicate that insulin is needed while green colored bolus numbers indicate that one need to eat some food. Just play around with the buttons. I'm sure you'll quickly find out how it works ..

Note: By setting the Amount of Meal to zero, the result is the Correction only. Setting the Blood Glucose to the Glucose Aim, the result is the Effective Meal only.

Therapy Settings

The 24h day is divided into 4 pieces: morning, noontime, evening and night. For each daytime the therapy settings Glucose Aim, Corr. Factor and Meal Factor can be adjusted separately by toggling the Therapy Settings button.

On load IBC automatically detects the correct therapy setting depending on the browsers daytime. To manually switch between different daytime settings use the labeled buttons. Red colored borders indicate that the selected setting does not match the auto-detected daytime.

Measurement Units

The default Blood Glucose measurement unit is [mg/dL]. It may be changed to international units [mmol/L]. Related therapy settings will change accordingly. This does not have any effect on the equations above. The transformation from [mmol/L] to [mg/dL] is just a factor of 18.

The default measurement unit for the Amount of Meal is [bread units]. It may be changed to [gram carbs]. The default amount of carbs [g] needed for on insulin unit [U] is 12g. This factor can be adjusted in the application setup.

Offline Usage

This webapp is developed for on- and offline usage. No server is needed to run this app. All settings are always stored locally. You can always execute it locally by just using a suitable browser. To do so, use the following best practice ...

  1. If you have a webkit based browser create an application shortcut to your desktop, finished.

  2. Clone or download this repository and place it somewhere locally

    A dropbox (or other cloud sync'ed) folder could be a good choice to also feed multiple devices.

    Then just open the local index.html file in the web browser et voila ...

Implementation Details

Think of something like a prototype or engineering app. It's developed as a kind of case study for myself, to learn something about web development technologies and intensive insulin therapy calculations ... Nearly all is implemented from scratch, just one lib R.js is used. It's all plain html with css and java-script. For offline usage the app makes heavy use of techniques such as local storage and cache.manifest.

Actually the code is not tested, reviewed or validated! I'm sure the implementation could be done more elegant, unit-tests are missing, especially css is a mess .. nothing is optimized .. Nevertheless for the actual purpose everything shall work as expected ;)

Feel free to contribute,

  • report - open issues
  • generate new translations
  • send me feature requests or
  • better send pull requests

Translations

To contribute translations for your favorite language refer to the multilang project. IBC uses multilang to generate all its translations. multilang's documentation is straight forward - Adding new languages is as easy as generating one translation file and registering it within another file.

Nice to have ..

  • Make the daytime time-spans user adjustable
  • Interpolate therapy settings (smoothstep)
  • Restructure UI and its show-/hide layout
    • Setup an optional high contrast theme
    • Add blind mode (bad eyes) large ui
    • Use more icons to improve setup menu
  • Validate the users input numbers
  • Add active insulin features

License

Feel free to use, modify, comment or whatever ... this implementation is licensed under MIT.