Building Personal Medicine Apps to Help Patients
AbstractRemembering to take medication or perform a test regularly, consistently, and at specific times can be difficult for elderly people with short-term memory loss, or teenagers absorbed in activities. With mobile devices becoming our constant companions, could a smartphone or tablet offer a solution?
The Massachusetts Institute of Technology (MIT) has created a simple tool making it possible for anyone who has a computer and Internet access to create a reminder app. It is easy, quick, and powerful. In this project, you will build a medicine-reminder app that employs a phone or tablet to remind its user to take action. It is up to you to customize the app and make it work for the user(s) of your choice.
Sabine De Brabandere, PhD, Science Buddies
Use MIT App Inventor to create a personalized medicine-reminder app.
Tired of hearing comments about the downside of electronic devices? What about an app that could help you manage your health? The Massachusetts Institute of Technology (MIT) has developed programming language enabling anyone to create an app on a computer with Internet access. And you don't need a computer programming background. In this science project, you will build a medicine-reminder app. Once you get comfortable with the program, you can build many more apps that facilitate a healthier lifestyle. Only your imagination sets the limit!
If you are young and healthy, you might wonder why people would need a reminder to take their medicines. It turns out that many elderly and chronically ill people have several medications to take, each on a different schedule. This is an increasing problem as the population of elderly adults rises in many countries. Data gathered by researchers (see the chapter by Marek and Antle in the Bibliography suggests that inability to take the right medications at the right time and at the right dose is one of the major reasons an elderly person enters a nursing home. Researchers also conclude that improperly taking medications is the cause of a significant percentage of hospitalizations for elderly patients. The medicine box shown in Figure 1 shows how difficult it can be to keep track of all the medications that patients on multiple medications need to take.
Figure 1. Medicine reminder boxes, with compartments for various days and times, can help patients keep track of all the medications they need to take.
Why is it such a big deal if someone does not take their medications as prescribed? Let's zoom into a couple of cases and explore the consequences of not following prescribed medical treatment. For diabetic patients, it is essential to check insulin levels several times a day, as frequent low insulin levels can lead to nerve damage, damaged eyesight, and kidney damage, among a host of other ailments. High blood pressure or high cholesterol levels are other examples that, if not treated regularly, can drastically reduce life expectancy. On the other hand, low blood pressure can put the patient in instant danger, because falls can occur when blood pressure drops below a threshold. While this is bad enough for the patient, not taking medications as directed also puts the wider population at risk. For example, a patient who doesn't follow the prescribed times and doses of antibiotic treatments can increase exposure to others of the number of drug-resistant germs. The resulting infections are difficult to treat. In short, a medicine reminder could help increase the quality of life of patients, shorten illnesses, reduce doctor visits or hospital stays, and reduce the need for more expensive (and toxic) medications.
Convinced? Before you start building a medicine-reminder app, let's see what an app is and what it can do.
App is the abbreviation for application software. It refers to a self-contained computer program designed to run on a mobile device like a smartphone or tablet. As the use of mobile devices has exploded, it has created a new field of science called mobile computing. It focuses on human-computer interactions with mobile devices. Creating apps is a big part of mobile computing.
You may already be familiar with a variety of apps. To name a few possibilities, apps can be programmed to be aware of the location of the device's user, send and receive text messages, give directions to a destination, connect to the Internet, and much more. You might notice that apps can be divided into two main categories: ones that entertain (like games) and ones that fulfill a human need (like informing you where the closest recycling center is). In this computer science project, your challenge is to build an app with App Inventor that reminds an individual to take medications or check blood pressure or blood-sugar level.
App Inventor is a visual programming environment designed to make it easy for anyone to create apps for smartphones and tablets. While the apps made using App Inventor can only be exported to and run on Android devices, you do not need an Android device to create apps using App Inventor. Instead, you use a web interface on a computer to design and code your apps. From there they can be packaged and shared by following a few simple steps.
Before you start coding, you need to have an idea of how your app will work and what it is supposed to do. Computer software engineers call this set of descriptions the user requirements . Do you have an idea what the user requirements of your medicine reminder app will be? Imagine being your intended user. What would you want from a medicine reminder app, and how can your app fill this need?
To get quick results, you will use an incremental approach to build and refine your app. The Procedure of this computer science project will guide you through building the core of your app. You can then pursue several rounds of improvements or changes with the medicine reminder app you have envisioned.
Finally, always keep the user in mind as you build your app. Think of who, how, and when the user will use the app. The better it fits their needs and lifestyle, the more successful your app will be.
Terms and Concepts
- Mobile computing
- App Inventor
- User requirements
- User interface
- If you ask a patient what a medicine reminder could do for him/her, what do you think he/she will answer?
- How would you translate this need into a user requirement for your app?
- Is it important to have a good idea of where and when the patient will use the app before you start building it? If so, why and where in the design process would you use this information?
- Marek KD and Antle L (April, 2008). Hughes RG, editor. Patient Safety and Quality: An Evidence-Based Handbook for Nurses. Chapter 18: Medication Management of the Community-Dwelling Older Adult. Rockville (MD): Agency for Healthcare Research and Quality. Retrieved August 19,2014.
- Computer Hope (2019, October 7). App. Computer Hope, Jargon. Retrieved June 10, 2021.
- Massachusetts Institute of Technology. (n.d.). The MIT App Inventor library: Documentation and support. MIT App Inventor. Retrieved June 26, 2014.
- Massachusetts Institute of Technology. (n.d.). Tutorials for App Inventor 2. MIT App Inventor. Retrieved June 26, 2014.
Materials and Equipment
- Computer with access to the Internet.
- For more information on system requirements, please visit Setting up App Inventor 2. Scroll down to the end of the page to find the system requirements.
- (Optional): An Android smart phone. This is useful for live testing if you have one.
- (Optional): Volunteer(s) taking medicine or check blood pressure or blood-sugar level on a regular schedule who could test your app.
If you have not already, watch the video overview of this project in the Summary.
Before you embark on building your medicine reminder app, you need to perform a couple of small tasks: First set up your computer and smartphone or emulator and then work through a couple of tutorials to become familiar with App Inventor 2. This section will walk you through the tasks.
- Follow the instructions listed on this App Inventor setup page to prep your computer and smartphone or emulator to use App Inventor.
- Have a quick look at the Designer and Blocks Editor overview page.
- Now, use the introductory TalkToMe text-to-speech project available from the
Beginner Video Tutorials page to build the TalkToMe app. You will learn:
- How to connect your computer with your device;
- How to use the design mode to design your app;
- How to use the block mode to add functionality;
- How to code a button; and
- How to use the text-to-speech block.
Note that what an app does is often referred to as its behavior in computer language. The blocks editor is where you code the behavior of your app. The user interface is specified in the design mode.
- Before you build your next app, save your project using the Save project command found in the Project drop-down menu,
as shown in Figure 2.
A screenshot within the program MIT app inventor shows menu options that allow projects to be saved. At the top of the app window a drop-down menu labeled 'Project' can be clicked to reveal a menu item labeled 'Save project' or 'Save project as...'.
Figure 2. The Project drop-down menu enables you to save a project, so you can come back to it at a later time.
Continue on to TalkToMe Part 2 for additional practice programming with App Inventor. You will probably finish these two parts in less than an hour!
- You can save this project under a different name using the Save project as... command found in the Project drop-down, as shown in Figure 2.
- Next, follow along with the Magic 8-ball tutorial. This
will help you get more comfortable with MIT App Inventor and teach you:
- How to start a new app,
- How to build and use a list; and
- How to package your app, so it stays on your phone when you disconnect from the Internet.
A list is a tool that can be used to store multiple pieces of information at once. You can see it as an ordered series of variables. They are used to store related data. As you learn to program, you will soon realize lists are commonly used and very handy.
The TalkToMe and Magic 8-ball tutorials will only take you about an hour to complete.
Set the User Requirements for the Core App
- You will now start specifying the core of your medicine reminder app. First, decide on the best means to provide
information to the user you have in mind.
This procedure will use spoken messages to communicate with the user. Although this might be appropriate for an elderly person, it might not be appreciated by a student sitting in a classroom or socializing with friends. With your target user in mind, what do you think is the best way to communicate? Some options are listed below. Note you can use combinations of these, but in no way should you feel limited to this list. You can use any means of communication that you feel appropriate:
- Spoken message
- Vibrating phone (only for cell phones)
- Displayed message
- Displayed picture
Adapt the following procedure to reflect your choice.
- Set the user requirements.
The core app will:
- display a welcome sentence or welcome image on the screen so the user knows it is running;
- provide one reminder message each day, at the hard-coded time of 2 p.m. (Note: This simple approach will let you gain familiarity with MIT App Inventor. Once you have done that, you can expand your app to do other things, let the user customize the reminder time, or add multiple reminders per day. There are more suggestions in the Enhancing Your App section.);
- give reminder messages even when the app is running in the background;
- make the reminder a spoken message such as "It is now 2 p.m.; please take your medication." You can change this specification to reflect your choice selected in step 1.
Build the Core App
- Get a jump start.
- Open the TalkToMe text-to-speech app you made in the Getting Started section.
- Use the Save project as ... function to save it under a different name. This will prevent overwriting your TalkToMe text-to-speech app.
- Create a welcome message.
- Change the app so it displays a message and/or image when running. Note you can use the Label or Image component to do this. Click the "?" next to a component (as shown in Figure 3) if you are curious about it. App Inventor will display a short description and a link to a more detailed description. It is a quick way to explore possibilities.
A screenshot within the program MIT app inventor shows components that can be added to an app. Links in the sidebar located on the left side of the page contain the components for apps. Next to each link is a question mark icon that will describe the function of each listed component when pressed.
Figure 3. Clicking on the question mark next to the component will display a short description and a link to a more detailed description of the component.
- Select a clock.
If you had to keep track of the time, you would not constantly stare at your watch, waiting for it to reach exactly 2 p.m., would you? That would be very inefficient — it's difficult to do other things while you are watching a clock. Instead, you would probably look down at your watch occasionally to check the time. You will program your app to do something similar using a timer. App Inventor provides a timer as part of the Clock component. This timer goes off at regular intervals specified in the TimeInterval property of the Clock. With a timer, you can let your app check the time at regular intervals. Whenever the timer goes off, your app jumps to the Clock.Timer event where you can specify what your app needs to do in case the timer fires. How to do this will be explained in step 4. In this step, you will create the Clock component and set the properties of the associated timer.
- Drag a Clock component from the list of user interface components in the designer mode palette to you viewer. Note the clock will appear as non-visible component under your screen. Figure 4 can help you find the Clock component.
- How often would you like your app to create a timer event? Or, how often does the timer need to go off? You can specify this in the Clock.TimeInterval property of the clock as shown in Figure 5. Note the number in the TimeInterval property needs to be expressed in milliseconds. There are 1000 milliseconds in a second.
- Set the TimeInterval property to 1 minute, or 60,000 milliseconds. If you wish to, you can change the TimeInterval property when you start enhancing your app (see the Enhancing Your App section).
- Ensure the timer is enabled and fires even when the focus is not on the screen and the app runs in the background. You can do this by checking the checkboxes in the Clock property window as can be seen in Figure 5.
A screenshot within the program MIT app inventor shows a clock component that can be found in the sidebar on the left side of the page.
Figure 4. The Clock component can be found under the User Interface list in the designer mode palette.
A screenshot within the program MIT app inventor shows that timed intervals for an alarm can be set in the properties menu of a clock component. The properties menu can be accessed by selecting the clock component from the component sidebar.
Figure 5. The interval between consecutive Clock events can be specified in the properties section of the Clock component. Note the number is specified in milliseconds.
- Code the timer event.
Though you have just created the clock with timer, you still need to tell the app what to do when the timer goes off.
- Because you want to code a behavior, you will navigate to the Block mode.
- Select the Clock. A list of associated blocks for Clock-specific behaviors will appear as shown in Figure 6.
- Drag the When Clock.Timer do ... block to the Blocks viewer. The app will execute the list of blocks clicked in the "do" field every time the timer fires.
A screenshot within the program MIT app inventor shows a clock component listed as Clock1 within the sidebar labeled 'Blocks'. Programming blocks can be seen on the right side of the page in a viewer window. Each block in the viewer window can be programmed to manipulate some aspect of a selected component.
Figure 6. Selecting the Clock component in the Block mode enables you to drag the When Clock.Timer do ... block to the Blocks viewer. You specify what the app should do each time the timer fires in the "do" field.
- Check the time.
You just used a Clock to create a timer. A second use of the Clock component is to manipulate time and express time in various units. The internal time format is called an instant. The clock's Now block (Clock.Now), visible in Figure 7, gives the current time as an instant. The Clock component provides blocks to manipulate instants, for example, to show the second, minute, hour, or day of a given instant. An example of how combining clock blocks allows easy access to the current hour is shown in Figure 8. This particular combination of blocks will show the current hour as a number from 0 (midnight) to 23 (11 pm).
- Use Clock blocks to note the current time in a user-friendly format. Figure 8 can help you do this.
- Use the TextToSpeech block to let your app give the hour as a spoken message. Note you can click the whole combination shown in Figure 8 into the TextToSpeech block or use an intermediate variable. The Join text block can help you frame the output in a sentence.
- As an option, can you do the same or add the minutes to the message?
- Run your app and verify
- if the time in the spoken message is correct and
- if the interval between timed events is what you thought it should be.
- Make adjustments where needed.
- You can remove the TextToSpeech block(s) once you are sure you have set the clock accurately.
A screenshot within the program MIT app inventor shows a clock component listed as Clock 1 within the sidebar labeled 'Blocks'. A programming block labeled call Clock1 now is highlighted in the viewer window on the right side of the page. The call Clock1 now block will return the value of the clock at the instant the block is initiated.
Figure 7. The Now block of the Clock indicated on this figure gives the current instant in internal time format. Other Clock blocks shown on this figure give easy access to the minute, month, and second of an instant. .
A cropped screenshot within the program MIT app inventor shows a call clock1 now block attached to the end of a call clock1 hour instant block. These blocks combined will result in a clock returning the hour value at a given instant.
Figure 8. Combining Clock blocks enable easy readability of the current hour as a number from 0 to 23 (midnight till 11 p.m.).
- Add a feature known as "logic checking" to verify that the correct time to send out a reminder has been reached.
- Select Control and Logic blocks in the Design mode, as shown in Figure 9.
- Start by coding a logical test in the Block mode that verifies if the specified time has been reached. In other words, the logical test should read "TRUE" whenever the specified time of 2 p.m. has been reached and "FALSE" in all other cases. If you need help on logical test blocks, try the Logic Blocks documentation of App Inventor.
- Click the logic test you just coded in a control block to direct the app to specific code that will be executed only when a reminder should be sent.
- Can you figure out how to use the if ... then block on your own? If you need help, visit the Control Blocks manual of App Inventor. Note: Click the blue square before the "if" in the block displayed in Figure 9 to display additional options available for the if ... then sequence.
A screenshot within the program MIT app inventor shows block components in a sidebar separated into three color coded groups on the left side of the screen: brown, green and blue. Brown blocks represent control blocks, green blocks are logic blocks and blue blocks are math blocks. An if then block is shown as a brown control block in the viewer on the right side of the page.
Figure 9. Control blocks are used to direct the app.
- Code the reminder message.
- Add code so the app sends the reminder message as specified in the user requirements.
- Save your current version.
- It is a good habit to frequently save your work.
- Test your app.
- Test your app in all the possible scenarios you can think of.
- Look for loopholes. For example, make sure your message is not repeated several times between 2 p.m. and 3 p.m. Introducing a variable that keeps track of whether the message has been sent out that day (reset this variable to 0 at midnight) is one way to solve this.
- Make changes where needed.
- Make sure to retest all scenarios after you have implemented changes.
General note: The method presented above is just one way of coding your medicine reminder app. You may discover totally different ways of writing the code that work just as well, or even better! Can you explore App Inventor and come up with a different way to write the program?
Enhancing Your App
This completes a first version of your medicine reminder app. You can now let your imagination run wild. What improvements would you like to implement? If you can, talk to your target users, show them your current app, and listen carefully to their feedback. This will guide you in making improvements that have the biggest impact.
- Some improvements you might consider are listed below.
- You can change the TimeInterval property of the clock. How do you think this will affect your medicine reminder? Can you find a good tradeoff between accuracy (sending out your reminder at 2 p.m. sharp) and processor use (frequent checking of the time)?
- Implement a button to confirm that users have taken the medication or performed a medical test. Repeat the reminder message every 15 minutes until the user confirms by clicking the button.
- Let users specify the time they need to take medical action. As an added functionality, you can prompt previous choice(s) each time users open the app. Hint: You might want to look into the TinyDB component of App Inventor if you like to store user choices.
- Enable the app to handle multiple reminders each day for different medications or actions.
- Let users enter and/or change the text of the reminder message they hear or upload the picture they see.
- When users are reminded to perform a test (like measuring blood pressure or glucose levels), ask them to enter their measurement. The app can then store it in a database for historical comparisons and/or create recommendations for the amount of medication to take, send an alert text message to a nurse if levels are above a specified level, etc.
- Each improvement iteration should consist of the following steps:
- Specify the change or improvement.
- Make the changes.
- Test your new app.
The following page will help you understand the Engineering Design Process.
- To do many of the improvements listed above, you may need your app to "remember" information like a value, a word, or a sentence. For example, if your app requests information from the user, or if it calculates a value, you will want to remember it somewhere so you can use it later. The way your app remembers things is by storing them in variables. So in essence, variables
are placeholders; they can hold information and be overwritten by new information. The video below is a good introduction
to how to use variables in App Inventor.
- Consult the Bibliography to find additional links to MIT App Inventor tutorials and libraries. They can be a great source of inspiration and help.
Package and Share Your App
Decide on how you would like to share your app:
- You can share your app in an executable form, which means it can be run on an Android device.
- You can also share the source code (the text listing of commands for an executable program or app) so other people can load it into App Inventor on their computer, open the project under their account, and work on changes if they wish to.
- There is also an option to distribute your app on the Google Play Store.
- The directions on sharing and packaging apps will guide you through the process.
- Show us what you made! We would love to see what problems your app solves and we may even feature it in a future blog post!
Ask an Expert
This project explores topics key to Good Health and Well-Being: Ensure healthy lives and promote well-being for all at all ages.
- Can you find other medical uses of apps? Here are some examples to get your imagination going:
- An app that tracks your allergy symptoms so you can map it against the historical pollen index for your area and find out what exactly you are allergic to.
- As a reminder to take action, you can create an app that displays a Web page with the UV index or allergy information on the phone.
- For a more challenging project, can your app provide a warning whenever a heat alert is in effect for your region? You can use an API (application programming interface) to retrieve information like weather alerts from sites on the Web supporting APIs. The Weather API designer is just one of them. You will need to ask for an "API key," which then provides a unique URL that you can point your program to for accessing the information supported by the site.
- Create a game for a phone or tablet that increases awareness of health-related issues or prompts users to live a more healthy lifestyle.
- Create an app that checks on users and sends a distress text message to an emergency contact. This could be useful for an elderly person living alone or a person going on an adventure. The app could ask at a preset time if you are still OK. If left unanswered, the app could then send a distress message including GPS location to one or a list of emergency contacts. Hints: Locations can be retrieved using the LocationSensor component listed under the Sensor components in the Palette; a text message can be set up using the texting component listed under the social components.
- Can you create phone apps for other areas in life where one could be useful, like increasing environmental awareness, apps helping researchers collect data, or apps enhancing your social life?
If you like this project, you might enjoy exploring these related careers:
- Science Fair Project Guide
- Other Ideas Like This
- Human Biology & Health Project Ideas
- Computer Science Project Ideas
- Diabetes Project Ideas
- My Favorites