Skip to content

Pseudocode

Shuchir Jain edited this page Mar 19, 2022 · 3 revisions

The Pseudocode

  • On app open, check to see if the user is logged in. If they are, then redirect to the home page

    • If not, then redirect to the login page
      • Once logged in, save the login settings in the database
      • Show the home page
      • If test mode is clicked
        • Set the username and password in the database to something the app recognizes as the test user.
  • Home page

    • Show a dashboard with the current glucose value, glucose value from last opened meal, graph, foods stored, and meals stored.
    • Add a drawer component to the screen, that will let the user select one of the following options- Ingredients, Insulin, Recipes, or Settings
    • Constantly fetch dexcom values and update the database with them
      • If the user is the test user, update the database with random values within a range.
  • Ingredients

    • Show a list of ingredients, with a button to add an ingredient
    • Let the user set the ingredient's name, carbs, and unit
      • Show delete option
  • Insulin

    • Let the user pick a meal- Breakfast, Lunch, Afternoon Snack, Dinner, or Night Snack
      • Show a date switcher
        • On date change, find the meal with the given date and set the current form to that meal
      • Show a button to go back to meal selector
        • On meal select, hide editor and show selector
      • Show a default set of an ingredient
        • Let the user pick a meal from an autocomplete dropdown
          • If meal is in the database, autofill carbs, servings, and unit
            • Add the carb and food id to a list for later reference. This will be used to automatically change the carbs when the serving amount is changed.
          • If not, let the user manually fill in the food data
      • Show a plus button to add a new blank set
      • On change of anything, calculate the insulin.
        • Get the dexcom value and show it
        • Calculate the total carbs by iterating through the form
        • Get the I:C and ISF preferences from settings
          • If not found, show a warning.
        • Plug all factors into the equation and display the insulin dosage.
      • On meal change, check if main meal is selected.
        • If it is, get all of the sugar values for one meal after the meal in which the main food was used
        • Calculate a moving average from these values
        • Show it as an infobox above the meal
  • Recipes

    • Show a list of recipes, with a button to add a recipe
      • On recipe select, show the ingredients in the recipe
        • Fill the form automatically with the recipe's ingredients found in the database
        • Let the user pick a meal from an autocomplete dropdown
          • If meal is in the database, autofill carbs, servings, and unit
            • Add the carb and food id to a list for later reference. This will be used to automatically change the carbs when the serving amount is changed.
          • If not, let the user manually fill in the food data
        • Show a plus button to add a new blank set
        • Show metadata, such as the recipe's name, servings, and unit
        • Every time something is changed, calculate all of the carbs.
        • Divide the carbs by the amount of servings and show it at the bottom.
  • Settings

    • Fetch preferences from a database
      • If preferences found, set the form to the preferences
      • If not, set the form to the default empty list
      • Show general I:C and ISF preferences, and hide specific meal factors under a button menu
      • Show a save button
        • When clicked, save to the database and show a success message.

Clone this wiki locally