The OMOP Common Data Model (v6) implemented in Django3.1. For more information regarding OMOP, please visit OHDSI CDM Working Group (https://ohdsi.github.io/CommonDataModel/index.html).
git clone https://github.com/airoscar/Django-OMOP
conda env create -f environment.yml
conda activate omop
mkdir secrets
nano secrets/env_vars.command
export DJANGO_SECRET_KEY="RANDOM_STRING_FOR_DJANGO_HASHING"
export DJANGO_DEBUG=True
The DJANGO_SECRET_KEY should be a long string of random characters. Save and close the file.
source ./secrets/env_vars.command
python manage.py migrate
And you should see the database being created, by default this would be a db.sqlite3
file located in the root directory.
https://athena.ohdsi.org/vocabulary/list
Make a OMOP_assets
folder in the secrets
folder, and copy the following vocabulary csv files into location:
Django-OMOP/secrets/OMOP_assets/CONCEPT_ANCESTOR.csv
Django-OMOP/secrets/OMOP_assets/CONCEPT_CLASS.csv
Django-OMOP/secrets/OMOP_assets/CONCEPT_CPT4.csv
Django-OMOP/secrets/OMOP_assets/CONCEPT_RELATIONSHIP.csv
Django-OMOP/secrets/OMOP_assets/CONCEPT_SYNONYM.csv
Django-OMOP/secrets/OMOP_assets/CONCEPT.csv
Django-OMOP/secrets/OMOP_assets/DOMAIN.csv
Django-OMOP/secrets/OMOP_assets/DRUG_STRENGTH.csv
Django-OMOP/secrets/OMOP_assets/RELATIONSHIP.csv
Django-OMOP/secrets/OMOP_assets/VOCABULARY.csv
Use Django's ORM to initialize vocabulary tables:
python manage.py initialize
This will launch a set of management commands to read the csv files into database. This process relies on SQL queries to populate the data tables, and may take several hours to complete; however it works with all database engines supported by Django.
Alternatively, you can use the database shell's built-in tools to load data into data tables much faster. This process will be database-dependent:
- PostgreSQL: COPY
- MySQL: LOAD DATA INFILE
- SQLite: .import FILE TABLE
Please note that some of these database-specific commands may load csv columns as is, therefore you will need to make sure the data tables have the same column order as the csv file, first row (column header) is skipped, etc.