diff --git a/Makefile b/Makefile index 25511e1..3cd187a 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,24 @@ -MIMIC_SCHEMA=mimic OMOP_SCHEMA=omop -MIMIC="host=localhost dbname=mimic user=postgres options=--search_path=$(MIMIC_SCHEMA)" -OMOP="host=localhost dbname=mimic user=postgres options=--search_path=$(OMOP_SCHEMA)" +MIMIC="host=$(DB_HOST) dbname=mimic user=postgres options=--search_path=$(MIMIC_SCHEMA),public" +OMOP="host=$(DB_HOST) dbname=mimic user=postgres options=--search_path=$(OMOP_SCHEMA),public" +build: buildmimic buildomop runetl: sequence concept load runetlprivate: runetl private -buildomop: - psql $(OMOP) -f omop/build-omop/postgresql/omop_ddl_comments.sql &&\ - psql $(OMOP) -f omop/build-omop/postgresql/mimic-omop-add-column.sql &&\ - psql $(OMOP) -f omop/build-omop/postgresql/mimic-omop-alter.sql +buildmimic: + cd mimic/build-mimic &&\ + psql $(MIMIC) -v mimic_data_dir="$(MIMIC_DATA_DIR)" -f build-$(MIMIC_SCHEMA).sql &&\ + psql $(MIMIC) -v mimic_data_dir="$(MIMIC_DATA_DIR)" -f postgres_add_indexes.sql &&\ + psql $(MIMIC) -v mimic_data_dir="$(MIMIC_DATA_DIR)" -f analyze.sql -loadvocab: - psql $(OMOP) -f omop/build-omop/postgresql/omop_vocab_load.sql +buildomop: + psql $(OMOP) -f "omop/build-omop/postgresql/OMOP CDM postgresql ddl.txt" &&\ + psql $(OMOP) -f omop/build-omop/postgresql/omop_cdm_comments.sql &&\ + psql $(OMOP) -f omop/build-omop/postgresql/mimic-omop-alter.sql &&\ + psql $(OMOP) -f omop/build-omop/postgresql/omop_vocab_load.sql &&\ + psql $(OMOP) -f "omop/build-omop/postgresql/OMOP CDM indexes required - PostgreSQL.sql" &&\ + psql $(OMOP) --set=OMOP_SCHEMA="$(OMOP_SCHEMA)" -f "omop/build-omop/postgresql/analyze.sql" concept: Rscript --vanilla etl/ConceptTables/loadTables.R $(MIMIC_SCHEMA) @@ -29,7 +35,7 @@ private: check: psql $(MIMIC) --set=OMOP_SCHEMA="$(OMOP_SCHEMA)" -f etl/check_etl.sql -export: +exporter: psql $(MIMIC) --set=OMOP_SCHEMA="$(OMOP_SCHEMA)" -f export/export_mimic_omop.sql &&\ cp import/import_mimic_omop.sql etl/Result/ &&\ cp omop/build-omop/postgresql/* etl/Result/ diff --git a/README.md b/README.md index 136d3f5..e8bac36 100755 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ Below in the README, we provide two sections. The first section, *OMOP TABLES LO The second section, *MIMIC TABLES EQUIVALENCE*, lists all the tables in MIMIC-III, and shows where the data now exists in the OMOP CDM. For example, we can see that the MIMIC-III table *patients* was used to populate the OMOP CDM tables *person* and *death*. +INSTALLATION INSTRUCTIONS +========================= + +- [Manual](./README-run-etl.md) +- [Docker-compose](./docker/README.md) + OMOP TABLES LOADED ================== diff --git a/docker/.env b/docker/.env new file mode 100644 index 0000000..b09a7c4 --- /dev/null +++ b/docker/.env @@ -0,0 +1,2 @@ +# either mimiciii or mimicdemo +MIMIC_SCHEMA=mimicdemo diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000..bdd2b7a --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,5 @@ +FROM debian:bullseye +RUN apt-get update && apt-get install -y postgresql-client postgresql-server-dev-13 r-base wget unzip \ + && apt-get clean && rm -rf /var/lib/apt/lists/* +RUN R -e "install.packages('DBI', repos='http://cran.rstudio.com/')" +RUN R -e "install.packages('RPostgres', repos='http://cran.rstudio.com/')" \ No newline at end of file diff --git a/docker/Dockerfile-pg b/docker/Dockerfile-pg new file mode 100644 index 0000000..094ddc4 --- /dev/null +++ b/docker/Dockerfile-pg @@ -0,0 +1,7 @@ +# we can not use version >= 12 because of the way CTE are handled +# see https://www.postgresql.org/docs/16/queries-with.html#QUERIES-WITH-CTE-MATERIALIZATION +FROM postgres:11-alpine + +RUN apk update && apk add wget unzip make perl patch +RUN wget https://api.pgxn.org/dist/pgtap/1.3.2/pgtap-1.3.2.zip && unzip pgtap-1.3.2.zip +RUN cd pgtap-1.3.2 && make && make install diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..c586e45 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,160 @@ +# How to + +Clone the repository + +You might adapt the `postgres.conf` file to your hardware. In particular the `shared_memory`. + +You will have to either download the `mimicdemo` or `mimiciii` datasets, and place them in the `mimic` folder, +respectively. `data-mimicdemo` and `data-mimiciii`. Place the (gzipped for mimiciii/plain for mimicdemo) csv files +directly in the folder. + +You will also need to download from athena the vocabulary and place it in the `extras/athena` folder. + +``` +root +├── extras +│   ├── athena +│   │   ├── CONCEPT.csv +│   │   ├── CONCEPT_ANCESTOR.csv +│   │   ├── CONCEPT_CLASS.csv +│   │   ├── CONCEPT_CPT4.csv +│   │   ├── CONCEPT_RELATIONSHIP.csv +│   │   ├── CONCEPT_SYNONYM.csv +│   │   ├── DOMAIN.csv +│   │   ├── DRUG_STRENGTH.csv +│   │   ├── RELATIONSHIP.csv +│   │   ├── VOCABULARY.csv +│   │   ├── athena2023.zip +│   │   ├── cpt.bat +│   │   ├── cpt.sh +│   │   ├── cpt4.jar +│   │   └── readme.txt +├── mimic +│   ├── data-mimicdemo +│   │   ├── ADMISSIONS.csv +│   │   ├── CALLOUT.csv +│   │   ├── CAREGIVERS.csv +│   │   ├── CHARTEVENTS.csv +│   │   ├── CPTEVENTS.csv +│   │   ├── DATETIMEEVENTS.csv +│   │   ├── DIAGNOSES_ICD.csv +│   │   ├── DRGCODES.csv +│   │   ├── D_CPT.csv +│   │   ├── D_ICD_DIAGNOSES.csv +│   │   ├── D_ICD_PROCEDURES.csv +│   │   ├── D_ITEMS.csv +│   │   ├── D_LABITEMS.csv +│   │   ├── ICUSTAYS.csv +│   │   ├── INPUTEVENTS_CV.csv +│   │   ├── INPUTEVENTS_MV.csv +│   │   ├── LABEVENTS.csv +│   │   ├── LICENSE.txt +│   │   ├── MICROBIOLOGYEVENTS.csv +│   │   ├── NOTEEVENTS.csv +│   │   ├── OUTPUTEVENTS.csv +│   │   ├── PATIENTS.csv +│   │   ├── PRESCRIPTIONS.csv +│   │   ├── PROCEDUREEVENTS_MV.csv +│   │   ├── PROCEDURES_ICD.csv +│   │   ├── SERVICES.csv +│   │   ├── SHA256SUMS.txt +│   │   ├── TRANSFERS.csv +│   │   └── index.html +│   ├── data-mimiciii +│   │   ├── ADMISSIONS.csv.gz +│   │   ├── CALLOUT.csv.gz +│   │   ├── CAREGIVERS.csv.gz +│   │   ├── CHARTEVENTS.csv.gz +│   │   ├── CPTEVENTS.csv.gz +│   │   ├── DATETIMEEVENTS.csv.gz +│   │   ├── DIAGNOSES_ICD.csv.gz +│   │   ├── DRGCODES.csv.gz +│   │   ├── D_CPT.csv.gz +│   │   ├── D_ICD_DIAGNOSES.csv.gz +│   │   ├── D_ICD_PROCEDURES.csv.gz +│   │   ├── D_ITEMS.csv.gz +│   │   ├── D_LABITEMS.csv.gz +│   │   ├── ICUSTAYS.csv.gz +│   │   ├── INPUTEVENTS_CV.csv.gz +│   │   ├── INPUTEVENTS_MV.csv.gz +│   │   ├── LABEVENTS.csv.gz +│   │   ├── LICENSE.txt +│   │   ├── MICROBIOLOGYEVENTS.csv.gz +│   │   ├── NOTEEVENTS.csv.gz +│   │   ├── OUTPUTEVENTS.csv.gz +│   │   ├── PATIENTS.csv.gz +│   │   ├── PRESCRIPTIONS.csv.gz +│   │   ├── PROCEDUREEVENTS_MV.csv.gz +│   │   ├── PROCEDURES_ICD.csv.gz +│   │   ├── README.md +│   │   ├── SERVICES.csv.gz +│   │   ├── SHA256SUMS.txt +│   │   ├── TRANSFERS.csv.gz +│   │   └── index.html + +``` + +Then run in the root folder: +```shell +# edit docker/.env to choose either mimiciii or mimicdemo +docker compose -f docker/docker-compose.yml build +docker compose -f docker/docker-compose.yml up +``` + +It should last almost two hour to build the database, and you will find the output gzipped csvs in the `etl/Result` +folder. + +``` +root +├── etl +│   ├── Result +│   │   ├── OMOP CDM indexes required - PostgreSQL.sql +│   │   ├── OMOP CDM postgresql ddl.txt +│   │   ├── README.md +│   │   ├── analyze.sql +│   │   ├── attribute_definition.csv.gz +│   │   ├── care_site.csv.gz +│   │   ├── cdm_source.csv.gz +│   │   ├── cohort.csv.gz +│   │   ├── cohort_attribute.csv.gz +│   │   ├── cohort_definition.csv.gz +│   │   ├── concept.csv.gz +│   │   ├── concept_ancestor.csv.gz +│   │   ├── concept_class.csv.gz +│   │   ├── concept_relationship.csv.gz +│   │   ├── concept_synonym.csv.gz +│   │   ├── condition_era.csv.gz +│   │   ├── condition_occurrence.csv.gz +│   │   ├── cost.csv.gz +│   │   ├── death.csv.gz +│   │   ├── device_exposure.csv.gz +│   │   ├── domain.csv.gz +│   │   ├── dose_era.csv.gz +│   │   ├── drug_era.csv.gz +│   │   ├── drug_exposure.csv.gz +│   │   ├── drug_strength.csv.gz +│   │   ├── fact_relationship.csv.gz +│   │   ├── import_mimic_omop.sql +│   │   ├── location.csv.gz +│   │   ├── measurement.csv.gz +│   │   ├── mimic-omop-alter.sql +│   │   ├── mimic-omop-disable-trigger.sql +│   │   ├── mimic-omop-enable-trigger.sql +│   │   ├── mimic-omop-primary.sql +│   │   ├── note.csv.gz +│   │   ├── note_nlp.csv.gz +│   │   ├── observation.csv.gz +│   │   ├── observation_period.csv.gz +│   │   ├── omop_cdm_comments.sql +│   │   ├── omop_vocab_load.sql +│   │   ├── payer_plan_period.csv.gz +│   │   ├── person.csv.gz +│   │   ├── procedure_occurrence.csv.gz +│   │   ├── provider.csv.gz +│   │   ├── relationship.csv.gz +│   │   ├── source_to_concept_map.csv.gz +│   │   ├── specimen.csv.gz +│   │   ├── visit_detail.csv.gz +│   │   ├── visit_occurrence.csv.gz +│   │   └── vocabulary.csv.gz +``` diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml new file mode 100644 index 0000000..68b20fc --- /dev/null +++ b/docker/docker-compose.yml @@ -0,0 +1,37 @@ +version: '3.9' +services: + db: + build: + context: . + dockerfile: Dockerfile-pg + environment: + - POSTGRES_DB=mimic + - POSTGRES_USER=postgres + - POSTGRES_PASSWORD=mypassword + ports: + - 5432:5432 + volumes: + - $PWD/docker/postgres.conf:/etc/postgresql/postgresql.conf +# - $PWD/db-data/:/var/lib/postgresql/data/ + healthcheck: + test: ["CMD-SHELL", "psql -U postgres -d mimic -c 'select 1' | grep -q column"] + interval: 5s + command: postgres -c config_file=/etc/postgresql/postgresql.conf + + etl: + build: + context: . + dockerfile: Dockerfile + depends_on: + db: + condition: service_healthy + environment: + - DB_HOST=db + - PGPASSWORD=mypassword + - MIMIC_DATA_DIR=/opt/mimic-omop/mimic/data-${MIMIC_SCHEMA} + volumes: + - "$PWD:/opt/mimic-omop/" + env_file: + - .env + entrypoint: /opt/mimic-omop/docker/entrypoint.sh +# command: ["tail", "-f", "/dev/null"] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 0000000..abf6aa0 --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +set -e # Exit immediately if a command exits with a non-zero status. + +cd /opt/mimic-omop/ +echo -e "dbname=mimic\nuser=postgres\nhost=db\nport=5432\npassword=$PGPASSWORD" > /opt/mimic-omop/mimic-omop.cfg +make build runetl exporter check diff --git a/docker/postgres.conf b/docker/postgres.conf new file mode 100644 index 0000000..456e865 --- /dev/null +++ b/docker/postgres.conf @@ -0,0 +1,29 @@ +# auto-generated by https://pgtune.leopard.in.ua/ +# DB Version: 16 +# OS Type: linux +# DB Type: dw +# Total Memory (RAM): 64 GB +# CPUs num: 8 +# Connections num: 20 +# Data Storage: ssd + +listen_addresses = '*' +max_connections = 20 +shared_buffers = 30GB +effective_cache_size = 16GB +maintenance_work_mem = 2GB +checkpoint_completion_target = 0.9 +wal_buffers = 16MB +work_mem = 104857kB +#default_statistics_target = 500 +#random_page_cost = 1.1 +#effective_io_concurrency = 200 +#huge_pages = try +min_wal_size = 4GB +max_wal_size = 16GB +#max_worker_processes = 8 +#max_parallel_workers_per_gather = 4 +#max_parallel_workers = 8 +#max_parallel_maintenance_workers = 4 +#track_activity_query_size=1048576 +autovacuum=off \ No newline at end of file diff --git a/etl/check_etl.sql b/etl/check_etl.sql index 5a01dc9..ad20021 100644 --- a/etl/check_etl.sql +++ b/etl/check_etl.sql @@ -12,6 +12,8 @@ \set ON_ERROR_STOP false \set QUIET 1 +CREATE EXTENSION IF NOT EXISTS pgtap; + \i etl/StandardizedVocabularies/CONCEPT/check_etl.sql \i etl/StandardizedVocabularies/COHORT_DEFINITION/check_etl.sql \i etl/StandardizedVocabularies/ATTRIBUTE_DEFINITION/check_etl.sql diff --git a/mimic/build-mimic/analyze.sql b/mimic/build-mimic/analyze.sql new file mode 100644 index 0000000..948e07e --- /dev/null +++ b/mimic/build-mimic/analyze.sql @@ -0,0 +1,26 @@ +analyze admissions ; +analyze callout ; +analyze caregivers ; +analyze chartevents ; +analyze cptevents ; +analyze d_cpt ; +analyze d_icd_diagnoses ; +analyze d_icd_procedures ; +analyze d_items ; +analyze d_labitems ; +analyze datetimeevents ; +analyze diagnoses_icd ; +analyze drgcodes ; +analyze icustays ; +analyze inputevents_cv ; +analyze inputevents_mv ; +analyze labevents ; +analyze microbiologyevents ; +analyze noteevents ; +analyze outputevents ; +analyze patients ; +analyze prescriptions ; +analyze procedureevents_mv ; +analyze procedures_icd ; +analyze services ; +analyze transfers ; diff --git a/mimic/build-mimic/postgres_add_indexes.sql b/mimic/build-mimic/postgres_add_indexes.sql index dad432f..0236f07 100644 --- a/mimic/build-mimic/postgres_add_indexes.sql +++ b/mimic/build-mimic/postgres_add_indexes.sql @@ -14,13 +14,13 @@ -- ADMISSIONS ------------- -drop index IF EXISTS ADMISSIONS_idx01; -CREATE INDEX ADMISSIONS_IDX01 - ON ADMISSIONS (SUBJECT_ID); - -drop index IF EXISTS ADMISSIONS_idx02; -CREATE INDEX ADMISSIONS_IDX02 - ON ADMISSIONS (HADM_ID); +-- drop index IF EXISTS ADMISSIONS_idx01; +-- CREATE INDEX ADMISSIONS_IDX01 +-- ON ADMISSIONS (SUBJECT_ID); +-- +-- drop index IF EXISTS ADMISSIONS_idx02; +-- CREATE INDEX ADMISSIONS_IDX02 +-- ON ADMISSIONS (HADM_ID); -- drop index IF EXISTS ADMISSIONS_idx03; -- CREATE INDEX ADMISSIONS_IDX03 @@ -31,13 +31,13 @@ CREATE INDEX ADMISSIONS_IDX02 --CALLOUT-- ----------- -drop index IF EXISTS CALLOUT_idx01; -CREATE INDEX CALLOUT_IDX01 - ON CALLOUT (SUBJECT_ID); - -drop index IF EXISTS CALLOUT_idx02; -CREATE INDEX CALLOUT_IDX02 - ON CALLOUT (HADM_ID); +-- drop index IF EXISTS CALLOUT_idx01; +-- CREATE INDEX CALLOUT_IDX01 +-- ON CALLOUT (SUBJECT_ID); +-- +-- drop index IF EXISTS CALLOUT_idx02; +-- CREATE INDEX CALLOUT_IDX02 +-- ON CALLOUT (HADM_ID); -- drop index IF EXISTS CALLOUT_idx03; -- CREATE INDEX CALLOUT_IDX03 @@ -75,141 +75,37 @@ CREATE INDEX CALLOUT_IDX02 -- index on itemid -- -drop index IF EXISTS chartevents_1_idx01; -CREATE INDEX chartevents_1_idx01 ON chartevents_1 (itemid); -drop index IF EXISTS chartevents_2_idx01; -CREATE INDEX chartevents_2_idx01 ON chartevents_2 (itemid); -drop index IF EXISTS chartevents_3_idx01; -CREATE INDEX chartevents_3_idx01 ON chartevents_3 (itemid); -drop index IF EXISTS chartevents_4_idx01; -CREATE INDEX chartevents_4_idx01 ON chartevents_4 (itemid); -drop index IF EXISTS chartevents_5_idx01; -CREATE INDEX chartevents_5_idx01 ON chartevents_5 (itemid); -drop index IF EXISTS chartevents_6_idx01; -CREATE INDEX chartevents_6_idx01 ON chartevents_6 (itemid); -drop index IF EXISTS chartevents_7_idx01; -CREATE INDEX chartevents_7_idx01 ON chartevents_7 (itemid); -drop index IF EXISTS chartevents_8_idx01; -CREATE INDEX chartevents_8_idx01 ON chartevents_8 (itemid); -drop index IF EXISTS chartevents_9_idx01; -CREATE INDEX chartevents_9_idx01 ON chartevents_9 (itemid); -drop index IF EXISTS chartevents_10_idx01; -CREATE INDEX chartevents_10_idx01 ON chartevents_10 (itemid); -drop index IF EXISTS chartevents_11_idx01; -CREATE INDEX chartevents_11_idx01 ON chartevents_11 (itemid); -drop index IF EXISTS chartevents_12_idx01; -CREATE INDEX chartevents_12_idx01 ON chartevents_12 (itemid); -drop index IF EXISTS chartevents_13_idx01; -CREATE INDEX chartevents_13_idx01 ON chartevents_13 (itemid); -drop index IF EXISTS chartevents_14_idx01; -CREATE INDEX chartevents_14_idx01 ON chartevents_14 (itemid); - --- index on subject_id -- - -drop index IF EXISTS chartevents_1_idx02; -CREATE INDEX chartevents_1_idx02 ON chartevents_1 (SUBJECT_ID); -drop index IF EXISTS chartevents_2_idx02; -CREATE INDEX chartevents_2_idx02 ON chartevents_2 (SUBJECT_ID); -drop index IF EXISTS chartevents_3_idx02; -CREATE INDEX chartevents_3_idx02 ON chartevents_3 (SUBJECT_ID); -drop index IF EXISTS chartevents_4_idx02; -CREATE INDEX chartevents_4_idx02 ON chartevents_4 (SUBJECT_ID); -drop index IF EXISTS chartevents_5_idx02; -CREATE INDEX chartevents_5_idx02 ON chartevents_5 (SUBJECT_ID); -drop index IF EXISTS chartevents_6_idx02; -CREATE INDEX chartevents_6_idx02 ON chartevents_6 (SUBJECT_ID); -drop index IF EXISTS chartevents_7_idx02; -CREATE INDEX chartevents_7_idx02 ON chartevents_7 (SUBJECT_ID); -drop index IF EXISTS chartevents_8_idx02; -CREATE INDEX chartevents_8_idx02 ON chartevents_8 (SUBJECT_ID); -drop index IF EXISTS chartevents_9_idx02; -CREATE INDEX chartevents_9_idx02 ON chartevents_9 (SUBJECT_ID); -drop index IF EXISTS chartevents_10_idx02; -CREATE INDEX chartevents_10_idx02 ON chartevents_10 (SUBJECT_ID); -drop index IF EXISTS chartevents_11_idx02; -CREATE INDEX chartevents_11_idx02 ON chartevents_11 (SUBJECT_ID); -drop index IF EXISTS chartevents_12_idx02; -CREATE INDEX chartevents_12_idx02 ON chartevents_12 (SUBJECT_ID); -drop index IF EXISTS chartevents_13_idx02; -CREATE INDEX chartevents_13_idx02 ON chartevents_13 (SUBJECT_ID); -drop index IF EXISTS chartevents_14_idx02; -CREATE INDEX chartevents_14_idx02 ON chartevents_14 (SUBJECT_ID); - --- index on hadm_id -- - -drop index IF EXISTS chartevents_1_idx04; -CREATE INDEX chartevents_1_idx04 ON chartevents_1 (HADM_ID); -drop index IF EXISTS chartevents_2_idx04; -CREATE INDEX chartevents_2_idx04 ON chartevents_2 (HADM_ID); -drop index IF EXISTS chartevents_3_idx04; -CREATE INDEX chartevents_3_idx04 ON chartevents_3 (HADM_ID); -drop index IF EXISTS chartevents_4_idx04; -CREATE INDEX chartevents_4_idx04 ON chartevents_4 (HADM_ID); -drop index IF EXISTS chartevents_5_idx04; -CREATE INDEX chartevents_5_idx04 ON chartevents_5 (HADM_ID); -drop index IF EXISTS chartevents_6_idx04; -CREATE INDEX chartevents_6_idx04 ON chartevents_6 (HADM_ID); -drop index IF EXISTS chartevents_7_idx04; -CREATE INDEX chartevents_7_idx04 ON chartevents_7 (HADM_ID); -drop index IF EXISTS chartevents_8_idx04; -CREATE INDEX chartevents_8_idx04 ON chartevents_8 (HADM_ID); -drop index IF EXISTS chartevents_9_idx04; -CREATE INDEX chartevents_9_idx04 ON chartevents_9 (HADM_ID); -drop index IF EXISTS chartevents_10_idx04; -CREATE INDEX chartevents_10_idx04 ON chartevents_10 (HADM_ID); -drop index IF EXISTS chartevents_11_idx04; -CREATE INDEX chartevents_11_idx04 ON chartevents_11 (HADM_ID); -drop index IF EXISTS chartevents_12_idx04; -CREATE INDEX chartevents_12_idx04 ON chartevents_12 (HADM_ID); -drop index IF EXISTS chartevents_13_idx04; -CREATE INDEX chartevents_13_idx04 ON chartevents_13 (HADM_ID); -drop index IF EXISTS chartevents_14_idx04; -CREATE INDEX chartevents_14_idx04 ON chartevents_14 (HADM_ID); - - --- index on icustay_id -- - -drop index IF EXISTS chartevents_1_idx06; -CREATE INDEX chartevents_1_idx06 ON chartevents_1 (ICUSTAY_ID); -drop index IF EXISTS chartevents_2_idx06; -CREATE INDEX chartevents_2_idx06 ON chartevents_2 (ICUSTAY_ID); -drop index IF EXISTS chartevents_3_idx06; -CREATE INDEX chartevents_3_idx06 ON chartevents_3 (ICUSTAY_ID); -drop index IF EXISTS chartevents_4_idx06; -CREATE INDEX chartevents_4_idx06 ON chartevents_4 (ICUSTAY_ID); -drop index IF EXISTS chartevents_5_idx06; -CREATE INDEX chartevents_5_idx06 ON chartevents_5 (ICUSTAY_ID); -drop index IF EXISTS chartevents_6_idx06; -CREATE INDEX chartevents_6_idx06 ON chartevents_6 (ICUSTAY_ID); -drop index IF EXISTS chartevents_7_idx06; -CREATE INDEX chartevents_7_idx06 ON chartevents_7 (ICUSTAY_ID); -drop index IF EXISTS chartevents_8_idx06; -CREATE INDEX chartevents_8_idx06 ON chartevents_8 (ICUSTAY_ID); -drop index IF EXISTS chartevents_9_idx06; -CREATE INDEX chartevents_9_idx06 ON chartevents_9 (ICUSTAY_ID); -drop index IF EXISTS chartevents_10_idx06; -CREATE INDEX chartevents_10_idx06 ON chartevents_10 (ICUSTAY_ID); -drop index IF EXISTS chartevents_11_idx06; -CREATE INDEX chartevents_11_idx06 ON chartevents_11 (ICUSTAY_ID); -drop index IF EXISTS chartevents_12_idx06; -CREATE INDEX chartevents_12_idx06 ON chartevents_12 (ICUSTAY_ID); -drop index IF EXISTS chartevents_13_idx06; -CREATE INDEX chartevents_13_idx06 ON chartevents_13 (ICUSTAY_ID); -drop index IF EXISTS chartevents_14_idx06; -CREATE INDEX chartevents_14_idx06 ON chartevents_14 (ICUSTAY_ID); +-- drop index IF EXISTS chartevents_1_idx01; +-- CREATE INDEX chartevents_1_idx01 ON chartevents (itemid); +-- +-- -- index on subject_id -- +-- +-- drop index IF EXISTS chartevents_1_idx02; +-- CREATE INDEX chartevents_1_idx02 ON chartevents (SUBJECT_ID); +-- +-- -- index on hadm_id -- +-- +-- drop index IF EXISTS chartevents_1_idx04; +-- CREATE INDEX chartevents_1_idx04 ON chartevents (HADM_ID); +-- +-- +-- -- index on icustay_id -- +-- +-- drop index IF EXISTS chartevents_1_idx06; +-- CREATE INDEX chartevents_1_idx06 ON chartevents (ICUSTAY_ID); --------------- -- CPTEVENTS --------------- -drop index IF EXISTS CPTEVENTS_idx01; -CREATE INDEX CPTEVENTS_idx01 - ON CPTEVENTS (SUBJECT_ID); - -drop index IF EXISTS CPTEVENTS_idx02; -CREATE INDEX CPTEVENTS_idx02 - ON CPTEVENTS (CPT_CD); +-- drop index IF EXISTS CPTEVENTS_idx01; +-- CREATE INDEX CPTEVENTS_idx01 +-- ON CPTEVENTS (SUBJECT_ID); +-- +-- drop index IF EXISTS CPTEVENTS_idx02; +-- CREATE INDEX CPTEVENTS_idx02 +-- ON CPTEVENTS (CPT_CD); ----------- -- D_CPT @@ -277,21 +173,21 @@ CREATE INDEX D_LABITEMS_idx03 -- DATETIMEEVENTS ------------------- -drop index IF EXISTS DATETIMEEVENTS_idx01; -CREATE INDEX DATETIMEEVENTS_idx01 - ON DATETIMEEVENTS (SUBJECT_ID); - -drop index IF EXISTS DATETIMEEVENTS_idx02; -CREATE INDEX DATETIMEEVENTS_idx02 - ON DATETIMEEVENTS (ITEMID); - -drop index IF EXISTS DATETIMEEVENTS_idx03; -CREATE INDEX DATETIMEEVENTS_idx03 - ON DATETIMEEVENTS (ICUSTAY_ID); - -drop index IF EXISTS DATETIMEEVENTS_idx04; -CREATE INDEX DATETIMEEVENTS_idx04 - ON DATETIMEEVENTS (HADM_ID); +-- drop index IF EXISTS DATETIMEEVENTS_idx01; +-- CREATE INDEX DATETIMEEVENTS_idx01 +-- ON DATETIMEEVENTS (SUBJECT_ID); +-- +-- drop index IF EXISTS DATETIMEEVENTS_idx02; +-- CREATE INDEX DATETIMEEVENTS_idx02 +-- ON DATETIMEEVENTS (ITEMID); +-- +-- drop index IF EXISTS DATETIMEEVENTS_idx03; +-- CREATE INDEX DATETIMEEVENTS_idx03 +-- ON DATETIMEEVENTS (ICUSTAY_ID); +-- +-- drop index IF EXISTS DATETIMEEVENTS_idx04; +-- CREATE INDEX DATETIMEEVENTS_idx04 +-- ON DATETIMEEVENTS (HADM_ID); -- drop index IF EXISTS DATETIMEEVENTS_idx05; -- CREATE INDEX DATETIMEEVENTS_idx05 @@ -301,33 +197,33 @@ CREATE INDEX DATETIMEEVENTS_idx04 -- DIAGNOSES_ICD ------------------ -drop index IF EXISTS DIAGNOSES_ICD_idx01; -CREATE INDEX DIAGNOSES_ICD_idx01 - ON DIAGNOSES_ICD (SUBJECT_ID); - -drop index IF EXISTS DIAGNOSES_ICD_idx02; -CREATE INDEX DIAGNOSES_ICD_idx02 - ON DIAGNOSES_ICD (ICD9_CODE); - -drop index IF EXISTS DIAGNOSES_ICD_idx03; -CREATE INDEX DIAGNOSES_ICD_idx03 - ON DIAGNOSES_ICD (HADM_ID); +-- drop index IF EXISTS DIAGNOSES_ICD_idx01; +-- CREATE INDEX DIAGNOSES_ICD_idx01 +-- ON DIAGNOSES_ICD (SUBJECT_ID); +-- +-- drop index IF EXISTS DIAGNOSES_ICD_idx02; +-- CREATE INDEX DIAGNOSES_ICD_idx02 +-- ON DIAGNOSES_ICD (ICD9_CODE); +-- +-- drop index IF EXISTS DIAGNOSES_ICD_idx03; +-- CREATE INDEX DIAGNOSES_ICD_idx03 +-- ON DIAGNOSES_ICD (HADM_ID); -------------- -- DRGCODES -------------- -drop index IF EXISTS DRGCODES_idx01; -CREATE INDEX DRGCODES_idx01 - ON DRGCODES (SUBJECT_ID); - -drop index IF EXISTS DRGCODES_idx02; -CREATE INDEX DRGCODES_idx02 - ON DRGCODES (DRG_CODE); - -drop index IF EXISTS DRGCODES_idx03; -CREATE INDEX DRGCODES_idx03 - ON DRGCODES (DESCRIPTION); +-- drop index IF EXISTS DRGCODES_idx01; +-- CREATE INDEX DRGCODES_idx01 +-- ON DRGCODES (SUBJECT_ID); +-- +-- drop index IF EXISTS DRGCODES_idx02; +-- CREATE INDEX DRGCODES_idx02 +-- ON DRGCODES (DRG_CODE); +-- +-- drop index IF EXISTS DRGCODES_idx03; +-- CREATE INDEX DRGCODES_idx03 +-- ON DRGCODES (DESCRIPTION); -- HADM_ID @@ -335,13 +231,13 @@ CREATE INDEX DRGCODES_idx03 -- ICUSTAYS ------------------ -drop index IF EXISTS ICUSTAYS_idx01; -CREATE INDEX ICUSTAYS_idx01 - ON ICUSTAYS (SUBJECT_ID); - -drop index IF EXISTS ICUSTAYS_idx02; -CREATE INDEX ICUSTAYS_idx02 - ON ICUSTAYS (ICUSTAY_ID); +-- drop index IF EXISTS ICUSTAYS_idx01; +-- CREATE INDEX ICUSTAYS_idx01 +-- ON ICUSTAYS (SUBJECT_ID); +-- +-- drop index IF EXISTS ICUSTAYS_idx02; +-- CREATE INDEX ICUSTAYS_idx02 +-- ON ICUSTAYS (ICUSTAY_ID); -- drop index IF EXISTS ICUSTAYS_idx03; -- CREATE INDEX ICUSTAYS_idx03 @@ -355,33 +251,33 @@ CREATE INDEX ICUSTAYS_idx02 -- CREATE INDEX ICUSTAYS_idx05 -- ON ICUSTAYS (LAST_CAREUNIT); -drop index IF EXISTS ICUSTAYS_idx06; -CREATE INDEX ICUSTAYS_IDX06 - ON ICUSTAYS (HADM_ID); +-- drop index IF EXISTS ICUSTAYS_idx06; +-- CREATE INDEX ICUSTAYS_IDX06 +-- ON ICUSTAYS (HADM_ID); ------------- -- INPUTEVENTS_CV ------------- -drop index IF EXISTS INPUTEVENTS_CV_idx01; -CREATE INDEX INPUTEVENTS_CV_idx01 - ON INPUTEVENTS_CV (SUBJECT_ID); - - drop index IF EXISTS INPUTEVENTS_CV_idx02; - CREATE INDEX INPUTEVENTS_CV_idx02 - ON INPUTEVENTS_CV (HADM_ID); - -drop index IF EXISTS INPUTEVENTS_CV_idx03; -CREATE INDEX INPUTEVENTS_CV_idx03 - ON INPUTEVENTS_CV (ICUSTAY_ID); - -drop index IF EXISTS INPUTEVENTS_CV_idx04; -CREATE INDEX INPUTEVENTS_CV_idx04 - ON INPUTEVENTS_CV (CHARTTIME); - -drop index IF EXISTS INPUTEVENTS_CV_idx05; -CREATE INDEX INPUTEVENTS_CV_idx05 - ON INPUTEVENTS_CV (ITEMID); +-- drop index IF EXISTS INPUTEVENTS_CV_idx01; +-- CREATE INDEX INPUTEVENTS_CV_idx01 +-- ON INPUTEVENTS_CV (SUBJECT_ID); +-- +-- drop index IF EXISTS INPUTEVENTS_CV_idx02; +-- CREATE INDEX INPUTEVENTS_CV_idx02 +-- ON INPUTEVENTS_CV (HADM_ID); +-- +-- drop index IF EXISTS INPUTEVENTS_CV_idx03; +-- CREATE INDEX INPUTEVENTS_CV_idx03 +-- ON INPUTEVENTS_CV (ICUSTAY_ID); +-- +-- drop index IF EXISTS INPUTEVENTS_CV_idx04; +-- CREATE INDEX INPUTEVENTS_CV_idx04 +-- ON INPUTEVENTS_CV (CHARTTIME); +-- +-- drop index IF EXISTS INPUTEVENTS_CV_idx05; +-- CREATE INDEX INPUTEVENTS_CV_idx05 +-- ON INPUTEVENTS_CV (ITEMID); -- drop index IF EXISTS INPUTEVENTS_CV_idx06; -- CREATE INDEX INPUTEVENTS_CV_idx06 @@ -403,25 +299,25 @@ CREATE INDEX INPUTEVENTS_CV_idx05 -- INPUTEVENTS_MV ------------- -drop index IF EXISTS INPUTEVENTS_MV_idx01; -CREATE INDEX INPUTEVENTS_MV_idx01 - ON INPUTEVENTS_MV (SUBJECT_ID); - -drop index IF EXISTS INPUTEVENTS_MV_idx02; -CREATE INDEX INPUTEVENTS_MV_idx02 - ON INPUTEVENTS_MV (HADM_ID); - -drop index IF EXISTS INPUTEVENTS_MV_idx03; -CREATE INDEX INPUTEVENTS_MV_idx03 - ON INPUTEVENTS_MV (ICUSTAY_ID); +-- drop index IF EXISTS INPUTEVENTS_MV_idx01; +-- CREATE INDEX INPUTEVENTS_MV_idx01 +-- ON INPUTEVENTS_MV (SUBJECT_ID); +-- +-- drop index IF EXISTS INPUTEVENTS_MV_idx02; +-- CREATE INDEX INPUTEVENTS_MV_idx02 +-- ON INPUTEVENTS_MV (HADM_ID); +-- +-- drop index IF EXISTS INPUTEVENTS_MV_idx03; +-- CREATE INDEX INPUTEVENTS_MV_idx03 +-- ON INPUTEVENTS_MV (ICUSTAY_ID); -- drop index IF EXISTS INPUTEVENTS_MV_idx04; -- CREATE INDEX INPUTEVENTS_MV_idx04 -- ON INPUTEVENTS_MV (ENDTIME, STARTTIME); -drop index IF EXISTS INPUTEVENTS_MV_idx05; -CREATE INDEX INPUTEVENTS_MV_idx05 - ON INPUTEVENTS_MV (ITEMID); +-- drop index IF EXISTS INPUTEVENTS_MV_idx05; +-- CREATE INDEX INPUTEVENTS_MV_idx05 +-- ON INPUTEVENTS_MV (ITEMID); -- drop index IF EXISTS INPUTEVENTS_MV_idx06; -- CREATE INDEX INPUTEVENTS_MV_idx06 @@ -454,17 +350,17 @@ CREATE INDEX INPUTEVENTS_MV_idx05 -- LABEVENTS -------------- -drop index IF EXISTS LABEVENTS_idx01; -CREATE INDEX LABEVENTS_idx01 - ON LABEVENTS (SUBJECT_ID); - -drop index IF EXISTS LABEVENTS_idx02; -CREATE INDEX LABEVENTS_idx02 - ON LABEVENTS (HADM_ID); - -drop index IF EXISTS LABEVENTS_idx03; -CREATE INDEX LABEVENTS_idx03 - ON LABEVENTS (ITEMID); +-- drop index IF EXISTS LABEVENTS_idx01; +-- CREATE INDEX LABEVENTS_idx01 +-- ON LABEVENTS (SUBJECT_ID); +-- +-- drop index IF EXISTS LABEVENTS_idx02; +-- CREATE INDEX LABEVENTS_idx02 +-- ON LABEVENTS (HADM_ID); +-- +-- drop index IF EXISTS LABEVENTS_idx03; +-- CREATE INDEX LABEVENTS_idx03 +-- ON LABEVENTS (ITEMID); -- drop index IF EXISTS LABEVENTS_idx04; -- CREATE INDEX LABEVENTS_idx04 @@ -474,13 +370,13 @@ CREATE INDEX LABEVENTS_idx03 -- MICROBIOLOGYEVENTS ---------------------- -drop index IF EXISTS MICROBIOLOGYEVENTS_idx01; -CREATE INDEX MICROBIOLOGYEVENTS_idx01 - ON MICROBIOLOGYEVENTS (SUBJECT_ID); - -drop index IF EXISTS MICROBIOLOGYEVENTS_idx02; -CREATE INDEX MICROBIOLOGYEVENTS_idx02 - ON MICROBIOLOGYEVENTS (HADM_ID); +-- drop index IF EXISTS MICROBIOLOGYEVENTS_idx01; +-- CREATE INDEX MICROBIOLOGYEVENTS_idx01 +-- ON MICROBIOLOGYEVENTS (SUBJECT_ID); +-- +-- drop index IF EXISTS MICROBIOLOGYEVENTS_idx02; +-- CREATE INDEX MICROBIOLOGYEVENTS_idx02 +-- ON MICROBIOLOGYEVENTS (HADM_ID); -- drop index IF EXISTS MICROBIOLOGYEVENTS_idx03; -- CREATE INDEX MICROBIOLOGYEVENTS_idx03 @@ -491,13 +387,13 @@ CREATE INDEX MICROBIOLOGYEVENTS_idx02 -- NOTEEVENTS --------------- -drop index IF EXISTS NOTEEVENTS_idx01; -CREATE INDEX NOTEEVENTS_idx01 - ON NOTEEVENTS (SUBJECT_ID); - -drop index IF EXISTS NOTEEVENTS_idx02; -CREATE INDEX NOTEEVENTS_idx02 - ON NOTEEVENTS (HADM_ID); +-- drop index IF EXISTS NOTEEVENTS_idx01; +-- CREATE INDEX NOTEEVENTS_idx01 +-- ON NOTEEVENTS (SUBJECT_ID); +-- +-- drop index IF EXISTS NOTEEVENTS_idx02; +-- CREATE INDEX NOTEEVENTS_idx02 +-- ON NOTEEVENTS (HADM_ID); -- drop index IF EXISTS NOTEEVENTS_idx03; -- CREATE INDEX NOTEEVENTS_idx03 @@ -507,32 +403,32 @@ CREATE INDEX NOTEEVENTS_idx02 -- CREATE INDEX NOTEEVENTS_idx04 -- ON NOTEEVENTS (RECORD_ID); -drop index IF EXISTS NOTEEVENTS_idx05; -CREATE INDEX NOTEEVENTS_idx05 - ON NOTEEVENTS (CATEGORY); +-- drop index IF EXISTS NOTEEVENTS_idx05; +-- CREATE INDEX NOTEEVENTS_idx05 +-- ON NOTEEVENTS (CATEGORY); --------------- -- OUTPUTEVENTS --------------- -drop index IF EXISTS OUTPUTEVENTS_idx01; -CREATE INDEX OUTPUTEVENTS_idx01 - ON OUTPUTEVENTS (SUBJECT_ID); - - -drop index IF EXISTS OUTPUTEVENTS_idx02; -CREATE INDEX OUTPUTEVENTS_idx02 - ON OUTPUTEVENTS (ITEMID); - - -drop index IF EXISTS OUTPUTEVENTS_idx03; -CREATE INDEX OUTPUTEVENTS_idx03 - ON OUTPUTEVENTS (ICUSTAY_ID); - - -drop index IF EXISTS OUTPUTEVENTS_idx04; -CREATE INDEX OUTPUTEVENTS_idx04 - ON OUTPUTEVENTS (HADM_ID); +-- drop index IF EXISTS OUTPUTEVENTS_idx01; +-- CREATE INDEX OUTPUTEVENTS_idx01 +-- ON OUTPUTEVENTS (SUBJECT_ID); +-- +-- +-- drop index IF EXISTS OUTPUTEVENTS_idx02; +-- CREATE INDEX OUTPUTEVENTS_idx02 +-- ON OUTPUTEVENTS (ITEMID); +-- +-- +-- drop index IF EXISTS OUTPUTEVENTS_idx03; +-- CREATE INDEX OUTPUTEVENTS_idx03 +-- ON OUTPUTEVENTS (ICUSTAY_ID); +-- +-- +-- drop index IF EXISTS OUTPUTEVENTS_idx04; +-- CREATE INDEX OUTPUTEVENTS_idx04 +-- ON OUTPUTEVENTS (HADM_ID); -- Perhaps not useful to index on just value? Index just for popular subset? -- drop index IF EXISTS OUTPUTEVENTS_idx05; @@ -555,50 +451,50 @@ CREATE INDEX OUTPUTEVENTS_idx04 -- PRESCRIPTIONS ------------------ -drop index IF EXISTS PRESCRIPTIONS_idx01; -CREATE INDEX PRESCRIPTIONS_idx01 - ON PRESCRIPTIONS (SUBJECT_ID); - -drop index IF EXISTS PRESCRIPTIONS_idx02; -CREATE INDEX PRESCRIPTIONS_idx02 - ON PRESCRIPTIONS (ICUSTAY_ID); - -drop index IF EXISTS PRESCRIPTIONS_idx03; -CREATE INDEX PRESCRIPTIONS_idx03 - ON PRESCRIPTIONS (DRUG_TYPE); - -drop index IF EXISTS PRESCRIPTIONS_idx04; -CREATE INDEX PRESCRIPTIONS_idx04 - ON PRESCRIPTIONS (DRUG); - -drop index IF EXISTS PRESCRIPTIONS_idx05; -CREATE INDEX PRESCRIPTIONS_idx05 - ON PRESCRIPTIONS (HADM_ID); +-- drop index IF EXISTS PRESCRIPTIONS_idx01; +-- CREATE INDEX PRESCRIPTIONS_idx01 +-- ON PRESCRIPTIONS (SUBJECT_ID); +-- +-- drop index IF EXISTS PRESCRIPTIONS_idx02; +-- CREATE INDEX PRESCRIPTIONS_idx02 +-- ON PRESCRIPTIONS (ICUSTAY_ID); +-- +-- drop index IF EXISTS PRESCRIPTIONS_idx03; +-- CREATE INDEX PRESCRIPTIONS_idx03 +-- ON PRESCRIPTIONS (DRUG_TYPE); +-- +-- drop index IF EXISTS PRESCRIPTIONS_idx04; +-- CREATE INDEX PRESCRIPTIONS_idx04 +-- ON PRESCRIPTIONS (DRUG); +-- +-- drop index IF EXISTS PRESCRIPTIONS_idx05; +-- CREATE INDEX PRESCRIPTIONS_idx05 +-- ON PRESCRIPTIONS (HADM_ID); --------------------- -- PROCEDUREEVENTS_MV --------------------- -drop index IF EXISTS PROCEDUREEVENTS_MV_idx01; -CREATE INDEX PROCEDUREEVENTS_MV_idx01 - ON PROCEDUREEVENTS_MV (SUBJECT_ID); - -drop index IF EXISTS PROCEDUREEVENTS_MV_idx02; -CREATE INDEX PROCEDUREEVENTS_MV_idx02 - ON PROCEDUREEVENTS_MV (HADM_ID); - -drop index IF EXISTS PROCEDUREEVENTS_MV_idx03; -CREATE INDEX PROCEDUREEVENTS_MV_idx03 - ON PROCEDUREEVENTS_MV (ICUSTAY_ID); +-- drop index IF EXISTS PROCEDUREEVENTS_MV_idx01; +-- CREATE INDEX PROCEDUREEVENTS_MV_idx01 +-- ON PROCEDUREEVENTS_MV (SUBJECT_ID); +-- +-- drop index IF EXISTS PROCEDUREEVENTS_MV_idx02; +-- CREATE INDEX PROCEDUREEVENTS_MV_idx02 +-- ON PROCEDUREEVENTS_MV (HADM_ID); +-- +-- drop index IF EXISTS PROCEDUREEVENTS_MV_idx03; +-- CREATE INDEX PROCEDUREEVENTS_MV_idx03 +-- ON PROCEDUREEVENTS_MV (ICUSTAY_ID); -- drop index IF EXISTS PROCEDUREEVENTS_MV_idx04; -- CREATE INDEX PROCEDUREEVENTS_MV_idx04 -- ON PROCEDUREEVENTS_MV (ENDTIME, STARTTIME); -drop index IF EXISTS PROCEDUREEVENTS_MV_idx05; -CREATE INDEX PROCEDUREEVENTS_MV_idx05 - ON PROCEDUREEVENTS_MV (ITEMID); +-- drop index IF EXISTS PROCEDUREEVENTS_MV_idx05; +-- CREATE INDEX PROCEDUREEVENTS_MV_idx05 +-- ON PROCEDUREEVENTS_MV (ITEMID); -- drop index IF EXISTS PROCEDUREEVENTS_MV_idx06; -- CREATE INDEX PROCEDUREEVENTS_MV_idx06 @@ -621,17 +517,17 @@ CREATE INDEX PROCEDUREEVENTS_MV_idx05 -- PROCEDURES_ICD ------------------- -drop index IF EXISTS PROCEDURES_ICD_idx01; -CREATE INDEX PROCEDURES_ICD_idx01 - ON PROCEDURES_ICD (SUBJECT_ID); - -drop index IF EXISTS PROCEDURES_ICD_idx02; -CREATE INDEX PROCEDURES_ICD_idx02 - ON PROCEDURES_ICD (ICD9_CODE); - -drop index IF EXISTS PROCEDURES_ICD_idx03; -CREATE INDEX PROCEDURES_ICD_idx03 - ON PROCEDURES_ICD (HADM_ID); +-- drop index IF EXISTS PROCEDURES_ICD_idx01; +-- CREATE INDEX PROCEDURES_ICD_idx01 +-- ON PROCEDURES_ICD (SUBJECT_ID); +-- +-- drop index IF EXISTS PROCEDURES_ICD_idx02; +-- CREATE INDEX PROCEDURES_ICD_idx02 +-- ON PROCEDURES_ICD (ICD9_CODE); +-- +-- drop index IF EXISTS PROCEDURES_ICD_idx03; +-- CREATE INDEX PROCEDURES_ICD_idx03 +-- ON PROCEDURES_ICD (HADM_ID); ------------- @@ -654,17 +550,17 @@ CREATE INDEX SERVICES_idx02 -- TRANSFERS ------------- -drop index IF EXISTS TRANSFERS_idx01; -CREATE INDEX TRANSFERS_idx01 - ON TRANSFERS (SUBJECT_ID); - -drop index IF EXISTS TRANSFERS_idx02; -CREATE INDEX TRANSFERS_idx02 - ON TRANSFERS (ICUSTAY_ID); - -drop index IF EXISTS TRANSFERS_idx03; -CREATE INDEX TRANSFERS_idx03 - ON TRANSFERS (HADM_ID); +-- drop index IF EXISTS TRANSFERS_idx01; +-- CREATE INDEX TRANSFERS_idx01 +-- ON TRANSFERS (SUBJECT_ID); +-- +-- drop index IF EXISTS TRANSFERS_idx02; +-- CREATE INDEX TRANSFERS_idx02 +-- ON TRANSFERS (ICUSTAY_ID); +-- +-- drop index IF EXISTS TRANSFERS_idx03; +-- CREATE INDEX TRANSFERS_idx03 +-- ON TRANSFERS (HADM_ID); -- drop index IF EXISTS TRANSFERS_idx04; -- CREATE INDEX TRANSFERS_idx04 diff --git a/mimic/build-mimic/postgres_create_tables.sql b/mimic/build-mimic/postgres_create_tables.sql index 212146d..d74fe9d 100644 --- a/mimic/build-mimic/postgres_create_tables.sql +++ b/mimic/build-mimic/postgres_create_tables.sql @@ -27,7 +27,7 @@ -------------------------------------------------------- DROP TABLE IF EXISTS ADMISSIONS CASCADE; -CREATE TABLE ADMISSIONS +CREATE UNLOGGED TABLE ADMISSIONS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -57,7 +57,7 @@ CREATE TABLE ADMISSIONS -------------------------------------------------------- DROP TABLE IF EXISTS CALLOUT CASCADE; -CREATE TABLE CALLOUT +CREATE UNLOGGED TABLE CALLOUT ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -91,7 +91,7 @@ CREATE TABLE CALLOUT -------------------------------------------------------- DROP TABLE IF EXISTS CAREGIVERS CASCADE; -CREATE TABLE CAREGIVERS +CREATE UNLOGGED TABLE CAREGIVERS ( ROW_ID INT NOT NULL, CGID INT NOT NULL, @@ -106,7 +106,7 @@ CREATE TABLE CAREGIVERS -------------------------------------------------------- DROP TABLE IF EXISTS CHARTEVENTS CASCADE; -CREATE TABLE CHARTEVENTS +CREATE UNLOGGED TABLE CHARTEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -131,20 +131,20 @@ CREATE TABLE CHARTEVENTS -------------------------------------------------------- -- CREATE CHARTEVENTS TABLE --- CREATE TABLE chartevents_1 ( CHECK ( itemid >= 1 AND itemid < 210 )) INHERITS (chartevents); --- CREATE TABLE chartevents_2 ( CHECK ( itemid >= 210 AND itemid < 250 )) INHERITS (chartevents); --- CREATE TABLE chartevents_3 ( CHECK ( itemid >= 250 AND itemid < 614 )) INHERITS (chartevents); --- CREATE TABLE chartevents_4 ( CHECK ( itemid >= 614 AND itemid < 640 )) INHERITS (chartevents); --- CREATE TABLE chartevents_5 ( CHECK ( itemid >= 640 AND itemid < 742 )) INHERITS (chartevents); --- CREATE TABLE chartevents_6 ( CHECK ( itemid >= 742 AND itemid < 1800 )) INHERITS (chartevents); --- CREATE TABLE chartevents_7 ( CHECK ( itemid >= 1800 AND itemid < 2700 )) INHERITS (chartevents); --- CREATE TABLE chartevents_8 ( CHECK ( itemid >= 2700 AND itemid < 3700 )) INHERITS (chartevents); --- CREATE TABLE chartevents_9 ( CHECK ( itemid >= 3700 AND itemid < 4700 )) INHERITS (chartevents); --- CREATE TABLE chartevents_10 ( CHECK ( itemid >= 4700 AND itemid < 6000 )) INHERITS (chartevents); --- CREATE TABLE chartevents_11 ( CHECK ( itemid >= 6000 AND itemid < 7000 )) INHERITS (chartevents); --- CREATE TABLE chartevents_12 ( CHECK ( itemid >= 7000 AND itemid < 8000 )) INHERITS (chartevents); --- CREATE TABLE chartevents_13 ( CHECK ( itemid >= 8000 AND itemid < 220074 )) INHERITS (chartevents); --- CREATE TABLE chartevents_14 ( CHECK ( itemid >= 220074 AND itemid < 323769 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_1 ( CHECK ( itemid >= 1 AND itemid < 210 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_2 ( CHECK ( itemid >= 210 AND itemid < 250 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_3 ( CHECK ( itemid >= 250 AND itemid < 614 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_4 ( CHECK ( itemid >= 614 AND itemid < 640 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_5 ( CHECK ( itemid >= 640 AND itemid < 742 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_6 ( CHECK ( itemid >= 742 AND itemid < 1800 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_7 ( CHECK ( itemid >= 1800 AND itemid < 2700 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_8 ( CHECK ( itemid >= 2700 AND itemid < 3700 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_9 ( CHECK ( itemid >= 3700 AND itemid < 4700 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_10 ( CHECK ( itemid >= 4700 AND itemid < 6000 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_11 ( CHECK ( itemid >= 6000 AND itemid < 7000 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_12 ( CHECK ( itemid >= 7000 AND itemid < 8000 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_13 ( CHECK ( itemid >= 8000 AND itemid < 220074 )) INHERITS (chartevents); +-- CREATE UNLOGGED TABLE chartevents_14 ( CHECK ( itemid >= 220074 AND itemid < 323769 )) INHERITS (chartevents); -- CREATE CHARTEVENTS TRIGGER -- CREATE OR REPLACE FUNCTION chartevents_insert_trigger() @@ -181,7 +181,7 @@ CREATE TABLE CHARTEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS CPTEVENTS CASCADE; -CREATE TABLE CPTEVENTS +CREATE UNLOGGED TABLE CPTEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -203,7 +203,7 @@ CREATE TABLE CPTEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS DATETIMEEVENTS CASCADE; -CREATE TABLE DATETIMEEVENTS +CREATE UNLOGGED TABLE DATETIMEEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -227,7 +227,7 @@ CREATE TABLE DATETIMEEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS DIAGNOSES_ICD CASCADE; -CREATE TABLE DIAGNOSES_ICD +CREATE UNLOGGED TABLE DIAGNOSES_ICD ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -242,7 +242,7 @@ CREATE TABLE DIAGNOSES_ICD -------------------------------------------------------- DROP TABLE IF EXISTS DRGCODES CASCADE; -CREATE TABLE DRGCODES +CREATE UNLOGGED TABLE DRGCODES ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -260,7 +260,7 @@ CREATE TABLE DRGCODES -------------------------------------------------------- DROP TABLE IF EXISTS D_CPT CASCADE; -CREATE TABLE D_CPT +CREATE UNLOGGED TABLE D_CPT ( ROW_ID INT NOT NULL, CATEGORY SMALLINT NOT NULL, @@ -280,7 +280,7 @@ CREATE TABLE D_CPT -------------------------------------------------------- DROP TABLE IF EXISTS D_ICD_DIAGNOSES CASCADE; -CREATE TABLE D_ICD_DIAGNOSES +CREATE UNLOGGED TABLE D_ICD_DIAGNOSES ( ROW_ID INT NOT NULL, ICD9_CODE VARCHAR(10) NOT NULL, @@ -295,7 +295,7 @@ CREATE TABLE D_ICD_DIAGNOSES -------------------------------------------------------- DROP TABLE IF EXISTS D_ICD_PROCEDURES CASCADE; -CREATE TABLE D_ICD_PROCEDURES +CREATE UNLOGGED TABLE D_ICD_PROCEDURES ( ROW_ID INT NOT NULL, ICD9_CODE VARCHAR(10) NOT NULL, @@ -310,7 +310,7 @@ CREATE TABLE D_ICD_PROCEDURES -------------------------------------------------------- DROP TABLE IF EXISTS D_ITEMS CASCADE; -CREATE TABLE D_ITEMS +CREATE UNLOGGED TABLE D_ITEMS ( ROW_ID INT NOT NULL, ITEMID INT NOT NULL, @@ -331,7 +331,7 @@ CREATE TABLE D_ITEMS -------------------------------------------------------- DROP TABLE IF EXISTS D_LABITEMS CASCADE; -CREATE TABLE D_LABITEMS +CREATE UNLOGGED TABLE D_LABITEMS ( ROW_ID INT NOT NULL, ITEMID INT NOT NULL, @@ -348,7 +348,7 @@ CREATE TABLE D_LABITEMS -------------------------------------------------------- DROP TABLE IF EXISTS ICUSTAYS CASCADE; -CREATE TABLE ICUSTAYS +CREATE UNLOGGED TABLE ICUSTAYS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -371,7 +371,7 @@ CREATE TABLE ICUSTAYS -------------------------------------------------------- DROP TABLE IF EXISTS INPUTEVENTS_CV CASCADE; -CREATE TABLE INPUTEVENTS_CV +CREATE UNLOGGED TABLE INPUTEVENTS_CV ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -403,7 +403,7 @@ CREATE TABLE INPUTEVENTS_CV -------------------------------------------------------- DROP TABLE IF EXISTS INPUTEVENTS_MV CASCADE; -CREATE TABLE INPUTEVENTS_MV +CREATE UNLOGGED TABLE INPUTEVENTS_MV ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -444,7 +444,7 @@ CREATE TABLE INPUTEVENTS_MV -------------------------------------------------------- DROP TABLE IF EXISTS LABEVENTS CASCADE; -CREATE TABLE LABEVENTS +CREATE UNLOGGED TABLE LABEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -463,7 +463,7 @@ CREATE TABLE LABEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS MICROBIOLOGYEVENTS CASCADE; -CREATE TABLE MICROBIOLOGYEVENTS +CREATE UNLOGGED TABLE MICROBIOLOGYEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -489,7 +489,7 @@ CREATE TABLE MICROBIOLOGYEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS NOTEEVENTS CASCADE; -CREATE TABLE NOTEEVENTS +CREATE UNLOGGED TABLE NOTEEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -510,7 +510,7 @@ CREATE TABLE NOTEEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS OUTPUTEVENTS CASCADE; -CREATE TABLE OUTPUTEVENTS +CREATE UNLOGGED TABLE OUTPUTEVENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -533,7 +533,7 @@ CREATE TABLE OUTPUTEVENTS -------------------------------------------------------- DROP TABLE IF EXISTS PATIENTS CASCADE; -CREATE TABLE PATIENTS +CREATE UNLOGGED TABLE PATIENTS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -552,7 +552,7 @@ CREATE TABLE PATIENTS -------------------------------------------------------- DROP TABLE IF EXISTS PRESCRIPTIONS CASCADE; -CREATE TABLE PRESCRIPTIONS +CREATE UNLOGGED TABLE PRESCRIPTIONS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -581,7 +581,7 @@ CREATE TABLE PRESCRIPTIONS -------------------------------------------------------- DROP TABLE IF EXISTS PROCEDUREEVENTS_MV CASCADE; -CREATE TABLE PROCEDUREEVENTS_MV +CREATE UNLOGGED TABLE PROCEDUREEVENTS_MV ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -616,7 +616,7 @@ CREATE TABLE PROCEDUREEVENTS_MV -------------------------------------------------------- DROP TABLE IF EXISTS PROCEDURES_ICD CASCADE; -CREATE TABLE PROCEDURES_ICD +CREATE UNLOGGED TABLE PROCEDURES_ICD ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -631,7 +631,7 @@ CREATE TABLE PROCEDURES_ICD -------------------------------------------------------- DROP TABLE IF EXISTS SERVICES CASCADE; -CREATE TABLE SERVICES +CREATE UNLOGGED TABLE SERVICES ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, @@ -647,7 +647,7 @@ CREATE TABLE SERVICES -------------------------------------------------------- DROP TABLE IF EXISTS TRANSFERS CASCADE; -CREATE TABLE TRANSFERS +CREATE UNLOGGED TABLE TRANSFERS ( ROW_ID INT NOT NULL, SUBJECT_ID INT NOT NULL, diff --git a/mimic/data-mimicdemo/.gitkeep b/mimic/data-mimicdemo/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mimic/data-mimiciii/.gitkeep b/mimic/data-mimiciii/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/omop/build-omop/postgresql/OMOP CDM indexes required - PostgreSQL.sql b/omop/build-omop/postgresql/OMOP CDM indexes required - PostgreSQL.sql index fb17a1a..3e6e9c4 100644 --- a/omop/build-omop/postgresql/OMOP CDM indexes required - PostgreSQL.sql +++ b/omop/build-omop/postgresql/OMOP CDM indexes required - PostgreSQL.sql @@ -42,6 +42,7 @@ description: These indices are considered a minimal requirement to ensure adequ Standardized vocabulary ************************/ +SET search_path TO omop; CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC); CLUSTER concept USING idx_concept_concept_id ; @@ -106,126 +107,126 @@ Standardized clinical data ************************/ -CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC); -CLUSTER person USING idx_person_id ; - -CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC); -CLUSTER observation_period USING idx_observation_period_id ; - -CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC); -CLUSTER specimen USING idx_specimen_person_id ; -CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); - -CREATE INDEX idx_death_person_id ON death (person_id ASC); -CLUSTER death USING idx_death_person_id ; - -CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); -CLUSTER visit_occurrence USING idx_visit_person_id ; -CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); - -CREATE INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC); -CLUSTER visit_detail USING idx_visit_detail_person_id ; -CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC); -CREATE INDEX idx_visit_detail_visit_occurrence_id ON visit_detail (visit_occurrence_id ASC); -CREATE INDEX idx_visit_detail_visit_detail_id ON visit_detail (visit_detail_parent_id ASC); - -CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); -CLUSTER procedure_occurrence USING idx_procedure_person_id ; -CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC); -CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC); -CREATE INDEX idx_procedure_visit_detail_id ON procedure_occurrence (visit_detail_id ASC); - -CREATE INDEX idx_drug_person_id ON drug_exposure (person_id ASC); -CLUSTER drug_exposure USING idx_drug_person_id ; -CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC); -CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC); -CREATE INDEX idx_drug_visit_detail_id ON drug_exposure (visit_detail_id ASC); - -CREATE INDEX idx_device_person_id ON device_exposure (person_id ASC); -CLUSTER device_exposure USING idx_device_person_id ; -CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC); -CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC); -CREATE INDEX idx_device_visit_detail_id ON device_exposure (visit_detail_id ASC); - -CREATE INDEX idx_condition_person_id ON condition_occurrence (person_id ASC); -CLUSTER condition_occurrence USING idx_condition_person_id ; -CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC); -CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC); -CREATE INDEX idx_condition_visit_detail_id ON condition_occurrence (visit_detail_id ASC); - -CREATE INDEX idx_measurement_person_id ON measurement (person_id ASC); -CLUSTER measurement USING idx_measurement_person_id ; -CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC); -CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC); -CREATE INDEX idx_measurement_visit_detail_id ON measurement (visit_detail_id ASC); - -CREATE INDEX idx_note_person_id ON note (person_id ASC); -CLUSTER note USING idx_note_person_id ; -CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC); -CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC); -CREATE INDEX idx_note_visit_detail_id ON note (visit_detail_id ASC); - -CREATE INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC); -CLUSTER note_nlp USING idx_note_nlp_note_id ; -CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC); - -CREATE INDEX idx_observation_person_id ON observation (person_id ASC); -CLUSTER observation USING idx_observation_person_id ; -CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC); -CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC); -CREATE INDEX idx_observation_visit_detail_id ON observation (visit_detail_id ASC); - -CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC); -CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC); -CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC); - - - -/************************ - -Standardized health system data - -************************/ - - - - - -/************************ - -Standardized health economics - -************************/ - -CREATE INDEX idx_period_person_id ON payer_plan_period (person_id ASC); -CLUSTER payer_plan_period USING idx_period_person_id ; - - - - - -/************************ - -Standardized derived elements - -************************/ - - -CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); -CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); - -CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC); -CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC); - -CREATE INDEX idx_drug_era_person_id ON drug_era (person_id ASC); -CLUSTER drug_era USING idx_drug_era_person_id ; -CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC); - -CREATE INDEX idx_dose_era_person_id ON dose_era (person_id ASC); -CLUSTER dose_era USING idx_dose_era_person_id ; -CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC); - -CREATE INDEX idx_condition_era_person_id ON condition_era (person_id ASC); -CLUSTER condition_era USING idx_condition_era_person_id ; -CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC); +-- CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC); +-- CLUSTER person USING idx_person_id ; +-- +-- CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC); +-- CLUSTER observation_period USING idx_observation_period_id ; +-- +-- CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC); +-- CLUSTER specimen USING idx_specimen_person_id ; +-- CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); +-- +-- CREATE INDEX idx_death_person_id ON death (person_id ASC); +-- CLUSTER death USING idx_death_person_id ; +-- +-- CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); +-- CLUSTER visit_occurrence USING idx_visit_person_id ; +-- CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); +-- +-- CREATE INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC); +-- CLUSTER visit_detail USING idx_visit_detail_person_id ; +-- CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC); +-- CREATE INDEX idx_visit_detail_visit_occurrence_id ON visit_detail (visit_occurrence_id ASC); +-- CREATE INDEX idx_visit_detail_visit_detail_id ON visit_detail (visit_detail_parent_id ASC); +-- +-- CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); +-- CLUSTER procedure_occurrence USING idx_procedure_person_id ; +-- CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC); +-- CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC); +-- CREATE INDEX idx_procedure_visit_detail_id ON procedure_occurrence (visit_detail_id ASC); +-- +-- CREATE INDEX idx_drug_person_id ON drug_exposure (person_id ASC); +-- CLUSTER drug_exposure USING idx_drug_person_id ; +-- CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC); +-- CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC); +-- CREATE INDEX idx_drug_visit_detail_id ON drug_exposure (visit_detail_id ASC); +-- +-- CREATE INDEX idx_device_person_id ON device_exposure (person_id ASC); +-- CLUSTER device_exposure USING idx_device_person_id ; +-- CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC); +-- CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC); +-- CREATE INDEX idx_device_visit_detail_id ON device_exposure (visit_detail_id ASC); +-- +-- CREATE INDEX idx_condition_person_id ON condition_occurrence (person_id ASC); +-- CLUSTER condition_occurrence USING idx_condition_person_id ; +-- CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC); +-- CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC); +-- CREATE INDEX idx_condition_visit_detail_id ON condition_occurrence (visit_detail_id ASC); +-- +-- CREATE INDEX idx_measurement_person_id ON measurement (person_id ASC); +-- CLUSTER measurement USING idx_measurement_person_id ; +-- CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC); +-- CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC); +-- CREATE INDEX idx_measurement_visit_detail_id ON measurement (visit_detail_id ASC); +-- +-- CREATE INDEX idx_note_person_id ON note (person_id ASC); +-- CLUSTER note USING idx_note_person_id ; +-- CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC); +-- CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC); +-- CREATE INDEX idx_note_visit_detail_id ON note (visit_detail_id ASC); +-- +-- CREATE INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC); +-- CLUSTER note_nlp USING idx_note_nlp_note_id ; +-- CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC); +-- +-- CREATE INDEX idx_observation_person_id ON observation (person_id ASC); +-- CLUSTER observation USING idx_observation_person_id ; +-- CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC); +-- CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC); +-- CREATE INDEX idx_observation_visit_detail_id ON observation (visit_detail_id ASC); +-- +-- CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC); +-- CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC); +-- CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC); +-- +-- +-- +-- /************************ +-- +-- Standardized health system data +-- +-- ************************/ +-- +-- +-- +-- +-- +-- /************************ +-- +-- Standardized health economics +-- +-- ************************/ +-- +-- CREATE INDEX idx_period_person_id ON payer_plan_period (person_id ASC); +-- CLUSTER payer_plan_period USING idx_period_person_id ; +-- +-- +-- +-- +-- +-- /************************ +-- +-- Standardized derived elements +-- +-- ************************/ +-- +-- +-- CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); +-- CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); +-- +-- CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC); +-- CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC); +-- +-- CREATE INDEX idx_drug_era_person_id ON drug_era (person_id ASC); +-- CLUSTER drug_era USING idx_drug_era_person_id ; +-- CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC); +-- +-- CREATE INDEX idx_dose_era_person_id ON dose_era (person_id ASC); +-- CLUSTER dose_era USING idx_dose_era_person_id ; +-- CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC); +-- +-- CREATE INDEX idx_condition_era_person_id ON condition_era (person_id ASC); +-- CLUSTER condition_era USING idx_condition_era_person_id ; +-- CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC); diff --git a/omop/build-omop/postgresql/OMOP CDM postgresql ddl.txt b/omop/build-omop/postgresql/OMOP CDM postgresql ddl.txt new file mode 100644 index 0000000..f8a0dcf --- /dev/null +++ b/omop/build-omop/postgresql/OMOP CDM postgresql ddl.txt @@ -0,0 +1,733 @@ +/********************************************************************************* +# Copyright 2017-11 Observational Health Data Sciences and Informatics +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ####### ##### + # # ## ## # # # # # # # # ## ## # # # # # + # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### + # # # # # # # # # # # # # # # ### # + # # # # # # # # # # # # # # # # # ### # # + ####### # # ####### # ##### ###### # # ## ##### ### ##### + + +postgresql script to create OMOP common data model version 5.3 + +last revised: 6-Nov-2017 + +Authors: Patrick Ryan, Christian Reich, Clair Blacketer + + +*************************/ + + +/************************ + +Standardized vocabulary + +************************/ + +DROP SCHEMA omop CASCADE; +CREATE SCHEMA omop; +SET search_path TO omop; + +CREATE UNLOGGED TABLE concept ( + concept_id INTEGER NOT NULL , + concept_name VARCHAR(255) NOT NULL , + domain_id VARCHAR(20) NOT NULL , + vocabulary_id VARCHAR(20) NOT NULL , + concept_class_id VARCHAR(20) NOT NULL , + standard_concept VARCHAR(1) NULL , + concept_code VARCHAR(50) NOT NULL , + valid_start_date DATE NOT NULL , + valid_end_date DATE NOT NULL , + invalid_reason VARCHAR(1) NULL +) +; + + +CREATE UNLOGGED TABLE vocabulary ( + vocabulary_id VARCHAR(20) NOT NULL, + vocabulary_name VARCHAR(255) NOT NULL, + vocabulary_reference VARCHAR(255) NOT NULL, + vocabulary_version VARCHAR(255) NULL, + vocabulary_concept_id INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE domain ( + domain_id VARCHAR(20) NOT NULL, + domain_name VARCHAR(255) NOT NULL, + domain_concept_id INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE concept_class ( + concept_class_id VARCHAR(20) NOT NULL, + concept_class_name VARCHAR(255) NOT NULL, + concept_class_concept_id INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE concept_relationship ( + concept_id_1 INTEGER NOT NULL, + concept_id_2 INTEGER NOT NULL, + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL + ) +; + + +CREATE UNLOGGED TABLE relationship ( + relationship_id VARCHAR(20) NOT NULL, + relationship_name VARCHAR(255) NOT NULL, + is_hierarchical VARCHAR(1) NOT NULL, + defines_ancestry VARCHAR(1) NOT NULL, + reverse_relationship_id VARCHAR(20) NOT NULL, + relationship_concept_id INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE concept_synonym ( + concept_id INTEGER NOT NULL, + concept_synonym_name VARCHAR(1000) NOT NULL, + language_concept_id INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE concept_ancestor ( + ancestor_concept_id INTEGER NOT NULL, + descendant_concept_id INTEGER NOT NULL, + min_levels_of_separation INTEGER NOT NULL, + max_levels_of_separation INTEGER NOT NULL +) +; + + +CREATE UNLOGGED TABLE source_to_concept_map ( + source_code VARCHAR(50) NOT NULL, + source_concept_id INTEGER NOT NULL, + source_vocabulary_id VARCHAR(20) NOT NULL, + source_code_description VARCHAR(255) NULL, + target_concept_id INTEGER NOT NULL, + target_vocabulary_id VARCHAR(20) NOT NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL +) +; + + + + +CREATE UNLOGGED TABLE drug_strength ( + drug_concept_id INTEGER NOT NULL, + ingredient_concept_id INTEGER NOT NULL, + amount_value NUMERIC NULL, + amount_unit_concept_id INTEGER NULL, + numerator_value NUMERIC NULL, + numerator_unit_concept_id INTEGER NULL, + denominator_value NUMERIC NULL, + denominator_unit_concept_id INTEGER NULL, + box_size INTEGER NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL +) +; + + + +CREATE UNLOGGED TABLE cohort_definition ( + cohort_definition_id INTEGER NOT NULL, + cohort_definition_name VARCHAR(255) NOT NULL, + cohort_definition_description TEXT NULL, + definition_type_concept_id INTEGER NOT NULL, + cohort_definition_syntax TEXT NULL, + subject_concept_id INTEGER NOT NULL, + cohort_initiation_date DATE NULL +) +; + + +CREATE UNLOGGED TABLE attribute_definition ( + attribute_definition_id INTEGER NOT NULL, + attribute_name VARCHAR(255) NOT NULL, + attribute_description TEXT NULL, + attribute_type_concept_id INTEGER NOT NULL, + attribute_syntax TEXT NULL +) +; + + +/************************** + +Standardized meta-data + +***************************/ + + +CREATE UNLOGGED TABLE cdm_source +( + cdm_source_name VARCHAR(255) NOT NULL , + cdm_source_abbreviation VARCHAR(25) NULL , + cdm_holder VARCHAR(255) NULL , + source_description TEXT NULL , + source_documentation_reference VARCHAR(255) NULL , + cdm_etl_reference VARCHAR(255) NULL , + source_release_date DATE NULL , + cdm_release_date DATE NULL , + cdm_version VARCHAR(10) NULL , + vocabulary_version VARCHAR(20) NULL +) +; + + +CREATE UNLOGGED TABLE metadata +( + metadata_concept_id INTEGER NOT NULL , + metadata_type_concept_id INTEGER NOT NULL , + name VARCHAR(250) NOT NULL , + value_as_string TEXT NULL , + value_as_concept_id INTEGER NULL , + metadata_date DATE NULL , + metadata_datetime TIMESTAMP NULL +) +; + + +/************************ + +Standardized clinical data + +************************/ + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE person +( + person_id INTEGER NOT NULL , + gender_concept_id INTEGER NOT NULL , + year_of_birth INTEGER NOT NULL , + month_of_birth INTEGER NULL, + day_of_birth INTEGER NULL, + birth_datetime TIMESTAMP NULL, + race_concept_id INTEGER NOT NULL, + ethnicity_concept_id INTEGER NOT NULL, + location_id INTEGER NULL, + provider_id INTEGER NULL, + care_site_id INTEGER NULL, + person_source_value VARCHAR(50) NULL, + gender_source_value VARCHAR(50) NULL, + gender_source_concept_id INTEGER NULL, + race_source_value VARCHAR(50) NULL, + race_source_concept_id INTEGER NULL, + ethnicity_source_value VARCHAR(50) NULL, + ethnicity_source_concept_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE observation_period +( + observation_period_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + observation_period_start_date DATE NOT NULL , + observation_period_end_date DATE NOT NULL , + period_type_concept_id INTEGER NOT NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE specimen +( + specimen_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + specimen_concept_id INTEGER NOT NULL , + specimen_type_concept_id INTEGER NOT NULL , + specimen_date DATE NOT NULL , + specimen_datetime TIMESTAMP NULL , + quantity NUMERIC NULL , + unit_concept_id INTEGER NULL , + anatomic_site_concept_id INTEGER NULL , + disease_status_concept_id INTEGER NULL , + specimen_source_id VARCHAR(50) NULL , + specimen_source_value VARCHAR(50) NULL , + unit_source_value VARCHAR(50) NULL , + anatomic_site_source_value VARCHAR(50) NULL , + disease_status_source_value VARCHAR(50) NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE death +( + person_id INTEGER NOT NULL , + death_date DATE NOT NULL , + death_datetime TIMESTAMP NULL , + death_type_concept_id INTEGER NOT NULL , + cause_concept_id INTEGER NULL , + cause_source_value VARCHAR(50) NULL, + cause_source_concept_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE visit_occurrence +( + visit_occurrence_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + visit_concept_id INTEGER NOT NULL , + visit_start_date DATE NOT NULL , + visit_start_datetime TIMESTAMP NULL , + visit_end_date DATE NOT NULL , + visit_end_datetime TIMESTAMP NULL , + visit_type_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL, + care_site_id INTEGER NULL, + visit_source_value VARCHAR(50) NULL, + visit_source_concept_id INTEGER NULL , + admitting_source_concept_id INTEGER NULL , + admitting_source_value VARCHAR(50) NULL , + discharge_to_concept_id INTEGER NULL , + discharge_to_source_value VARCHAR(50) NULL , + preceding_visit_occurrence_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE visit_detail +( + visit_detail_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + visit_detail_concept_id INTEGER NOT NULL , + visit_start_date DATE NOT NULL , + visit_start_datetime TIMESTAMP NULL , + visit_end_date DATE NOT NULL , + visit_end_datetime TIMESTAMP NULL , + visit_type_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL , + care_site_id INTEGER NULL , + admitting_source_concept_id INTEGER NULL , + discharge_to_concept_id INTEGER NULL , + preceding_visit_detail_id INTEGER NULL , + visit_source_value VARCHAR(50) NULL , + visit_source_concept_id INTEGER NULL , + admitting_source_value VARCHAR(50) NULL , + discharge_to_source_value VARCHAR(50) NULL , + visit_detail_parent_id INTEGER NULL , + visit_occurrence_id INTEGER NOT NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE procedure_occurrence +( + procedure_occurrence_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + procedure_concept_id INTEGER NOT NULL , + procedure_date DATE NOT NULL , + procedure_datetime TIMESTAMP NULL , + procedure_type_concept_id INTEGER NOT NULL , + modifier_concept_id INTEGER NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + procedure_source_value VARCHAR(50) NULL , + procedure_source_concept_id INTEGER NULL , + modifier_source_value VARCHAR(50) NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE drug_exposure +( + drug_exposure_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + drug_concept_id INTEGER NOT NULL , + drug_exposure_start_date DATE NOT NULL , + drug_exposure_start_datetime TIMESTAMP NULL , + drug_exposure_end_date DATE NOT NULL , + drug_exposure_end_datetime TIMESTAMP NULL , + verbatim_end_date DATE NULL , + drug_type_concept_id INTEGER NOT NULL , + stop_reason VARCHAR(20) NULL , + refills INTEGER NULL , + quantity NUMERIC NULL , + days_supply INTEGER NULL , + sig TEXT NULL , + route_concept_id INTEGER NULL , + lot_number VARCHAR(50) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + drug_source_value VARCHAR(50) NULL , + drug_source_concept_id INTEGER NULL , + route_source_value VARCHAR(50) NULL , + dose_unit_source_value VARCHAR(50) NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE device_exposure +( + device_exposure_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + device_concept_id INTEGER NOT NULL , + device_exposure_start_date DATE NOT NULL , + device_exposure_start_datetime TIMESTAMP NULL , + device_exposure_end_date DATE NULL , + device_exposure_end_datetime TIMESTAMP NULL , + device_type_concept_id INTEGER NOT NULL , + unique_device_id VARCHAR(50) NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + device_source_value VARCHAR(100) NULL , + device_source_concept_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE condition_occurrence +( + condition_occurrence_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + condition_concept_id INTEGER NOT NULL , + condition_start_date DATE NOT NULL , + condition_start_datetime TIMESTAMP NULL , + condition_end_date DATE NULL , + condition_end_datetime TIMESTAMP NULL , + condition_type_concept_id INTEGER NOT NULL , + stop_reason VARCHAR(20) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + condition_source_value VARCHAR(50) NULL , + condition_source_concept_id INTEGER NULL , + condition_status_source_value VARCHAR(50) NULL , + condition_status_concept_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE measurement +( + measurement_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + measurement_concept_id INTEGER NOT NULL , + measurement_date DATE NOT NULL , + measurement_datetime TIMESTAMP NULL , + measurement_time VARCHAR(10) NULL , + measurement_type_concept_id INTEGER NOT NULL , + operator_concept_id INTEGER NULL , + value_as_number NUMERIC NULL , + value_as_concept_id INTEGER NULL , + unit_concept_id INTEGER NULL , + range_low NUMERIC NULL , + range_high NUMERIC NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + measurement_source_value VARCHAR(50) NULL , + measurement_source_concept_id INTEGER NULL , + unit_source_value VARCHAR(50) NULL , + value_source_value VARCHAR(50) NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE note +( + note_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + note_date DATE NOT NULL , + note_datetime TIMESTAMP NULL , + note_type_concept_id INTEGER NOT NULL , + note_class_concept_id INTEGER NOT NULL , + note_title VARCHAR(250) NULL , + note_text TEXT NULL , + encoding_concept_id INTEGER NOT NULL , + language_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + note_source_value VARCHAR(50) NULL +) +; + + + +CREATE UNLOGGED TABLE note_nlp +( + note_nlp_id INTEGER NOT NULL , + note_id INTEGER NOT NULL , + section_concept_id INTEGER NULL , + snippet VARCHAR(250) NULL , + "offset" VARCHAR(250) NULL , + lexical_variant VARCHAR(250) NOT NULL , + note_nlp_concept_id INTEGER NULL , + note_nlp_source_concept_id INTEGER NULL , + nlp_system VARCHAR(250) NULL , + nlp_date DATE NOT NULL , + nlp_datetime TIMESTAMP NULL , + term_exists VARCHAR(1) NULL , + term_temporal VARCHAR(50) NULL , + term_modifiers VARCHAR(2000) NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE observation +( + observation_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + observation_concept_id INTEGER NOT NULL , + observation_date DATE NOT NULL , + observation_datetime TIMESTAMP NULL , + observation_type_concept_id INTEGER NOT NULL , + value_as_number NUMERIC NULL , + value_as_string VARCHAR(60) NULL , + value_as_concept_id INTEGER NULL , + qualifier_concept_id INTEGER NULL , + unit_concept_id INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + observation_source_value VARCHAR(50) NULL , + observation_source_concept_id INTEGER NULL , + unit_source_value VARCHAR(50) NULL , + qualifier_source_value VARCHAR(50) NULL +) +; + + +CREATE UNLOGGED TABLE fact_relationship +( + domain_concept_id_1 INTEGER NOT NULL , + fact_id_1 INTEGER NOT NULL , + domain_concept_id_2 INTEGER NOT NULL , + fact_id_2 INTEGER NOT NULL , + relationship_concept_id INTEGER NOT NULL +) +; + + + +/************************ + +Standardized health system data + +************************/ + + +CREATE UNLOGGED TABLE location +( + location_id INTEGER NOT NULL , + address_1 VARCHAR(50) NULL , + address_2 VARCHAR(50) NULL , + city VARCHAR(50) NULL , + state VARCHAR(2) NULL , + zip VARCHAR(9) NULL , + county VARCHAR(20) NULL , + location_source_value VARCHAR(50) NULL +) +; + + +CREATE UNLOGGED TABLE care_site +( + care_site_id INTEGER NOT NULL , + care_site_name VARCHAR(255) NULL , + place_of_service_concept_id INTEGER NULL , + location_id INTEGER NULL , + care_site_source_value VARCHAR(50) NULL , + place_of_service_source_value VARCHAR(50) NULL +) +; + + +CREATE UNLOGGED TABLE provider +( + provider_id INTEGER NOT NULL , + provider_name VARCHAR(255) NULL , + NPI VARCHAR(20) NULL , + DEA VARCHAR(20) NULL , + specialty_concept_id INTEGER NULL , + care_site_id INTEGER NULL , + year_of_birth INTEGER NULL , + gender_concept_id INTEGER NULL , + provider_source_value VARCHAR(50) NULL , + specialty_source_value VARCHAR(50) NULL , + specialty_source_concept_id INTEGER NULL , + gender_source_value VARCHAR(50) NULL , + gender_source_concept_id INTEGER NULL +) +; + + +/************************ + +Standardized health economics + +************************/ + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE payer_plan_period +( + payer_plan_period_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + payer_plan_period_start_date DATE NOT NULL , + payer_plan_period_end_date DATE NOT NULL , + payer_concept_id INTEGER NULL , + payer_source_value VARCHAR(50) NULL , + payer_source_concept_id INTEGER NULL , + plan_concept_id INTEGER NULL , + plan_source_value VARCHAR(50) NULL , + plan_source_concept_id INTEGER NULL , + sponsor_concept_id INTEGER NULL , + sponsor_source_value VARCHAR(50) NULL , + sponsor_source_concept_id INTEGER NULL , + family_source_value VARCHAR(50) NULL , + stop_reason_concept_id INTEGER NULL , + stop_reason_source_value VARCHAR(50) NULL , + stop_reason_source_concept_id INTEGER NULL +) +; + + +CREATE UNLOGGED TABLE cost +( + cost_id INTEGER NOT NULL , + cost_event_id INTEGER NOT NULL , + cost_domain_id VARCHAR(20) NOT NULL , + cost_type_concept_id INTEGER NOT NULL , + currency_concept_id INTEGER NULL , + total_charge NUMERIC NULL , + total_cost NUMERIC NULL , + total_paid NUMERIC NULL , + paid_by_payer NUMERIC NULL , + paid_by_patient NUMERIC NULL , + paid_patient_copay NUMERIC NULL , + paid_patient_coinsurance NUMERIC NULL , + paid_patient_deductible NUMERIC NULL , + paid_by_primary NUMERIC NULL , + paid_ingredient_cost NUMERIC NULL , + paid_dispensing_fee NUMERIC NULL , + payer_plan_period_id INTEGER NULL , + amount_allowed NUMERIC NULL , + revenue_code_concept_id INTEGER NULL , + revenue_code_source_value VARCHAR(50) NULL, + drg_concept_id INTEGER NULL, + drg_source_value VARCHAR(3) NULL +) +; + + +/************************ + +Standardized derived elements + +************************/ + + +--HINT DISTRIBUTE_ON_KEY(subject_id) +CREATE UNLOGGED TABLE cohort +( + cohort_definition_id INTEGER NOT NULL , + subject_id INTEGER NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(subject_id) +CREATE UNLOGGED TABLE cohort_attribute +( + cohort_definition_id INTEGER NOT NULL , + subject_id INTEGER NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL , + attribute_definition_id INTEGER NOT NULL , + value_as_number NUMERIC NULL , + value_as_concept_id INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE drug_era +( + drug_era_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + drug_concept_id INTEGER NOT NULL , + drug_era_start_date DATE NOT NULL , + drug_era_end_date DATE NOT NULL , + drug_exposure_count INTEGER NULL , + gap_days INTEGER NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE dose_era +( + dose_era_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + drug_concept_id INTEGER NOT NULL , + unit_concept_id INTEGER NOT NULL , + dose_value NUMERIC NOT NULL , + dose_era_start_date DATE NOT NULL , + dose_era_end_date DATE NOT NULL +) +; + + +--HINT DISTRIBUTE_ON_KEY(person_id) +CREATE UNLOGGED TABLE condition_era +( + condition_era_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , + condition_concept_id INTEGER NOT NULL , + condition_era_start_date DATE NOT NULL , + condition_era_end_date DATE NOT NULL , + condition_occurrence_count INTEGER NULL +) +; diff --git a/omop/build-omop/postgresql/analyze.sql b/omop/build-omop/postgresql/analyze.sql new file mode 100644 index 0000000..8329be8 --- /dev/null +++ b/omop/build-omop/postgresql/analyze.sql @@ -0,0 +1,57 @@ +/********************************************************************************* +# Copyright 2014 Observational Health Data Sciences and Informatics +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, + +# See the License for the specific language governing permissions and +# limitations under the License. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### #### + + +script to create the required indexes within OMOP common data model, version 5.2 for PostgreSQL database + +last revised: 14 July 2017 + +author: Patrick Ryan + +description: These indices are considered a minimal requirement to ensure adequate performance of analyses. + +*************************/ + + +/************************ + +Standardized vocabulary + +************************/ + +analyze :OMOP_SCHEMA.concept; +analyze :OMOP_SCHEMA.vocabulary; +analyze :OMOP_SCHEMA.domain; +analyze :OMOP_SCHEMA.concept_class; +analyze :OMOP_SCHEMA.concept_relationship; +analyze :OMOP_SCHEMA.relationship; +analyze :OMOP_SCHEMA.concept_synonym; +analyze :OMOP_SCHEMA.concept_ancestor; +analyze :OMOP_SCHEMA.source_to_concept_map; +analyze :OMOP_SCHEMA.drug_strength; +analyze :OMOP_SCHEMA.cohort_definition; +analyze :OMOP_SCHEMA.attribute_definition; \ No newline at end of file