Skip to main content

pypi

META3 Demo Project

This is a demo project of the EDC used by the META3 clinical trial.

This demo sets up the META3 EDC to run on a Django test server in DEBUG mode on your local machine.

These are NOT the installation steps for a production system.

See also:

https://www.lstmed.ac.uk/research/departments/international-public-health/respond-africa/meta

https://github.com/meta-trial/meta-edc

https://github.com/clinicedc

https://www.djangoproject.com

Installation

You’ll need mysql and conda.

Create the database

mysql -Bse 'create database meta_example character set utf8;'

Create a working folder and clone the repo

mkdir -p ~/projects/ && \
cd ~/projects && \
git clone https://github.com/meta-trial/meta3-sample.git && \
cd ~/projects/meta3-sample

Create a conda environment named “meta3_sample” and activate

conda create -n meta3_sample python=3.10 && \
conda activate meta3_sample

Install the meta-edc application

pip install meta-edc

The application is now installed, but there is more to do.

We need to make some changes to the configuration. Sensitive config values are stored in the environment (see https://12factor.net) by using an .env and environ. A sample environment file has been provided. Copy the sample environment file to a working copy

cd ~/projects/meta3-sample && cp .env-sample .env

Edit the working copy of the environment file (.env). At the top of the file you will find DATABASE_URL. Change the value for DATABASE_URL to include your mysql user and password. The mysql account will need root or root-like permissions. Since this is a test server running locally, just use root.

DATABASE_URL=mysql://<username>:<password>@127.0.0.1:3306/meta3_sample

Next we need to create the keys used for data encryption. The system encrypts sensitive data (personally identifiable information or PII) using django-crypto-fields.

Run manage.py for the first time to create the encryption keys

python manage.py check

Go back and edit the environment file (.env). Change DJANGO_AUTO_CREATE_KEYS to False

DJANGO_AUTO_CREATE_KEYS=False

Run manage.py check again. You should see a final message “System check identified 3 issues (1 silenced)”. For the test server, you may ignore these warnings.

python manage.py check

Now you are ready to prepare the database.

For now we will just restore the sample data provided in this repo. (Of course, you may run python manage.py migrate but see the note below before going that route.)

The sample database is the exactly what you would get if you ran python manage.py migrate.

Restore the sample data instead migrating from a clean database

cd ~/project/meta3-sample/sample_data && \
tar xczf meta3_sample.sql.tar.gz && \
mysql met3_sample < meta3_sample.sql
Note

Running migrate on an empty database takes more than 30 min. If you do try to run migrate instead of restoring the sample data, in addition to the time it takes, you will run into a few simple problems with the data migrations. See the note on running migrations on an empty database in Troubleshooting below.

Now that our database has the required data schema, we need to run the post-migrate signals. To do this we just run the migrate command.

# run migrate to trigger the post-migrate signals
python manage.py migrate

Next, import the list of holidays that will be used when scheduling appointments.

python manage.py import_holidays

Next, create a user. Do this from the command line using the createsuperuser command.

python manage.py createsuperuser
Important

The new user you just created is a “superuser”. Once logged in you need to remove the superuser status for this account.

Now start up the test server using the runserver command

python manage.py runserver

Open your browser and point it to

localhost:8000

You should see the login screen.

Type in the credentials of the superuser account you just created.

Once logged in, go to your user account and edit the permissions on your account. You can use the link at the top right corner.

  • Under the section Personal Details, fill in your name and email.

  • Under the section Permissions, uncheck Superuser status.

  • At the bottom of section User Profile you will see Roles. Add yourself to the following roles:

    • Account Manager

    • Staff

    • Clinician Super

Now you are ready to screen your first participant.

Troubleshooting

Running migrate on an empty database

If you run migrate on an empty database, a few of the data migrations might fail. Since these failed migrations are data migrations and not schema migrations, it is safe to run migrate until it fails, fake the failed data migration, and continue.

python manage.py migrate

# fake the data migration
python manage.py migrate meta_prn 0035 --fake

# restart migrate
python manage.py migrate

# fake the data migration
python manage.py migrate meta_subject 0107 --fake

# restart migrate
python manage.py migrate

# fake the data migration
python manage.py migrate meta_subject 0132 --fake

# restart migrate
python manage.py migrate

Metadata

Release files for meta3-sample 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for meta3-sample 0.1.0
File Size Uploaded
meta3-sample-0.1.0.tar.gz 946.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for meta3-sample 0.1.0
File Interpreter ABI Platform
meta3_sample-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 969.8 kB

Release files / meta3-sample-0.1.0.tar.gz

Download URL meta3-sample-0.1.0.tar.gz
Size 946.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38f24c51372486a847915489750ef90a9fd0016ec51fcbb063870c023cd6bf3b
BLAKE2b-256 checksum
How to use checksums
c79d6417a5e375707d477a5fc47884c7be6a8d3a7774838e4c949db888d87bc3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release files / meta3_sample-0.1.0-py3-none-any.whl

Download URL meta3_sample-0.1.0-py3-none-any.whl
Size 23.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e3b6fda171b460704bc9cc387e0351d4b7272ef4144e96a6a3d9d8a14048017
BLAKE2b-256 checksum
How to use checksums
00437768c4a0e510ea7083dc2263d82f77f12fba79c24b89259ae8e33bb40b84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page