Package: meta3-sample
META3 Demo ProjectThis 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/metahttps://github.com/meta-trial/meta-edchttps://github.com/clinicedchttps://www.djangoproject.comInstallationYou’ll needmysqlandconda.Create the databasemysql-Bse'create database meta_example character set utf8;'Create a working folder and clone the repomkdir-p~/projects/&&\cd~/projects&&\gitclonehttps://github.com/meta-trial/meta3-sample.git&&\cd~/projects/meta3-sampleCreate a conda environment named “meta3_sample” and activatecondacreate-nmeta3_samplepython=3.10&&\condaactivatemeta3_sampleInstall the meta-edc applicationpipinstallmeta-edcThe 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 (seehttps://12factor.net) by using an.envandenviron. A sample environment file has been provided. Copy the sample environment file to a working copycd~/projects/meta3-sample&&cp.env-sample.envEdit the working copy of the environment file (.env). At the top of the file you will findDATABASE_URL. Change the value forDATABASE_URLto 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 useroot.DATABASE_URL=mysql://<username>:<password>@127.0.0.1:3306/meta3_sampleNext 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 keyspythonmanage.pycheckGo back and edit the environment file (.env). Change DJANGO_AUTO_CREATE_KEYS to FalseDJANGO_AUTO_CREATE_KEYS=FalseRun manage.pycheckagain. You should see a final message “System check identified 3 issues (1 silenced)”. For the test server, you may ignore these warnings.pythonmanage.pycheckNow you are ready to prepare the database.For now we will just restore the sample data provided in this repo. (Of course, you may runpython manage.py migratebut see the note below before going that route.)The sample database is the exactly
what you would get if you ranpython manage.py migrate.Restore the sample data instead migrating from a clean databasecd~/project/meta3-sample/sample_data&&\tarxczfmeta3_sample.sql.tar.gz&&\mysqlmet3_sample<meta3_sample.sqlNoteRunningmigrateon an empty database takes more than 30 min. If you do try to runmigrateinstead of
restoring the sample data, in addition to the time it takes, you will run into a few simple problems with
thedatamigrations. See the note onrunning migrations on an empty databaseinTroubleshootingbelow.Now that our database has the required data schema, we need to run the post-migrate signals. To do this we just
run themigratecommand.# run migrate to trigger the post-migrate signalspythonmanage.pymigrateNext, import the list of holidays that will be used when scheduling appointments.pythonmanage.pyimport_holidaysNext, create a user. Do this from the command line using thecreatesuperusercommand.pythonmanage.pycreatesuperuserImportantThe 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 therunservercommandpythonmanage.pyrunserverOpen your browser and point it tolocalhost:8000You should see the login screen.Type in the credentials of thesuperuseraccount 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 sectionPersonal Details, fill in your name and email.Under the sectionPermissions, uncheckSuperuser status.At the bottom of sectionUser Profileyou will seeRoles. Add yourself to the following roles:Account ManagerStaffClinician SuperNow you are ready to screen your first participant.TroubleshootingRunning migrate on an empty databaseIf you runmigrateon an empty database, a few of thedatamigrations might fail.
Since these failed migrations aredatamigrations and notschemamigrations, it is safe to run migrate until it fails,
fake the faileddatamigration, and continue.pythonmanage.pymigrate# fake the data migrationpythonmanage.pymigratemeta_prn0035--fake# restart migratepythonmanage.pymigrate# fake the data migrationpythonmanage.pymigratemeta_subject0107--fake# restart migratepythonmanage.pymigrate# fake the data migrationpythonmanage.pymigratemeta_subject0132--fake# restart migratepythonmanage.pymigrate