diff --git a/Impala/DataImport/OMOP_CDM_synpuf_load_Impala.sql b/Impala/DataImport/OMOP_CDM_synpuf_load_Impala.sql deleted file mode 100644 index 59c6fa4..0000000 --- a/Impala/DataImport/OMOP_CDM_synpuf_load_Impala.sql +++ /dev/null @@ -1,15 +0,0 @@ -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_CARE_SITE.csv' OVERWRITE INTO TABLE care_site; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_CONDITION_OCCURRENCE.csv' OVERWRITE INTO TABLE condition_occurrence; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_DEATH.csv' OVERWRITE INTO TABLE death; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_DRUG_EXPOSURE.csv' OVERWRITE INTO TABLE drug_exposure; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_DEVICE_EXPOSURE.csv' OVERWRITE INTO TABLE device_exposure; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_LOCATION.csv' OVERWRITE INTO TABLE `location`; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_MEASUREMENT.csv' OVERWRITE INTO TABLE measurement; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_OBSERVATION.csv' OVERWRITE INTO TABLE observation; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_OBSERVATION_PERIOD.csv' OVERWRITE INTO TABLE observation_period; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_PERSON.csv' OVERWRITE INTO TABLE person; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_PROCEDURE_OCCURRENCE.csv' OVERWRITE INTO TABLE procedure_occurrence; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_PROVIDER.csv' OVERWRITE INTO TABLE provider; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_VISIT_OCCURRENCE.csv' OVERWRITE INTO TABLE visit_occurrence; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_DRUG_ERA.csv' OVERWRITE INTO TABLE drug_era; -LOAD DATA INPATH '${VAR:OMOP_SYNPUF_PATH}/CDM_CONDITION_ERA.csv' OVERWRITE INTO TABLE condition_era; diff --git a/Impala/OMOP_CDM_ddl_Impala.sql b/Impala/OMOP_CDM_ddl_Impala.sql deleted file mode 100644 index ab1bdf5..0000000 --- a/Impala/OMOP_CDM_ddl_Impala.sql +++ /dev/null @@ -1,763 +0,0 @@ -/********************************************************************************* -# Copyright 2014-6 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -script to create OMOP common data model, version 5.0 for Hadoop (Hive/Impala) database - -Based on the PostgreSQL version, with the following changes: -* NULL/NOT NULL is not used. -* Dates are stored as VARCHAR(8). See http://stackoverflow.com/questions/33024309/convert-yyyymmdd-string-to-date-in-impala for how to treat date columns as dates. -* PostgreSQL NUMERIC is stored as DOUBLE for amounts, and DECIMAL(19,4) for prices. -* PostgreSQL TEXT is stored as STRING. - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -CREATE TABLE concept ( - concept_id INTEGER, - concept_name VARCHAR(255), - domain_id VARCHAR(20), - vocabulary_id VARCHAR(20), - concept_class_id VARCHAR(20), - standard_concept VARCHAR(1), - concept_code VARCHAR(50), - valid_start_date VARCHAR(8), -- DATE - valid_end_date VARCHAR(8), -- DATE - invalid_reason VARCHAR(1) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - -CREATE TABLE vocabulary ( - vocabulary_id VARCHAR(20), - vocabulary_name VARCHAR(255), - vocabulary_reference VARCHAR(255), - vocabulary_version VARCHAR(255), - vocabulary_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - -CREATE TABLE domain ( - domain_id VARCHAR(20), - domain_name VARCHAR(255), - domain_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE concept_class ( - concept_class_id VARCHAR(20), - concept_class_name VARCHAR(255), - concept_class_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - -CREATE TABLE concept_relationship ( - concept_id_1 INTEGER, - concept_id_2 INTEGER, - relationship_id VARCHAR(20), - valid_start_date VARCHAR(8), -- DATE - valid_end_date VARCHAR(8), -- DATE - invalid_reason VARCHAR(1) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE relationship ( - relationship_id VARCHAR(20), - relationship_name VARCHAR(255), - is_hierarchical VARCHAR(1), - defines_ancestry VARCHAR(1), - reverse_relationship_id VARCHAR(20), - relationship_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - -CREATE TABLE concept_synonym ( - concept_id INTEGER, - concept_synonym_name VARCHAR(1000), - language_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - -CREATE TABLE concept_ancestor ( - ancestor_concept_id INTEGER, - descendant_concept_id INTEGER, - min_levels_of_separation INTEGER, - max_levels_of_separation INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE source_to_concept_map ( - source_code VARCHAR(50), - source_concept_id INTEGER, - source_vocabulary_id VARCHAR(20), - source_code_description VARCHAR(255), - target_concept_id INTEGER, - target_vocabulary_id VARCHAR(20), - valid_start_date VARCHAR(8), -- DATE - valid_end_date VARCHAR(8), -- DATE - invalid_reason VARCHAR(1) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - -CREATE TABLE drug_strength ( - drug_concept_id INTEGER, - ingredient_concept_id INTEGER, - amount_value DOUBLE, -- NUMERIC - amount_unit_concept_id INTEGER, - numerator_value DOUBLE, -- NUMERIC - numerator_unit_concept_id INTEGER, - denominator_value DOUBLE, -- NUMERIC - denominator_unit_concept_id INTEGER, - box_size INTEGER, - valid_start_date VARCHAR(8), -- DATE - valid_end_date VARCHAR(8), -- DATE - invalid_reason VARCHAR(1) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE cohort_definition ( - cohort_definition_id INTEGER, - cohort_definition_name VARCHAR(255), - cohort_definition_description STRING, -- TEXT - definition_type_concept_id INTEGER, - cohort_definition_syntax STRING, -- TEXT - subject_concept_id INTEGER, - cohort_initiation_date VARCHAR(8) -- DATE -) -; - - -CREATE TABLE attribute_definition ( - attribute_definition_id INTEGER, - attribute_name VARCHAR(255), - attribute_description STRING, -- TEXT - attribute_type_concept_id INTEGER, - attribute_syntax STRING -- TEXT -) -; - -/************************** - -Standardized meta-data - -***************************/ - - -CREATE TABLE cdm_source - ( - cdm_source_name VARCHAR(255), - cdm_source_abbreviation VARCHAR(25), - cdm_holder VARCHAR(255), - source_description STRING, -- TEXT - source_documentation_reference VARCHAR(255), - cdm_etl_reference VARCHAR(255), - source_release_date VARCHAR(8), -- DATE - cdm_release_date VARCHAR(8), -- DATE - cdm_version VARCHAR(10), - vocabulary_version VARCHAR(20) - ) -; - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -CREATE TABLE person ( - person_id INTEGER, - gender_concept_id INTEGER, - year_of_birth INTEGER, - month_of_birth INTEGER, - day_of_birth INTEGER, - time_of_birth VARCHAR(10), - race_concept_id INTEGER, - ethnicity_concept_id INTEGER, - location_id INTEGER, - provider_id INTEGER, - care_site_id INTEGER, - person_source_value VARCHAR(50), - gender_source_value VARCHAR(50), - gender_source_concept_id INTEGER, - race_source_value VARCHAR(50), - race_source_concept_id INTEGER, - ethnicity_source_value VARCHAR(50), - ethnicity_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - - -CREATE TABLE observation_period ( - observation_period_id INTEGER, - person_id INTEGER, - observation_period_start_date VARCHAR(8), -- DATE - observation_period_end_date VARCHAR(8), -- DATE - period_type_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE specimen ( - specimen_id INTEGER, - person_id INTEGER, - specimen_concept_id INTEGER, - specimen_type_concept_id INTEGER, - specimen_date VARCHAR(8), -- DATE - specimen_time VARCHAR(10), - quantity DOUBLE, -- NUMERIC - unit_concept_id INTEGER, - anatomic_site_concept_id INTEGER, - disease_status_concept_id INTEGER, - specimen_source_id VARCHAR(50), - specimen_source_value VARCHAR(50), - unit_source_value VARCHAR(50), - anatomic_site_source_value VARCHAR(50), - disease_status_source_value VARCHAR(50) -) -; - - - -CREATE TABLE death ( - person_id INTEGER, - death_date VARCHAR(8), -- DATE - death_type_concept_id INTEGER, - cause_concept_id INTEGER, - cause_source_value VARCHAR(50), - cause_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE visit_occurrence ( - visit_occurrence_id INTEGER, - person_id INTEGER, - visit_concept_id INTEGER, - visit_start_date VARCHAR(8), -- DATE - visit_start_time VARCHAR(10), - visit_end_date VARCHAR(8), -- DATE - visit_end_time VARCHAR(10), - visit_type_concept_id INTEGER, - provider_id INTEGER, - care_site_id INTEGER, - visit_source_value VARCHAR(50), - visit_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE procedure_occurrence ( - procedure_occurrence_id INTEGER, - person_id INTEGER, - procedure_concept_id INTEGER, - procedure_date VARCHAR(8), -- DATE - procedure_type_concept_id INTEGER, - modifier_concept_id INTEGER, - quantity INTEGER, - provider_id INTEGER, - visit_occurrence_id INTEGER, - procedure_source_value VARCHAR(50), - procedure_source_concept_id INTEGER, - qualifier_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE drug_exposure ( - drug_exposure_id INTEGER, - person_id INTEGER, - drug_concept_id INTEGER, - drug_exposure_start_date VARCHAR(8), -- DATE - drug_exposure_end_date VARCHAR(8), -- DATE - drug_type_concept_id INTEGER, - stop_reason VARCHAR(20), - refills INTEGER, - quantity DOUBLE, -- NUMERIC - days_supply INTEGER, - sig STRING, -- TEXT - route_concept_id INTEGER, - effective_drug_dose DOUBLE, -- NUMERIC - dose_unit_concept_id INTEGER, - lot_number VARCHAR(50), - provider_id INTEGER, - visit_occurrence_id INTEGER, - drug_source_value VARCHAR(50), - drug_source_concept_id INTEGER, - route_source_value VARCHAR(50), - dose_unit_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - -CREATE TABLE device_exposure ( - device_exposure_id INTEGER, - person_id INTEGER, - device_concept_id INTEGER, - device_exposure_start_date VARCHAR(8), -- DATE - device_exposure_end_date VARCHAR(8), -- DATE - device_type_concept_id INTEGER, - unique_device_id VARCHAR(50), - quantity INTEGER, - provider_id INTEGER, - visit_occurrence_id INTEGER, - device_source_value VARCHAR(100), - device_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - -CREATE TABLE condition_occurrence ( - condition_occurrence_id INTEGER, - person_id INTEGER, - condition_concept_id INTEGER, - condition_start_date VARCHAR(8), -- DATE - condition_end_date VARCHAR(8), -- DATE - condition_type_concept_id INTEGER, - stop_reason VARCHAR(20), - provider_id INTEGER, - visit_occurrence_id INTEGER, - condition_source_value VARCHAR(50), - condition_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE measurement ( - measurement_id INTEGER, - person_id INTEGER, - measurement_concept_id INTEGER, - measurement_date VARCHAR(8), -- DATE - measurement_time VARCHAR(10), - measurement_type_concept_id INTEGER, - operator_concept_id INTEGER, - value_as_number DOUBLE, -- NUMERIC - value_as_concept_id INTEGER, - unit_concept_id INTEGER, - range_low DOUBLE, -- NUMERIC - range_high DOUBLE, -- NUMERIC - provider_id INTEGER, - visit_occurrence_id INTEGER, - measurement_source_value VARCHAR(50), - measurement_source_concept_id INTEGER, - unit_source_value VARCHAR(50), - value_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE note ( - note_id INTEGER, - person_id INTEGER, - note_date VARCHAR(8), -- DATE - note_time VARCHAR(10), - note_type_concept_id INTEGER, - note_text STRING, -- TEXT - provider_id INTEGER, - visit_occurrence_id INTEGER, - note_source_value VARCHAR(50) -) -; - - - -CREATE TABLE observation ( - observation_id INTEGER, - person_id INTEGER, - observation_concept_id INTEGER, - observation_date VARCHAR(8), -- DATE - observation_time VARCHAR(10), - observation_type_concept_id INTEGER, - value_as_number DOUBLE, -- NUMERIC - value_as_string VARCHAR(60), - value_as_concept_id INTEGER, - qualifier_concept_id INTEGER, - unit_concept_id INTEGER, - provider_id INTEGER, - visit_occurrence_id INTEGER, - observation_source_value VARCHAR(50), - observation_source_concept_id INTEGER, - unit_source_value VARCHAR(50), - qualifier_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE fact_relationship ( - domain_concept_id_1 INTEGER, - fact_id_1 INTEGER, - domain_concept_id_2 INTEGER, - fact_id_2 INTEGER, - relationship_concept_id INTEGER -) -; - - - - -/************************ - -Standardized health system data - -************************/ - - - -CREATE TABLE `location` ( - location_id INTEGER, - address_1 VARCHAR(50), - address_2 VARCHAR(50), - city VARCHAR(50), - state VARCHAR(2), - zip VARCHAR(9), - county VARCHAR(20), - location_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE care_site ( - care_site_id INTEGER, - care_site_name VARCHAR(255), - place_of_service_concept_id INTEGER, - location_id INTEGER, - care_site_source_value VARCHAR(50), - place_of_service_source_value VARCHAR(50) -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - -CREATE TABLE provider ( - provider_id INTEGER, - provider_name VARCHAR(255), - NPI VARCHAR(20), - DEA VARCHAR(20), - specialty_concept_id INTEGER, - care_site_id INTEGER, - year_of_birth INTEGER, - gender_concept_id INTEGER, - provider_source_value VARCHAR(50), - specialty_source_value VARCHAR(50), - specialty_source_concept_id INTEGER, - gender_source_value VARCHAR(50), - gender_source_concept_id INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - -/************************ - -Standardized health economics - -************************/ - - -CREATE TABLE payer_plan_period ( - payer_plan_period_id INTEGER, - person_id INTEGER, - payer_plan_period_start_date VARCHAR(8), -- DATE - payer_plan_period_end_date VARCHAR(8), -- DATE - payer_source_value VARCHAR (50), - plan_source_value VARCHAR (50), - family_source_value VARCHAR (50) -) -; - - -/* The individual cost tables are being phased out and will disappear soon - -CREATE TABLE visit_cost ( - visit_cost_id INTEGER, - visit_occurrence_id INTEGER, - currency_concept_id INTEGER, - paid_copay DECIMAL(19,4), -- NUMERIC - paid_coinsurance DECIMAL(19,4), -- NUMERIC - paid_toward_deductible DECIMAL(19,4), -- NUMERIC - paid_by_payer DECIMAL(19,4), -- NUMERIC - paid_by_coordination_benefits DECIMAL(19,4), -- NUMERIC - total_out_of_pocket DECIMAL(19,4), -- NUMERIC - total_paid DECIMAL(19,4), -- NUMERIC - payer_plan_period_id INTEGER -) -; - - - -CREATE TABLE procedure_cost ( - procedure_cost_id INTEGER, - procedure_occurrence_id INTEGER, - currency_concept_id INTEGER, - paid_copay DECIMAL(19,4), -- NUMERIC - paid_coinsurance DECIMAL(19,4), -- NUMERIC - paid_toward_deductible DECIMAL(19,4), -- NUMERIC - paid_by_payer DECIMAL(19,4), -- NUMERIC - paid_by_coordination_benefits DECIMAL(19,4), -- NUMERIC - total_out_of_pocket DECIMAL(19,4), -- NUMERIC - total_paid DECIMAL(19,4), -- NUMERIC - revenue_code_concept_id INTEGER, - payer_plan_period_id INTEGER, - revenue_code_source_value VARCHAR(50) -) -; - - - -CREATE TABLE drug_cost ( - drug_cost_id INTEGER, - drug_exposure_id INTEGER, - currency_concept_id INTEGER, - paid_copay DECIMAL(19,4), -- NUMERIC - paid_coinsurance DECIMAL(19,4), -- NUMERIC - paid_toward_deductible DECIMAL(19,4), -- NUMERIC - paid_by_payer DECIMAL(19,4), -- NUMERIC - paid_by_coordination_benefits DECIMAL(19,4), -- NUMERIC - total_out_of_pocket DECIMAL(19,4), -- NUMERIC - total_paid DECIMAL(19,4), -- NUMERIC - ingredient_cost DECIMAL(19,4), -- NUMERIC - dispensing_fee DECIMAL(19,4), -- NUMERIC - average_wholesale_price DECIMAL(19,4), -- NUMERIC - payer_plan_period_id INTEGER -) -; - - - - - -CREATE TABLE device_cost ( - device_cost_id INTEGER, - device_exposure_id INTEGER, - currency_concept_id INTEGER, - paid_copay DECIMAL(19,4), -- NUMERIC - paid_coinsurance DECIMAL(19,4), -- NUMERIC - paid_toward_deductible DECIMAL(19,4), -- NUMERIC - paid_by_payer DECIMAL(19,4), -- NUMERIC - paid_by_coordination_benefits DECIMAL(19,4), -- NUMERIC - total_out_of_pocket DECIMAL(19,4), -- NUMERIC - total_paid DECIMAL(19,4), -- NUMERIC - payer_plan_period_id INTEGER -) -; -*/ - - -CREATE TABLE cost ( - cost_id INTEGER, - cost_event_id INTEGER, - cost_domain_id VARCHAR(20), - cost_type_concept_id INTEGER, - currency_concept_id INTEGER, - total_charge DECIMAL(19,4), -- NUMERIC - total_cost DECIMAL(19,4), -- NUMERIC - total_paid DECIMAL(19,4), -- NUMERIC - paid_by_payer DECIMAL(19,4), -- NUMERIC - paid_by_patient DECIMAL(19,4), -- NUMERIC - paid_patient_copay DECIMAL(19,4), -- NUMERIC - paid_patient_coinsurance DECIMAL(19,4), -- NUMERIC - paid_patient_deductible DECIMAL(19,4), -- NUMERIC - paid_by_primary DECIMAL(19,4), -- NUMERIC - paid_ingredient_cost DECIMAL(19,4), -- NUMERIC - paid_dispensing_fee DECIMAL(19,4), -- NUMERIC - payer_plan_period_id INTEGER, - amount_allowed DECIMAL(19,4), -- NUMERIC - revenue_code_concept_id INTEGER, - reveue_code_source_value VARCHAR(50) -) -; - - - - - -/************************ - -Standardized derived elements - -************************/ - -CREATE TABLE cohort ( - cohort_definition_id INTEGER, - subject_id INTEGER, - cohort_start_date VARCHAR(8), -- DATE - cohort_end_date VARCHAR(8) -- DATE -) -; - - -CREATE TABLE cohort_attribute ( - cohort_definition_id INTEGER, - cohort_start_date VARCHAR(8), -- DATE - cohort_end_date VARCHAR(8), -- DATE - subject_id INTEGER, - attribute_definition_id INTEGER, - value_as_number DOUBLE, -- NUMERIC - value_as_concept_id INTEGER -) -; - - - - -CREATE TABLE drug_era ( - drug_era_id INTEGER, - person_id INTEGER, - drug_concept_id INTEGER, - drug_era_start_date VARCHAR(8), -- DATE - drug_era_end_date VARCHAR(8), -- DATE - drug_exposure_count INTEGER, - gap_days INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - -CREATE TABLE dose_era ( - dose_era_id INTEGER, - person_id INTEGER, - drug_concept_id INTEGER, - unit_concept_id INTEGER, - dose_value DOUBLE, -- NUMERIC - dose_era_start_date VARCHAR(8), -- DATE - dose_era_end_date VARCHAR(8) -- DATE -) -; - - - - -CREATE TABLE condition_era ( - condition_era_id INTEGER, - person_id INTEGER, - condition_concept_id INTEGER, - condition_era_start_date VARCHAR(8), -- DATE - condition_era_end_date VARCHAR(8), -- DATE - condition_occurrence_count INTEGER -) -ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' -TBLPROPERTIES ("skip.header.line.count"="1") -; - - - - - - - diff --git a/Impala/README.md b/Impala/README.md deleted file mode 100644 index 2d0fb5e..0000000 --- a/Impala/README.md +++ /dev/null @@ -1,51 +0,0 @@ -Common-Data-Model / Impala -================= - -This folder contains the SQL scripts for Impala. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -```bash -impala-shell -q 'CREATE DATABASE omop_cdm' -``` - -2. Execute the script `OMOP_CDM_ddl_Impala.sql` to create the tables and fields. - -```bash -impala-shell -d omop_cdm -f OMOP_CDM_ddl_Impala.sql -``` - -3. Load your data into the schema. - -a. Load the vocabulary tables. - -First, download the data from -[http://www.ohdsi.org/web/athena/](http://www.ohdsi.org/web/athena/) -and unzip into a _cdmv5vocab_ directory, then run - -```bash -hadoop fs -put cdmv5vocab cdmv5vocab -hadoop fs -chmod +w cdmv5vocab -impala-shell -d omop_cdm -f VocabImport/OMOP_CDM_vocabulary_load_Impala.sql --var=OMOP_VOCAB_PATH=/user/$USER/cdmv5vocab -``` - -b. Load the patient data. - -For example, download the 1000 person sample of simulated CMS SynPUF patient data from -[http://www.ltscomputingllc.com/downloads/](http://www.ltscomputingllc.com/downloads/) -and unzip into a _synpuf_ directory, then run - -```bash -hadoop fs -put synpuf synpuf -hadoop fs -chmod +w synpuf -impala-shell -d omop_cdm -f DataImport/OMOP_CDM_synpuf_load_Impala.sql --var=OMOP_SYNPUF_PATH=/user/$USER/synpuf -``` - -4. Run simple queries to sanity check. - -```bash -impala-shell -d omop_cdm -q 'SELECT COUNT(1) FROM concept' -impala-shell -d omop_cdm -q 'SELECT COUNT(1) FROM person' -``` \ No newline at end of file diff --git a/Impala/VocabImport/OMOP_CDM_vocabulary_load_Impala.sql b/Impala/VocabImport/OMOP_CDM_vocabulary_load_Impala.sql deleted file mode 100644 index 57c5093..0000000 --- a/Impala/VocabImport/OMOP_CDM_vocabulary_load_Impala.sql +++ /dev/null @@ -1,9 +0,0 @@ -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/CONCEPT.csv' OVERWRITE INTO TABLE concept; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/VOCABULARY.csv' OVERWRITE INTO TABLE vocabulary; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/DOMAIN.csv' OVERWRITE INTO TABLE domain; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/CONCEPT_CLASS.csv' OVERWRITE INTO TABLE concept_class; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/CONCEPT_RELATIONSHIP.csv' OVERWRITE INTO TABLE concept_relationship; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/RELATIONSHIP.csv' OVERWRITE INTO TABLE relationship; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/CONCEPT_SYNONYM.csv' OVERWRITE INTO TABLE concept_synonym; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/CONCEPT_ANCESTOR.csv' OVERWRITE INTO TABLE concept_ancestor; -LOAD DATA INPATH '${VAR:OMOP_VOCAB_PATH}/DRUG_STRENGTH.csv' OVERWRITE INTO TABLE drug_strength; diff --git a/Oracle/OMOP CDM constraints - Oracle.sql b/Oracle/OMOP CDM constraints - Oracle.sql deleted file mode 100644 index 024ae3c..0000000 --- a/Oracle/OMOP CDM constraints - Oracle.sql +++ /dev/null @@ -1,544 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ##### - # # ## ## # # # # # # # # ## ## # # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ##### #### # # #### # # # # # # # # # #### - - -script to create constraints within OMOP common data model, version 5.0 for Oracle database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - -*************************/ - - -/************************ -************************* -************************* -************************* - -Primary key constraints - -************************* -************************* -************************* -************************/ - - - -/************************ - -Standardized vocabulary - -************************/ - - - -ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); - -ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); - -ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); - -ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date); - -ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id); - -ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -/**PRIMARY KEY NONCLUSTERED constraints**/ - -ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ; - -ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ; - -ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ; - -ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ; - -ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ; - -ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ; - -ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ; - -ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ; - -ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ; - -ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ; - -ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ; - -ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ; - - - - -/************************ - -Standardized health system data - -************************/ - - -ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ; - -ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ; - -ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ; - - - -/************************ - -Standardized health economics - -************************/ - - -ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ; - -ALTER TABLE visit_cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( visit_cost_id ) ; - -ALTER TABLE procedure_cost ADD CONSTRAINT xpk_procedure_cost PRIMARY KEY ( procedure_cost_id ) ; - -ALTER TABLE drug_cost ADD CONSTRAINT xpk_drug_cost PRIMARY KEY ( drug_cost_id ) ; - -ALTER TABLE device_cost ADD CONSTRAINT xpk_device_cost PRIMARY KEY ( device_cost_id ) ; - - - -/************************ - -Standardized derived elements - -************************/ - -ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; - -ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ; - -ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ; - -ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ; - -ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ; - - - - - - - - -/************************ -************************* -************************* -************************* - -Foreign key constraints - -************************* -************************* -************************* -************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_domain FOREIGN KEY (domain_id) REFERENCES domain (domain_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_class FOREIGN KEY (concept_class_id) REFERENCES concept_class (concept_class_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_vocabulary FOREIGN KEY (vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE vocabulary ADD CONSTRAINT fpk_vocabulary_concept FOREIGN KEY (vocabulary_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE domain ADD CONSTRAINT fpk_domain_concept FOREIGN KEY (domain_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_class ADD CONSTRAINT fpk_concept_class_concept FOREIGN KEY (concept_class_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_1 FOREIGN KEY (concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_2 FOREIGN KEY (concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_id FOREIGN KEY (relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_concept FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (reverse_relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_2 FOREIGN KEY (descendant_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_1 FOREIGN KEY (source_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_2 FOREIGN KEY (target_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_c_1 FOREIGN KEY (target_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_1 FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_2 FOREIGN KEY (ingredient_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_1 FOREIGN KEY (amount_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (numerator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept FOREIGN KEY (race_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept FOREIGN KEY (ethnicity_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept_s FOREIGN KEY (race_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept_s FOREIGN KEY (ethnicity_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_concept FOREIGN KEY (period_type_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_concept FOREIGN KEY (specimen_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_type_concept FOREIGN KEY (specimen_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anatomic_site_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept FOREIGN KEY (procedure_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_type_concept FOREIGN KEY (procedure_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_modifier FOREIGN KEY (modifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept_s FOREIGN KEY (procedure_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_type_concept FOREIGN KEY (drug_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_route_concept FOREIGN KEY (route_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_dose_unit_concept FOREIGN KEY (dose_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept_s FOREIGN KEY (drug_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept FOREIGN KEY (device_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_type_concept FOREIGN KEY (device_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept_s FOREIGN KEY (device_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_type_concept FOREIGN KEY (condition_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept_s FOREIGN KEY (condition_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept FOREIGN KEY (measurement_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_type_concept FOREIGN KEY (measurement_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_operator FOREIGN KEY (operator_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept_s FOREIGN KEY (measurement_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE note ADD CONSTRAINT fpk_note_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_type_concept FOREIGN KEY (note_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept FOREIGN KEY (observation_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_type_concept FOREIGN KEY (observation_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_qualifier FOREIGN KEY (qualifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_2 FOREIGN KEY (domain_concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_relationship FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - - - -/************************ - -Standardized health system data - -************************/ - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_place FOREIGN KEY (place_of_service_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty FOREIGN KEY (specialty_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specialty_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - - - - -/************************ - -Standardized health economics - -************************/ - -ALTER TABLE payer_plan_period ADD CONSTRAINT fpk_payer_plan_period FOREIGN KEY (person_id) REFERENCES person (person_id); - - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_id FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_id FOREIGN KEY (procedure_occurrence_id) REFERENCES procedure_occurrence (procedure_occurrence_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_revenue FOREIGN KEY (revenue_code_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_id FOREIGN KEY (drug_exposure_id) REFERENCES drug_exposure (drug_exposure_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_id FOREIGN KEY (device_exposure_id) REFERENCES device_exposure (device_exposure_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - - - - - -/************************ - -Standardized derived elements - -************************/ - - -ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - diff --git a/Oracle/OMOP CDM ddl - Oracle.sql b/Oracle/OMOP CDM ddl - Oracle.sql deleted file mode 100644 index 17dc75d..0000000 --- a/Oracle/OMOP CDM ddl - Oracle.sql +++ /dev/null @@ -1,740 +0,0 @@ -/********************************************************************************* -# Copyright 2014-6 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -script to create OMOP common data model, version 5.0 for Oracle database - -last revised: 1-May-2016 - -Authors: Patrick Ryan, Christian Reich - - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -CREATE 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 TABLE vocabulary ( - vocabulary_id VARCHAR(20) NOT NULL, - vocabulary_name VARCHAR(255) NOT NULL, - vocabulary_reference VARCHAR(255) NULL, - vocabulary_version VARCHAR(255) NULL, - vocabulary_concept_id INTEGER NOT NULL -) -; - - - - -CREATE TABLE domain ( - domain_id VARCHAR(20) NOT NULL, - domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL -) -; - - - -CREATE 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 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 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 TABLE concept_synonym ( - concept_id INTEGER NOT NULL, - concept_synonym_name VARCHAR(1000) NOT NULL, - language_concept_id INTEGER NOT NULL -) -; - - -CREATE 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 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 TABLE drug_strength ( - drug_concept_id INTEGER NOT NULL, - ingredient_concept_id INTEGER NOT NULL, - amount_value FLOAT NULL, - amount_unit_concept_id INTEGER NULL, - numerator_value FLOAT NULL, - numerator_unit_concept_id INTEGER NULL, - denominator_value FLOAT 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 TABLE cohort_definition ( - cohort_definition_id INTEGER NOT NULL, - cohort_definition_name VARCHAR(255) NOT NULL, - cohort_definition_description CLOB NULL, - definition_type_concept_id INTEGER NOT NULL, - cohort_definition_syntax CLOB NULL, - subject_concept_id INTEGER NOT NULL, - cohort_initiation_date DATE NULL -) -; - - -CREATE TABLE attribute_definition ( - attribute_definition_id INTEGER NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_description CLOB NULL, - attribute_type_concept_id INTEGER NOT NULL, - attribute_syntax CLOB NULL -) -; - - -/************************** - -Standardized meta-data - -***************************/ - - -CREATE TABLE cdm_source - ( - cdm_source_name VARCHAR(255) NOT NULL, - cdm_source_abbreviation VARCHAR(25) NULL, - cdm_holder VARCHAR(255) NULL, - source_description CLOB 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 - ) -; - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -CREATE 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, - time_of_birth VARCHAR(10) 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 - ) -; - - - - - -CREATE 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 - ) -; - - - -CREATE 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_time VARCHAR(10) NULL , - quantity FLOAT 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 - ) -; - - - -CREATE TABLE death - ( - person_id INTEGER NOT NULL , - death_date DATE NOT 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 - ) -; - - - -CREATE 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_time VARCHAR(10) NULL , - visit_end_date DATE NOT NULL , - visit_end_time VARCHAR(10) 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 - ) -; - - - -CREATE 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_type_concept_id INTEGER NOT NULL , - modifier_concept_id INTEGER NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , - procedure_source_concept_id INTEGER NULL , - qualifier_source_value VARCHAR(50) NULL - ) -; - - - -CREATE 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_end_date DATE NULL , - drug_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - refills INTEGER NULL , - quantity FLOAT NULL , - days_supply INTEGER NULL , - sig CLOB NULL , - route_concept_id INTEGER NULL , - effective_drug_dose FLOAT NULL , - dose_unit_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_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 - ) -; - - -CREATE 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_end_date DATE 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 , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL - ) -; - - -CREATE 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_end_date DATE NULL , - condition_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL - ) -; - - - -CREATE TABLE measurement - ( - measurement_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NOT NULL , - measurement_time VARCHAR(10) NULL , - measurement_type_concept_id INTEGER NOT NULL , - operator_concept_id INTEGER NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL , - unit_concept_id INTEGER NULL , - range_low FLOAT NULL , - range_high FLOAT NULL , - provider_id INTEGER NULL , - visit_occurrence_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 - ) -; - - - -CREATE TABLE note - ( - note_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - note_date DATE NOT NULL , - note_time VARCHAR(10) NULL , - note_type_concept_id INTEGER NOT NULL , - note_text CLOB NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - note_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE observation - ( - observation_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NOT NULL , - observation_time VARCHAR(10) NULL , - observation_type_concept_id INTEGER NOT NULL , - value_as_number FLOAT 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 , - 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 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 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 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 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 - -************************/ - - -CREATE 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_source_value VARCHAR (50) NULL , - plan_source_value VARCHAR (50) NULL , - family_source_value VARCHAR (50) NULL - ) -; - - --- The individual cost tables are phased out and will be removed -/* -CREATE TABLE visit_cost - ( - visit_cost_id INTEGER NOT NULL , - visit_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE procedure_cost - ( - procedure_cost_id INTEGER NOT NULL , - procedure_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - revenue_code_concept_id INTEGER NULL , - payer_plan_period_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE drug_cost - ( - drug_cost_id INTEGER NOT NULL , - drug_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - ingredient_cost FLOAT NULL , - dispensing_fee FLOAT NULL , - average_wholesale_price FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - - - -CREATE TABLE device_cost - ( - device_cost_id INTEGER NOT NULL , - device_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; -*/ - - -CREATE TABLE cost - ( - cost_id INTEGER NOT NULL , - cost_event_id INTEGER NOT NULL , - cost_domain_id VARCHAR2(20) NOT NULL , - cost_type_concept_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - total_charge FLOAT NULL , - total_cost FLOAT NULL , - total_paid FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_patient FLOAT NULL , - paid_patient_copay FLOAT NULL , - paid_patient_coinsurance FLOAT NULL , - paid_patient_deductible FLOAT NULL , - paid_by_primary FLOAT NULL , - paid_ingredient_cost FLOAT NULL , - paid_dispensing_fee FLOAT NULL , - payer_plan_period_id INTEGER NULL , - amount_allowed FLOAT NULL , - revenue_code_concept_id INTEGER NULL , - reveue_code_source_value VARCHAR2(50) NULL - ) -; - - - - - -/************************ - -Standardized derived elements - -************************/ - -CREATE 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 - ) -; - - -CREATE TABLE cohort_attribute - ( - cohort_definition_id INTEGER NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - subject_id INTEGER NOT NULL , - attribute_definition_id INTEGER NOT NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL - ) -; - - - - -CREATE 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 - ) -; - - -CREATE 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 FLOAT NOT NULL , - dose_era_start_date DATE NOT NULL , - dose_era_end_date DATE NOT NULL - ) -; - - - - -CREATE 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/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql b/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql deleted file mode 100644 index 9aeea74..0000000 --- a/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql +++ /dev/null @@ -1,168 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ### - # # ## ## # # # # # # # # ## ## # # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### # # ##### ###### # # ###### #### - - -script to create the required indexes within OMOP common data model, version 5.0 for Oracle database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - -description: These indices are considered a minimal requirement to ensure adequate performance of analyses. - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - -CREATE INDEX idx_concept_code ON concept (concept_code ASC); -CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC); -CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC); -CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC); - -CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC); -CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC); -CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC); - -CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC); - -CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC); -CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC); - -CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC); -CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC); - -CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC); -CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC); - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC); - -CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC); -CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); - -CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); -CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); - -CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); -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_drug_person_id ON drug_exposure (person_id ASC); -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_device_person_id ON device_exposure (person_id ASC); -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_condition_person_id ON condition_occurrence (person_id ASC); -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_measurement_person_id ON measurement (person_id ASC); -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_note_person_id ON note (person_id ASC); -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_observation_person_id ON observation (person_id ASC); -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_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); - - - - - -/************************ - -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); -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); -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); -CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC); - diff --git a/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql b/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql deleted file mode 100644 index a46c565..0000000 --- a/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql +++ /dev/null @@ -1,188 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ### - # # ## ## # # # # # # # # ## ## # # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### # # ##### ###### # # ###### #### - - -script to create the required indexes within OMOP common data model, version 5.0 for Oracle database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - -description: These indices are considered a minimal requirement to ensure adequate performance of analyses. - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - -CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC); - -CREATE INDEX idx_concept_code ON concept (concept_code ASC); -CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC); -CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC); -CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC); - -CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC); - -CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC); - -CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC); - -CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC); -CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC); -CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC); - -CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC); - -CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC); - -CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC); -CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC); - -CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC); -CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC); - -CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC); -CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC); - -CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); - -CREATE INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC); - -CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC); - -CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC); -CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); - -CREATE INDEX idx_death_person_id ON death (person_id ASC); - -CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); -CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); - -CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); -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_drug_person_id ON drug_exposure (person_id ASC); -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_device_person_id ON device_exposure (person_id ASC); -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_condition_person_id ON condition_occurrence (person_id ASC); -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_measurement_person_id ON measurement (person_id ASC); -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_note_person_id ON note (person_id ASC); -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_observation_person_id ON observation (person_id ASC); -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_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); - - - - - -/************************ - -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); -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); -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); -CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC); - diff --git a/Oracle/README.md b/Oracle/README.md deleted file mode 100644 index 2aee521..0000000 --- a/Oracle/README.md +++ /dev/null @@ -1,20 +0,0 @@ -Common-Data-Model / Oracle -================= - -This folder contains the SQL scripts for Oracle. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `OMOP CDM ddl - Oracle.sql` to create the tables and fields. - -3. Load your data into the schema. - -4. Execute the script `OMOP CDM constraints - Oracle.sql` to add the constraints (primary and foreign keys). - -5. Execute the script `OMOP CDM indexes required - Oracle - With constraints.sql` to add the minimum set of indexes we recommend. - -Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably. - -Also note: you can apply the indexes without first applying the constraints, but then we recommend you use the script `OMOP CDM indexes required - Oracle - Without constraints.sql`. (This script will also create the indexes that would normally be automatically created by the primary key constraints.) diff --git a/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat b/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat deleted file mode 100644 index e31b562..0000000 --- a/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat +++ /dev/null @@ -1,52 +0,0 @@ -REM ********************************************************************************* -REM Copyright 2014 Observational Health Data Sciences and Informatics -REM -REM -REM Licensed under the Apache License, Version 2.0 (the "License"); -REM you may not use this file except in compliance with the License. -REM You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. -REM *******************************************************************************/ - -REM ************************ -REM -REM ####### # # ####### ###### ##### ###### # # ####### -REM # # ## ## # # # # # # # # ## ## # # # -REM # # # # # # # # # # # # # # # # # # # # -REM # # # # # # # ###### # # # # # # # # ###### -REM # # # # # # # # # # # # # # # -REM # # # # # # # # # # # # # # # # # -REM ####### # # ####### # ##### ###### # # ## ##### -REM -REM -REM Script to load the common data model, version 5.0 vocabulary tables for PostgreSQL database on Windows (MS-DOS style file paths) -REM -REM Notes -REM -REM 1) There is no data file load for the SOURCE_TO_CONCEPT_MAP table because that table is deprecated in CDM version 5.0 -REM 2) This script assumes the CDM version 5 vocabulary zip file has been unzipped into the "C:\CDMV5VOCAB" directory. -REM 3) If you unzipped your CDM version 5 vocabulary files into a different directory then replace all file paths below, with your directory path. -REM -REM last revised: 26 Nov 2014 -REM -REM author: Lee Evans -REM -REM -REM *************************/ - -sqlldr CDMV5/ CONTROL=CONCEPT.ctl LOG=C:\CDMV5VOCAB\CONCEPT.log BAD=C:\CDMV5VOCAB\CONCEPT.bad -sqlldr CDMV5/ CONTROL=CONCEPT_ANCESTOR.ctl LOG=C:\CDMV5VOCAB\CONCEPT_ANCESTOR.log BAD=C:\CDMV5VOCAB\CONCEPT_ANCESTOR.bad -sqlldr CDMV5/ CONTROL=CONCEPT_CLASS.ctl LOG=C:\CDMV5VOCAB\CONCEPT_CLASS.log BAD=C:\CDMV5VOCAB\CONCEPT_CLASS.bad -sqlldr CDMV5/ CONTROL=CONCEPT_RELATIONSHIP.ctl LOG=C:\CDMV5VOCAB\CONCEPT_RELATIONSHIP.log BAD=C:\CDMV5VOCAB\CONCEPT_RELATIONSHIP.bad -sqlldr CDMV5/ CONTROL=CONCEPT_SYNONYM.ctl LOG=C:\CDMV5VOCAB\CONCEPT_SYNONYM.log BAD=C:\CDMV5VOCAB\CONCEPT_SYNONYM.bad -sqlldr CDMV5/ CONTROL=DOMAIN.ctl LOG=C:\CDMV5VOCAB\DOMAIN.log BAD=C:\CDMV5VOCAB\DOMAIN.bad -sqlldr CDMV5/ CONTROL=DRUG_STRENGTH.ctl LOG=C:\CDMV5VOCAB\DRUG_STRENGTH.log BAD=C:\CDMV5VOCAB\DRUG_STRENGTH.bad -sqlldr CDMV5/ CONTROL=RELATIONSHIP.ctl LOG=C:\CDMV5VOCAB\RELATIONSHIP.log BAD=C:\CDMV5VOCAB\RELATIONSHIP.bad -sqlldr CDMV5/ CONTROL=VOCABULARY.ctl LOG=C:\CDMV5VOCAB\VOCABULARY.log BAD=C:\CDMV5VOCAB\VOCABULARY.bad diff --git a/Oracle/VocabImport/concept.ctl b/Oracle/VocabImport/concept.ctl deleted file mode 100644 index 76e3f11..0000000 --- a/Oracle/VocabImport/concept.ctl +++ /dev/null @@ -1,19 +0,0 @@ -options (skip=1) -load data -infile concept.csv -into table concept -replace -fields terminated by '\t' -trailing nullcols -( - concept_id, - concept_name, - domain_id, - vocabulary_id, - concept_class_id, - standard_concept, - concept_code, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Oracle/VocabImport/concept_ancestor.ctl b/Oracle/VocabImport/concept_ancestor.ctl deleted file mode 100644 index 350015a..0000000 --- a/Oracle/VocabImport/concept_ancestor.ctl +++ /dev/null @@ -1,13 +0,0 @@ -options (skip=1) -load data -infile concept_ancestor.csv -into table concept_ancestor -replace -fields terminated by '\t' -trailing nullcols -( - ancestor_concept_id, - descendant_concept_id, - min_levels_of_separation, - max_levels_of_separation -) \ No newline at end of file diff --git a/Oracle/VocabImport/concept_class.ctl b/Oracle/VocabImport/concept_class.ctl deleted file mode 100644 index b7adfb5..0000000 --- a/Oracle/VocabImport/concept_class.ctl +++ /dev/null @@ -1,12 +0,0 @@ -options (skip=1) -load data -infile concept_class.csv -into table concept_class -replace -fields terminated by '\t' -trailing nullcols -( - concept_class_id, - concept_class_name, - concept_class_concept_id -) \ No newline at end of file diff --git a/Oracle/VocabImport/concept_relationship.ctl b/Oracle/VocabImport/concept_relationship.ctl deleted file mode 100644 index d26ce3e..0000000 --- a/Oracle/VocabImport/concept_relationship.ctl +++ /dev/null @@ -1,15 +0,0 @@ -options (skip=1) -load data -infile concept_relationship.csv -into table concept_relationship -replace -fields terminated by '\t' -trailing nullcols -( - concept_id_1, - concept_id_2, - relationship_id, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Oracle/VocabImport/concept_synonym.ctl b/Oracle/VocabImport/concept_synonym.ctl deleted file mode 100644 index 84561da..0000000 --- a/Oracle/VocabImport/concept_synonym.ctl +++ /dev/null @@ -1,12 +0,0 @@ -options (skip=1) -load data -infile concept_synonym.csv -into table concept_synonym -replace -fields terminated by '\t' -trailing nullcols -( - concept_id, - concept_synonym_name CHAR(1000), - language_concept_id -) \ No newline at end of file diff --git a/Oracle/VocabImport/domain.ctl b/Oracle/VocabImport/domain.ctl deleted file mode 100644 index 3075edb..0000000 --- a/Oracle/VocabImport/domain.ctl +++ /dev/null @@ -1,12 +0,0 @@ -options (skip=1) -load data -infile domain.csv -into table domain -replace -fields terminated by '\t' -trailing nullcols -( - domain_id, - domain_name, - domain_concept_id -) \ No newline at end of file diff --git a/Oracle/VocabImport/drug_strength.ctl b/Oracle/VocabImport/drug_strength.ctl deleted file mode 100644 index 070f2f7..0000000 --- a/Oracle/VocabImport/drug_strength.ctl +++ /dev/null @@ -1,21 +0,0 @@ -options (skip=1) -load data -infile drug_strength.csv -into table drug_strength -replace -fields terminated by '\t' -trailing nullcols -( - drug_concept_id, - ingredient_concept_id, - amount_value, - amount_unit_concept_id, - numerator_value, - numerator_unit_concept_id, - denominator_value, - denominator_unit_concept_id, - box_size, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) diff --git a/Oracle/VocabImport/relationship.ctl b/Oracle/VocabImport/relationship.ctl deleted file mode 100644 index 436b042..0000000 --- a/Oracle/VocabImport/relationship.ctl +++ /dev/null @@ -1,15 +0,0 @@ -options (skip=1) -load data -infile relationship.csv -into table relationship -replace -fields terminated by '\t' -trailing nullcols -( - relationship_id, - relationship_name, - is_hierarchical, - defines_ancestry, - reverse_relationship_id, - relationship_concept_id -) \ No newline at end of file diff --git a/Oracle/VocabImport/vocabulary.ctl b/Oracle/VocabImport/vocabulary.ctl deleted file mode 100644 index 76324e2..0000000 --- a/Oracle/VocabImport/vocabulary.ctl +++ /dev/null @@ -1,14 +0,0 @@ -options (skip=1) -load data -infile vocabulary.csv -into table vocabulary -replace -fields terminated by '\t' -trailing nullcols -( - vocabulary_id, - vocabulary_name, - vocabulary_reference, - vocabulary_version, - vocabulary_concept_id -) \ No newline at end of file diff --git a/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql b/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql deleted file mode 100644 index af459a5..0000000 --- a/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql +++ /dev/null @@ -1,545 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ##### - # # ## ## # # # # # # # # ## ## # # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ##### #### # # #### # # # # # # # # # #### - - -script to create constraints within OMOP common data model, version 5.0 for PostgreSQL database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - - -*************************/ - - -/************************ -************************* -************************* -************************* - -Primary key constraints - -************************* -************************* -************************* -************************/ - - - -/************************ - -Standardized vocabulary - -************************/ - - - -ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); - -ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); - -ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); - -ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date); - -ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id); - -ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -/**PRIMARY KEY NONCLUSTERED constraints**/ - -ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ; - -ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ; - -ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ; - -ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ; - -ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ; - -ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ; - -ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ; - -ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ; - -ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ; - -ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ; - -ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ; - -ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ; - - - - -/************************ - -Standardized health system data - -************************/ - - -ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ; - -ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ; - -ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ; - - - -/************************ - -Standardized health economics - -************************/ - - -ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ; - -ALTER TABLE visit_cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( visit_cost_id ) ; - -ALTER TABLE procedure_cost ADD CONSTRAINT xpk_procedure_cost PRIMARY KEY ( procedure_cost_id ) ; - -ALTER TABLE drug_cost ADD CONSTRAINT xpk_drug_cost PRIMARY KEY ( drug_cost_id ) ; - -ALTER TABLE device_cost ADD CONSTRAINT xpk_device_cost PRIMARY KEY ( device_cost_id ) ; - - - -/************************ - -Standardized derived elements - -************************/ - -ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; - -ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ; - -ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ; - -ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ; - -ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ; - - - - - - - - -/************************ -************************* -************************* -************************* - -Foreign key constraints - -************************* -************************* -************************* -************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_domain FOREIGN KEY (domain_id) REFERENCES domain (domain_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_class FOREIGN KEY (concept_class_id) REFERENCES concept_class (concept_class_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_vocabulary FOREIGN KEY (vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE vocabulary ADD CONSTRAINT fpk_vocabulary_concept FOREIGN KEY (vocabulary_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE domain ADD CONSTRAINT fpk_domain_concept FOREIGN KEY (domain_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_class ADD CONSTRAINT fpk_concept_class_concept FOREIGN KEY (concept_class_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_1 FOREIGN KEY (concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_2 FOREIGN KEY (concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_id FOREIGN KEY (relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_concept FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (reverse_relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_2 FOREIGN KEY (descendant_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_1 FOREIGN KEY (source_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_2 FOREIGN KEY (target_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_c_1 FOREIGN KEY (target_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_1 FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_2 FOREIGN KEY (ingredient_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_1 FOREIGN KEY (amount_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (numerator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept FOREIGN KEY (race_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept FOREIGN KEY (ethnicity_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept_s FOREIGN KEY (race_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept_s FOREIGN KEY (ethnicity_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_concept FOREIGN KEY (period_type_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_concept FOREIGN KEY (specimen_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_type_concept FOREIGN KEY (specimen_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anatomic_site_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept FOREIGN KEY (procedure_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_type_concept FOREIGN KEY (procedure_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_modifier FOREIGN KEY (modifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept_s FOREIGN KEY (procedure_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_type_concept FOREIGN KEY (drug_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_route_concept FOREIGN KEY (route_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_dose_unit_concept FOREIGN KEY (dose_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept_s FOREIGN KEY (drug_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept FOREIGN KEY (device_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_type_concept FOREIGN KEY (device_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept_s FOREIGN KEY (device_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_type_concept FOREIGN KEY (condition_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept_s FOREIGN KEY (condition_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept FOREIGN KEY (measurement_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_type_concept FOREIGN KEY (measurement_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_operator FOREIGN KEY (operator_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept_s FOREIGN KEY (measurement_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE note ADD CONSTRAINT fpk_note_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_type_concept FOREIGN KEY (note_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept FOREIGN KEY (observation_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_type_concept FOREIGN KEY (observation_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_qualifier FOREIGN KEY (qualifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_2 FOREIGN KEY (domain_concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_relationship FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - - - -/************************ - -Standardized health system data - -************************/ - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_place FOREIGN KEY (place_of_service_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty FOREIGN KEY (specialty_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specialty_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - - - - -/************************ - -Standardized health economics - -************************/ - -ALTER TABLE payer_plan_period ADD CONSTRAINT fpk_payer_plan_period FOREIGN KEY (person_id) REFERENCES person (person_id); - - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_id FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_id FOREIGN KEY (procedure_occurrence_id) REFERENCES procedure_occurrence (procedure_occurrence_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_revenue FOREIGN KEY (revenue_code_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_id FOREIGN KEY (drug_exposure_id) REFERENCES drug_exposure (drug_exposure_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_id FOREIGN KEY (device_exposure_id) REFERENCES device_exposure (device_exposure_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - - - - - -/************************ - -Standardized derived elements - -************************/ - - -ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - diff --git a/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql b/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql deleted file mode 100644 index 9f40559..0000000 --- a/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql +++ /dev/null @@ -1,740 +0,0 @@ -/********************************************************************************* -# Copyright 2014-6 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -script to create OMOP common data model, version 5.0 for PostgreSQL database - -last revised: 1-May-2016 - -Authors: Patrick Ryan, Christian Reich - - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -CREATE 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 TABLE vocabulary ( - vocabulary_id VARCHAR(20) NOT NULL, - vocabulary_name VARCHAR(255) NOT NULL, - vocabulary_reference VARCHAR(255) NULL, - vocabulary_version VARCHAR(255) NULL, - vocabulary_concept_id INTEGER NOT NULL -) -; - - - - -CREATE TABLE domain ( - domain_id VARCHAR(20) NOT NULL, - domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL -) -; - - - -CREATE 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 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 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 TABLE concept_synonym ( - concept_id INTEGER NOT NULL, - concept_synonym_name VARCHAR(1000) NOT NULL, - language_concept_id INTEGER NOT NULL -) -; - - -CREATE 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 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 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 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 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 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 - ) -; - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -CREATE 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, - time_of_birth VARCHAR(10) 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 - ) -; - - - - - -CREATE 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 - ) -; - - - -CREATE 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_time VARCHAR(10) 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 - ) -; - - - -CREATE TABLE death - ( - person_id INTEGER NOT NULL , - death_date DATE NOT 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 - ) -; - - - -CREATE 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_time VARCHAR(10) NULL , - visit_end_date DATE NOT NULL , - visit_end_time VARCHAR(10) 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 - ) -; - - - -CREATE 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_type_concept_id INTEGER NOT NULL , - modifier_concept_id INTEGER NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , - procedure_source_concept_id INTEGER NULL , - qualifier_source_value VARCHAR(50) NULL - ) -; - - - -CREATE 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_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 , - effective_drug_dose NUMERIC NULL , - dose_unit_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_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 - ) -; - - -CREATE 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_end_date DATE 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 , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL - ) -; - - -CREATE 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_end_date DATE NULL , - condition_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL - ) -; - - - -CREATE TABLE measurement - ( - measurement_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NOT 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 , - measurement_source_value VARCHAR(50) NULL , - measurement_source_concept_id INTEGER NULL , - unit_source_value VARCHAR(50) NULL , - value_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE note - ( - note_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - note_date DATE NOT NULL , - note_time VARCHAR(10) NULL , - note_type_concept_id INTEGER NOT NULL , - note_text TEXT NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - note_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE observation - ( - observation_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NOT NULL , - observation_time VARCHAR(10) 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 , - 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 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 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 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 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 - -************************/ - - -CREATE 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_source_value VARCHAR (50) NULL , - plan_source_value VARCHAR (50) NULL , - family_source_value VARCHAR (50) NULL - ) -; - - -/* The individual cost tables are being phased out and will disappear soon - -CREATE TABLE visit_cost - ( - visit_cost_id INTEGER NOT NULL , - visit_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay NUMERIC NULL , - paid_coinsurance NUMERIC NULL , - paid_toward_deductible NUMERIC NULL , - paid_by_payer NUMERIC NULL , - paid_by_coordination_benefits NUMERIC NULL , - total_out_of_pocket NUMERIC NULL , - total_paid NUMERIC NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE procedure_cost - ( - procedure_cost_id INTEGER NOT NULL , - procedure_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay NUMERIC NULL , - paid_coinsurance NUMERIC NULL , - paid_toward_deductible NUMERIC NULL , - paid_by_payer NUMERIC NULL , - paid_by_coordination_benefits NUMERIC NULL , - total_out_of_pocket NUMERIC NULL , - total_paid NUMERIC NULL , - revenue_code_concept_id INTEGER NULL , - payer_plan_period_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE drug_cost - ( - drug_cost_id INTEGER NOT NULL , - drug_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay NUMERIC NULL , - paid_coinsurance NUMERIC NULL , - paid_toward_deductible NUMERIC NULL , - paid_by_payer NUMERIC NULL , - paid_by_coordination_benefits NUMERIC NULL , - total_out_of_pocket NUMERIC NULL , - total_paid NUMERIC NULL , - ingredient_cost NUMERIC NULL , - dispensing_fee NUMERIC NULL , - average_wholesale_price NUMERIC NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - - - -CREATE TABLE device_cost - ( - device_cost_id INTEGER NOT NULL , - device_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay NUMERIC NULL , - paid_coinsurance NUMERIC NULL , - paid_toward_deductible NUMERIC NULL , - paid_by_payer NUMERIC NULL , - paid_by_coordination_benefits NUMERIC NULL , - total_out_of_pocket NUMERIC NULL , - total_paid NUMERIC NULL , - payer_plan_period_id INTEGER NULL - ) -; -*/ - - -CREATE 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 , - reveue_code_source_value VARCHAR(50) NULL - ) -; - - - - - -/************************ - -Standardized derived elements - -************************/ - -CREATE 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 - ) -; - - -CREATE TABLE cohort_attribute - ( - cohort_definition_id INTEGER NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - subject_id INTEGER NOT NULL , - attribute_definition_id INTEGER NOT NULL , - value_as_number NUMERIC NULL , - value_as_concept_id INTEGER NULL - ) -; - - - - -CREATE 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 - ) -; - - -CREATE 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 - ) -; - - - - -CREATE 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/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql b/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql deleted file mode 100644 index 65760d5..0000000 --- a/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql +++ /dev/null @@ -1,214 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ### - # # ## ## # # # # # # # # ## ## # # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### # # ##### ###### # # ###### #### - - -script to create the required indexes within OMOP common data model, version 5.0 for PostgreSQL database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - -description: These indices are considered a minimal requirement to ensure adequate performance of analyses. - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - -CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC); -CLUSTER concept USING idx_concept_concept_id ; -CREATE INDEX idx_concept_code ON concept (concept_code ASC); -CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC); -CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC); -CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC); - -CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC); -CLUSTER vocabulary USING idx_vocabulary_vocabulary_id ; - -CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC); -CLUSTER domain USING idx_domain_domain_id ; - -CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC); -CLUSTER concept_class USING idx_concept_class_class_id ; - -CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC); -CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC); -CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC); - -CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC); -CLUSTER relationship USING idx_relationship_rel_id ; - -CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC); -CLUSTER concept_synonym USING idx_concept_synonym_id ; - -CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC); -CLUSTER concept_ancestor USING idx_concept_ancestor_id_1 ; -CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC); - -CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC); -CLUSTER source_to_concept_map USING idx_source_to_concept_map_id_3 ; -CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC); - -CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC); -CLUSTER drug_strength USING idx_drug_strength_id_1 ; -CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC); - -CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); -CLUSTER cohort_definition USING idx_cohort_definition_id ; - -CREATE INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC); -CLUSTER attribute_definition USING idx_attribute_definition_id ; - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -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_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_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_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_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_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_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_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_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/PostgreSQL/README.md b/PostgreSQL/README.md deleted file mode 100644 index 28ef453..0000000 --- a/PostgreSQL/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Common-Data-Model / PostgreSQL -================= - -This folder contains the SQL scripts for PostgreSQL. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `OMOP CDM ddl - PostgreSQL.sql` to create the tables and fields. - -3. Load your data into the schema. - -4. Execute the script `OMOP CDM constraints - PostgreSQL.sql` to add the constraints (primary and foreign keys). - -5. Execute the script `OMOP CDM indexes required - PostgreSQL.sql` to add the minimum set of indexes we recommend. - -Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably. diff --git a/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql b/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql deleted file mode 100644 index 9da1998..0000000 --- a/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql +++ /dev/null @@ -1,63 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -Script to load the common data model, version 5.0 vocabulary tables for PostgreSQL database on Windows (MS-DOS style file paths) -The database account running this script must have the "superuser" permission in the database. - -Notes - -1) There is no data file load for the SOURCE_TO_CONCEPT_MAP table because that table is deprecated in CDM version 5.0 -2) This script assumes the CDM version 5 vocabulary zip file has been unzipped into the "C:\CDMV5VOCAB" directory. -3) If you unzipped your CDM version 5 vocabulary files into a different directory then replace all file paths below, with your directory path. -4) Truncate each table that will be lodaed below, before running this script. - -last revised: 5 Dec 2014 - -author: Lee Evans - - -*************************/ - -COPY DRUG_STRENGTH FROM 'C:\CDMV5VOCAB\DRUG_STRENGTH.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY CONCEPT FROM 'C:\CDMV5VOCAB\CONCEPT.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY CONCEPT_RELATIONSHIP FROM 'C:\CDMV5VOCAB\CONCEPT_RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY CONCEPT_ANCESTOR FROM 'C:\CDMV5VOCAB\CONCEPT_ANCESTOR.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY CONCEPT_SYNONYM FROM 'C:\CDMV5VOCAB\CONCEPT_SYNONYM.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY VOCABULARY FROM 'C:\CDMV5VOCAB\VOCABULARY.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY RELATIONSHIP FROM 'C:\CDMV5VOCAB\RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY CONCEPT_CLASS FROM 'C:\CDMV5VOCAB\CONCEPT_CLASS.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - -COPY DOMAIN FROM 'C:\CDMV5VOCAB\DOMAIN.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - diff --git a/Sql Server/OMOP CDM constraints - SQL Server.sql b/Sql Server/OMOP CDM constraints - SQL Server.sql deleted file mode 100644 index 623b3fe..0000000 --- a/Sql Server/OMOP CDM constraints - SQL Server.sql +++ /dev/null @@ -1,545 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ##### - # # ## ## # # # # # # # # ## ## # # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ##### #### # # #### # # # # # # # # # #### - - -script to create constraints within OMOP common data model, version 5.0 for SQL Server database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - - -*************************/ - - -/************************ -************************* -************************* -************************* - -Primary key constraints - -************************* -************************* -************************* -************************/ - - - -/************************ - -Standardized vocabulary - -************************/ - - - -ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY NONCLUSTERED (concept_id); - -ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY NONCLUSTERED (vocabulary_id); - -ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY NONCLUSTERED (domain_id); - -ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY NONCLUSTERED (concept_class_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY NONCLUSTERED (concept_id_1,concept_id_2,relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY NONCLUSTERED (relationship_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY NONCLUSTERED (ancestor_concept_id,descendant_concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY NONCLUSTERED (source_vocabulary_id,target_concept_id,source_code,valid_end_date); - -ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY NONCLUSTERED (drug_concept_id, ingredient_concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id); - -ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY NONCLUSTERED (attribute_definition_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -/**PRIMARY KEY NONCLUSTERED constraints**/ - -ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY NONCLUSTERED ( person_id ) ; - -ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY NONCLUSTERED ( observation_period_id ) ; - -ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY NONCLUSTERED ( specimen_id ) ; - -ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY NONCLUSTERED ( person_id ) ; - -ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY NONCLUSTERED ( visit_occurrence_id ) ; - -ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY NONCLUSTERED ( procedure_occurrence_id ) ; - -ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY NONCLUSTERED ( drug_exposure_id ) ; - -ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY NONCLUSTERED ( device_exposure_id ) ; - -ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY NONCLUSTERED ( condition_occurrence_id ) ; - -ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY NONCLUSTERED ( measurement_id ) ; - -ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY NONCLUSTERED ( note_id ) ; - -ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ; - - - - -/************************ - -Standardized health system data - -************************/ - - -ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ; - -ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ; - -ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY NONCLUSTERED ( provider_id ) ; - - - -/************************ - -Standardized health economics - -************************/ - - -ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY NONCLUSTERED ( payer_plan_period_id ) ; - -ALTER TABLE visit_cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY NONCLUSTERED ( visit_cost_id ) ; - -ALTER TABLE procedure_cost ADD CONSTRAINT xpk_procedure_cost PRIMARY KEY NONCLUSTERED ( procedure_cost_id ) ; - -ALTER TABLE drug_cost ADD CONSTRAINT xpk_drug_cost PRIMARY KEY NONCLUSTERED ( drug_cost_id ) ; - -ALTER TABLE device_cost ADD CONSTRAINT xpk_device_cost PRIMARY KEY NONCLUSTERED ( device_cost_id ) ; - - - -/************************ - -Standardized derived elements - -************************/ - -ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; - -ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ; - -ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY NONCLUSTERED ( drug_era_id ) ; - -ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY NONCLUSTERED ( dose_era_id ) ; - -ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY NONCLUSTERED ( condition_era_id ) ; - - - - - - - - -/************************ -************************* -************************* -************************* - -Foreign key constraints - -************************* -************************* -************************* -************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_domain FOREIGN KEY (domain_id) REFERENCES domain (domain_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_class FOREIGN KEY (concept_class_id) REFERENCES concept_class (concept_class_id); - -ALTER TABLE concept ADD CONSTRAINT fpk_concept_vocabulary FOREIGN KEY (vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE vocabulary ADD CONSTRAINT fpk_vocabulary_concept FOREIGN KEY (vocabulary_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE domain ADD CONSTRAINT fpk_domain_concept FOREIGN KEY (domain_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_class ADD CONSTRAINT fpk_concept_class_concept FOREIGN KEY (concept_class_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_1 FOREIGN KEY (concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_2 FOREIGN KEY (concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_id FOREIGN KEY (relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_concept FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (reverse_relationship_id) REFERENCES relationship (relationship_id); - -ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_2 FOREIGN KEY (descendant_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_1 FOREIGN KEY (source_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_2 FOREIGN KEY (target_vocabulary_id) REFERENCES vocabulary (vocabulary_id); - -ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_c_1 FOREIGN KEY (target_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_1 FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_2 FOREIGN KEY (ingredient_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_1 FOREIGN KEY (amount_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (numerator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept FOREIGN KEY (race_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept FOREIGN KEY (ethnicity_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept_s FOREIGN KEY (race_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept_s FOREIGN KEY (ethnicity_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE person ADD CONSTRAINT fpk_person_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_concept FOREIGN KEY (period_type_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_concept FOREIGN KEY (specimen_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_type_concept FOREIGN KEY (specimen_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anatomic_site_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept FOREIGN KEY (procedure_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_type_concept FOREIGN KEY (procedure_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_modifier FOREIGN KEY (modifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept_s FOREIGN KEY (procedure_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_type_concept FOREIGN KEY (drug_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_route_concept FOREIGN KEY (route_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_dose_unit_concept FOREIGN KEY (dose_unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept_s FOREIGN KEY (drug_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept FOREIGN KEY (device_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_type_concept FOREIGN KEY (device_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept_s FOREIGN KEY (device_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_type_concept FOREIGN KEY (condition_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept_s FOREIGN KEY (condition_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept FOREIGN KEY (measurement_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_type_concept FOREIGN KEY (measurement_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_operator FOREIGN KEY (operator_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept_s FOREIGN KEY (measurement_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE note ADD CONSTRAINT fpk_note_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_type_concept FOREIGN KEY (note_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE note ADD CONSTRAINT fpk_note_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept FOREIGN KEY (observation_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_type_concept FOREIGN KEY (observation_type_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_qualifier FOREIGN KEY (qualifier_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_2 FOREIGN KEY (domain_concept_id_2) REFERENCES concept (concept_id); - -ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_relationship FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id); - - - -/************************ - -Standardized health system data - -************************/ - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_location FOREIGN KEY (location_id) REFERENCES location (location_id); - -ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_place FOREIGN KEY (place_of_service_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty FOREIGN KEY (specialty_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specialty_source_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id); - - - - -/************************ - -Standardized health economics - -************************/ - -ALTER TABLE payer_plan_period ADD CONSTRAINT fpk_payer_plan_period FOREIGN KEY (person_id) REFERENCES person (person_id); - - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_id FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE visit_cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_id FOREIGN KEY (procedure_occurrence_id) REFERENCES procedure_occurrence (procedure_occurrence_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - -ALTER TABLE procedure_cost ADD CONSTRAINT fpk_procedure_cost_revenue FOREIGN KEY (revenue_code_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_id FOREIGN KEY (drug_exposure_id) REFERENCES drug_exposure (drug_exposure_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE drug_cost ADD CONSTRAINT fpk_drug_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_id FOREIGN KEY (device_exposure_id) REFERENCES device_exposure (device_exposure_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE device_cost ADD CONSTRAINT fpk_device_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id); - - - - - - -/************************ - -Standardized derived elements - -************************/ - - -ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id); - -ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id); - -ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (person_id) REFERENCES person (person_id); - -ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id); - diff --git a/Sql Server/OMOP CDM ddl - SQL Server.sql b/Sql Server/OMOP CDM ddl - SQL Server.sql deleted file mode 100644 index fdb4855..0000000 --- a/Sql Server/OMOP CDM ddl - SQL Server.sql +++ /dev/null @@ -1,738 +0,0 @@ -/********************************************************************************* -# Copyright 2014-6 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -script to create OMOP common data model, version 5.0 for SQL Server database - -last revised: 1-May-2016 - -Authors: Patrick Ryan, Christian Reich - - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - - -CREATE 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 TABLE vocabulary ( - vocabulary_id VARCHAR(20) NOT NULL, - vocabulary_name VARCHAR(255) NOT NULL, - vocabulary_reference VARCHAR(255) NULL, - vocabulary_version VARCHAR(255) NULL, - vocabulary_concept_id INTEGER NOT NULL -) -; - - - - -CREATE TABLE domain ( - domain_id VARCHAR(20) NOT NULL, - domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL -) -; - - - -CREATE 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 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 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 TABLE concept_synonym ( - concept_id INTEGER NOT NULL, - concept_synonym_name VARCHAR(1000) NOT NULL, - language_concept_id INTEGER NOT NULL -) -; - - -CREATE 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 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 TABLE drug_strength ( - drug_concept_id INTEGER NOT NULL, - ingredient_concept_id INTEGER NOT NULL, - amount_value FLOAT NULL, - amount_unit_concept_id INTEGER NULL, - numerator_value FLOAT NULL, - numerator_unit_concept_id INTEGER NULL, - denominator_value FLOAT 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 TABLE cohort_definition ( - cohort_definition_id INTEGER NOT NULL, - cohort_definition_name VARCHAR(255) NOT NULL, - cohort_definition_description VARCHAR(MAX) NULL, - definition_type_concept_id INTEGER NOT NULL, - cohort_definition_syntax VARCHAR(MAX) NULL, - subject_concept_id INTEGER NOT NULL, - cohort_initiation_date DATE NULL -) -; - - -CREATE TABLE attribute_definition ( - attribute_definition_id INTEGER NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_description VARCHAR(MAX) NULL, - attribute_type_concept_id INTEGER NOT NULL, - attribute_syntax VARCHAR(MAX) NULL -) -; - - -/************************** - -Standardized meta-data - -***************************/ - - -CREATE TABLE cdm_source - ( - cdm_source_name VARCHAR(255) NOT NULL, - cdm_source_abbreviation VARCHAR(25) NULL, - cdm_holder VARCHAR(255) NULL, - source_description VARCHAR(MAX) 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 - ) -; - - - - - - - -/************************ - -Standardized clinical data - -************************/ - - -CREATE 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, - time_of_birth VARCHAR(10) 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 - ) -; - - - - - -CREATE 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 - ) -; - - - -CREATE 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_time VARCHAR(10) NULL , - quantity FLOAT 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 - ) -; - - - -CREATE TABLE death - ( - person_id INTEGER NOT NULL , - death_date DATE NOT 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 - ) -; - - - -CREATE 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_time VARCHAR(10) NULL , - visit_end_date DATE NOT NULL , - visit_end_time VARCHAR(10) 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 - ) -; - - - -CREATE 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_type_concept_id INTEGER NOT NULL , - modifier_concept_id INTEGER NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , - procedure_source_concept_id INTEGER NULL , - qualifier_source_value VARCHAR(50) NULL - ) -; - - - -CREATE 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_end_date DATE NULL , - drug_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - refills INTEGER NULL , - quantity FLOAT NULL , - days_supply INTEGER NULL , - sig VARCHAR(MAX) NULL , - route_concept_id INTEGER NULL , - effective_drug_dose FLOAT NULL , - dose_unit_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_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 - ) -; - - -CREATE 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_end_date DATE 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 , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL - ) -; - - -CREATE 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_end_date DATE NULL , - condition_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL - ) -; - - - -CREATE TABLE measurement - ( - measurement_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NOT NULL , - measurement_time VARCHAR(10) NULL , - measurement_type_concept_id INTEGER NOT NULL , - operator_concept_id INTEGER NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL , - unit_concept_id INTEGER NULL , - range_low FLOAT NULL , - range_high FLOAT NULL , - provider_id INTEGER NULL , - visit_occurrence_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 - ) -; - - - -CREATE TABLE note - ( - note_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - note_date DATE NOT NULL , - note_time VARCHAR(10) NULL , - note_type_concept_id INTEGER NOT NULL , - note_text VARCHAR(MAX) NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - note_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE observation - ( - observation_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NOT NULL , - observation_time VARCHAR(10) NULL , - observation_type_concept_id INTEGER NOT NULL , - value_as_number FLOAT 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 , - 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 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 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 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 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 - -************************/ - - -CREATE 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_source_value VARCHAR (50) NULL , - plan_source_value VARCHAR (50) NULL , - family_source_value VARCHAR (50) NULL - ) -; - - -/* The individual cost tables are being phased out and will disappear - -CREATE TABLE visit_cost - ( - visit_cost_id INTEGER NOT NULL , - visit_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE procedure_cost - ( - procedure_cost_id INTEGER NOT NULL , - procedure_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - revenue_code_concept_id INTEGER NULL , - payer_plan_period_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE drug_cost - ( - drug_cost_id INTEGER NOT NULL , - drug_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - ingredient_cost FLOAT NULL , - dispensing_fee FLOAT NULL , - average_wholesale_price FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE device_cost - ( - device_cost_id INTEGER NOT NULL , - device_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; -*/ - - -CREATE 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 FLOAT NULL , - total_cost FLOAT NULL , - total_paid FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_patient FLOAT NULL , - paid_patient_copay FLOAT NULL , - paid_patient_coinsurance FLOAT NULL , - paid_patient_deductible FLOAT NULL , - paid_by_primary FLOAT NULL , - paid_ingredient_cost FLOAT NULL , - paid_dispensing_fee FLOAT NULL , - payer_plan_period_id INTEGER NULL , - amount_allowed FLOAT NULL , - revenue_code_concept_id INTEGER NULL , - reveue_code_source_value VARCHAR(50) NULL - ) -; - - - - - -/************************ - -Standardized derived elements - -************************/ - -CREATE 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 - ) -; - - -CREATE TABLE cohort_attribute - ( - cohort_definition_id INTEGER NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - subject_id INTEGER NOT NULL , - attribute_definition_id INTEGER NOT NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL - ) -; - - - - -CREATE 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 - ) -; - - -CREATE 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 FLOAT NOT NULL , - dose_era_start_date DATE NOT NULL , - dose_era_end_date DATE NOT NULL - ) -; - - - - -CREATE 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/Sql Server/OMOP CDM indexes required - SQL Server.sql b/Sql Server/OMOP CDM indexes required - SQL Server.sql deleted file mode 100644 index f701dba..0000000 --- a/Sql Server/OMOP CDM indexes required - SQL Server.sql +++ /dev/null @@ -1,187 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### ### - # # ## ## # # # # # # # # ## ## # # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### # # ##### ###### # # ###### #### - - -script to create the required indexes within OMOP common data model, version 5.0 for SQL Server database - -last revised: 12 Oct 2014 - -author: Patrick Ryan - -description: These indices are considered a minimal requirement to ensure adequate performance of analyses. - -*************************/ - - -/************************ - -Standardized vocabulary - -************************/ - -CREATE UNIQUE CLUSTERED INDEX idx_concept_concept_id ON concept (concept_id ASC); -CREATE INDEX idx_concept_code ON concept (concept_code ASC); -CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC); -CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC); -CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC); - -CREATE UNIQUE CLUSTERED INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC); - -CREATE UNIQUE CLUSTERED INDEX idx_domain_domain_id ON domain (domain_id ASC); - -CREATE UNIQUE CLUSTERED INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC); - -CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC); -CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC); -CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC); - -CREATE UNIQUE CLUSTERED INDEX idx_relationship_rel_id ON relationship (relationship_id ASC); - -CREATE CLUSTERED INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC); - -CREATE CLUSTERED INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC); -CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC); - -CREATE CLUSTERED INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC); -CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC); -CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC); - -CREATE CLUSTERED INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC); -CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC); - -CREATE CLUSTERED INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); - -CREATE CLUSTERED INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC); - - -/************************** - -Standardized meta-data - -***************************/ - - - - - -/************************ - -Standardized clinical data - -************************/ - -CREATE UNIQUE CLUSTERED INDEX idx_person_id ON person (person_id ASC); - -CREATE CLUSTERED INDEX idx_observation_period_id ON observation_period (person_id ASC); - -CREATE CLUSTERED INDEX idx_specimen_person_id ON specimen (person_id ASC); -CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC); - -CREATE CLUSTERED INDEX idx_death_person_id ON death (person_id ASC); - -CREATE CLUSTERED INDEX idx_visit_person_id ON visit_occurrence (person_id ASC); -CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC); - -CREATE CLUSTERED INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC); -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 CLUSTERED INDEX idx_drug_person_id ON drug_exposure (person_id ASC); -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 CLUSTERED INDEX idx_device_person_id ON device_exposure (person_id ASC); -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 CLUSTERED INDEX idx_condition_person_id ON condition_occurrence (person_id ASC); -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 CLUSTERED INDEX idx_measurement_person_id ON measurement (person_id ASC); -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 CLUSTERED INDEX idx_note_person_id ON note (person_id ASC); -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 CLUSTERED INDEX idx_observation_person_id ON observation (person_id ASC); -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_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 CLUSTERED INDEX idx_period_person_id ON payer_plan_period (person_id ASC); - - - - - -/************************ - -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 CLUSTERED INDEX idx_drug_era_person_id ON drug_era (person_id ASC); -CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC); - -CREATE CLUSTERED INDEX idx_dose_era_person_id ON dose_era (person_id ASC); -CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC); - -CREATE CLUSTERED INDEX idx_condition_era_person_id ON condition_era (person_id ASC); -CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC); - diff --git a/Sql Server/README.md b/Sql Server/README.md deleted file mode 100644 index 4e09011..0000000 --- a/Sql Server/README.md +++ /dev/null @@ -1,18 +0,0 @@ -Common-Data-Model / SQL Server -================= - -This folder contains the SQL scripts for SQL Server. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `OMOP CDM ddl - SQL Server.sql` to create the tables and fields. - -3. Load your data into the schema. - -4. Execute the script `OMOP CDM constraints - SQL Server.sql` to add the constraints (primary and foreign keys). - -5. Execute the script `OMOP CDM indexes required - SQL Server.sql` to add the minimum set of indexes we recommend. - -Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably. diff --git a/Sql Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql b/Sql Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql deleted file mode 100644 index 59108c1..0000000 --- a/Sql Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql +++ /dev/null @@ -1,142 +0,0 @@ -/********************************************************************************* -# 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, -# 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -Script to load the common data model, version 5.0 vocabulary tables for SQL Server database - -Notes - -1) There is no data file load for the SOURCE_TO_CONCEPT_MAP table because that table is deprecated in CDM version 5.0 -2) This script assumes the CDM version 5 vocabulary zip file has been unzipped into the "C:\CDMV5Vocabulary" directory. -3) If you unzipped your CDM version 5 vocabulary files into a different directory then replace all file paths below, with your directory path. -4) Run this SQL query script in the database where you created your CDM Version 5 tables - -last revised: 26 Nov 2014 - -author: Lee Evans - - -*************************/ - -TRUNCATE TABLE DRUG_STRENGTH; -BULK INSERT DRUG_STRENGTH -FROM 'C:\CDMV5VOCAB\DRUG_STRENGTH.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\DRUG_STRENGTH.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT; -BULK INSERT CONCEPT -FROM 'C:\CDMV5VOCAB\CONCEPT.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\CONCEPT.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_RELATIONSHIP; -BULK INSERT CONCEPT_RELATIONSHIP -FROM 'C:\CDMV5VOCAB\CONCEPT_RELATIONSHIP.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\CONCEPT_RELATIONSHIP.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_ANCESTOR; -BULK INSERT CONCEPT_ANCESTOR -FROM 'C:\CDMV5VOCAB\CONCEPT_ANCESTOR.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\CONCEPT_ANCESTOR.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_SYNONYM; -BULK INSERT CONCEPT_SYNONYM -FROM 'C:\CDMV5VOCAB\CONCEPT_SYNONYM.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\CONCEPT_SYNONYM.bad', -TABLOCK -); - -TRUNCATE TABLE VOCABULARY; -BULK INSERT VOCABULARY -FROM 'C:\CDMV5VOCAB\VOCABULARY.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\VOCABULARY.bad', -TABLOCK -); - -TRUNCATE TABLE RELATIONSHIP; -BULK INSERT RELATIONSHIP -FROM 'C:\CDMV5VOCAB\RELATIONSHIP.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\RELATIONSHIP.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_CLASS; -BULK INSERT CONCEPT_CLASS -FROM 'C:\CDMV5VOCAB\CONCEPT_CLASS.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\CONCEPT_CLASS.bad', -TABLOCK -); - -TRUNCATE TABLE DOMAIN; -BULK INSERT DOMAIN -FROM 'C:\CDMV5VOCAB\DOMAIN.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDMV5VOCAB\DOMAIN.bad', -TABLOCK -); diff --git a/Version4/Oracle/CDM V4 DDL.sql b/Version4/Oracle/CDM V4 DDL.sql deleted file mode 100644 index 5c4b794..0000000 --- a/Version4/Oracle/CDM V4 DDL.sql +++ /dev/null @@ -1,310 +0,0 @@ -/********************************************************************************* -# Copyright 2015 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.4 -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ## ####### - # # ## ## # # # # # # # # ## ## # # # # # - # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ####### ####### - # # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## # # ##### - - -script to create OMOP common data model, version 5.0 for Oracle database - -last revised: 1 Mar 2015 - -author: Christian Reich - - -*************************/ - -CREATE TABLE concept -( - concept_id INTEGER NOT NULL, - concept_name VARCHAR2(256 BYTE) NOT NULL, - concept_level NUMBER NOT NULL, - concept_class VARCHAR2(60 BYTE) NOT NULL, - vocabulary_id INTEGER NOT NULL, - concept_code VARCHAR2(40 BYTE) NOT NULL, - valid_start_date DATE NOT NULL, - valid_end_date DATE DEFAULT '31-Dec-2099' NOT NULL, - invalid_reason CHAR(1 BYTE) -) NOLOGGING; - -COMMENT ON TABLE concept IS 'A list of all valid terminology concepts across domains and their attributes. Concepts are derived from existing standards.'; - -COMMENT ON COLUMN concept.concept_id IS 'A system-generated identifier to uniquely identify each concept across all concept types.'; - -COMMENT ON COLUMN concept.concept_name IS 'An unambiguous, meaningful and descriptive name for the concept.'; - -COMMENT ON COLUMN concept.concept_level IS 'The level of hierarchy associated with the concept. Different concept levels are assigned to concepts to depict their seniority in a clearly defined hierarchy, such as drugs, conditions, etc. A concept level of 0 is assigned to concepts that are not part of a standard vocabulary, but are part of the vocabulary for reference purposes (e.g. drug form).'; - -COMMENT ON COLUMN concept.concept_class IS 'The category or class of the concept along both the hierarchical tree as well as different domains within a vocabulary. Examples are ''Clinical Drug'', ''Ingredient'', ''Clinical Finding'' etc.'; - -COMMENT ON COLUMN concept.vocabulary_id IS 'A foreign key to the vocabulary table indicating from which source the concept has been adapted.'; - -COMMENT ON COLUMN concept.concept_code IS 'The concept code represents the identifier of the concept in the source data it originates from, such as SNOMED-CT concept IDs, RxNorm RXCUIs etc. Note that concept codes are not unique across vocabularies.'; - -COMMENT ON COLUMN concept.valid_start_date IS 'The date when the was first recorded.'; - -COMMENT ON COLUMN concept.valid_end_date IS 'The date when the concept became invalid because it was deleted or superseded (updated) by a new concept. The default value is 31-Dec-2099.'; - -COMMENT ON COLUMN concept.invalid_reason IS 'Concepts that are replaced with a new concept are designated "Updated" (U) and concepts that are removed without replacement are "Deprecated" (D).'; - -CREATE INDEX concept_code ON concept (concept_code, vocabulary_id); -CREATE UNIQUE INDEX XPKconcept ON concept (concept_id); - -ALTER TABLE concept ADD ( - CHECK ( invalid_reason IN ('D', 'U')) - ENABLE VALIDATE, - CONSTRAINT XPKCONCEPT - PRIMARY KEY - (concept_id) - USING INDEX XPKCONCEPT - ENABLE VALIDATE); - ---add table RELATIONSHIP - -CREATE TABLE relationship -( - relationship_id INTEGER NOT NULL, - relationship_name VARCHAR2(256 BYTE) NOT NULL, - is_hierarchical INTEGER NOT NULL, - defines_ancestry INTEGER DEFAULT 1 NOT NULL, - reverse_relationship INTEGER -) NOLOGGING; - -COMMENT ON TABLE relationship IS 'A list of relationship between concepts. Some of these relationships are generic (e.g. "Subsumes" relationship), others are domain-specific.'; - -COMMENT ON COLUMN relationship.relationship_id IS 'The type of relationship captured by the relationship record.'; - -COMMENT ON COLUMN relationship.relationship_name IS 'The text that describes the relationship type.'; - -COMMENT ON COLUMN relationship.is_hierarchical IS 'Defines whether a relationship defines concepts into classes or hierarchies. Values are Y for hierarchical relationship or NULL if not'; - -COMMENT ON COLUMN relationship.defines_ancestry IS 'Defines whether a hierarchical relationship contributes to the concept_ancestor table. These are subsets of the hierarchical relationships. Valid values are Y or NULL.'; - -COMMENT ON COLUMN relationship.reverse_relationship IS 'relationship ID of the reverse relationship to this one. Corresponding records of reverse relationships have their concept_id_1 and concept_id_2 swapped.'; - -CREATE UNIQUE INDEX XPKRELATIONHIP_TYPE ON relationship -(relationship_id); - -ALTER TABLE relationship ADD ( - CONSTRAINT xpkrelationship_type - PRIMARY KEY - (relationship_id) - USING INDEX xpkrelationship_type - ENABLE VALIDATE); - ---add table concept_relationship - -CREATE TABLE concept_relationship -( - concept_id_1 INTEGER NOT NULL, - concept_id_2 INTEGER NOT NULL, - relationship_id INTEGER NOT NULL, - valid_start_date DATE NOT NULL, - valid_end_date DATE DEFAULT '31-Dec-2099' NOT NULL, - invalid_reason CHAR(1 BYTE) -) NOLOGGING; - -COMMENT ON TABLE concept_relationship IS 'A list of relationship between concepts. Some of these relationships are generic (e.g. ''Subsumes'' relationship), others are domain-specific.'; - -COMMENT ON COLUMN concept_relationship.concept_id_1 IS 'A foreign key to the concept in the concept table associated with the relationship. relationships are directional, and this field represents the source concept designation.'; - -COMMENT ON COLUMN concept_relationship.concept_id_2 IS 'A foreign key to the concept in the concept table associated with the relationship. relationships are directional, and this field represents the destination concept designation.'; - -COMMENT ON COLUMN concept_relationship.relationship_id IS 'The type of relationship as defined in the relationship table.'; - -COMMENT ON COLUMN concept_relationship.valid_start_date IS 'The date when the the relationship was first recorded.'; - -COMMENT ON COLUMN concept_relationship.valid_end_date IS 'The date when the relationship became invalid because it was deleted or superseded (updated) by a new relationship. Default value is 31-Dec-2099.'; - -COMMENT ON COLUMN concept_relationship.invalid_reason IS 'Reason the relationship was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.'; - -CREATE UNIQUE INDEX xpkconcept_relationship ON concept_relationship -(concept_id_1, concept_id_2, relationship_id); - - -ALTER TABLE concept_relationship ADD ( - CHECK ( invalid_reason IN ('D', 'U')) - ENABLE VALIDATE, - CHECK ( invalid_reason IN ('D', 'U')) - ENABLE VALIDATE, - CHECK (invalid_reason in ('D', 'U')) - ENABLE VALIDATE, - CONSTRAINT xpkconcept_relationship - PRIMARY KEY - (concept_id_1, concept_id_2, relationship_id) - USING INDEX xpkconcept_relationship - ENABLE VALIDATE); - - -ALTER TABLE concept_relationship ADD ( - CONSTRAINT concept_REL_CHILD_FK - FOREIGN KEY (concept_id_2) - REFERENCES concept (concept_id) - ENABLE VALIDATE, - CONSTRAINT concept_REL_PARENT_FK - FOREIGN KEY (concept_id_1) - REFERENCES concept (concept_id) - ENABLE VALIDATE, - CONSTRAINT concept_REL_REL_type_FK - FOREIGN KEY (relationship_id) - REFERENCES relationship (relationship_id) - ENABLE VALIDATE); - ---add table concept_ancestor - -CREATE TABLE concept_ancestor -( - ancestor_concept_id INTEGER NOT NULL, - descendant_concept_id INTEGER NOT NULL, - max_levels_of_separation NUMBER, - min_levels_of_separation NUMBER -) NOLOGGING; - -COMMENT ON TABLE concept_ancestor IS 'A specialized table containing only hierarchical relationship between concepts that may span several generations.'; - -COMMENT ON COLUMN concept_ancestor.ancestor_concept_id IS 'A foreign key to the concept code in the concept table for the higher-level concept that forms the ancestor in the relationship.'; - -COMMENT ON COLUMN concept_ancestor.descendant_concept_id IS 'A foreign key to the concept code in the concept table for the lower-level concept that forms the descendant in the relationship.'; - -COMMENT ON COLUMN concept_ancestor.max_levels_of_separation IS 'The maximum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an optional attribute that is used to simplify hierarchic analysis. '; - -COMMENT ON COLUMN concept_ancestor.min_levels_of_separation IS 'The minimum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an optional attribute that is used to simplify hierarchic analysis.'; - -CREATE UNIQUE INDEX xpkconcept_ancestor ON concept_ancestor -(ancestor_concept_id, descendant_concept_id); - -ALTER TABLE concept_ancestor ADD ( - CONSTRAINT xpkconcept_ancestor - PRIMARY KEY - (ancestor_concept_id, descendant_concept_id) - USING INDEX xpkconcept_ancestor - ENABLE VALIDATE); - -ALTER TABLE concept_ancestor ADD ( - CONSTRAINT concept_ancestor_FK - FOREIGN KEY (ancestor_concept_id) - REFERENCES concept (concept_id) - ENABLE VALIDATE, - CONSTRAINT concept_descendant_FK - FOREIGN KEY (descendant_concept_id) - REFERENCES concept (concept_id) - ENABLE VALIDATE); - ---add table concept_synonym - -CREATE TABLE concept_synonym -( - concept_synonym_id INTEGER NOT NULL, - concept_id INTEGER NOT NULL, - concept_synonym_name VARCHAR2(1000 BYTE) NOT NULL -) NOLOGGING; - -COMMENT ON TABLE concept_synonym IS 'A table with synonyms for concepts that have more than one valid name or description.'; - -COMMENT ON COLUMN concept_synonym.concept_synonym_id IS 'A system-generated unique identifier for each concept synonym.'; - -COMMENT ON COLUMN concept_synonym.concept_id IS 'A foreign key to the concept in the concept table. '; - -COMMENT ON COLUMN concept_synonym.concept_synonym_name IS 'The alternative name for the concept.'; - -CREATE UNIQUE INDEX xpkconcept_synonym ON concept_synonym -(concept_synonym_id); - -ALTER TABLE concept_synonym ADD ( - CONSTRAINT xpkconcept_synonym - PRIMARY KEY - (concept_synonym_id) - USING INDEX xpkconcept_synonym - ENABLE VALIDATE); - -ALTER TABLE concept_synonym ADD ( - CONSTRAINT concept_synonym_concept_FK - FOREIGN KEY (concept_id) - REFERENCES concept (concept_id) - ENABLE VALIDATE); - ---add table source_to_concept_map - -CREATE TABLE source_to_concept_map -( - source_code VARCHAR2(40 BYTE) NOT NULL, - source_vocabulary_id INTEGER NOT NULL, - source_code_description VARCHAR2(256 BYTE), - target_concept_id INTEGER NOT NULL, - target_vocabulary_id INTEGER NOT NULL, - mapping_type VARCHAR2(256 BYTE), - primary_map CHAR(1 BYTE), - valid_start_date DATE NOT NULL, - valid_end_date DATE NOT NULL, - invalid_reason CHAR(1 BYTE) -) NOLOGGING; - -CREATE INDEX SOURCE_TO_concept_SOURCE_idX ON source_to_concept_map -(SOURCE_CODE); - -CREATE UNIQUE INDEX xpksource_to_concept_map ON source_to_concept_map -(SOURCE_vocabulary_id, TARGET_concept_id, SOURCE_CODE, valid_end_date); - -ALTER TABLE source_to_concept_map ADD ( - CHECK (primary_map in ('Y')) - ENABLE VALIDATE, - CHECK (invalid_reason in ('D', 'U')) - ENABLE VALIDATE, - CONSTRAINT xpksource_to_concept_map - PRIMARY KEY - (SOURCE_vocabulary_id, TARGET_concept_id, SOURCE_CODE, valid_end_date) - USING INDEX xpksource_to_concept_map - ENABLE VALIDATE); - -ALTER TABLE source_to_concept_map ADD ( - CONSTRAINT SOURCE_TO_concept_concept - FOREIGN KEY (TARGET_concept_id) - REFERENCES concept (concept_id) - ENABLE VALIDATE); - ---add table drug_strength - -CREATE TABLE drug_strength -( - drug_concept_id INTEGER NOT NULL, - ingredient_concept_id INTEGER NOT NULL, - amount_value NUMBER, - amount_unit VARCHAR2 (60 BYTE), - concentration_value NUMBER, - concentration_enum_unit VARCHAR2 (60 BYTE), - concentration_denom_unit VARCHAR2 (60 BYTE), - valid_start_date DATE NOT NULL, - valid_end_date DATE NOT NULL, - invalid_reason VARCHAR2 (1 BYTE) -); - ---add table vocabulary - -CREATE TABLE VOCABULARY -( - VOCABULARY_ID INTEGER NOT NULL, - VOCABULARY_NAME VARCHAR2 (256 BYTE) NOT NULL -); - - \ No newline at end of file diff --git a/Version4/Oracle/README.md b/Version4/Oracle/README.md deleted file mode 100644 index 4b362b0..0000000 --- a/Version4/Oracle/README.md +++ /dev/null @@ -1,14 +0,0 @@ -Common-Data-Model / Oracle -================= - -This folder contains the SQL scripts for Oracle. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `CDM V4 ddl.sql` to create the tables and fields. - -3. Load your data into the schema using the loading scripts in VocabImport - -Note: you could also apply the constraints and the indexes after loading the data, this will speed up the insertion of the data considerably. diff --git a/Version4/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat b/Version4/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat deleted file mode 100644 index 5d621d5..0000000 --- a/Version4/Oracle/VocabImport/OMOP CDM vocabulary load - Oracle.bat +++ /dev/null @@ -1,51 +0,0 @@ -/********************************************************************************* -# Copyright 2015 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.4 -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ## ####### - # # ## ## # # # # # # # # ## ## # # # # # - # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ####### ####### - # # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## # # ##### - - -script to load the Vocabulary related tables in the OMOP common data model, version 4.5 for Oracle database - -last revised: 19 Mar 2015 - -author: Lee Evans - -Notes - -1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory. -2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path. -3) If you have existing data in your CDM vocabulary tables then backup that data (if needed) and truncate those tables before loading - - -*************************/ - -sqlldr CDM/ CONTROL=CONCEPT.ctl LOG=C:\CDM\CONCEPT.log BAD=C:\CDM\CONCEPT.bad -sqlldr CDM/ CONTROL=CONCEPT_ANCESTOR.ctl LOG=C:\CDM\CONCEPT_ANCESTOR.log BAD=C:\CDM\CONCEPT_ANCESTOR.bad -sqlldr CDM/ CONTROL=CONCEPT_RELATIONSHIP.ctl LOG=C:\CDM\CONCEPT_RELATIONSHIP.log BAD=C:\CDM\CONCEPT_RELATIONSHIP.bad -sqlldr CDM/ CONTROL=CONCEPT_SYNONYM.ctl LOG=C:\CDM\CONCEPT_SYNONYM.log BAD=C:\CDM\CONCEPT_SYNONYM.bad -sqlldr CDM/ CONTROL=DRUG_STRENGTH.ctl LOG=C:\CDM\DRUG_STRENGTH.log BAD=C:\CDM\DRUG_STRENGTH.bad -sqlldr CDM/ CONTROL=RELATIONSHIP.ctl LOG=C:\CDM\RELATIONSHIP.log BAD=C:\CDM\RELATIONSHIP.bad -sqlldr CDM/ CONTROL=VOCABULARY.ctl LOG=C:\CDM\VOCABULARY.log BAD=C:\CDM\VOCABULARY.bad -sqlldr CDM/ CONTROL=SOURCE_TO_CONCEPT_MAP.ctl LOG=C:\CDM\SOURCE_TO_CONCEPT_MAP.log BAD=C:\CDM\SOURCE_TO_CONCEPT_MAP.bad diff --git a/Version4/Oracle/VocabImport/concept.ctl b/Version4/Oracle/VocabImport/concept.ctl deleted file mode 100644 index d18106a..0000000 --- a/Version4/Oracle/VocabImport/concept.ctl +++ /dev/null @@ -1,18 +0,0 @@ -options (skip=1) -load data -infile concept.csv -into table concept -replace -fields terminated by '\t' -trailing nullcols -( - concept_id, - concept_name CHAR(256), - concept_level, - concept_class, - vocabulary_id, - concept_code, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/concept_ancestor.ctl b/Version4/Oracle/VocabImport/concept_ancestor.ctl deleted file mode 100644 index 350015a..0000000 --- a/Version4/Oracle/VocabImport/concept_ancestor.ctl +++ /dev/null @@ -1,13 +0,0 @@ -options (skip=1) -load data -infile concept_ancestor.csv -into table concept_ancestor -replace -fields terminated by '\t' -trailing nullcols -( - ancestor_concept_id, - descendant_concept_id, - min_levels_of_separation, - max_levels_of_separation -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/concept_relationship.ctl b/Version4/Oracle/VocabImport/concept_relationship.ctl deleted file mode 100644 index d26ce3e..0000000 --- a/Version4/Oracle/VocabImport/concept_relationship.ctl +++ /dev/null @@ -1,15 +0,0 @@ -options (skip=1) -load data -infile concept_relationship.csv -into table concept_relationship -replace -fields terminated by '\t' -trailing nullcols -( - concept_id_1, - concept_id_2, - relationship_id, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/concept_synonym.ctl b/Version4/Oracle/VocabImport/concept_synonym.ctl deleted file mode 100644 index a7ef6fa..0000000 --- a/Version4/Oracle/VocabImport/concept_synonym.ctl +++ /dev/null @@ -1,12 +0,0 @@ -options (skip=1) -load data -infile concept_synonym.csv -into table concept_synonym -replace -fields terminated by '\t' -trailing nullcols -( - concept_synonym_id, - concept_id, - concept_synonym_name CHAR(1000) -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/drug_strength.ctl b/Version4/Oracle/VocabImport/drug_strength.ctl deleted file mode 100644 index dc858c3..0000000 --- a/Version4/Oracle/VocabImport/drug_strength.ctl +++ /dev/null @@ -1,19 +0,0 @@ -options (skip=1) -load data -infile drug_strength.csv -into table drug_strength -replace -fields terminated by '\t' -trailing nullcols -( - drug_concept_id, - ingredient_concept_id, - amount_value, - amount_unit, - concentration_value, - concentration_enum_unit, - concentration_denom_unit, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/relationship.ctl b/Version4/Oracle/VocabImport/relationship.ctl deleted file mode 100644 index 40daf29..0000000 --- a/Version4/Oracle/VocabImport/relationship.ctl +++ /dev/null @@ -1,14 +0,0 @@ -options (skip=1) -load data -infile relationship.csv -into table relationship -replace -fields terminated by '\t' -trailing nullcols -( - relationship_id, - relationship_name, - is_hierarchical, - defines_ancestry, - reverse_relationship -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/source_to_concept_map.ctl b/Version4/Oracle/VocabImport/source_to_concept_map.ctl deleted file mode 100644 index d9e0ef0..0000000 --- a/Version4/Oracle/VocabImport/source_to_concept_map.ctl +++ /dev/null @@ -1,19 +0,0 @@ -options (skip=1) -load data -infile source_to_concept_map.csv -into table source_to_concept_map -replace -fields terminated by '\t' -trailing nullcols -( - source_code, - source_vocabulary_id, - source_code_description CHAR(256), - target_concept_id, - target_vocabulary_id, - mapping_type, - primary_map, - valid_start_date DATE 'YYYYMMDD', - valid_end_date DATE 'YYYYMMDD', - invalid_reason -) \ No newline at end of file diff --git a/Version4/Oracle/VocabImport/vocabulary.ctl b/Version4/Oracle/VocabImport/vocabulary.ctl deleted file mode 100644 index 3f80f25..0000000 --- a/Version4/Oracle/VocabImport/vocabulary.ctl +++ /dev/null @@ -1,11 +0,0 @@ -options (skip=1) -load data -infile vocabulary.csv -into table vocabulary -replace -fields terminated by '\t' -trailing nullcols -( - vocabulary_id, - vocabulary_name -) \ No newline at end of file diff --git a/Version4/PostgreSQL/CDM V4 DDL.sql b/Version4/PostgreSQL/CDM V4 DDL.sql deleted file mode 100644 index 8586422..0000000 --- a/Version4/PostgreSQL/CDM V4 DDL.sql +++ /dev/null @@ -1,131 +0,0 @@ - -/********************************************************************************* -# Copyright 2015 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.4 -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ## ####### - # # ## ## # # # # # # # # ## ## # # # # # - # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ####### ####### - # # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## # # ##### - - -script to create OMOP common data model, version 4.5 for PostgreSQL database - -last revised: 20 Mar 2015 - -author: Lee Evans - - -*************************/ - -CREATE TABLE concept ( - concept_id integer NOT NULL, - concept_name varchar(256) NOT NULL, - concept_level integer NOT NULL, - concept_class varchar(60) NOT NULL, - vocabulary_id integer NOT NULL, - concept_code varchar(40) NOT NULL, - valid_start_date date NOT NULL, - valid_end_date date NOT NULL DEFAULT '2099-12-31'::date, - invalid_reason varchar(1) -) -; - - -CREATE 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 TABLE concept_relationship ( - concept_id_1 integer NOT NULL, - concept_id_2 integer NOT NULL, - relationship_id integer NOT NULL, - valid_start_date date NOT NULL, - valid_end_date date NOT NULL DEFAULT '2099-12-31'::date, - invalid_reason varchar(1) -) -; - - -CREATE TABLE concept_synonym ( - concept_synonym_id integer NOT NULL, - concept_id integer NOT NULL, - concept_synonym_name varchar(1000) NOT NULL -) -; - - - -CREATE TABLE drug_strength ( - drug_concept_id integer NOT NULL, - ingredient_concept_id integer NOT NULL, - amount_value double precision, - amount_unit varchar(60), - concentration_value double precision, - concentration_enum_unit character varying(60), - concentration_denom_unit character varying(60), - valid_start_date date NOT NULL, - valid_end_date date NOT NULL, - invalid_reason varchar(1) -) -; - - - - -CREATE TABLE relationship ( - relationship_id VARCHAR(20) NOT NULL, - relationship_name VARCHAR(256) NOT NULL, - is_hierarchical integer NOT NULL, - defines_ancestry integer DEFAULT 1, - reverse_relationship integer -) -; - - - -CREATE TABLE source_to_concept_map ( - source_code VARCHAR(40) NOT NULL, - source_vocabulary_id INTEGER NOT NULL, - source_code_description VARCHAR(256), - target_concept_id INTEGER NOT NULL, - target_vocabulary_id INTEGER NOT NULL, - mapping_type VARCHAR(256), - primary_map VARCHAR(1), - valid_start_date DATE NOT NULL, - valid_end_date DATE NOT NULL, - invalid_reason VARCHAR(1) NULL -) -; - - - - -CREATE TABLE vocabulary ( - vocabulary_id integer NOT NULL, - vocabulary_name VARCHAR(256) NOT NULL -) -; diff --git a/Version4/PostgreSQL/README.md b/Version4/PostgreSQL/README.md deleted file mode 100644 index 7e4699b..0000000 --- a/Version4/PostgreSQL/README.md +++ /dev/null @@ -1,13 +0,0 @@ -Common-Data-Model / PostgreSQL -================= - -This folder contains the SQL scripts for PostgreSQL. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `CDM V4 ddl.sql` to create the tables and fields. - -3. Load your data into the schema. - diff --git a/Version4/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql b/Version4/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql deleted file mode 100644 index 238b003..0000000 --- a/Version4/PostgreSQL/VocabImport/OMOP CDM vocabulary load - PostgreSQL.sql +++ /dev/null @@ -1,54 +0,0 @@ -/********************************************************************************* -# Copyright 2015 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -Script to load the common data model, version 4.5 vocabulary tables for PostgreSQL database - -Notes - -1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory. -2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path. -3) Run this SQL query script in the database where you created your CDM Version 4.5 tables - -last revised: 20th March 2015 - -author: Lee Evans - - -*************************/ - -COPY CONCEPT FROM 'C:\CDM\CONCEPT.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY CONCEPT_ANCESTOR FROM 'C:\CDM\CONCEPT_ANCESTOR.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY CONCEPT_RELATIONSHIP FROM 'C:\CDM\CONCEPT_RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY CONCEPT_SYNONYM FROM 'C:\CDM\CONCEPT_SYNONYM.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY DRUG_STRENGTH FROM 'C:\CDM\DRUG_STRENGTH.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY RELATIONSHIP FROM 'C:\CDM\RELATIONSHIP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY SOURCE_TO_CONCEPT_MAP FROM 'C:\CDM\SOURCE_TO_CONCEPT_MAP.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; -COPY VOCABULARY FROM 'C:\CDM\VOCABULARY.csv' WITH DELIMITER E'\t' CSV HEADER QUOTE E'\b' ; - - - diff --git a/Version4/SQL Server/CDM V4 DDL.sql b/Version4/SQL Server/CDM V4 DDL.sql deleted file mode 100644 index 981cec8..0000000 --- a/Version4/SQL Server/CDM V4 DDL.sql +++ /dev/null @@ -1,117 +0,0 @@ -/********************************************************************************* -# Copyright 2015 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.4 -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ## ####### - # # ## ## # # # # # # # # ## ## # # # # # - # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ####### ####### - # # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## # # ##### - - -script to create OMOP common data model, version 4.5 for Sql Server database - -last revised: 20 Mar 2015 - -author: Lee Evans - - -*************************/ - - -CREATE TABLE CONCEPT( - CONCEPT_ID int NOT NULL, - CONCEPT_NAME varchar(256) NOT NULL, - CONCEPT_LEVEL int NOT NULL, - CONCEPT_CLASS varchar(60) NOT NULL, - VOCABULARY_ID int NOT NULL, - CONCEPT_CODE varchar(40) NOT NULL, - VALID_START_DATE date NOT NULL, - VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'), - INVALID_REASON char(1) NULL -); - - -CREATE TABLE CONCEPT_ANCESTOR( - ANCESTOR_CONCEPT_ID int NOT NULL, - DESCENDANT_CONCEPT_ID int NOT NULL, - MAX_LEVELS_OF_SEPARATION int NULL, - MIN_LEVELS_OF_SEPARATION int NULL -); - - -CREATE TABLE CONCEPT_RELATIONSHIP( - CONCEPT_ID_1 int NOT NULL, - CONCEPT_ID_2 int NOT NULL, - RELATIONSHIP_ID int NOT NULL, - VALID_START_DATE date NOT NULL, - VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'), - INVALID_REASON char(1) NULL -); - - -CREATE TABLE CONCEPT_SYNONYM( - CONCEPT_SYNONYM_ID int NOT NULL, - CONCEPT_ID int NOT NULL, - CONCEPT_SYNONYM_NAME varchar(1000) NOT NULL -); - - -CREATE TABLE DRUG_STRENGTH( - DRUG_CONCEPT_ID int NOT NULL, - INGREDIENT_CONCEPT_ID int NOT NULL, - AMOUNT_VALUE float NULL, - AMOUNT_UNIT varchar(60) NULL, - CONCENTRATION_VALUE float NULL, - CONCENTRATION_ENUM_UNIT varchar(60) NULL, - CONCENTRATION_DENOM_UNIT varchar(60) NULL, - VALID_START_DATE date NOT NULL, - VALID_END_DATE date NOT NULL, - INVALID_REASON varchar(1) NULL -); - - -CREATE TABLE RELATIONSHIP( - RELATIONSHIP_ID int NOT NULL, - RELATIONSHIP_NAME varchar(256) NOT NULL, - IS_HIERARCHICAL int NOT NULL, - DEFINES_ANCESTRY int NOT NULL DEFAULT ((1)), - REVERSE_RELATIONSHIP int NULL -); - - -CREATE TABLE SOURCE_TO_CONCEPT_MAP( - SOURCE_CODE varchar(40) NOT NULL, - SOURCE_VOCABULARY_ID int NOT NULL, - SOURCE_CODE_DESCRIPTION varchar(256) NULL, - TARGET_CONCEPT_ID int NOT NULL, - TARGET_VOCABULARY_ID int NOT NULL, - MAPPING_TYPE varchar(256) NULL, - PRIMARY_MAP char(1) NULL, - VALID_START_DATE date NOT NULL, - VALID_END_DATE date NOT NULL DEFAULT ('31-Dec-2099'), - INVALID_REASON char(1) NULL -); - - -CREATE TABLE VOCABULARY( - VOCABULARY_ID int NOT NULL, - VOCABULARY_NAME varchar(256) NOT NULL -); diff --git a/Version4/SQL Server/README.md b/Version4/SQL Server/README.md deleted file mode 100644 index 27af881..0000000 --- a/Version4/SQL Server/README.md +++ /dev/null @@ -1,14 +0,0 @@ -Common-Data-Model / SQL Server -================= - -This folder contains the SQL scripts for SQL Server. - -In order to create your instantiation of the Common Data Model, we recommend following these steps: - -1. Create an empty schema. - -2. Execute the script `CDM V4 ddl.sql` to create the tables and fields. - -3. Load your data into the schema using the loading scripts in VocabImport - -Note: you could also apply the constraints and the indexes after loading the data, this will speed up the insertion of the data considerably. diff --git a/Version4/SQL Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql b/Version4/SQL Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql deleted file mode 100644 index bc2218e..0000000 --- a/Version4/SQL Server/VocabImport/OMOP CDM vocabulary load - SQL Server.sql +++ /dev/null @@ -1,130 +0,0 @@ -/********************************************************************************* -# Copyright 2015 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. -********************************************************************************/ - -/************************ - - ####### # # ####### ###### ##### ###### # # ####### - # # ## ## # # # # # # # # ## ## # # # - # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### - # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### - - -Script to load the common data model, version 4.5 vocabulary tables for SQL Server database - -Notes - -1) This script assumes the CDM version 4.5 vocabulary zip file has been unzipped into the "C:\CDM" directory. -2) If you unzipped your CDM version 4.5 vocabulary files into a different directory then replace all file paths below, with your directory path. -3) Run this SQL query script in the database where you created your CDM Version 4.5 tables - -last revised: 20th March 2015 - -author: Lee Evans - - -*************************/ - -TRUNCATE TABLE CONCEPT; -BULK INSERT CONCEPT -FROM 'C:\CDM\CONCEPT.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\CONCEPT.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_ANCESTOR; -BULK INSERT CONCEPT_ANCESTOR -FROM 'C:\CDM\CONCEPT_ANCESTOR.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\CONCEPT_ANCESTOR.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_RELATIONSHIP; -BULK INSERT CONCEPT_RELATIONSHIP -FROM 'C:\CDM\CONCEPT_RELATIONSHIP.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\CONCEPT_RELATIONSHIP.bad', -TABLOCK -); - -TRUNCATE TABLE CONCEPT_SYNONYM; -BULK INSERT CONCEPT_SYNONYM -FROM 'C:\CDM\CONCEPT_SYNONYM.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\CONCEPT_SYNONYM.bad', -TABLOCK -); - -TRUNCATE TABLE DRUG_STRENGTH; -BULK INSERT DRUG_STRENGTH -FROM 'C:\CDM\DRUG_STRENGTH.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\DRUG_STRENGTH.bad', -TABLOCK -); - -TRUNCATE TABLE RELATIONSHIP; -BULK INSERT RELATIONSHIP -FROM 'C:\CDM\RELATIONSHIP.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\RELATIONSHIP.bad', -TABLOCK -); - -TRUNCATE TABLE SOURCE_TO_CONCEPT_MAP; -BULK INSERT SOURCE_TO_CONCEPT_MAP -FROM 'C:\CDM\SOURCE_TO_CONCEPT_MAP.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\SOURCE_TO_CONCEPT_MAP.bad', -TABLOCK -); - -TRUNCATE TABLE VOCABULARY; -BULK INSERT VOCABULARY -FROM 'C:\CDM\VOCABULARY.csv' -WITH ( -FIRSTROW = 2, -FIELDTERMINATOR = '\t', -ROWTERMINATOR = '0x0a', -ERRORFILE = 'C:\CDM\VOCABULARY.bad', -TABLOCK -);