A tutorial about automation with Python and ReportLab

Photo by Scott Graham on Unsplash

The first humans set foot on the moon in 1969. It’s now 2021 and the routine completion of medical forms is still done in some cases with pen and paper…

Let’s take the case of a death declaration. With pen and paper, you have to find the information in different tables scattered throughout a patient file and write them down. This takes about 5–10 minutes of your time if you’re lucky. But if you’re doing it in the middle of the night and you make a mistake because your head is still dreaming about that nice vacation on the beautiful…

Software engineers are improving health care behind the curtains

Image created by author


I’m a physician with a heart for automation, machine learning and data science. The power of technology is increasing exponentially. The purpose of this post is to inform you about what is going on among individuals living with diabetes type 1 and how technology is changing their lives in an unusual way.

What is Diabetes type 1?

“Type 1 diabetes is an autoimmune disease that is a form of diabetes in which very little or no insulin is produced by the islets of Langerhans (containing beta cells) in the pancreas. Insulin is a hormone required for the cells to use blood sugar for energy and…

Choosing an insulin pump can be messy. Diabetes nurses take extra courses to be able to guide patients in the decision. To help one of my family members make the right choice I created a web scraping script for getting the right information in an overview. The code:

The result:

It’s in Dutch, if you don’t have a similar website in your own language you can try to translate using the google translate python API. The full table can be found on my personal website.

I would also recommend looking at the detailed paper of Delia Waldenmaier in which they looked at the different steps needed to perform with the pump interface in order to achieve different operations (e.g. change basal insulin rate, bolus administration, infusion renewal, etc).


The Definition of a modal window:

“A modal window is a graphical control element subordinate to an application’s main window. A modal window creates a mode that disables the main window but keeps it visible, with the modal window as a child window in front of it.”

The workflow for making a modal:

Adding the modal callback

The code of the call back:

The modal code that you can copy and paste within your Dash app for creating the modal window within your Dash app:

Applying CSS

You need the right stylesheet to have a modal that is centred in the window. There are…

In short, this code uses this Dash callback example, to create a JSON file that stores a time-frequency that is being used to configure the Python Apscheduler that is run 24/7 in the background of a webpage localized on the Cloud Platform Heroku. The full code can be found on my GitHub.

This is how it looks at the front:

This is how it looks in the back when something happens at the front:

A guide for novice Pythonistas

Python can extend the power of your brain exponentially through mass data analysis, but getting started with coding can be just as chaotic as entering any community within normal life. There are different versions of the language, different modules to achieve the same thing, different habits for testing and debugging code, different software programs you can use as a coding interface, etc. In everyday culture, there are rituals that give structure to the chaotic environment that we live in. We say “Hi” to our neighbours, we go to school to get a diploma, we comb our hair in the morning…

Using tabs and sharing data between callbacks in Dash

Clicking four times to find a patient, then three times to see vital signs and then five times to prescribe a drug. Even Hitler seems to be frustrated of working with these kinds of electronic health records (EHRs):

The dissatisfaction has been studied in the past by a Finnish research group and made public in their publication “Usability problems do not heal by themselves.” The group studied around 3000 physicians in 2010 and 2014 and compared their opinions based on a set of usability statements. …

Creating a conversation in Python

Drugs can be prescribed to help patients heal from disease or stay in balance. However, some of these prescription tasks are part of routine jobs in case the patient has a well-known or high prevalence disease with a standard treatment. In other cases, there can be a ‘batch’ of prescriptions to perform to acquire a certain treatment protocol. During the prescription process, variables like weight, kidney function and liver function can all have an influence on which drugs are prescribed and in which dose.

In this Python tutorial, we are going to see how drugs can be prescribed with a…

From tables to interactive graphs

Photo by Matteo Fusco on Unsplash

I vividly remember the graphs of the vital signs of patients during my working period as an MD in the IC department. Graphical representations of vital signs can help in getting a better insight into what is happening behind the curtains. The graphs usually gave far more insight into the health state of a patient than the snapshots of vital signs in other work environments.

Dash is a python module that is getting an increasing amount of attention. With <100 lines of code you can make remarkable beautiful and interactive charts. Dash creates a local server on your computer and…

In 1887, the Italian economist Vilfredo Pareto observed an exponential relation between the amount of wealth an inhabitant owned and the rank-order of the inhabitant. He discovered that 80% of the property is owned by merely 20% of the inhabitants, a pattern which later was popularized in the 1950s by management consultant Joseph M. Juran as the Pareto-principle or ‘80–20 rule’. The Pareto-principle is best known for its use in increasing business returns by identifying the vital-few causes responsible for the bulk of income within a company and consequently increasing its efficiency by focusing investments on these company facets. But…

Kelvin Kramp

MD and PhD. Let’s bring health and tech together.

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