# Automatic completion of a patient death certificate

Completing forms with pen and paper is shit.

– takes 5-10 minutes time.

– its easy to make mistakes if you ahve to do it your own.

– if you make a mistake you have to start all over again.

On this page I show how you can fill in an medical form with python.

Flowchart

start webbrowser with selenium -> go to page -> scrape data -> process data -> write pdf for check -> write pdf for print.

pip3 install selenium

pip3 install pandas

pip3 install lxml

pip install reportlab

First step is going to the electronic patient file with a web application.  We are gonna use selenium and chrome for that Import selenium, start a webbrowser and go to the right page:

from selenium import webdriverimport pandas as pddriver = webdriver.Chrome()driver.get("https://medicalprogress.dev/patient_file/")html = driver.page_sourcedata = pd.read_html(html) #needs lxml to work

Once on the right page, get the navbar. Then scroll the navbar and scrape all pages.

Proces the information by filtering required patient information for filling in the form.

use information to write on pdf. You need one for checking if everything is filled in allright and another to print.

This is the full code:

Untitled
In [2]:
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy

Requirement already satisfied: numpy in /Users/mackliniek/anaconda3/lib/python3.8/site-packages (1.18.5)
WARNING: You are using pip version 21.0; however, version 21.0.1 is available.
You should consider upgrading via the '/Users/mackliniek/anaconda3/bin/python -m pip install --upgrade pip' command.

In [ ]: