Druggist

Due to some recent events, I’ve found myself in the position of needing to track medicine intake. There are medicines that have to be taken daily, which have to be audited (“Did I remember to take my bufaximol?”) and others taken as needed to manage symptoms (“How much metryptine have I taken today?”).

I had been using a chat program to log what was taken when, but it gets awkward and tedious typing out doses every time. What I needed was a button I could press. So I made one.

Druggist is a Django app for tracking medicine consumption. It’s pretty bare bones (about 1 weekend of hacking at the moment) but it’s doing the job.

Setup

I’m not going to go through the Django site setup stuff; that’s boring, and belongs in the README with the source code. Instead, I’ll talk about setting up the app once it’s already installed and running.

Add Drugs

The first step is adding drugs through the Django admin interface.

Drug creation through the Django admin interface.

Just add some drugs to the Drugs table. Once those are there, you can start making logs. The Index field is just a unique number. Drugs are sorted in the dropdown by this index, so you can reorder your lists of drugs without changing the primary keys in the database.

Log Drugs

Once the drugs are added, you can use the /entry/ endpoint to log things. Here’s an example that’s about to log 8 units of Glucosol, after having already logged 5 units of Zytrope today.

Logged some Zytrope for the day, about to add some Glucosol.

Wicket will stare intently while you log your drugs. She wants to be sure you take the right doses.

This page has a few extra features that may be non-obvious. For one thing, the date/time field doesn’t do anything unless the Not now box is checked. If you want to log that pill you took 3 hours ago, you have to check the box and change the time in the text box.

Second is the Notes field. This adds some text to the entry in the database, but it’s not displayed anywhere at the moment. It’s in there, though, and a future version will probably add a column to the log display.

Lastly, the log under Wicket only shows the most recent 24 hours. To see further back, you have to go to the full log, via the link at the bottom of the page.

More Setup

That’s not all, though. Choosing a drug from a dropdown list, entering a number, and clicking a button is easier than typing out the name of the drug and its dosage in a messaging app, and it leaves the data in a much easier format for analysis, but it’s still a bit of faff.

Of course, setting this next part up is a bit of faff too. The goal of the next bit is to tell the database what drugs are commonly taken together and in what doses.

First, we add doses.

Adding new entries to the Doses table

Add entries to the Doses table.

A populated Doses table

The same drug can be added with multiple different doses.

Next, we combine doses in macros:

Adding an entry to the Macros table

Drugs can be grouped together in macros.

Some macros have been added

Now we have some macros defined.

Buttons

Once some macros have been defined, we can use the Buttons link in the navigation list from the end of the /entry/ page, or go to /macros/. This page has some buttons for conveniently logging groups of drugs taken together or in specific common doses.

Buttons for the previously defined macros

This is what it looks like after clicking the Morning Pills button.

Wrapping Up

It’s not super featureful, but that will probably change in the months to come. I do plan to add some analysis for things like how much of a given drug was taken per day or how consistently a particular pill was taken.

Since this is just a Django application, it needs a Django project around it. That can run on any web server. If you don’t like the idea of keeping this sort of information on the Internet, it can run on a desktop. If you still want it accessible via LAN, it can run on a server next to your home router.

I have mine running on a publicly accessible web server with HTTPS, which was not particularly hard to set up with some help from Let’s Encrypt <https://letsencrypt.org/>_. That’s not an ad; I just think they’re great.

It can also track entries for multiple people if you’ve got more than one person in your household who needs to log their drug intake. Each person is just a Django admin user. Oh, and all the pages require login to the Django auth system.

That’s it. I plan to use this project for a pretty long time, so it will probably get new features and bug fixes for a while.

Previous: D4D4