Skip to content

Pseudocode

Shuchir Jain edited this page Apr 11, 2022 · 3 revisions

The Pseudocode

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

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

    • This page is where the user selects an option.
    • Show the following options:
      • Home
      • Ingredients
      • Insulin
      • Recipes
      • Settings
      • Logout
    • If a button to a page is clicked, navigate to that page
    • If logout is clicked, delete the existing login information and redirect to the login page
  • Home page

    • Show a dashboard with the current blood glucose value, blood glucose value from last edited meal, graph showing blood glucose values over the last 2 hours, number of ingredients stored, and number of meals stored.
    • 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
    • If the user enters something in the search box
      • go through each ingredient and check if the search query is in the ingredient's name
      • If it isn't, hide the ingredient
  • Insulin

    • Gather all of the ingredients from all of the meals that exist in the database and add it to a list. This will later be used for search
    • 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 any input value, 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
    • Show a search option in the main menu
      • If the user searches something, go through each ingredient in the list stored earlier, and check if the search query is in the ingredient's name
      • If it is, add the card to a list that will be looped and displayed
        • The card should show the ingredient name, carbs, date, and meal
        • Show a button to go to that meal
          • When clicked, set date to the date of the ingredient and fetch meal data by the id.
          • Show the insulin editor and hide the search screen
  • 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.
    • If the user enters something in the search box
      • go through each ingredient and check if the search query is in the ingredient's name
      • If it isn't, hide the ingredient
  • 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 all I:C and ISF preference options and save any time a value is edited.

Clone this wiki locally