Improving Health with a Simple CRUD app

I have gotten severe chronic migraines since I was 4yrs old, at least, that is the earliest one I have memory of. I remember camping out in the living room, in my Barney sleeping bag, crying because the pain hurt so bad. My Mom had given me kids Tylenol and I wasn’t getting better, rather my condition had progressed to throwing up. She called my Grandpa and asked him if I should be taken to the hospital. I remember hearing her tell my dad later that my Grandpa had told her, “Kid’s don’t get headaches. She must have heard somebody mention a headache, and now she’s faking it for attention. She’s only throwing up because she cried hard enough to make herself sick.”

It’s that statement that had my migraines dubbed as dubious from a young age, despite having many throughout my childhood. It wasn’t until I was an adult that I was able to make an appointment with a doctor and discuss my migraines (which had gotten worst as I had gotten older). I left that appointment with an official diagnosis of Severe Chronic Migraines, and 3 prescriptions (one to take daily as a preventative) and a followup appointment scheduled for 2 weeks later. This appointment was intended to help me assess the effectiveness of my medication. It took months of followup appointments, increases in dosage, and a completely different medication for me to find a happy place that reduced my migraines. In that time, the followup appointments were always difficult. Trying to assess if my migraines had improved when the dosage had increased so slowly, and over so much time was difficult. The doctor recommended keeping a journal so I could easily look at my numbers over time. But I kept losing the notebook, forgetting to fill it out, or it was just difficult to see the changes in a handwritten notebook that spanned months. I thought to myself, “There has to be a simple medical app that lets you track a condition and shows you charts over time?” But I was wrong. The apps were complicated, and never displayed the data in an effective way.

Ever since having that thought I’ve very much wanted to build a simple tracking app. An app that let you log in, list a condition, and rate it, with maybe some comments. So I was especially excited to start building my CRUD app.

The index page of Medigrowth

MediGrowth is a simple CRUD application, that is effective primarily due to it’s ability to display data. It is made to be simple, quick, and easy to use. I wanted to accomplish this:

  1. The ability to add conditions, and track your health through ratings
  2. The ability to view and edit those entries
  3. The ability to view your progress as charts
  4. The ability to add a physician account as your physician
  5. Physician accounts that view data of patients associated with them.

The application is built using the Sinatra framework, and utilizes Activerecord, Rake, Sqlite, Bcrypt, Groupdate, and Chartkick.

The hardest gem to work with was easily Chartkick. I didn’t find the documentation to be extremely helpful in either installing or usage, I had to search the depths of the internet just to get my charts displaying (hint, restart your server after you install it), and I spent hours reading stackoverflow to figure out exactly how to format my queries so they pulled and grouped the data I needed properly. The end results looked something like this.

You can view charts by individual condition
Or you can view charts tracking all your conditions

The other important feature that gave me a bit of difficulty was adding doctors. Doctor accounts are kept in a separate table than User accounts, as doctors have a “Has Many” relationship with Users. Users can view all the available physicians, select one, and that physician has the option to view the user’s charts and notes. The physician has the option to remove a patient if they were mistakenly added, and the user can change physicians at any time.

The difficulty came in differentiating the two types of accounts so that Doctors can not access user functions, and users can not access Doctor functions. I ended up using 2 Helper methods to accomplish this.

The first helper method, “current_user” tracks whoever is logged in based on their session, whether it is a doctor or a user. I accomplished this using the else if statement. Then I created a method that checks if you are a doctor, using a boolean stored in the database. All doctors have a 1, and users have a 0. This made it easy to say you can only access pages if you are logged in, and if this is a doctor page, you have to be a doctor. If it’s a user page, you have to be a user.

These methods were really helpful for one of the most important aspects of my website, which was that the app had to be extremely restrictive in who could view data, since this was a medical app. So every page is constantly checking, are you logged in? If so who are you? And only displaying data that directly relates to the users who are allowed to see it.

Doctors can view the charts of patients who have added them as a physician

Building this app a major goal was to keep it as simple and easy to use as possible, and not overload it with unnecessary features. Since the goal of the app is to encourage people to log in daily, and track conditions, it’s meant to be as simple as possible. My future goal for this app is the get a mailing system added to remind people to log in daily, and I’d like to add a little additional styling to make the whole thing just a little prettier. But aside from that I’m extremely happy with the functionality of this application, and I hope to some day launch it as a tool that can help people.

Jessica is a Designer who is studying Software Engineering at Flatiron School, she has 2 giant dogs, a love of javascript, and hates Papyrus (the font).

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store