Self portrait where I'm only visible from the eyes-up and hanging upside down from the top of the frame.

From the Desk of Brian Richards

A collection of thoughts and Ideas from Brian Richards, creator of WPSessions.com

My T1D Calculator

In July 2022, one of my boys was diagnosed with type-1 diabetes (T1D). A lot changed for our family that day. One of those things was the need to calculate the carbohydrates in every meal we were preparing for our middlest.

To aid in that effort, I built a simple database within Airtable to help us catalog:

  • The carb totals in all of the foods he was eating;
  • The insulin-to-carb ratio for each meal time;
  • The insulin:blood glucose for corrections;
  • The meals themselves with a record of each calculation.

In an earlier version we were also using it to track all of our prescriptions and supplies, along with notifications for when a supply was presumed to be running low or expiring.

After living with it for a year, I’m sharing our carb and insulin calculator in hopes of helping others. Below you’ll find a combination demo and explainer video, a link to duplicate and make your own, and further explanation of the different tables and fields inside the database.

How it works

Make it Your Own

You can use the link below to see and duplicate this Airtable base for your own use. I’ve left sample data in the food and ratio tables so you can see how they look and more easily customize them to meet your needs.

DO NOT FORGET TO CHANGE THE MEAL AND CORRECTION RATIOS!

This is a tool I built for personal use and am sharing publicly for others to learn and create their own tools. You are liable for your own decisions and actions. Be sure to consult a medical professional before making any decisions regarding your care and the care of others. This template is presented as-is without any warranties, expressed or implied.

Embedded Preview


What’s Inside

This database has 4 different tables (Logs, Foods, Meal Ratios, and Correction Ratios) and each of those tables have a number of different fields for tracking or calculating all of the information we need to keep straight for managing T1D.

  • Logs table
    • Purpose:
      • Use this table to log meals and calculate total carbs as well as insulin doses.
      • If you only want to calculate carbs, you can hide every field except Date, Meal, Foods, and Carbs.
    • Views:
      • Logs (entries from the past 3 days)
      • All Logs (all entries from all time)
    • Fields:
      • Date
      • Meal (for setting the meal ratio)
      • Last Dose (for setting the correction ratio)
      • Foods
      • BG
      • Carbs (calculated from Foods)
      • Target BG (referenced from Last Dose)
      • Correction Ratio (referenced from Last Dose)
      • Correction Start (referenced from Last Dose)
      • Carb Ratio (referenced from Meal)
      • Carb Dose (formula)
      • Correction Dose (formula)
      • Suggested Dose (formula)
      • Actual Dose
      • Actual Ratio (formula)
      • Target Ratio (pulled from Meal)
  • Foods table
    • Purpose:
      • Use this table to catalog every food that regularly appears in meals/snacks, along with their serving size (in plain english, however you want to describe it) and total carbs (integer, in grams).
      • These can be created on-the-fly when creating a new Log entry, or in advance from this table.
    • Fields:
      • Food name
      • Serving Size
      • Carbs (in grams)
  • Meal Ratios table
    • Purpose:
      • Use this table to capture each different insulin-to-carb ratio used throughout the day.
      • Our example data includes breakfast, lunch, dinner, and snack time.
    • Fields:
      • Meal name
      • Ratio
  • Correction Ratios table
    • Purpose:
      • Use this table to capture each different correction ratio (or “correction factor”).
      • Our example data includes corrections after 4 hours, 3 hours, 2 hours, and under 2 hours.
    • Fields:
      • Last Dose
      • Target BG
      • Ratio
      • Correction Start

The Formulas

There are four critical formulas hidden in this entire setup:

  1. Carb Dose – how much insulin is needed to cover the carbs in the meal
  2. Correction Dose – how much insulin is needed to cover a high BG
  3. Suggested Dose – The total of the two individual doses
  4. Actual Ratio – the actual insulin-to-carb ratio for the “actual dose” value

Carb Dose

IF(
    {Carb Ratio} > 0,
    {Carbs} / {Carb Ratio},
    0
)

In plain English: if the carb ratio is greater than zero, divide the carbs by the carb ratio, otherwise output 0.

What it’s for: This calculates how much insulin is needed to cover the total carbs in the current meal.

Correction Dose

IF(
    AND(
        {BG},
        {Correction Start},
        {BG} >= {Correction Start},
        {Correction Start} > 0
    ),
    ROUND( ( {BG} - {Target BG} ) / {Correction Ratio} / 0.5 ) * 0.5,
    0
)

In plain English: if we have a BG value, AND a correction start value, AND the BG is greater than or equal to the correction start, AND the correction start is greater than zero, subtract the target BG from the current BG, divide the result by the correction ratio, and round to the nearest half unit… otherwise output 0.

What it’s for: This determines how much insulin is needed to correct a high blood glucose value. In order to round down OR up to the nearest 0.5 units we need to first divide by 0.5, round that result to the nearest whole number, then multiply the whole result by 0.5 to get back to our proper scale.

Suggested Dose

FLOOR(
    SUM( {Carb Dose}, {Correction Dose} ),
    0.5
)

In plain English: Round down the sum of both the carb dose and correction dose to the closest 0.5U.

What it’s for: calculating the total recommended dose for both the carb total and BG correction, rounded to half units to match the increments on our insulin pens.

Actual Ratio

IF(
    AND(
        {Carbs} > 0,
        {Actual Dose} > 0
    ),
    "1:" & ROUND( {Carbs} / ( {Actual Dose} - {Correction Dose} ) ),
    ""
)

In plain English: if both the carbs AND actual dose are greater than zero, divide the carbs total by the difference between the actual dose and the correction dose and output it as a ratio, e.g. “1:30”

What it’s for: a sanity check to make sure the actual amount of insulin being dosed is reasonably close to the desired carb ratio.

But why, though? Because of the rounding necessary to get to 0.5 unit increments, sometimes the suggested dose is slightly too low or too high for the current insulin needs.

Or sometimes intuition tells you – based on the type of food being eaten, or the exercise before/after the meal, or any other number of factors – that a stronger or weaker dose may be necessary.

This output helps corroborate that the actual dose matches that intended strength.


Want help?

Please reach out! I would be happy to help you with setup or to answer any questions you might have.

Managing diabetes is hard enough by itself. Let me help eliminate one of your many burdens!