This is a program that emulates the functionality of the Personal Diabetes Management system called the Omnipod Dash created by Insulet. It (is a work in progress but eventually) will include a bolus calculator, a user programmable basal rate system, insulin delivery and blood glucose history, pod expiry, and other small features of the Dash.
I am using JavaFX, json.simple and Java 12 to create the GUI. JavaFX will not work with Java versions later than 12, so in your project structure you must change the project SDK to Java 12.
Additionally, I am using the JavaFX library in the JavaFX SDK version 17.0.0.1. In the modules section of your project structure, you must add this library titled "lib" in this SDK folder. You can download this SDK at https://gluonhq.com/products/javafx/
If you get errors that there are modules missing, in the run configurations VM options, include this line: --module-path --add-modules=javafx.controls,javafx.fxml
Furthermore, this application uses json.simple for reading/writing json files that act as "save states". I am using json-simple-1.1.1.jar which can be downloaded at https://jar-download.com/artifacts/com.googlecode.json-simple/json-simple/1.1.1/source-code. Similarly to the JavaFX library, you must add this dependency in the modules section of the project structure. For json.simple, you can simply add the entire jar, unlike the lib folder from JavaFX.
This application is structured so that each scene in the program is paired with a controller class that handles all of the logic for that scene. To pass data between scenes, I am making use of JavaFX's setUserData and getUserData built into the Stage class to pass a Data object that collects and contains all of the ratios/factors/targets entered by the user as they progress through the scenes. See each scene controller's sendData and receiveData methods to observe how this works.
Each scene is written in FXML that was generated by using JavaFX's SceneBuilder which can be installed here: https://gluonhq.com/products/scene-builder/. The SceneBuilder makes it incredibly easy to drag and drop GUI elements into your scene and visualize, position, and customize them to fit on the window exactly how you want. I highly recommend using it if you plan on creating scenes of your own.
Prompts users to enter an hourly basal rate for each 24-hour segment of the day. Save button saves current inputs, next button moves to next scene.
Prompts users to enter insulin carb ratio, correction factor, and target blood glucose for use in bolus calculations. Save button saves current inputs, next button moves to next scene.
Contains a graph that displays user's basal plan as entered on BasalInput scene. Displays current hourly basal rate based on system time below. Edit Basal button takes user back to BasalInput scene to change basal rates. Edit Ratios/Factors/Targets button takes user back to StartupScene to change ratios/factors/targets. Bolus button brings users to BolusCalc scene.
Prompts users to enter current blood glucose and amount of carbs to be consumed. Calculate bolus button calculates how much insulin user should recieve based on ratios/factors/targets entered as well as current bg & carbs. Start insulin delivery makes text on screen visible indicating that bolus has been delivered. Back button takes user back to Home scene.
Below is a brief description of each class in the program to give you a sense of what each class is doing and how.
Contains FXML references to all TextFields on BasalInput scene. sendData method saves all inputs in each TextField when save button is pressed and both writes them to a json file, and makes a Data object with the basal plan. Data object is then set as stage user data to be retrieved by other scenes. switchToStartupScene method takes user to StartupScene when next button is pressed.
Contains FXML references to all TextFields on StartupScene scene. receiveData method retrieves Data object stored by BasalInputController when the mouse enters the screen so that the Data object can be added on to while still retaining basal plan data. sendData method saves all TextField inputs both to the json file as well as the Data object when save button is pressed. switchToHome method takes the user to the home scene when next button is pressed.
Contains FXML references to lineChart and current hourly basal rate Label. receiveData method retrieves Data object stored by StartupSceneController when mouse enters the screen, and generates a series using basalPlan data to be used in the lineChart to display the basal plan. It also sets the Label's text to the current hourly rate. Each "switch" method subsequently takes the user to whichever scene's button they clicked on.
Contains FXML references to all TextFields on BolusCalc scene as well as the total bolus Label and invisible bolus delivery Label. receiveData method retrieves Data object stored by previous scenes when mouse enters the screen. calculateBolus method calculates how much insulin should be given to the user based on their inputted ratios/factors/targets and updates the bolus Label with correct dosage when calculate bolus button is pressed. startBolusDelivery method sets the bolus delivery label to visible when start insulin delivery button is pressed. switchToHome takes the user to the home scene when back button is pressed.
This class is incredibly important as it is passed scene to scene and gradually modified as the user inputs data on various scenes. It contains variables for each possible input, as well as a BasalPlan object and a JSONArray for the purpose of writing a json file to save the object. It has multiple constructors that take various inputs depending on which scene the object is created on, as well as getters and setters for each variable.
This class contains an array of 24 doubles which stores each hourly basal rate. There are getters and setters both for the entire array, as well as a single rate in the array given an index.
This class attempts to build a Data object with a json file in the root folder. If it finds the json, it will create a BasalPlan object which will then be used to create a Data object, and then the Data object will be updated with ratios/factors/targets found in the file. It will then set the Stage userData to that Data object so that it can be retrieved, used, and modified in each scene. It then boots the app right to the Home scene. If the app cannot find the json file, it will boot to the BasalInput scene, and prompt the user to enter all of the rates, ratios/factors/targets, and then build a Data object and json file from scratch. The purpose of the json file is so that as the user goes through the app setting all of their ratios/factors/targets, when they close the app and open it again, it should take them directly to the Home scene having saved all of that information rather than forcing them to re-enter everything everytime the app is booted.
Jack Theall: Programmed entire application and created all documentation