Package: meta3-demo
META3 Demo ProjectThis is a demo project of the EDC used by theMETA3clinical trial.This demo sets up the META3 EDC to run on aDjangotestserverinDEBUGmode 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.comhttps://www.fda.gov/regulatory-information/search-fda-guidance-documents/clinical-trials-guidance-documentshttps://www.fda.gov/regulatory-information/search-fda-guidance-documents/oversight-clinical-investigations-risk-based-approach-monitoringInstallationYou’ll need to installmysqlandminicondaon your local machine.Get miniconda herehttps://docs.conda.io/en/latest/miniconda.htmlNow thatmysqlandminicondaare install on your local machine, let’s get started.First, create the demo databasemysql-Bse'create database meta3_demo character set utf8;'Create a project folder and clone the repo into itmkdir~/clinicedc&&\cd~/clinicedc&&\gitclonehttps://github.com/meta-trial/meta3-demo.gitCreate acondaenvironment namedmeta3_demoand activate itcondacreate-nmeta3_demopython=3.10&&\condaactivatemeta3_demoWith thecondaenvironment activated, install themeta-edcpython packagepipinstallmeta-edc==0.2.33Now that the application is installed, we need to make some changes to the configuration.Copy the sample environment file to a working copycd~/clinicedc/meta3-demo&&cp.env-sample.envNoteSensitive config values are stored in the environment by using an.envfile andenviron. (see also seehttps://12factor.net)Next, edit your working copy of the environment file (.env). Look forDATABASE_URLat the top of the file. 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.# find this lineDATABASE_URL=mysql://<username>:<password>@127.0.0.1:3306/meta3_demo# and change with your details, for exampleDATABASE_URL=mysql://root:dumela@127.0.0.1:3306/meta3_demoNext we need to create the keys used for data encryption.Runmanage.pycheckfor the first time. This will askdjango-crypto-fieldsto create encryption keys.pythonmanage.pycheckNoteThe system encrypts sensitive data (personally identifiable information or PII) usingdjango-crypto-fields. The first time you runmanage.py,django-crypto-fieldslooks for the keys. If they do not exist, it creates them.Now go back and edit the working copy of your environment file.env.ChangeDJANGO_AUTO_CREATE_KEYSto FalseDJANGO_AUTO_CREATE_KEYS=FalseRun manage.pycheckagain.pythonmanage.pycheckYou should see a final messageSystem check identified 3 issues (1 silenced). Since this is a test server, you may ignore these warnings.Now you are ready to prepare the database that you created earlier.We have a set ofmigrationsincluded.Migrationsare python scripts that create all the tables, relations, contraints, etc needed to run the system. To save time, we will just restore the demo data provided in this repo. The demo data is an empty mysql database archive that is exactly what you would get if you ran themigratecommand.Restore the demo datacd~/clinicedc/meta3-demo/demo_data&&\tarxzfmeta3_demo.sql.tar.gz&&\mysqlmeta3_demo<meta3_demo.sql&&\cd~/clinicedc/meta3-demo/NoteThere are a few caveats to migrating your own database instead of using the demo data. Runningmigrateon an empty database takes more than 30 min. Also, you will run into a few simple problems with thedatamigrations. See the note on`running migrations on an empty database` inTroubleshootingbelow.Now that our database has the required data schema, we need to run the post-migratesignalsto populate some static data. But this does not take long.To do this, run themigratecommand.# run migrate to trigger the post-migrate signalspythonmanage.pymigrateNext, import the list ofholidaysto 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 asuperuser. Once logged in you will 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 for theMETA3trial running atTemeke Hospitalin Tanzania.Type in the credentials of thesuperuseraccount you created above.Now that you are logged in, let’s make some necessary changes to your account.Go to your user account. You can use the user name link at the top right corner of the page.Follow these steps to configure a working account with rights to create new users and rights to add, update and delete clinical data.Under the sectionPersonal Details, fill in your name and email.Under the sectionPermissions, uncheckSuperuser status.In the middle of sectionUser Profileyou will seeSites. Add yourself to the following site:temeke.tz.meta3.clinicedc.orgAt the bottom of sectionUser Profileyou will seeRoles. Add yourself to the following roles:Account ManagerStaffClinician SuperClick SAVE at the bottom of the formNow you are ready to screen your first participant!ClickHomeon the breadcrumbs at the left on the top bar to get started.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.pymigrateRemoving the demo when you are donedrop the database:mysql -Bse "drop database meta3_demo;"deactivate the conda environment:conda deactivateremove the conda environment:conda env remove -n meta3_demoFinally, delete theclinicedcfolder.