From 86dbcec3e08d757b07763a0ff31d164b41582576 Mon Sep 17 00:00:00 2001 From: clairblacketer Date: Tue, 25 Sep 2018 12:40:53 -0400 Subject: [PATCH] Fixes from testers for pdw, redshit, postgres and sql server and survey -> survey_conduct changes. --- Impala/OMOP CDM impala ddl.txt | 18 +- Netezza/OMOP CDM netezza ddl.txt | 10 +- Oracle/OMOP CDM oracle constraints.txt | 24 +- Oracle/OMOP CDM oracle ddl.txt | 12 +- .../OMOP CDM Results pdw ddl.txt | 78 ++ .../OMOP CDM pdw constraints.txt | 52 +- ParallelDataWarehouse/OMOP CDM pdw ddl.txt | 891 +++++++++--------- .../OMOP CDM pdw pk indexes.txt | 18 +- ParallelDataWarehouse/README.md | 4 + .../OMOP CDM Results postgresql ddl.txt | 90 ++ .../OMOP CDM postgresql constraints.txt | 46 +- PostgreSQL/OMOP CDM postgresql ddl.txt | 801 ++++++++-------- PostgreSQL/OMOP CDM postgresql pk indexes.txt | 28 +- PostgreSQL/README.md | 2 + Redshift/OMOP CDM Results redshift ddl.txt | 59 ++ Redshift/OMOP CDM redshift ddl.txt | 847 ++++++++--------- Redshift/README.md | 4 +- Sql Server/OMOP CDM Results sql server.txt | 37 + .../OMOP CDM sql server constraints.txt | 44 +- Sql Server/OMOP CDM sql server ddl.txt | 331 +++---- Sql Server/OMOP CDM sql server pk indexes.txt | 26 +- Sql Server/README.md | 2 + 22 files changed, 1720 insertions(+), 1704 deletions(-) create mode 100644 ParallelDataWarehouse/OMOP CDM Results pdw ddl.txt create mode 100644 PostgreSQL/OMOP CDM Results postgresql ddl.txt create mode 100644 Redshift/OMOP CDM Results redshift ddl.txt diff --git a/Impala/OMOP CDM impala ddl.txt b/Impala/OMOP CDM impala ddl.txt index bdb6e6f..1875db8 100644 --- a/Impala/OMOP CDM impala ddl.txt +++ b/Impala/OMOP CDM impala ddl.txt @@ -203,7 +203,7 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( - person_id BIGINT , --BIGINTs added + person_id BIGINT , gender_concept_id INTEGER , year_of_birth INTEGER , month_of_birth INTEGER , @@ -274,7 +274,7 @@ CREATE TABLE visit_occurrence care_site_id BIGINT , visit_source_value VARCHAR(50), visit_source_concept_id INTEGER , - admitted_from_concept_id INTEGER , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER , admitted_from_source_value VARCHAR(50), discharge_to_source_value VARCHAR(50) , discharge_to_concept_id INTEGER , @@ -297,7 +297,7 @@ CREATE TABLE visit_detail provider_id BIGINT , care_site_id BIGINT , discharge_to_concept_id INTEGER , - admitted_from_concept_id INTEGER , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER , admitted_from_source_value VARCHAR(50) , visit_detail_source_value VARCHAR(50) , visit_detail_source_concept_id INTEGER , @@ -496,8 +496,8 @@ CREATE TABLE observation observation_source_concept_id INTEGER , unit_source_value VARCHAR(50) , qualifier_source_value VARCHAR(50) , - observation_event_id BIGINT , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - obs_event_field_concept_id INTEGER , /* Changed name to comply with COST and NOTE. This should be 'Survey'. Had to use 'obs' for oracle restriction, may be added on 9/4*/ + observation_event_id BIGINT , + obs_event_field_concept_id INTEGER , value_as_datetime TIMESTAMP ) ; @@ -529,12 +529,11 @@ CREATE TABLE survey_conduct survey_version_number VARCHAR(20) , visit_occurrence_id BIGINT , visit_detail_id BIGINT , - response_to_visit_occurrence_id BIGINT + response_visit_occurrence_id BIGINT ) ; - CREATE TABLE fact_relationship ( domain_concept_id_1 INTEGER , @@ -546,7 +545,6 @@ CREATE TABLE fact_relationship ; - /************************ Standardized health system data @@ -574,7 +572,7 @@ CREATE TABLE location_history ( location_history_id BIGINT , location_id BIGINT , - relationship_type_concept_id INTEGER , --Recent addition based on github discussion + relationship_type_concept_id INTEGER , domain_id VARCHAR(50) , entity_id BIGINT , start_date TIMESTAMP , @@ -654,7 +652,7 @@ CREATE TABLE cost cost_id BIGINT , person_id BIGINT, cost_event_id BIGINT , - cost_event_field_concept_id INTEGER , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/ + cost_event_field_concept_id INTEGER , cost_concept_id INTEGER , cost_type_concept_id INTEGER , currency_concept_id INTEGER , diff --git a/Netezza/OMOP CDM netezza ddl.txt b/Netezza/OMOP CDM netezza ddl.txt index ef7c8a2..c3bc084 100644 --- a/Netezza/OMOP CDM netezza ddl.txt +++ b/Netezza/OMOP CDM netezza ddl.txt @@ -227,7 +227,7 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( - person_id BIGINT NOT NULL , --BIGINTs added + person_id BIGINT NOT NULL , gender_concept_id INTEGER NOT NULL , year_of_birth INTEGER NOT NULL , month_of_birth INTEGER NULL, @@ -542,7 +542,7 @@ DISTRIBUTE ON (person_id) --HINT DISTRIBUTE ON KEY(person_id) -CREATE TABLE survey_conduct /*Should this be SURVEY_OCCURRENCE instead to comply with the other tables?*/ +CREATE TABLE survey_conduct ( survey_conduct_id BIGINT NOT NULL , person_id BIGINT NOT NULL , @@ -568,7 +568,7 @@ CREATE TABLE survey_conduct /*Should this be SURVEY_OCCURRENCE instead to comply survey_version_number VARCHAR(20) NULL , visit_occurrence_id BIGINT NULL , visit_detail_id BIGINT NULL , - response_to_visit_occurrence_id BIGINT NULL + response_visit_occurrence_id BIGINT NULL ) DISTRIBUTE ON (person_id) ; @@ -616,9 +616,9 @@ DISTRIBUTE ON RANDOM --HINT DISTRIBUTE ON RANDOM CREATE TABLE location_history ( - location_history_id BIGINT NOT NULL , --unauthorized addition based on CDM conventions + location_history_id BIGINT NOT NULL , location_id BIGINT NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion + relationship_type_concept_id INTEGER NULL , domain_id VARCHAR(50) NOT NULL , entity_id BIGINT NOT NULL , start_date DATE NOT NULL , diff --git a/Oracle/OMOP CDM oracle constraints.txt b/Oracle/OMOP CDM oracle constraints.txt index 916f7a7..8800181 100644 --- a/Oracle/OMOP CDM oracle constraints.txt +++ b/Oracle/OMOP CDM oracle constraints.txt @@ -352,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); -ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); diff --git a/Oracle/OMOP CDM oracle ddl.txt b/Oracle/OMOP CDM oracle ddl.txt index 22e7e63..5c4e5d4 100644 --- a/Oracle/OMOP CDM oracle ddl.txt +++ b/Oracle/OMOP CDM oracle ddl.txt @@ -215,7 +215,7 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( - person_id NUMBER(19) NOT NULL , --BIGINTs added + person_id NUMBER(19) NOT NULL , gender_concept_id INTEGER NOT NULL , year_of_birth INTEGER NOT NULL , month_of_birth INTEGER NULL, @@ -309,7 +309,7 @@ CREATE TABLE visit_detail provider_id NUMBER(19) NULL , care_site_id NUMBER(19) NULL , discharge_to_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , visit_detail_source_value VARCHAR(50) NULL , visit_detail_source_concept_id INTEGER NULL , @@ -509,8 +509,8 @@ CREATE TABLE observation observation_source_concept_id INTEGER NULL , unit_source_value VARCHAR(50) NULL , qualifier_source_value VARCHAR(50) NULL , - observation_event_id NUMBER(19) NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - obs_event_field_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/ + observation_event_id NUMBER(19) NULL , + obs_event_field_concept_id INTEGER NULL , value_as_datetime TIMESTAMP NULL ) ; @@ -543,7 +543,7 @@ CREATE TABLE survey_conduct --Table added survey_version_number VARCHAR(20) NULL , visit_occurrence_id NUMBER(19) NULL , visit_detail_id NUMBER(19) NULL , - response_visit_occurrence_id NUMBER(19) NULL + response_visit_occurrence_id NUMBER(19) NULL ) ; @@ -591,7 +591,7 @@ CREATE TABLE location_history --Table added ( location_history_id NUMBER(19) NOT NULL , location_id NUMBER(19) NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion + relationship_type_concept_id INTEGER NULL , domain_id VARCHAR(50) NOT NULL , entity_id NUMBER(19) NOT NULL , start_date DATE NOT NULL , diff --git a/ParallelDataWarehouse/OMOP CDM Results pdw ddl.txt b/ParallelDataWarehouse/OMOP CDM Results pdw ddl.txt new file mode 100644 index 0000000..c722613 --- /dev/null +++ b/ParallelDataWarehouse/OMOP CDM Results pdw ddl.txt @@ -0,0 +1,78 @@ +/********************************************************************************* +# Copyright 2018-08 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. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # + # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### # # + # # # # # # # # # # # # # # # # ### # # + # # # # # # # # # # # # # # # # # ### # # + ####### # # ####### # ##### ###### # # ## ##### ### ### + +pdw script to create OMOP common data model results schema version 6.0 + +last revised: 27-Aug-2018 + +Authors: Patrick Ryan, Christian Reich, Clair Blacketer + + +*************************/ + + +--HINT DISTRIBUTE_ON_KEY(subject_id) +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +cohort ( + cohort_definition_id BIGINT NOT NULL , + subject_id BIGINT NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL +) +WITH (DISTRIBUTION = HASH(subject_id)); + + +--HINT DISTRIBUTE ON RANDOM +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +cohort_definition ( + cohort_definition_id INTEGER NOT NULL, + cohort_definition_name VARCHAR(255) NOT NULL, + cohort_definition_description VARCHAR(1000) NULL, + definition_type_concept_id INTEGER NOT NULL, + cohort_definition_syntax VARCHAR(1000) NULL, + subject_concept_id INTEGER NOT NULL, + cohort_initiation_date DATE NULL +) +WITH (DISTRIBUTION = REPLICATE); + + +ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; + +ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id); + + +ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); + + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); + + +CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); +CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); + diff --git a/ParallelDataWarehouse/OMOP CDM pdw constraints.txt b/ParallelDataWarehouse/OMOP CDM pdw constraints.txt index 07a96d9..f3fe321 100644 --- a/ParallelDataWarehouse/OMOP CDM pdw constraints.txt +++ b/ParallelDataWarehouse/OMOP CDM pdw constraints.txt @@ -28,7 +28,7 @@ pdw script to create foreign key, unique, and check constraints within the OMOP common data model, version 6.0 -last revised: 30-Aug┌-2018 +last revised: 30-Aug-2018 author: Patrick Ryan, Clair Blacketer @@ -86,7 +86,7 @@ ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (re ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id); -ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id); +ALTER TABLE concept_synonym ADD CONSTRAINT fpk_synonym_language FOREIGN KEY (language_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); @@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n 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); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id); - - /************************** Standardized meta-data @@ -194,9 +186,9 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov 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 visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitted_frome_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id); @@ -215,7 +207,7 @@ ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id); -ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitted_from_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_detail_source_concept_id) REFERENCES concept (concept_id); @@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); -ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); @@ -476,16 +468,6 @@ 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); diff --git a/ParallelDataWarehouse/OMOP CDM pdw ddl.txt b/ParallelDataWarehouse/OMOP CDM pdw ddl.txt index d97883e..b20f56c 100644 --- a/ParallelDataWarehouse/OMOP CDM pdw ddl.txt +++ b/ParallelDataWarehouse/OMOP CDM pdw ddl.txt @@ -43,79 +43,95 @@ Standardized vocabulary --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept (concept_id INTEGER NOT NULL , - concept_name VARCHAR(255) NOT NULL , +IF XACT_STATE() = 1 COMMIT; 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 + 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 ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE vocabulary (vocabulary_id VARCHAR(20) NOT NULL, +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +vocabulary ( + vocabulary_id VARCHAR(20) NOT NULL, vocabulary_name VARCHAR(255) NOT NULL, - vocabulary_reference VARCHAR(255) NOT NULL, - vocabulary_version VARCHAR(255) NOT NULL, - vocabulary_concept_id INTEGER NOT NULL + vocabulary_reference VARCHAR(255) NOT NULL, + vocabulary_version VARCHAR(255) NOT NULL, + vocabulary_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE domain (domain_id VARCHAR(20) NOT NULL, +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +domain ( + domain_id VARCHAR(20) NOT NULL, domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL + domain_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_class (concept_class_id VARCHAR(20) NOT NULL, +IF XACT_STATE() = 1 COMMIT; 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 + concept_class_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_relationship (concept_id_1 INTEGER NOT NULL, +IF XACT_STATE() = 1 COMMIT; 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, + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE NOT NULL, valid_end_date DATE NOT NULL, - invalid_reason VARCHAR(1) NULL + invalid_reason VARCHAR(1) NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE relationship (relationship_id VARCHAR(20) NOT NULL, - relationship_name VARCHAR(255) NOT NULL, +IF XACT_STATE() = 1 COMMIT; 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 + defines_ancestry VARCHAR(1) NOT NULL, + reverse_relationship_id VARCHAR(20) NOT NULL, + relationship_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_synonym (concept_id INTEGER NOT NULL, - concept_synonym_name VARCHAR(1000) NOT NULL, - language_concept_id INTEGER NOT NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +concept_synonym ( + concept_id INTEGER NOT NULL, + concept_synonym_name VARCHAR(1000) NOT NULL, + language_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_ancestor (ancestor_concept_id INTEGER NOT NULL, - descendant_concept_id INTEGER NOT NULL, +IF XACT_STATE() = 1 COMMIT; 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 ) @@ -123,54 +139,36 @@ WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE source_to_concept_map (source_code VARCHAR(50) NOT NULL, - source_concept_id INTEGER NOT NULL, +IF XACT_STATE() = 1 COMMIT; 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_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 + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; 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, +IF XACT_STATE() = 1 COMMIT; 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_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 -) -WITH (DISTRIBUTION = REPLICATE); - - ---HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort_definition (cohort_definition_id INTEGER NOT NULL, - cohort_definition_name VARCHAR(255) NOT NULL, - cohort_definition_description VARCHAR(1000) NULL, - definition_type_concept_id INTEGER NOT NULL, - cohort_definition_syntax VARCHAR(1000) NULL, - subject_concept_id INTEGER NOT NULL, - cohort_initiation_date DATE NULL -) -WITH (DISTRIBUTION = REPLICATE); - - ---HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE attribute_definition (attribute_definition_id INTEGER NOT NULL, - attribute_name VARCHAR(255) NOT NULL, - attribute_description VARCHAR(1000) NULL, - attribute_type_concept_id INTEGER NOT NULL, - attribute_syntax VARCHAR(1000) NULL + box_size INTEGER NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) WITH (DISTRIBUTION = REPLICATE); @@ -183,35 +181,37 @@ Standardized meta-data --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; 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(1000) NULL , +IF XACT_STATE() = 1 COMMIT; 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(1000) 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 + 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 ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE metadata - (metadata_concept_id INTEGER NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +metadata ( + metadata_concept_id INTEGER NOT NULL , metadata_type_concept_id INTEGER NOT NULL , name VARCHAR(250) NOT NULL , - value_as_string VARCHAR(1000) NULL , + value_as_string VARCHAR(1000) NULL , value_as_concept_id INTEGER NULL , metadata_date DATE NULL , - metadata_datetime DATETIME2 NULL + metadata_datetime DATETIME2 NULL ) WITH (DISTRIBUTION = REPLICATE); -INSERT INTO metadata (name, value_as_string) --Added cdm version record -VALUES ('CDM Version', '6.0') +INSERT INTO metadata (metadata_concept_id, metadata_type_concept_id, name, value_as_string, value_as_concept_id, metadata_date, metadata_datetime) +VALUES (0, 0, 'CDM Version', '6.0', 0, NULL, NULL) ; @@ -223,100 +223,92 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE person - (person_id BIGINT NOT NULL , --BIGINTs added - gender_concept_id INTEGER NOT NULL , - year_of_birth INTEGER NOT NULL , - month_of_birth INTEGER NULL, - day_of_birth INTEGER NULL, - birth_datetime DATETIME2 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 +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +person ( + person_id BIGINT NOT NULL , + gender_concept_id INTEGER NOT NULL , + year_of_birth INTEGER NOT NULL , + month_of_birth INTEGER NULL, + day_of_birth INTEGER NULL, + birth_datetime DATETIME2 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 ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation_period - (observation_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_period_start_date DATE NOT NULL , - observation_period_end_date DATE NOT NULL , - period_type_concept_id INTEGER NOT NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +observation_period ( + observation_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_period_start_date DATE NOT NULL , + observation_period_end_date DATE NOT NULL , + period_type_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE specimen - (specimen_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - specimen_concept_id INTEGER NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +specimen ( + specimen_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + specimen_concept_id INTEGER NOT NULL , specimen_type_concept_id INTEGER NOT NULL , - specimen_date DATE NULL , - specimen_datetime DATETIME2 NOT NULL , - quantity FLOAT NULL , - unit_concept_id INTEGER NULL , + specimen_date DATE NULL , + specimen_datetime DATETIME2 NOT 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 + 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 ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE death - (person_id BIGINT NOT NULL , - death_date DATE NULL , - death_datetime DATETIME2 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 -) -WITH (DISTRIBUTION = HASH(person_id)); - - ---HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_occurrence - (visit_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - visit_concept_id INTEGER NOT NULL , - visit_start_date DATE NULL , - visit_start_datetime DATETIME2 NOT NULL , - visit_end_date DATE NULL , - visit_end_datetime DATETIME2 NOT 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 , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ - admitted_from_source_value VARCHAR(50) NULL , - discharge_to_source_value VARCHAR(50) NULL , - discharge_to_concept_id INTEGER NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +visit_occurrence ( + visit_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + visit_concept_id INTEGER NOT NULL , + visit_start_date DATE NULL , + visit_start_datetime DATETIME2 NOT NULL , + visit_end_date DATE NULL , + visit_end_datetime DATETIME2 NOT 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 , + admitted_from_concept_id INTEGER NULL , + admitted_from_source_value VARCHAR(50) NULL , + discharge_to_source_value VARCHAR(50) NULL , + discharge_to_concept_id INTEGER NULL , preceding_visit_occurrence_id INTEGER NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_detail - (visit_detail_id BIGINT NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +visit_detail ( + visit_detail_id BIGINT NOT NULL , person_id BIGINT NOT NULL , visit_detail_concept_id INTEGER NOT NULL , visit_detail_start_date DATE NULL , @@ -327,7 +319,7 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_detail provider_id INTEGER NULL , care_site_id INTEGER NULL , discharge_to_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , visit_detail_source_value VARCHAR(50) NULL , visit_detail_source_concept_id INTEGER NULL , @@ -340,231 +332,239 @@ WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE procedure_occurrence - (procedure_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - procedure_concept_id INTEGER NOT NULL , - procedure_date DATE NULL , - procedure_datetime DATETIME2 NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +procedure_occurrence ( + procedure_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + procedure_concept_id INTEGER NOT NULL , + procedure_date DATE NULL , + procedure_datetime DATETIME2 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 , - visit_detail_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , + modifier_concept_id INTEGER NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + procedure_source_value VARCHAR(50) NULL , procedure_source_concept_id INTEGER NULL , - modifier_source_value VARCHAR(50) NULL , + modifier_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_exposure - (drug_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - drug_concept_id INTEGER NOT NULL , - drug_exposure_start_date DATE NULL , - drug_exposure_start_datetime DATETIME2 NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime DATETIME2 NOT NULL , - verbatim_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(1000) NULL , - route_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - drug_source_value VARCHAR(50) NULL , - drug_source_concept_id INTEGER NULL , - route_source_value VARCHAR(50) NULL , - dose_unit_source_value VARCHAR(50) NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +drug_exposure ( + drug_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + drug_concept_id INTEGER NOT NULL , + drug_exposure_start_date DATE NULL , + drug_exposure_start_datetime DATETIME2 NOT NULL , + drug_exposure_end_date DATE NULL , + drug_exposure_end_datetime DATETIME2 NOT NULL , + verbatim_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(1000) NULL , + route_concept_id INTEGER NULL , + lot_number VARCHAR(50) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + drug_source_value VARCHAR(50) NULL , + drug_source_concept_id INTEGER NULL , + route_source_value VARCHAR(50) NULL , + dose_unit_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE device_exposure - (device_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - device_concept_id INTEGER NOT NULL , - device_exposure_start_date DATE NULL , - device_exposure_start_datetime DATETIME2 NOT NULL , - device_exposure_end_date DATE NULL , - device_exposure_end_datetime DATETIME2 NULL , - device_type_concept_id INTEGER NOT NULL , - unique_device_id VARCHAR(50) NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +device_exposure ( + device_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + device_concept_id INTEGER NOT NULL , + device_exposure_start_date DATE NULL , + device_exposure_start_datetime DATETIME2 NOT NULL , + device_exposure_end_date DATE NULL , + device_exposure_end_datetime DATETIME2 NULL , + device_type_concept_id INTEGER NOT NULL , + unique_device_id VARCHAR(50) NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + device_source_value VARCHAR(100) NULL , + device_source_concept_id INTEGER NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE condition_occurrence - (condition_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_start_date DATE NULL , - condition_start_datetime DATETIME2 NOT NULL , - condition_end_date DATE NULL , - condition_end_datetime DATETIME2 NULL , - condition_type_concept_id INTEGER NOT NULL , - condition_status_concept_id INTEGER NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +condition_occurrence ( + condition_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + condition_concept_id INTEGER NOT NULL , + condition_start_date DATE NULL , + condition_start_datetime DATETIME2 NOT NULL , + condition_end_date DATE NULL , + condition_end_datetime DATETIME2 NULL , + condition_type_concept_id INTEGER NOT NULL , + condition_status_concept_id INTEGER NULL , + stop_reason VARCHAR(20) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , visit_detail_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL , + condition_source_value VARCHAR(50) NULL , + condition_source_concept_id INTEGER NULL , condition_status_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE measurement - (measurement_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NULL , - measurement_datetime DATETIME2 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 , - visit_detail_id INTEGER NULL , - measurement_source_value VARCHAR(50) NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +measurement ( + measurement_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + measurement_concept_id INTEGER NOT NULL , + measurement_date DATE NULL , + measurement_datetime DATETIME2 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 , + visit_detail_id INTEGER NULL , + measurement_source_value VARCHAR(50) NULL , measurement_source_concept_id INTEGER NULL , - unit_source_value VARCHAR(50) NULL , - value_source_value VARCHAR(50) NULL + unit_source_value VARCHAR(50) NULL , + value_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE note - (note_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - note_event_id BIGINT NULL , --This and the field below added - note_domain_id VARCHAR(20) NULL , --This field may be removed in favor of the one below ---note_event_table_concept_id INTEGER NULL , --This may be added based on 9/4 meeting - note_date DATE NULL , - note_datetime DATETIME2 NOT NULL , - note_type_concept_id INTEGER NOT NULL , - note_class_concept_id INTEGER NOT NULL , - note_title VARCHAR(250) NULL , - note_text VARCHAR(1000) NULL , - encoding_concept_id INTEGER NOT NULL , - language_concept_id INTEGER NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - note_source_value VARCHAR(50) NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +note ( + note_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + note_event_id BIGINT NULL , + note_event_field_concept_id INTEGER NULL , + note_date DATE NULL , + note_datetime DATETIME2 NOT NULL , + note_type_concept_id INTEGER NOT NULL , + note_class_concept_id INTEGER NOT NULL , + note_title VARCHAR(250) NULL , + note_text VARCHAR(1000) NULL , + encoding_concept_id INTEGER NOT NULL , + language_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + note_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE note_nlp - (note_nlp_id BIGINT NOT NULL , - note_id BIGINT NOT NULL , - section_concept_id INTEGER NULL , - snippet VARCHAR(250) NULL , - "offset" VARCHAR(250) NULL , - lexical_variant VARCHAR(250) NOT NULL , - note_nlp_concept_id INTEGER NULL , - nlp_system VARCHAR(250) NULL , - nlp_date DATE NOT NULL , - nlp_datetime DATETIME2 NULL , - term_exists VARCHAR(1) NULL , - term_temporal VARCHAR(50) NULL , - term_modifiers VARCHAR(2000) NULL , - note_nlp_source_concept_id INTEGER NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +note_nlp ( + note_nlp_id BIGINT NOT NULL , + note_id BIGINT NOT NULL , + section_concept_id INTEGER NULL , + snippet VARCHAR(250) NULL , + "offset" VARCHAR(250) NULL , + lexical_variant VARCHAR(250) NOT NULL , + note_nlp_concept_id INTEGER NULL , + nlp_system VARCHAR(250) NULL , + nlp_date DATE NOT NULL , + nlp_datetime DATETIME2 NULL , + term_exists VARCHAR(1) NULL , + term_temporal VARCHAR(50) NULL , + term_modifiers VARCHAR(2000) NULL , + note_nlp_source_concept_id INTEGER NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation - (observation_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NULL , - observation_datetime DATETIME2 NOT 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 BIGINT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +observation ( + observation_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_concept_id INTEGER NOT NULL , + observation_date DATE NULL , + observation_datetime DATETIME2 NOT 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 BIGINT NULL , visit_detail_id BIGINT 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 , - observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - observation_event_domain_id VARCHAR(20) NULL , ---obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/ - value_as_datetime DATETIME2 NULL + observation_source_concept_id INTEGER NULL , + unit_source_value VARCHAR(50) NULL , + qualifier_source_value VARCHAR(50) NULL , + observation_event_id BIGINT NULL , + obs_event_field_concept_id INTEGER NULL , + value_as_datetime DATETIME2 NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE ON KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE survey_conduct --Table added - (survey_conduct_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - survey_concept_id INTEGER NOT NULL , - survey_start_date DATE NULL , - survey_start_datetime DATETIME2 NULL , - survey_end_date DATE NULL , - survey_end_datetime DATETIME2 NOT NULL , - provider_id BIGINT NULL , - assisted_concept_id INTEGER NULL , - respondent_type_concept_id INTEGER NULL , - timing_concept_id INTEGER NULL , - collection_method_concept_id INTEGER NULL , - assisted_source_value VARCHAR(50) NULL , - respondent_type_source_value VARCHAR(100) NULL , - timing_source_value VARCHAR(100) NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +survey_conduct ( + survey_conduct_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + survey_concept_id INTEGER NOT NULL , + survey_start_date DATE NULL , + survey_start_datetime DATETIME2 NULL , + survey_end_date DATE NULL , + survey_end_datetime DATETIME2 NOT NULL , + provider_id BIGINT NULL , + assisted_concept_id INTEGER NULL , + respondent_type_concept_id INTEGER NULL , + timing_concept_id INTEGER NULL , + collection_method_concept_id INTEGER NULL , + assisted_source_value VARCHAR(50) NULL , + respondent_type_source_value VARCHAR(100) NULL , + timing_source_value VARCHAR(100) NULL , collection_method_source_value VARCHAR(100) NULL , - survey_source_value VARCHAR(100) NULL , - survey_source_concept_id INTEGER NULL , - survey_source_identifier VARCHAR(100) NULL , - validated_survey_concept_id INTEGER NULL , + survey_source_value VARCHAR(100) NULL , + survey_source_concept_id INTEGER NULL , + survey_source_identifier VARCHAR(100) NULL , + validated_survey_concept_id INTEGER NULL , validated_survey_source_value VARCHAR(100) NULL , - survey_version_number VARCHAR(20) NULL , - visit_occurrence_id BIGINT NULL , - visit_detail_id BIGINT NULL , - response_to_visit_occurrence_id BIGINT NULL + survey_version_number VARCHAR(20) NULL , + visit_occurrence_id BIGINT NULL , + visit_detail_id BIGINT NULL , + response_visit_occurrence_id BIGINT NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE fact_relationship - (domain_concept_id_1 INTEGER NOT NULL , - fact_id_1 BIGINT NOT NULL , - domain_concept_id_2 INTEGER NOT NULL , - fact_id_2 BIGINT NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +fact_relationship ( + domain_concept_id_1 INTEGER NOT NULL , + fact_id_1 BIGINT NOT NULL , + domain_concept_id_2 INTEGER NOT NULL , + fact_id_2 BIGINT NOT NULL , relationship_concept_id INTEGER NOT NULL ) WITH (DISTRIBUTION = REPLICATE); @@ -579,62 +579,66 @@ Standardized health system data --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE location - (location_id BIGINT 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 , - country VARCHAR(100) NULL , - location_source_value VARCHAR(50) NULL , - latitude FLOAT NULL , - longitude FLOAT NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +location ( + location_id BIGINT 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 , + country VARCHAR(100) NULL , + location_source_value VARCHAR(50) NULL , + latitude FLOAT NULL , + longitude FLOAT NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE location_history --Table added - (location_history_id BIGINT NOT NULL , - location_id BIGINT NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion - domain_id VARCHAR(50) NOT NULL , - entity_id BIGINT NOT NULL , - start_date DATE NOT NULL , - end_date DATE NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +location_history ( + location_history_id BIGINT NOT NULL , + location_id BIGINT NOT NULL , + relationship_type_concept_id INTEGER NULL , + domain_id VARCHAR(50) NOT NULL , + entity_id BIGINT NOT NULL , + start_date DATE NOT NULL , + end_date DATE NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE care_site - (care_site_id BIGINT NOT NULL , - care_site_name VARCHAR(255) NULL , - place_of_service_concept_id INTEGER NULL , - location_id BIGINT NULL , - care_site_source_value VARCHAR(50) NULL , - place_of_service_source_value VARCHAR(50) NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +care_site ( + care_site_id BIGINT NOT NULL , + care_site_name VARCHAR(255) NULL , + place_of_service_concept_id INTEGER NULL , + location_id BIGINT NULL , + care_site_source_value VARCHAR(50) NULL , + place_of_service_source_value VARCHAR(50) NULL ) WITH (DISTRIBUTION = REPLICATE); --HINT DISTRIBUTE ON RANDOM -IF XACT_STATE() = 1 COMMIT; CREATE TABLE provider - (provider_id BIGINT NOT NULL , - provider_name VARCHAR(255) NULL , - NPI VARCHAR(20) NULL , - DEA VARCHAR(20) NULL , - specialty_concept_id INTEGER NULL , - care_site_id BIGINT 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 +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +provider ( + provider_id BIGINT NOT NULL , + provider_name VARCHAR(255) NULL , + NPI VARCHAR(20) NULL , + DEA VARCHAR(20) NULL , + specialty_concept_id INTEGER NULL , + care_site_id BIGINT 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 ) WITH (DISTRIBUTION = REPLICATE); @@ -647,53 +651,54 @@ Standardized health economics --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE payer_plan_period - (payer_plan_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - contract_person_id BIGINT NULL , - payer_plan_period_start_date DATE NOT NULL , - payer_plan_period_end_date DATE NOT NULL , - payer_concept_id INTEGER NULL , - plan_concept_id INTEGER NULL , - contract_concept_id INTEGER NULL , - sponsor_concept_id INTEGER NULL , - stop_reason_concept_id INTEGER NULL , - payer_source_value VARCHAR(50) NULL , - payer_source_concept_id INTEGER NULL , - plan_source_value VARCHAR(50) NULL , - plan_source_concept_id INTEGER NULL , - contract_source_value VARCHAR(50) NULL , - contract_source_concept_id INTEGER NULL , - sponsor_source_value VARCHAR(50) NULL , - sponsor_source_concept_id INTEGER NULL , - family_source_value VARCHAR(50) NULL , - stop_reason_source_value VARCHAR(50) NULL , - stop_reason_source_concept_id INTEGER NULL +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +payer_plan_period ( + payer_plan_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + contract_person_id BIGINT NULL , + payer_plan_period_start_date DATE NOT NULL , + payer_plan_period_end_date DATE NOT NULL , + payer_concept_id INTEGER NULL , + plan_concept_id INTEGER NULL , + contract_concept_id INTEGER NULL , + sponsor_concept_id INTEGER NULL , + stop_reason_concept_id INTEGER NULL , + payer_source_value VARCHAR(50) NULL , + payer_source_concept_id INTEGER NULL , + plan_source_value VARCHAR(50) NULL , + plan_source_concept_id INTEGER NULL , + contract_source_value VARCHAR(50) NULL , + contract_source_concept_id INTEGER NULL , + sponsor_source_value VARCHAR(50) NULL , + sponsor_source_concept_id INTEGER NULL , + family_source_value VARCHAR(50) NULL , + stop_reason_source_value VARCHAR(50) NULL , + stop_reason_source_concept_id INTEGER NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE ON KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE cost - (cost_id BIGINT NOT NULL , - person_id BIGINT NOT NULL, - cost_event_id BIGINT NOT NULL , - cost_domain_id VARCHAR(20) NOT NULL , ---cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/ - cost_concept_id INTEGER NOT NULL , - cost_type_concept_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - cost FLOAT NULL , - incurred_date DATE NOT NULL , - billed_date DATE NULL , - paid_date DATE NULL , - revenue_code_concept_id INTEGER NULL , - drg_concept_id INTEGER NULL , - cost_source_value VARCHAR(50) NULL , - cost_source_concept_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +cost ( + cost_id BIGINT NOT NULL , + person_id BIGINT NOT NULL, + cost_event_id BIGINT NOT NULL , + cost_event_field_concept_id INTEGER NOT NULL , + cost_concept_id INTEGER NOT NULL , + cost_type_concept_id INTEGER NOT NULL , + currency_concept_id INTEGER NULL , + cost FLOAT NULL , + incurred_date DATE NOT NULL , + billed_date DATE NULL , + paid_date DATE NULL , + revenue_code_concept_id INTEGER NULL , + drg_concept_id INTEGER NULL , + cost_source_value VARCHAR(50) NULL , + cost_source_concept_id INTEGER NULL , + revenue_code_source_value VARCHAR(50) NULL , drg_source_value VARCHAR(3) NULL , - payer_plan_period_id BIGINT NULL + payer_plan_period_id BIGINT NULL ) WITH (DISTRIBUTION = HASH(person_id)); @@ -705,62 +710,42 @@ Standardized derived elements ************************/ ---HINT DISTRIBUTE_ON_KEY(subject_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort - (cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL -) -WITH (DISTRIBUTION = HASH(subject_id)); - - ---HINT DISTRIBUTE_ON_KEY(subject_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort_attribute - (cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - attribute_definition_id BIGINT NOT NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL -) -WITH (DISTRIBUTION = HASH(subject_id)); - - --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_era - (drug_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - drug_concept_id INTEGER NOT NULL , - drug_era_start_date DATE NOT NULL , - drug_era_end_date DATE NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +drug_era ( + drug_era_id BIGINT NOT NULL , + person_id BIGINT 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 + gap_days INTEGER NULL ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE dose_era - (dose_era_id BIGINT NOT NULL , - person_id BIGINT 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 +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +dose_era ( + dose_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) WITH (DISTRIBUTION = HASH(person_id)); --HINT DISTRIBUTE_ON_KEY(person_id) -IF XACT_STATE() = 1 COMMIT; CREATE TABLE condition_era - (condition_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_era_start_date DATE NOT NULL , - condition_era_end_date DATE NOT NULL , +IF XACT_STATE() = 1 COMMIT; CREATE TABLE +condition_era ( + condition_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) WITH (DISTRIBUTION = HASH(person_id)); diff --git a/ParallelDataWarehouse/OMOP CDM pdw pk indexes.txt b/ParallelDataWarehouse/OMOP CDM pdw pk indexes.txt index 62b2c1f..c4827bb 100644 --- a/ParallelDataWarehouse/OMOP CDM pdw pk indexes.txt +++ b/ParallelDataWarehouse/OMOP CDM pdw pk indexes.txt @@ -77,10 +77,6 @@ ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMA 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); - /************************** @@ -127,7 +123,7 @@ ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ; -ALTER TABLE survey ADD CONSTRAINT xpk_survey PRIMARY KEY NONCLUSTERED ( survey_occurrence_id ) ; +ALTER TABLE survey_conduct ADD CONSTRAINT xpk_survey PRIMARY KEY NONCLUSTERED ( survey_conduct_id ) ; /************************ @@ -165,9 +161,6 @@ 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 ) ; @@ -225,9 +218,6 @@ CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_cod 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); /************************** @@ -328,12 +318,6 @@ 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); diff --git a/ParallelDataWarehouse/README.md b/ParallelDataWarehouse/README.md index 22559f0..a4fb2be 100644 --- a/ParallelDataWarehouse/README.md +++ b/ParallelDataWarehouse/README.md @@ -14,3 +14,7 @@ n order to create your instantiation of the Common Data Model, we recommend foll 4. Execute the script `OMOP CDM pdw indexes.txt` to add the minimum set of indices and primary keys we recommend. 5. Execute the script `OMOP CDM pdw constraints.txt` to add the foreign key constraints. + +6. Create an empty schema for results. + +7. Execute the script `OMOP CDM Results pdw ddl.txt` to create the tables and fields in the results schema. diff --git a/PostgreSQL/OMOP CDM Results postgresql ddl.txt b/PostgreSQL/OMOP CDM Results postgresql ddl.txt new file mode 100644 index 0000000..f56ecd2 --- /dev/null +++ b/PostgreSQL/OMOP CDM Results postgresql ddl.txt @@ -0,0 +1,90 @@ +/********************************************************************************* +# Copyright 2018-08 Observational Health Data Sciences and Informatics +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # + # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### # # + # # # # # # # # # # # # # # # # ### # # + # # # # # # # # # # # # # # # # # ### # # + ####### # # ####### # ##### ###### # # ## ##### ### ### + +postgresql script to create OMOP common data model results schema version 6.0 + +last revised: 27-Aug-2018 + +Authors: Patrick Ryan, Christian Reich, Clair Blacketer + + +*************************/ + + + +--HINT DISTRIBUTE_ON_KEY(subject_id) +CREATE TABLE cohort +( + cohort_definition_id BIGINT NOT NULL , + subject_id BIGINT NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL +) +; + + +--HINT DISTRIBUTE ON RANDOM +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 +) +; + + +ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; + +ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id); + + +CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); +CLUSTER cohort_definition USING idx_cohort_definition_id ; + +CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); +CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); + + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); + + +ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); + + + + + + + + + + diff --git a/PostgreSQL/OMOP CDM postgresql constraints.txt b/PostgreSQL/OMOP CDM postgresql constraints.txt index cb01e23..0f41d65 100644 --- a/PostgreSQL/OMOP CDM postgresql constraints.txt +++ b/PostgreSQL/OMOP CDM postgresql constraints.txt @@ -28,7 +28,7 @@ postgresql script to create foreign key, unique, and check constraints within the OMOP common data model, version 6.0 -last revised: 30-Aug┌-2018 +last revised: 30-Aug-2018 author: Patrick Ryan, Clair Blacketer @@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n 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); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id); - - /************************** Standardized meta-data @@ -194,7 +186,7 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov 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 visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); @@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); -ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); @@ -476,16 +468,6 @@ 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); diff --git a/PostgreSQL/OMOP CDM postgresql ddl.txt b/PostgreSQL/OMOP CDM postgresql ddl.txt index f3a4ea7..7cf2ad6 100644 --- a/PostgreSQL/OMOP CDM postgresql ddl.txt +++ b/PostgreSQL/OMOP CDM postgresql ddl.txt @@ -44,27 +44,27 @@ Standardized vocabulary --HINT DISTRIBUTE ON RANDOM 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_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 + concept_code VARCHAR(50) NOT NULL , + valid_start_date DATE NOT NULL , + valid_end_date DATE NOT NULL , + invalid_reason VARCHAR(1) NULL ) ; --HINT DISTRIBUTE ON RANDOM CREATE TABLE vocabulary ( - vocabulary_id VARCHAR(20) NOT NULL, - vocabulary_name VARCHAR(255) NOT NULL, + vocabulary_id VARCHAR(20) NOT NULL, + vocabulary_name VARCHAR(255) NOT NULL, vocabulary_reference VARCHAR(255) NOT NULL, - vocabulary_version VARCHAR(255) NOT NULL, - vocabulary_concept_id INTEGER NOT NULL + vocabulary_version VARCHAR(255) NOT NULL, + vocabulary_concept_id INTEGER NOT NULL ) ; @@ -73,16 +73,16 @@ CREATE TABLE vocabulary ( CREATE TABLE domain ( domain_id VARCHAR(20) NOT NULL, domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL + domain_concept_id INTEGER NOT NULL ) ; --HINT DISTRIBUTE ON RANDOM 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 + concept_class_id VARCHAR(20) NOT NULL, + concept_class_name VARCHAR(255) NOT NULL, + concept_class_concept_id INTEGER NOT NULL ) ; @@ -91,39 +91,39 @@ CREATE TABLE concept_class ( 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 + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) ; --HINT DISTRIBUTE ON RANDOM 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, + 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 + relationship_concept_id INTEGER NOT NULL ) ; --HINT DISTRIBUTE ON RANDOM CREATE TABLE concept_synonym ( - concept_id INTEGER NOT NULL, + concept_id INTEGER NOT NULL, concept_synonym_name VARCHAR(1000) NOT NULL, - language_concept_id INTEGER NOT NULL + language_concept_id INTEGER NOT NULL ) ; --HINT DISTRIBUTE ON RANDOM CREATE TABLE concept_ancestor ( - ancestor_concept_id INTEGER NOT NULL, - descendant_concept_id INTEGER NOT NULL, + 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 ) @@ -132,46 +132,33 @@ CREATE TABLE concept_ancestor ( --HINT DISTRIBUTE ON RANDOM CREATE TABLE source_to_concept_map ( - source_code VARCHAR(50) NOT NULL, - source_concept_id INTEGER NOT NULL, + 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_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 + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) ; --HINT DISTRIBUTE ON RANDOM 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 -) -; - - ---HINT DISTRIBUTE ON RANDOM -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 + 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 ) ; @@ -197,16 +184,16 @@ Standardized meta-data --HINT DISTRIBUTE ON RANDOM 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 , + 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 + 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 ) ; @@ -214,18 +201,18 @@ CREATE TABLE cdm_source --HINT DISTRIBUTE ON RANDOM CREATE TABLE metadata ( - metadata_concept_id INTEGER NOT NULL , - metadata_type_concept_id INTEGER NOT NULL , - name VARCHAR(250) NOT NULL , - value_as_string TEXT NULL , - value_as_concept_id INTEGER NULL , - metadata_date DATE NULL , - metadata_datetime DATETIME2 NULL + metadata_concept_id INTEGER NOT NULL , + metadata_type_concept_id INTEGER NOT NULL , + name VARCHAR(250) NOT NULL , + value_as_string TEXT NULL , + value_as_concept_id INTEGER NULL , + metadata_date DATE NULL , + metadata_datetime TIMESTAMP NULL ) ; -INSERT INTO metadata (name, value_as_string) --Added cdm version record -VALUES ('CDM Version', '6.0') +INSERT INTO metadata (metadata_concept_id, metadata_type_concept_id, name, value_as_string, value_as_concept_id, metadata_date, metadata_datetime) +VALUES (0, 0, 'CDM Version', '6.0', 0, NULL, NULL) ; @@ -239,24 +226,24 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( - person_id BIGINT NOT NULL , --BIGINTs added - gender_concept_id INTEGER NOT NULL , - year_of_birth INTEGER NOT NULL , - month_of_birth INTEGER NULL, - day_of_birth INTEGER NULL, - birth_datetime DATETIME2 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 + person_id BIGINT NOT NULL , + gender_concept_id INTEGER NOT NULL , + year_of_birth INTEGER NOT NULL , + month_of_birth INTEGER NULL, + day_of_birth INTEGER NULL, + birth_datetime TIMESTAMP NULL, + race_concept_id INTEGER NOT NULL, + ethnicity_concept_id INTEGER NOT NULL, + location_id INTEGER NULL, + provider_id INTEGER NULL, + care_site_id INTEGER NULL, + person_source_value VARCHAR(50) NULL, + gender_source_value VARCHAR(50) NULL, + gender_source_concept_id INTEGER NULL, + race_source_value VARCHAR(50) NULL, + race_source_concept_id INTEGER NULL, + ethnicity_source_value VARCHAR(50) NULL, + ethnicity_source_concept_id INTEGER NULL ) ; @@ -264,11 +251,11 @@ CREATE TABLE person --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation_period ( - observation_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_period_start_date DATE NOT NULL , - observation_period_end_date DATE NOT NULL , - period_type_concept_id INTEGER NOT NULL + observation_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_period_start_date DATE NOT NULL , + observation_period_end_date DATE NOT NULL , + period_type_concept_id INTEGER NOT NULL ) ; @@ -276,21 +263,21 @@ CREATE TABLE observation_period --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE specimen ( - specimen_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - specimen_concept_id INTEGER NOT NULL , + specimen_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + specimen_concept_id INTEGER NOT NULL , specimen_type_concept_id INTEGER NOT NULL , - specimen_date DATE NULL , - specimen_datetime DATETIME2 NOT NULL , - quantity NUMERIC NULL , - unit_concept_id INTEGER NULL , + specimen_date DATE NULL , + specimen_datetime TIMESTAMP NOT 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 + 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 ) ; @@ -298,13 +285,13 @@ CREATE TABLE specimen --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE death ( - person_id BIGINT NOT NULL , - death_date DATE NULL , - death_datetime DATETIME2 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 + person_id BIGINT NOT NULL , + death_date DATE NULL , + death_datetime TIMESTAMP 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 ) ; @@ -312,22 +299,22 @@ CREATE TABLE death --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_occurrence ( - visit_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - visit_concept_id INTEGER NOT NULL , - visit_start_date DATE NULL , - visit_start_datetime DATETIME2 NOT NULL , - visit_end_date DATE NULL , - visit_end_datetime DATETIME2 NOT 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 , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ - admitted_from_source_value VARCHAR(50) NULL , - discharge_to_source_value VARCHAR(50) NULL , - discharge_to_concept_id INTEGER NULL , + visit_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + visit_concept_id INTEGER NOT NULL , + visit_start_date DATE NULL , + visit_start_datetime TIMESTAMP NOT NULL , + visit_end_date DATE NULL , + visit_end_datetime TIMESTAMP NOT 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 , + admitted_from_concept_id INTEGER NULL , + admitted_from_source_value VARCHAR(50) NULL , + discharge_to_source_value VARCHAR(50) NULL , + discharge_to_concept_id INTEGER NULL , preceding_visit_occurrence_id INTEGER NULL ) ; @@ -340,14 +327,14 @@ CREATE TABLE visit_detail person_id BIGINT NOT NULL , visit_detail_concept_id INTEGER NOT NULL , visit_detail_start_date DATE NULL , - visit_detail_start_datetime DATETIME2 NOT NULL , + visit_detail_start_datetime TIMESTAMP NOT NULL , visit_detail_end_date DATE NULL , - visit_detail_end_datetime DATETIME2 NOT NULL , + visit_detail_end_datetime TIMESTAMP NOT NULL , visit_detail_type_concept_id INTEGER NOT NULL , provider_id INTEGER NULL , care_site_id INTEGER NULL , discharge_to_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , visit_detail_source_value VARCHAR(50) NULL , visit_detail_source_concept_id INTEGER NULL , @@ -362,20 +349,20 @@ CREATE TABLE visit_detail --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE procedure_occurrence ( - procedure_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - procedure_concept_id INTEGER NOT NULL , - procedure_date DATE NULL , - procedure_datetime DATETIME2 NOT NULL , + procedure_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + procedure_concept_id INTEGER NOT NULL , + procedure_date DATE NULL , + procedure_datetime TIMESTAMP 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 , - visit_detail_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , + modifier_concept_id INTEGER NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + procedure_source_value VARCHAR(50) NULL , procedure_source_concept_id INTEGER NULL , - modifier_source_value VARCHAR(50) NULL , + modifier_source_value VARCHAR(50) NULL ) ; @@ -383,29 +370,29 @@ CREATE TABLE procedure_occurrence --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_exposure ( - drug_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - drug_concept_id INTEGER NOT NULL , - drug_exposure_start_date DATE NULL , - drug_exposure_start_datetime DATETIME2 NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime DATETIME2 NOT NULL , - verbatim_end_date DATE NULL , - drug_type_concept_id INTEGER NOT NULL , - stop_reason VARCHAR(20) NULL , - refills INTEGER NULL , - quantity NUMERIC NULL , - days_supply INTEGER NULL , - sig TEXT NULL , - route_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - drug_source_value VARCHAR(50) NULL , - drug_source_concept_id INTEGER NULL , - route_source_value VARCHAR(50) NULL , - dose_unit_source_value VARCHAR(50) NULL + drug_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + drug_concept_id INTEGER NOT NULL , + drug_exposure_start_date DATE NULL , + drug_exposure_start_datetime TIMESTAMP NOT NULL , + drug_exposure_end_date DATE NULL , + drug_exposure_end_datetime TIMESTAMP NOT NULL , + verbatim_end_date DATE NULL , + drug_type_concept_id INTEGER NOT NULL , + stop_reason VARCHAR(20) NULL , + refills INTEGER NULL , + quantity NUMERIC NULL , + days_supply INTEGER NULL , + sig TEXT NULL , + route_concept_id INTEGER NULL , + lot_number VARCHAR(50) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + drug_source_value VARCHAR(50) NULL , + drug_source_concept_id INTEGER NULL , + route_source_value VARCHAR(50) NULL , + dose_unit_source_value VARCHAR(50) NULL ) ; @@ -413,21 +400,21 @@ CREATE TABLE drug_exposure --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE device_exposure ( - device_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - device_concept_id INTEGER NOT NULL , - device_exposure_start_date DATE NULL , - device_exposure_start_datetime DATETIME2 NOT NULL , - device_exposure_end_date DATE NULL , - device_exposure_end_datetime DATETIME2 NULL , - device_type_concept_id INTEGER NOT NULL , - unique_device_id VARCHAR(50) NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL + device_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + device_concept_id INTEGER NOT NULL , + device_exposure_start_date DATE NULL , + device_exposure_start_datetime TIMESTAMP NOT NULL , + device_exposure_end_date DATE NULL , + device_exposure_end_datetime TIMESTAMP NULL , + device_type_concept_id INTEGER NOT NULL , + unique_device_id VARCHAR(50) NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + device_source_value VARCHAR(100) NULL , + device_source_concept_id INTEGER NULL ) ; @@ -435,22 +422,22 @@ CREATE TABLE device_exposure --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_occurrence ( - condition_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_start_date DATE NULL , - condition_start_datetime DATETIME2 NOT NULL , - condition_end_date DATE NULL , - condition_end_datetime DATETIME2 NULL , - condition_type_concept_id INTEGER NOT NULL , - condition_status_concept_id INTEGER NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL , - condition_status_source_value VARCHAR(50) NULL + condition_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + condition_concept_id INTEGER NOT NULL , + condition_start_date DATE NULL , + condition_start_datetime TIMESTAMP NOT NULL , + condition_end_date DATE NULL , + condition_end_datetime TIMESTAMP NULL , + condition_type_concept_id INTEGER NOT NULL , + condition_status_concept_id INTEGER NULL , + stop_reason VARCHAR(20) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + condition_source_value VARCHAR(50) NULL , + condition_source_concept_id INTEGER NULL , + condition_status_source_value VARCHAR(50) NULL ) ; @@ -458,26 +445,26 @@ CREATE TABLE condition_occurrence --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE measurement ( - measurement_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NULL , - measurement_datetime DATETIME2 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 , - visit_detail_id INTEGER NULL , - measurement_source_value VARCHAR(50) NULL , + measurement_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + measurement_concept_id INTEGER NOT NULL , + measurement_date DATE NULL , + measurement_datetime TIMESTAMP 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 , + visit_detail_id INTEGER NULL , + measurement_source_value VARCHAR(50) NULL , measurement_source_concept_id INTEGER NULL , - unit_source_value VARCHAR(50) NULL , - value_source_value VARCHAR(50) NULL + unit_source_value VARCHAR(50) NULL , + value_source_value VARCHAR(50) NULL ) ; @@ -485,23 +472,22 @@ CREATE TABLE measurement --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE note ( - note_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - note_event_id BIGINT NULL , --This and the field below added - note_domain_id VARCHAR(20) NULL , --This field may be removed in favor of the one below ---note_event_table_concept_id INTEGER NULL , --This may be added based on 9/4 meeting - note_date DATE NULL , - note_datetime DATETIME2 NOT NULL , - note_type_concept_id INTEGER NOT NULL , - note_class_concept_id INTEGER NOT NULL , - note_title VARCHAR(250) NULL , - note_text TEXT NULL , - encoding_concept_id INTEGER NOT NULL , - language_concept_id INTEGER NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - note_source_value VARCHAR(50) NULL + note_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + note_event_id BIGINT NULL , + note_event_field_concept_id INTEGER NULL , + note_date DATE NULL , + note_datetime TIMESTAMP NOT NULL , + note_type_concept_id INTEGER NOT NULL , + note_class_concept_id INTEGER NOT NULL , + note_title VARCHAR(250) NULL , + note_text TEXT NULL , + encoding_concept_id INTEGER NOT NULL , + language_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + note_source_value VARCHAR(50) NULL ) ; @@ -509,20 +495,20 @@ CREATE TABLE note --HINT DISTRIBUTE ON RANDOM CREATE TABLE note_nlp ( - note_nlp_id BIGINT NOT NULL , - note_id BIGINT NOT NULL , - section_concept_id INTEGER NULL , - snippet VARCHAR(250) NULL , - "offset" VARCHAR(250) NULL , - lexical_variant VARCHAR(250) NOT NULL , - note_nlp_concept_id INTEGER NULL , - nlp_system VARCHAR(250) NULL , - nlp_date DATE NOT NULL , - nlp_datetime DATETIME2 NULL , - term_exists VARCHAR(1) NULL , - term_temporal VARCHAR(50) NULL , - term_modifiers VARCHAR(2000) NULL , - note_nlp_source_concept_id INTEGER NULL + note_nlp_id BIGINT NOT NULL , + note_id BIGINT NOT NULL , + section_concept_id INTEGER NULL , + snippet VARCHAR(250) NULL , + "offset" VARCHAR(250) NULL , + lexical_variant VARCHAR(250) NOT NULL , + note_nlp_concept_id INTEGER NULL , + nlp_system VARCHAR(250) NULL , + nlp_date DATE NOT NULL , + nlp_datetime TIMESTAMP NULL , + term_exists VARCHAR(1) NULL , + term_temporal VARCHAR(50) NULL , + term_modifiers VARCHAR(2000) NULL , + note_nlp_source_concept_id INTEGER NULL ) ; @@ -530,60 +516,59 @@ CREATE TABLE note_nlp --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation ( - observation_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NULL , - observation_datetime DATETIME2 NOT NULL , + observation_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_concept_id INTEGER NOT NULL , + observation_date DATE NULL , + observation_datetime TIMESTAMP NOT 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 BIGINT NULL , - visit_detail_id BIGINT NULL , - observation_source_value VARCHAR(50) 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 BIGINT NULL , + visit_detail_id BIGINT 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 , - observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - observation_event_domain_id VARCHAR(20) NULL , ---obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/ - value_as_datetime DATETIME2 NULL + unit_source_value VARCHAR(50) NULL , + qualifier_source_value VARCHAR(50) NULL , + observation_event_id BIGINT NULL , + obs_event_field_concept_id INTEGER NULL , + value_as_datetime TIMESTAMP NULL ) ; --HINT DISTRIBUTE ON KEY(person_id) -CREATE TABLE survey_conduct --Table added +CREATE TABLE survey_conduct ( - survey_conduct_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - survey_concept_id INTEGER NOT NULL , - survey_start_date DATE NULL , - survey_start_datetime DATETIME2 NULL , - survey_end_date DATE NULL , - survey_end_datetime DATETIME2 NOT NULL , - provider_id BIGINT NULL , - assisted_concept_id INTEGER NULL , - respondent_type_concept_id INTEGER NULL , - timing_concept_id INTEGER NULL , - collection_method_concept_id INTEGER NULL , - assisted_source_value VARCHAR(50) NULL , - respondent_type_source_value VARCHAR(100) NULL , - timing_source_value VARCHAR(100) NULL , + survey_conduct_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + survey_concept_id INTEGER NOT NULL , + survey_start_date DATE NULL , + survey_start_datetime TIMESTAMP NULL , + survey_end_date DATE NULL , + survey_end_datetime TIMESTAMP NOT NULL , + provider_id BIGINT NULL , + assisted_concept_id INTEGER NULL , + respondent_type_concept_id INTEGER NULL , + timing_concept_id INTEGER NULL , + collection_method_concept_id INTEGER NULL , + assisted_source_value VARCHAR(50) NULL , + respondent_type_source_value VARCHAR(100) NULL , + timing_source_value VARCHAR(100) NULL , collection_method_source_value VARCHAR(100) NULL , - survey_source_value VARCHAR(100) NULL , - survey_source_concept_id INTEGER NULL , - survey_source_identifier VARCHAR(100) NULL , - validated_survey_concept_id INTEGER NULL , + survey_source_value VARCHAR(100) NULL , + survey_source_concept_id INTEGER NULL , + survey_source_identifier VARCHAR(100) NULL , + validated_survey_concept_id INTEGER NULL , validated_survey_source_value VARCHAR(100) NULL , - survey_version_number VARCHAR(20) NULL , - visit_occurrence_id BIGINT NULL , - visit_detail_id BIGINT NULL , - response_to_visit_occurrence_id BIGINT NULL + survey_version_number VARCHAR(20) NULL , + visit_occurrence_id BIGINT NULL , + visit_detail_id BIGINT NULL , + response_visit_occurrence_id BIGINT NULL ) ; @@ -591,10 +576,10 @@ CREATE TABLE survey_conduct --Table added --HINT DISTRIBUTE ON RANDOM CREATE TABLE fact_relationship ( - domain_concept_id_1 INTEGER NOT NULL , - fact_id_1 BIGINT NOT NULL , - domain_concept_id_2 INTEGER NOT NULL , - fact_id_2 BIGINT NOT NULL , + domain_concept_id_1 INTEGER NOT NULL , + fact_id_1 BIGINT NOT NULL , + domain_concept_id_2 INTEGER NOT NULL , + fact_id_2 BIGINT NOT NULL , relationship_concept_id INTEGER NOT NULL ) ; @@ -611,17 +596,17 @@ Standardized health system data --HINT DISTRIBUTE ON RANDOM CREATE TABLE location ( - location_id BIGINT 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 , - country VARCHAR(100) NULL , + location_id BIGINT 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 , + country VARCHAR(100) NULL , location_source_value VARCHAR(50) NULL , - latitude NUMERIC NULL , - longitude NUMERIC NULL + latitude NUMERIC NULL , + longitude NUMERIC NULL ) ; @@ -630,12 +615,12 @@ CREATE TABLE location CREATE TABLE location_history --Table added ( location_history_id BIGINT NOT NULL , - location_id BIGINT NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion - domain_id VARCHAR(50) NOT NULL , - entity_id BIGINT NOT NULL , - start_date DATE NOT NULL , - end_date DATE NULL + location_id BIGINT NOT NULL , + relationship_type_concept_id INTEGER NULL , + domain_id VARCHAR(50) NOT NULL , + entity_id BIGINT NOT NULL , + start_date DATE NOT NULL , + end_date DATE NULL ) ; @@ -643,12 +628,12 @@ CREATE TABLE location_history --Table added --HINT DISTRIBUTE ON RANDOM CREATE TABLE care_site ( - care_site_id BIGINT NOT NULL , - care_site_name VARCHAR(255) NULL , - place_of_service_concept_id INTEGER NULL , - location_id BIGINT NULL , - care_site_source_value VARCHAR(50) NULL , - place_of_service_source_value VARCHAR(50) NULL + care_site_id BIGINT NOT NULL , + care_site_name VARCHAR(255) NULL , + place_of_service_concept_id INTEGER NULL , + location_id BIGINT NULL , + care_site_source_value VARCHAR(50) NULL , + place_of_service_source_value VARCHAR(50) NULL ) ; @@ -656,19 +641,19 @@ CREATE TABLE care_site --HINT DISTRIBUTE ON RANDOM CREATE TABLE provider ( - provider_id BIGINT NOT NULL , - provider_name VARCHAR(255) NULL , - NPI VARCHAR(20) NULL , - DEA VARCHAR(20) NULL , - specialty_concept_id INTEGER NULL , - care_site_id BIGINT 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 + provider_id BIGINT NOT NULL , + provider_name VARCHAR(255) NULL , + NPI VARCHAR(20) NULL , + DEA VARCHAR(20) NULL , + specialty_concept_id INTEGER NULL , + care_site_id BIGINT 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 ) ; @@ -683,27 +668,27 @@ Standardized health economics --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period ( - payer_plan_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - contract_person_id BIGINT NULL , - payer_plan_period_start_date DATE NOT NULL , - payer_plan_period_end_date DATE NOT NULL , - payer_concept_id INTEGER NULL , - plan_concept_id INTEGER NULL , - contract_concept_id INTEGER NULL , - sponsor_concept_id INTEGER NULL , - stop_reason_concept_id INTEGER NULL , - payer_source_value VARCHAR(50) NULL , - payer_source_concept_id INTEGER NULL , - plan_source_value VARCHAR(50) NULL , - plan_source_concept_id INTEGER NULL , - contract_source_value VARCHAR(50) NULL , - contract_source_concept_id INTEGER NULL , - sponsor_source_value VARCHAR(50) NULL , - sponsor_source_concept_id INTEGER NULL , - family_source_value VARCHAR(50) NULL , - stop_reason_source_value VARCHAR(50) NULL , - stop_reason_source_concept_id INTEGER NULL + payer_plan_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + contract_person_id BIGINT NULL , + payer_plan_period_start_date DATE NOT NULL , + payer_plan_period_end_date DATE NOT NULL , + payer_concept_id INTEGER NULL , + plan_concept_id INTEGER NULL , + contract_concept_id INTEGER NULL , + sponsor_concept_id INTEGER NULL , + stop_reason_concept_id INTEGER NULL , + payer_source_value VARCHAR(50) NULL , + payer_source_concept_id INTEGER NULL , + plan_source_value VARCHAR(50) NULL , + plan_source_concept_id INTEGER NULL , + contract_source_value VARCHAR(50) NULL , + contract_source_concept_id INTEGER NULL , + sponsor_source_value VARCHAR(50) NULL , + sponsor_source_concept_id INTEGER NULL , + family_source_value VARCHAR(50) NULL , + stop_reason_source_value VARCHAR(50) NULL , + stop_reason_source_concept_id INTEGER NULL ) ; @@ -711,25 +696,24 @@ CREATE TABLE payer_plan_period --HINT DISTRIBUTE ON KEY(person_id) CREATE TABLE cost ( - cost_id BIGINT NOT NULL , - person_id BIGINT NOT NULL, - cost_event_id BIGINT NOT NULL , - cost_domain_id VARCHAR(20) NOT NULL , ---cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/ - cost_concept_id INTEGER NOT NULL , - cost_type_concept_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - cost NUMERIC NULL , - incurred_date DATE NOT NULL , - billed_date DATE NULL , - paid_date DATE NULL , - revenue_code_concept_id INTEGER NULL , - drg_concept_id INTEGER NULL , - cost_source_value VARCHAR(50) NULL , - cost_source_concept_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL , + cost_id BIGINT NOT NULL , + person_id BIGINT NOT NULL, + cost_event_id BIGINT NOT NULL , + cost_event_field_concept_id INTEGER NOT NULL , + cost_concept_id INTEGER NOT NULL , + cost_type_concept_id INTEGER NOT NULL , + currency_concept_id INTEGER NULL , + cost NUMERIC NULL , + incurred_date DATE NOT NULL , + billed_date DATE NULL , + paid_date DATE NULL , + revenue_code_concept_id INTEGER NULL , + drg_concept_id INTEGER NULL , + cost_source_value VARCHAR(50) NULL , + cost_source_concept_id INTEGER NULL , + revenue_code_source_value VARCHAR(50) NULL , drg_source_value VARCHAR(3) NULL , - payer_plan_period_id BIGINT NULL + payer_plan_period_id BIGINT NULL ) ; @@ -741,41 +725,16 @@ Standardized derived elements ************************/ ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort -( - cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL -) -; - - ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort_attribute -( - cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - attribute_definition_id BIGINT NOT NULL , - value_as_number NUMERIC NULL , - value_as_concept_id INTEGER NULL -) -; - - --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_era ( - drug_era_id BIGINT NOT NULL , - person_id BIGINT 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 + drug_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) ; @@ -783,13 +742,13 @@ CREATE TABLE drug_era --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE dose_era ( - dose_era_id BIGINT NOT NULL , - person_id BIGINT 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 + dose_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) ; @@ -797,11 +756,11 @@ CREATE TABLE dose_era --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_era ( - condition_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_era_start_date DATE NOT NULL , - condition_era_end_date DATE NOT NULL , + condition_era_id BIGINT NOT NULL , + person_id BIGINT 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 postgresql pk indexes.txt b/PostgreSQL/OMOP CDM postgresql pk indexes.txt index 44fc3ed..7776979 100644 --- a/PostgreSQL/OMOP CDM postgresql pk indexes.txt +++ b/PostgreSQL/OMOP CDM postgresql pk indexes.txt @@ -77,10 +77,6 @@ ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMA 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); - /************************** @@ -127,7 +123,7 @@ ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ; ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ; -ALTER TABLE survey ADD CONSTRAINT xpk_survey PRIMARY KEY ( survey_occurrence_id ) ; +ALTER TABLE survey_conduct ADD CONSTRAINT xpk_survey PRIMARY KEY ( survey_conduct_id ) ; /************************ @@ -139,7 +135,7 @@ Standardized health system data ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ; -ALTER TABLE location_history ADD CONSTRAINT xpk_location_history PRIMARY KEY ( location_history_id ) ; --Assuming this should be added +ALTER TABLE location_history ADD CONSTRAINT xpk_location_history PRIMARY KEY ( location_history_id ) ; ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ; @@ -165,10 +161,6 @@ 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 ) ; @@ -234,12 +226,6 @@ 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 ; - /************************** @@ -317,8 +303,8 @@ 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_survey_person_id ON survey (person_id ASC); -CLUSTER survey USING idx_survey_person_id ; +CREATE INDEX idx_survey_person_id ON survey_conduct (person_id ASC); +CLUSTER survey_conduct USING idx_survey_person_id ; 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); @@ -356,12 +342,6 @@ 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); diff --git a/PostgreSQL/README.md b/PostgreSQL/README.md index da1519f..42d64fa 100644 --- a/PostgreSQL/README.md +++ b/PostgreSQL/README.md @@ -16,3 +16,5 @@ In order to create your instantiation of the Common Data Model, we recommend fol 5. Execute the script `OMOP CDM postgresql constraints.txt` to add the constraints (foreign keys). 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. + +6. Repeat steps 1-3, executing the script `OMOP CDM Results postgresql ddl.txt` diff --git a/Redshift/OMOP CDM Results redshift ddl.txt b/Redshift/OMOP CDM Results redshift ddl.txt new file mode 100644 index 0000000..0bf9024 --- /dev/null +++ b/Redshift/OMOP CDM Results redshift ddl.txt @@ -0,0 +1,59 @@ +/********************************************************************************* +# Copyright 2018-08 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. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # + # # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### # # + # # # # # # # # # # # # # # # # ### # # + # # # # # # # # # # # # # # # # # ### # # + ####### # # ####### # ##### ###### # # ## ##### ### ### + +redshift script to create OMOP common data model results schema version 6.0 + +last revised: 27-Aug-2018 + +Authors: Patrick Ryan, Christian Reich, Clair Blacketer + + +*************************/ + + +--HINT DISTRIBUTE_ON_KEY(subject_id) +CREATE TABLE cohort ( + cohort_definition_id BIGINT NOT NULL , + subject_id BIGINT NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL +) +DISTKEY(subject_id); + + +--HINT DISTRIBUTE ON RANDOM +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 +) +DISTSTYLE ALL; + diff --git a/Redshift/OMOP CDM redshift ddl.txt b/Redshift/OMOP CDM redshift ddl.txt index 39497f8..ed8d955 100644 --- a/Redshift/OMOP CDM redshift ddl.txt +++ b/Redshift/OMOP CDM redshift ddl.txt @@ -43,78 +43,86 @@ Standardized vocabulary --HINT DISTRIBUTE ON RANDOM -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 , +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 + concept_code VARCHAR(50) NOT NULL , + valid_start_date DATE NOT NULL , + valid_end_date DATE NOT NULL , + invalid_reason VARCHAR(1) NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE vocabulary (vocabulary_id VARCHAR(20) NOT NULL, +CREATE TABLE vocabulary ( + vocabulary_id VARCHAR(20) NOT NULL, vocabulary_name VARCHAR(255) NOT NULL, - vocabulary_reference VARCHAR(255) NOT NULL, - vocabulary_version VARCHAR(255) NOT NULL, - vocabulary_concept_id INTEGER NOT NULL + vocabulary_reference VARCHAR(255) NOT NULL, + vocabulary_version VARCHAR(255) NOT NULL, + vocabulary_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE domain (domain_id VARCHAR(20) NOT NULL, +CREATE TABLE domain ( + domain_id VARCHAR(20) NOT NULL, domain_name VARCHAR(255) NOT NULL, - domain_concept_id INTEGER NOT NULL + domain_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE concept_class (concept_class_id VARCHAR(20) 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 + concept_class_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE concept_relationship (concept_id_1 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 + relationship_id VARCHAR(20) NOT NULL, + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -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, +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 + relationship_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -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_synonym ( + concept_id INTEGER NOT NULL, + concept_synonym_name VARCHAR(1000) NOT NULL, + language_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE concept_ancestor (ancestor_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 @@ -123,54 +131,34 @@ DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE source_to_concept_map (source_code VARCHAR(50) NOT NULL, - source_concept_id 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_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 + valid_start_date DATE NOT NULL, + valid_end_date DATE NOT NULL, + invalid_reason VARCHAR(1) NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -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 -) -DISTSTYLE ALL; - - ---HINT DISTRIBUTE ON RANDOM -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 -) -DISTSTYLE ALL; - - ---HINT DISTRIBUTE ON RANDOM -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 +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 ) DISTSTYLE ALL; @@ -183,35 +171,35 @@ Standardized meta-data --HINT DISTRIBUTE ON RANDOM -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 , +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 + 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 ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE metadata - (metadata_concept_id INTEGER NOT NULL , +CREATE TABLE metadata ( + metadata_concept_id INTEGER NOT NULL , metadata_type_concept_id INTEGER NOT NULL , name VARCHAR(250) NOT NULL , value_as_string VARCHAR(MAX) NULL , value_as_concept_id INTEGER NULL , metadata_date DATE NULL , - metadata_datetime TIMESTAMP NULL + metadata_datetime TIMESTAMP NULL ) DISTSTYLE ALL; -INSERT INTO metadata (name, value_as_string) --Added cdm version record -VALUES ('CDM Version', '6.0') +INSERT INTO metadata (metadata_concept_id, metadata_type_concept_id, name, value_as_string, value_as_concept_id, metadata_date, metadata_datetime) +VALUES (0, 0, 'CDM Version', '6.0', 0, NULL, NULL) ; @@ -223,100 +211,87 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE person - (person_id BIGINT NOT NULL , --BIGINTs added - gender_concept_id INTEGER NOT NULL , - year_of_birth INTEGER NOT NULL , - month_of_birth INTEGER NULL, - day_of_birth INTEGER NULL, - birth_datetime TIMESTAMP NULL, - race_concept_id INTEGER NOT NULL, - ethnicity_concept_id INTEGER NOT NULL, - location_id INTEGER NULL, - provider_id INTEGER NULL, - care_site_id INTEGER NULL, - person_source_value VARCHAR(50) NULL, - gender_source_value VARCHAR(50) NULL, - gender_source_concept_id INTEGER NULL, - race_source_value VARCHAR(50) NULL, - race_source_concept_id INTEGER NULL, - ethnicity_source_value VARCHAR(50) NULL, - ethnicity_source_concept_id INTEGER NULL +CREATE TABLE person ( + person_id BIGINT NOT NULL , + gender_concept_id INTEGER NOT NULL , + year_of_birth INTEGER NOT NULL , + month_of_birth INTEGER NULL, + day_of_birth INTEGER NULL, + birth_datetime TIMESTAMP NULL, + race_concept_id INTEGER NOT NULL, + ethnicity_concept_id INTEGER NOT NULL, + location_id INTEGER NULL, + provider_id INTEGER NULL, + care_site_id INTEGER NULL, + person_source_value VARCHAR(50) NULL, + gender_source_value VARCHAR(50) NULL, + gender_source_concept_id INTEGER NULL, + race_source_value VARCHAR(50) NULL, + race_source_concept_id INTEGER NULL, + ethnicity_source_value VARCHAR(50) NULL, + ethnicity_source_concept_id INTEGER NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE observation_period - (observation_period_id BIGINT NOT NULL , - person_id BIGINT 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 observation_period ( + observation_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_period_start_date DATE NOT NULL , + observation_period_end_date DATE NOT NULL , + period_type_concept_id INTEGER NOT NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE specimen - (specimen_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - specimen_concept_id INTEGER NOT NULL , +CREATE TABLE specimen ( + specimen_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + specimen_concept_id INTEGER NOT NULL , specimen_type_concept_id INTEGER NOT NULL , - specimen_date DATE NULL , - specimen_datetime TIMESTAMP NOT NULL , - quantity FLOAT NULL , - unit_concept_id INTEGER NULL , + specimen_date DATE NULL , + specimen_datetime TIMESTAMP NOT 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 + 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 ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE death - (person_id BIGINT NOT NULL , - death_date DATE NULL , - death_datetime TIMESTAMP 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 -) -DISTKEY(person_id); - - ---HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE visit_occurrence - (visit_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - visit_concept_id INTEGER NOT NULL , - visit_start_date DATE NULL , - visit_start_datetime TIMESTAMP NOT NULL , - visit_end_date DATE NULL , - visit_end_datetime TIMESTAMP NOT NULL , +CREATE TABLE visit_occurrence ( + visit_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + visit_concept_id INTEGER NOT NULL , + visit_start_date DATE NULL , + visit_start_datetime TIMESTAMP NOT NULL , + visit_end_date DATE NULL , + visit_end_datetime TIMESTAMP NOT NULL , visit_type_concept_id INTEGER NOT NULL , - provider_id INTEGER NULL, - care_site_id INTEGER NULL, - visit_source_value VARCHAR(50) NULL, + provider_id INTEGER NULL, + care_site_id INTEGER NULL, + visit_source_value VARCHAR(50) NULL, visit_source_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ - admitted_from_source_value VARCHAR(50) NULL , - discharge_to_source_value VARCHAR(50) NULL , - discharge_to_concept_id INTEGER NULL , - preceding_visit_occurrence_id INTEGER NULL + admitted_from_concept_id INTEGER NULL , + admitted_from_source_value VARCHAR(50) NULL , + discharge_to_source_value VARCHAR(50) NULL , + discharge_to_concept_id INTEGER NULL , + preceding_visit_occurrence_id INTEGER NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE visit_detail - (visit_detail_id BIGINT NOT NULL , +CREATE TABLE visit_detail ( + visit_detail_id BIGINT NOT NULL , person_id BIGINT NOT NULL , visit_detail_concept_id INTEGER NOT NULL , visit_detail_start_date DATE NULL , @@ -327,7 +302,7 @@ CREATE TABLE visit_detail provider_id INTEGER NULL , care_site_id INTEGER NULL , discharge_to_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , visit_detail_source_value VARCHAR(50) NULL , visit_detail_source_concept_id INTEGER NULL , @@ -340,231 +315,229 @@ DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE procedure_occurrence - (procedure_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - procedure_concept_id INTEGER NOT NULL , - procedure_date DATE NULL , - procedure_datetime TIMESTAMP NOT NULL , +CREATE TABLE procedure_occurrence ( + procedure_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + procedure_concept_id INTEGER NOT NULL , + procedure_date DATE NULL , + procedure_datetime TIMESTAMP 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 , - visit_detail_id INTEGER NULL , - procedure_source_value VARCHAR(50) NULL , + modifier_concept_id INTEGER NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + procedure_source_value VARCHAR(50) NULL , procedure_source_concept_id INTEGER NULL , - modifier_source_value VARCHAR(50) NULL , + modifier_source_value VARCHAR(50) NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE drug_exposure - (drug_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - drug_concept_id INTEGER NOT NULL , - drug_exposure_start_date DATE NULL , - drug_exposure_start_datetime TIMESTAMP NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime TIMESTAMP NOT NULL , - verbatim_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 , - lot_number VARCHAR(50) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - drug_source_value VARCHAR(50) NULL , - drug_source_concept_id INTEGER NULL , - route_source_value VARCHAR(50) NULL , - dose_unit_source_value VARCHAR(50) NULL +CREATE TABLE drug_exposure ( + drug_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + drug_concept_id INTEGER NOT NULL , + drug_exposure_start_date DATE NULL , + drug_exposure_start_datetime TIMESTAMP NOT NULL , + drug_exposure_end_date DATE NULL , + drug_exposure_end_datetime TIMESTAMP NOT NULL , + verbatim_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 , + lot_number VARCHAR(50) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + drug_source_value VARCHAR(50) NULL , + drug_source_concept_id INTEGER NULL , + route_source_value VARCHAR(50) NULL , + dose_unit_source_value VARCHAR(50) NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE device_exposure - (device_exposure_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - device_concept_id INTEGER NOT NULL , - device_exposure_start_date DATE NULL , - device_exposure_start_datetime TIMESTAMP NOT NULL , - device_exposure_end_date DATE NULL , - device_exposure_end_datetime TIMESTAMP NULL , - device_type_concept_id INTEGER NOT NULL , - unique_device_id VARCHAR(50) NULL , - quantity INTEGER NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - device_source_value VARCHAR(100) NULL , - device_source_concept_id INTEGER NULL +CREATE TABLE device_exposure ( + device_exposure_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + device_concept_id INTEGER NOT NULL , + device_exposure_start_date DATE NULL , + device_exposure_start_datetime TIMESTAMP NOT NULL , + device_exposure_end_date DATE NULL , + device_exposure_end_datetime TIMESTAMP NULL , + device_type_concept_id INTEGER NOT NULL , + unique_device_id VARCHAR(50) NULL , + quantity INTEGER NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + device_source_value VARCHAR(100) NULL , + device_source_concept_id INTEGER NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE condition_occurrence - (condition_occurrence_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , +CREATE TABLE condition_occurrence ( + condition_occurrence_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , condition_concept_id INTEGER NOT NULL , - condition_start_date DATE NULL , - condition_start_datetime TIMESTAMP NOT NULL , - condition_end_date DATE NULL , + condition_start_date DATE NULL , + condition_start_datetime TIMESTAMP NOT NULL , + condition_end_date DATE NULL , condition_end_datetime TIMESTAMP NULL , - condition_type_concept_id INTEGER NOT NULL , - condition_status_concept_id INTEGER NULL , - stop_reason VARCHAR(20) NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , - condition_source_concept_id INTEGER NULL , - condition_status_source_value VARCHAR(50) NULL + condition_type_concept_id INTEGER NOT NULL , + condition_status_concept_id INTEGER NULL , + stop_reason VARCHAR(20) NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + condition_source_value VARCHAR(50) NULL , + condition_source_concept_id INTEGER NULL , + condition_status_source_value VARCHAR(50) NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE measurement - (measurement_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - measurement_concept_id INTEGER NOT NULL , - measurement_date DATE NULL , - measurement_datetime TIMESTAMP 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 , - visit_detail_id INTEGER NULL , - measurement_source_value VARCHAR(50) NULL , +CREATE TABLE measurement ( + measurement_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + measurement_concept_id INTEGER NOT NULL , + measurement_date DATE NULL , + measurement_datetime TIMESTAMP 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 , + visit_detail_id INTEGER NULL , + measurement_source_value VARCHAR(50) NULL , measurement_source_concept_id INTEGER NULL , - unit_source_value VARCHAR(50) NULL , - value_source_value VARCHAR(50) NULL + unit_source_value VARCHAR(50) NULL , + value_source_value VARCHAR(50) NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE note - (note_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - note_event_id BIGINT NULL , --This and the field below added - note_domain_id VARCHAR(20) NULL , --This field may be removed in favor of the one below ---note_event_table_concept_id INTEGER NULL , --This may be added based on 9/4 meeting - note_date DATE NULL , - note_datetime TIMESTAMP NOT NULL , - note_type_concept_id INTEGER NOT NULL , - note_class_concept_id INTEGER NOT NULL , - note_title VARCHAR(250) NULL , - note_text VARCHAR(MAX) NULL , - encoding_concept_id INTEGER NOT NULL , - language_concept_id INTEGER NOT NULL , - provider_id INTEGER NULL , - visit_occurrence_id INTEGER NULL , - visit_detail_id INTEGER NULL , - note_source_value VARCHAR(50) NULL +CREATE TABLE note ( + note_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + note_event_id BIGINT NULL , + note_event_field_concept_id INTEGER NULL , + note_date DATE NULL , + note_datetime TIMESTAMP NOT NULL , + note_type_concept_id INTEGER NOT NULL , + note_class_concept_id INTEGER NOT NULL , + note_title VARCHAR(250) NULL , + note_text VARCHAR(MAX) NULL , + encoding_concept_id INTEGER NOT NULL , + language_concept_id INTEGER NOT NULL , + provider_id INTEGER NULL , + visit_occurrence_id INTEGER NULL , + visit_detail_id INTEGER NULL , + note_source_value VARCHAR(50) NULL ) DISTKEY(person_id); --HINT DISTRIBUTE ON RANDOM -CREATE TABLE note_nlp - (note_nlp_id BIGINT NOT NULL , - note_id BIGINT NOT NULL , - section_concept_id INTEGER NULL , - snippet VARCHAR(250) NULL , - "offset" VARCHAR(250) NULL , - lexical_variant VARCHAR(250) NOT NULL , - note_nlp_concept_id INTEGER NULL , - nlp_system VARCHAR(250) NULL , - nlp_date DATE NOT NULL , - nlp_datetime TIMESTAMP NULL , - term_exists VARCHAR(1) NULL , - term_temporal VARCHAR(50) NULL , - term_modifiers VARCHAR(2000) NULL , - note_nlp_source_concept_id INTEGER NULL +CREATE TABLE note_nlp ( + note_nlp_id BIGINT NOT NULL , + note_id BIGINT NOT NULL , + section_concept_id INTEGER NULL , + snippet VARCHAR(250) NULL , + "offset" VARCHAR(250) NULL , + lexical_variant VARCHAR(250) NOT NULL , + note_nlp_concept_id INTEGER NULL , + nlp_system VARCHAR(250) NULL , + nlp_date DATE NOT NULL , + nlp_datetime TIMESTAMP NULL , + term_exists VARCHAR(1) NULL , + term_temporal VARCHAR(50) NULL , + term_modifiers VARCHAR(2000) NULL , + note_nlp_source_concept_id INTEGER NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation - (observation_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NULL , - observation_datetime TIMESTAMP NOT NULL , + (observation_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_concept_id INTEGER NOT NULL , + observation_date DATE NULL , + observation_datetime TIMESTAMP NOT 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 BIGINT NULL , - visit_detail_id BIGINT NULL , - observation_source_value VARCHAR(50) 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 BIGINT NULL , + visit_detail_id BIGINT 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 , - observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - observation_event_domain_id VARCHAR(20) NULL , ---obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/ - value_as_datetime TIMESTAMP NULL + unit_source_value VARCHAR(50) NULL , + qualifier_source_value VARCHAR(50) NULL , + observation_event_id BIGINT NULL , + obs_event_field_concept_id INTEGER NULL , + value_as_datetime TIMESTAMP NULL ) DISTKEY(person_id); --HINT DISTRIBUTE ON KEY(person_id) -CREATE TABLE survey_conduct --Table added - (survey_conduct_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - survey_concept_id INTEGER NOT NULL , - survey_start_date DATE NULL , - survey_start_datetime TIMESTAMP NULL , - survey_end_date DATE NULL , - survey_end_datetime TIMESTAMP NOT NULL , - provider_id BIGINT NULL , - assisted_concept_id INTEGER NULL , - respondent_type_concept_id INTEGER NULL , - timing_concept_id INTEGER NULL , - collection_method_concept_id INTEGER NULL , - assisted_source_value VARCHAR(50) NULL , - respondent_type_source_value VARCHAR(100) NULL , - timing_source_value VARCHAR(100) NULL , +CREATE TABLE survey_conduct ( + survey_conduct_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + survey_concept_id INTEGER NOT NULL , + survey_start_date DATE NULL , + survey_start_datetime TIMESTAMP NULL , + survey_end_date DATE NULL , + survey_end_datetime TIMESTAMP NOT NULL , + provider_id BIGINT NULL , + assisted_concept_id INTEGER NULL , + respondent_type_concept_id INTEGER NULL , + timing_concept_id INTEGER NULL , + collection_method_concept_id INTEGER NULL , + assisted_source_value VARCHAR(50) NULL , + respondent_type_source_value VARCHAR(100) NULL , + timing_source_value VARCHAR(100) NULL , collection_method_source_value VARCHAR(100) NULL , - survey_source_value VARCHAR(100) NULL , - survey_source_concept_id INTEGER NULL , - survey_source_identifier VARCHAR(100) NULL , - validated_survey_concept_id INTEGER NULL , + survey_source_value VARCHAR(100) NULL , + survey_source_concept_id INTEGER NULL , + survey_source_identifier VARCHAR(100) NULL , + validated_survey_concept_id INTEGER NULL , validated_survey_source_value VARCHAR(100) NULL , - survey_version_number VARCHAR(20) NULL , - visit_occurrence_id BIGINT NULL , - visit_detail_id BIGINT NULL , - response_to_visit_occurrence_id BIGINT NULL + survey_version_number VARCHAR(20) NULL , + visit_occurrence_id BIGINT NULL , + visit_detail_id BIGINT NULL , + response_visit_occurrence_id BIGINT NULL ) DISTKEY(person_id); --HINT DISTRIBUTE ON RANDOM -CREATE TABLE fact_relationship - (domain_concept_id_1 INTEGER NOT NULL , - fact_id_1 BIGINT NOT NULL , - domain_concept_id_2 INTEGER NOT NULL , - fact_id_2 BIGINT NOT NULL , +CREATE TABLE fact_relationship ( + domain_concept_id_1 INTEGER NOT NULL , + fact_id_1 BIGINT NOT NULL , + domain_concept_id_2 INTEGER NOT NULL , + fact_id_2 BIGINT NOT NULL , relationship_concept_id INTEGER NOT NULL ) DISTSTYLE ALL; @@ -580,61 +553,61 @@ Standardized health system data --HINT DISTRIBUTE ON RANDOM CREATE TABLE location - (location_id BIGINT 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 , - country VARCHAR(100) NULL , - location_source_value VARCHAR(50) NULL , - latitude FLOAT NULL , - longitude FLOAT NULL + (location_id BIGINT 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 , + country VARCHAR(100) NULL , + location_source_value VARCHAR(50) NULL , + latitude FLOAT NULL , + longitude FLOAT NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE location_history --Table added - (location_history_id BIGINT NOT NULL , - location_id BIGINT NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion - domain_id VARCHAR(50) NOT NULL , - entity_id BIGINT NOT NULL , - start_date DATE NOT NULL , - end_date DATE NULL +CREATE TABLE location_history ( + location_history_id BIGINT NOT NULL , + location_id BIGINT NOT NULL , + relationship_type_concept_id INTEGER NULL , + domain_id VARCHAR(50) NOT NULL , + entity_id BIGINT NOT NULL , + start_date DATE NOT NULL , + end_date DATE NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE care_site - (care_site_id BIGINT NOT NULL , - care_site_name VARCHAR(255) NULL , - place_of_service_concept_id INTEGER NULL , - location_id BIGINT NULL , - care_site_source_value VARCHAR(50) NULL , - place_of_service_source_value VARCHAR(50) NULL +CREATE TABLE care_site ( + care_site_id BIGINT NOT NULL , + care_site_name VARCHAR(255) NULL , + place_of_service_concept_id INTEGER NULL , + location_id BIGINT NULL , + care_site_source_value VARCHAR(50) NULL , + place_of_service_source_value VARCHAR(50) NULL ) DISTSTYLE ALL; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE provider - (provider_id BIGINT NOT NULL , - provider_name VARCHAR(255) NULL , - NPI VARCHAR(20) NULL , - DEA VARCHAR(20) NULL , - specialty_concept_id INTEGER NULL , - care_site_id BIGINT 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 +CREATE TABLE provider ( + provider_id BIGINT NOT NULL , + provider_name VARCHAR(255) NULL , + NPI VARCHAR(20) NULL , + DEA VARCHAR(20) NULL , + specialty_concept_id INTEGER NULL , + care_site_id BIGINT 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 ) DISTSTYLE ALL; @@ -648,52 +621,51 @@ Standardized health economics --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period - (payer_plan_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - contract_person_id BIGINT NULL , - payer_plan_period_start_date DATE NOT NULL , - payer_plan_period_end_date DATE NOT NULL , - payer_concept_id INTEGER NULL , - plan_concept_id INTEGER NULL , - contract_concept_id INTEGER NULL , - sponsor_concept_id INTEGER NULL , - stop_reason_concept_id INTEGER NULL , - payer_source_value VARCHAR(50) NULL , - payer_source_concept_id INTEGER NULL , - plan_source_value VARCHAR(50) NULL , - plan_source_concept_id INTEGER NULL , - contract_source_value VARCHAR(50) NULL , - contract_source_concept_id INTEGER NULL , - sponsor_source_value VARCHAR(50) NULL , - sponsor_source_concept_id INTEGER NULL , - family_source_value VARCHAR(50) NULL , - stop_reason_source_value VARCHAR(50) NULL , - stop_reason_source_concept_id INTEGER NULL + (payer_plan_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + contract_person_id BIGINT NULL , + payer_plan_period_start_date DATE NOT NULL , + payer_plan_period_end_date DATE NOT NULL , + payer_concept_id INTEGER NULL , + plan_concept_id INTEGER NULL , + contract_concept_id INTEGER NULL , + sponsor_concept_id INTEGER NULL , + stop_reason_concept_id INTEGER NULL , + payer_source_value VARCHAR(50) NULL , + payer_source_concept_id INTEGER NULL , + plan_source_value VARCHAR(50) NULL , + plan_source_concept_id INTEGER NULL , + contract_source_value VARCHAR(50) NULL , + contract_source_concept_id INTEGER NULL , + sponsor_source_value VARCHAR(50) NULL , + sponsor_source_concept_id INTEGER NULL , + family_source_value VARCHAR(50) NULL , + stop_reason_source_value VARCHAR(50) NULL , + stop_reason_source_concept_id INTEGER NULL ) DISTKEY(person_id); --HINT DISTRIBUTE ON KEY(person_id) -CREATE TABLE cost - (cost_id BIGINT NOT NULL , - person_id BIGINT NOT NULL, - cost_event_id BIGINT NOT NULL , - cost_domain_id VARCHAR(20) NOT NULL , ---cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/ - cost_concept_id INTEGER NOT NULL , - cost_type_concept_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - cost FLOAT NULL , - incurred_date DATE NOT NULL , - billed_date DATE NULL , - paid_date DATE NULL , - revenue_code_concept_id INTEGER NULL , - drg_concept_id INTEGER NULL , - cost_source_value VARCHAR(50) NULL , - cost_source_concept_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL , +CREATE TABLE cost ( + cost_id BIGINT NOT NULL , + person_id BIGINT NOT NULL, + cost_event_id BIGINT NOT NULL , + cost_event_field_concept_id INTEGER NOT NULL , + cost_concept_id INTEGER NOT NULL , + cost_type_concept_id INTEGER NOT NULL , + currency_concept_id INTEGER NULL , + cost FLOAT NULL , + incurred_date DATE NOT NULL , + billed_date DATE NULL , + paid_date DATE NULL , + revenue_code_concept_id INTEGER NULL , + drg_concept_id INTEGER NULL , + cost_source_value VARCHAR(50) NULL , + cost_source_concept_id INTEGER NULL , + revenue_code_source_value VARCHAR(50) NULL , drg_source_value VARCHAR(3) NULL , - payer_plan_period_id BIGINT NULL + payer_plan_period_id BIGINT NULL ) DISTKEY(person_id); @@ -705,62 +677,39 @@ Standardized derived elements ************************/ ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort - (cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL -) -DISTKEY(subject_id); - - ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort_attribute - (cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - attribute_definition_id BIGINT NOT NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL -) -DISTKEY(subject_id); - - --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE drug_era - (drug_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - drug_concept_id INTEGER NOT NULL , - drug_era_start_date DATE NOT NULL , - drug_era_end_date DATE NOT NULL , +CREATE TABLE drug_era ( + drug_era_id BIGINT NOT NULL , + person_id BIGINT 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 + gap_days INTEGER NULL ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE dose_era - (dose_era_id BIGINT NOT NULL , - person_id BIGINT 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 dose_era ( + dose_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) DISTKEY(person_id); --HINT DISTRIBUTE_ON_KEY(person_id) -CREATE TABLE condition_era - (condition_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_era_start_date DATE NOT NULL , - condition_era_end_date DATE NOT NULL , +CREATE TABLE condition_era ( + condition_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) DISTKEY(person_id); diff --git a/Redshift/README.md b/Redshift/README.md index d6feb1c..849c890 100644 --- a/Redshift/README.md +++ b/Redshift/README.md @@ -11,4 +11,6 @@ In order to create your instantiation of the Common Data Model, we recommend fol 3. Execute the script `OMOP CDM redshift ddl.txt` to create the tables and fields. -4. Load your data into the schema using COPY commands from Amazon S3. \ No newline at end of file +4. Load your data into the schema using COPY commands from Amazon S3. + +5. Repeat to create the results schema, executing the script `OMOP CDM Results redshift ddl.txt` \ No newline at end of file diff --git a/Sql Server/OMOP CDM Results sql server.txt b/Sql Server/OMOP CDM Results sql server.txt index deb5d1d..6cf4197 100644 --- a/Sql Server/OMOP CDM Results sql server.txt +++ b/Sql Server/OMOP CDM Results sql server.txt @@ -41,6 +41,18 @@ Standardized vocabulary ************************/ + +--HINT DISTRIBUTE_ON_KEY(subject_id) +CREATE TABLE cohort +( + cohort_definition_id BIGINT NOT NULL , + subject_id BIGINT NOT NULL , + cohort_start_date DATE NOT NULL , + cohort_end_date DATE NOT NULL +) +; + + --HINT DISTRIBUTE ON RANDOM CREATE TABLE cohort_definition ( cohort_definition_id INTEGER NOT NULL, @@ -52,3 +64,28 @@ CREATE TABLE cohort_definition ( cohort_initiation_date DATE NULL ) ; + +ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id); + +ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; + + +CREATE CLUSTERED INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC); + +CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC); +CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC); + + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id); + +ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); + + +ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id); + + + + + + + diff --git a/Sql Server/OMOP CDM sql server constraints.txt b/Sql Server/OMOP CDM sql server constraints.txt index 3568dbb..7f41455 100644 --- a/Sql Server/OMOP CDM sql server constraints.txt +++ b/Sql Server/OMOP CDM sql server constraints.txt @@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n 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); - -ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id); - - -ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id); - - /************************** Standardized meta-data @@ -194,7 +186,7 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov 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 visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id); ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id); @@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id); -ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id); -ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); +ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id); ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id); @@ -476,16 +468,6 @@ 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); diff --git a/Sql Server/OMOP CDM sql server ddl.txt b/Sql Server/OMOP CDM sql server ddl.txt index 8786514..5f2c9b8 100644 --- a/Sql Server/OMOP CDM sql server ddl.txt +++ b/Sql Server/OMOP CDM sql server ddl.txt @@ -215,7 +215,7 @@ Standardized clinical data --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( - person_id BIGINT NOT NULL , --BIGINTs added + person_id BIGINT NOT NULL , gender_concept_id INTEGER NOT NULL , year_of_birth INTEGER NOT NULL , month_of_birth INTEGER NULL, @@ -271,20 +271,6 @@ CREATE TABLE specimen ; ---HINT DISTRIBUTE_ON_KEY(person_id) -/*CREATE TABLE death -( - person_id BIGINT NOT NULL , - death_date DATE NULL , - death_datetime DATETIME2 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 -) -;*/ - - --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_occurrence ( @@ -300,7 +286,7 @@ CREATE TABLE visit_occurrence care_site_id BIGINT NULL, visit_source_value VARCHAR(50) NULL, visit_source_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , discharge_to_source_value VARCHAR(50) NULL , discharge_to_concept_id INTEGER NULL , @@ -323,7 +309,7 @@ CREATE TABLE visit_detail provider_id BIGINT NULL , care_site_id BIGINT NULL , discharge_to_concept_id INTEGER NULL , - admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */ + admitted_from_concept_id INTEGER NULL , admitted_from_source_value VARCHAR(50) NULL , visit_detail_source_value VARCHAR(50) NULL , visit_detail_source_concept_id INTEGER NULL , @@ -464,7 +450,7 @@ CREATE TABLE note note_id BIGINT NOT NULL , person_id BIGINT NOT NULL , note_event_id BIGINT NULL , - note_event_domain_id VARCHAR(20) NULL , + note_event_domain_id VARCHAR(20) NULL , note_event_field_concept_id INTEGER NULL , note_date DATE NULL , note_datetime DATETIME2 NOT NULL , @@ -506,60 +492,59 @@ CREATE TABLE note_nlp --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation ( - observation_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - observation_concept_id INTEGER NOT NULL , - observation_date DATE NULL , - observation_datetime DATETIME2 NOT NULL , + observation_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + observation_concept_id INTEGER NOT NULL , + observation_date DATE NULL , + observation_datetime DATETIME2 NOT 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 BIGINT NULL , - visit_detail_id BIGINT NULL , - observation_source_value VARCHAR(50) 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 BIGINT NULL , + visit_detail_id BIGINT 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 , - observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/ - observation_event_domain_id VARCHAR(20) NULL , ---obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/ - value_as_datetime DATETIME2 NULL + unit_source_value VARCHAR(50) NULL , + qualifier_source_value VARCHAR(50) NULL , + observation_event_id BIGINT NULL , + obs_event_field_concept_id INTEGER NULL , + value_as_datetime DATETIME2 NULL ) ; --HINT DISTRIBUTE ON KEY(person_id) -CREATE TABLE survey_conduct --Table added +CREATE TABLE survey_conduct ( - survey_conduct_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - survey_concept_id INTEGER NOT NULL , - survey_start_date DATE NULL , - survey_start_datetime DATETIME2 NULL , - survey_end_date DATE NULL , - survey_end_datetime DATETIME2 NOT NULL , - provider_id BIGINT NULL , - assisted_concept_id INTEGER NULL , - respondent_type_concept_id INTEGER NULL , - timing_concept_id INTEGER NULL , - collection_method_concept_id INTEGER NULL , - assisted_source_value VARCHAR(50) NULL , - respondent_type_source_value VARCHAR(100) NULL , - timing_source_value VARCHAR(100) NULL , + survey_conduct_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + survey_concept_id INTEGER NOT NULL , + survey_start_date DATE NULL , + survey_start_datetime DATETIME2 NULL , + survey_end_date DATE NULL , + survey_end_datetime DATETIME2 NOT NULL , + provider_id BIGINT NULL , + assisted_concept_id INTEGER NULL , + respondent_type_concept_id INTEGER NULL , + timing_concept_id INTEGER NULL , + collection_method_concept_id INTEGER NULL , + assisted_source_value VARCHAR(50) NULL , + respondent_type_source_value VARCHAR(100) NULL , + timing_source_value VARCHAR(100) NULL , collection_method_source_value VARCHAR(100) NULL , - survey_source_value VARCHAR(100) NULL , - survey_source_concept_id INTEGER NULL , - survey_source_identifier VARCHAR(100) NULL , - validated_survey_concept_id INTEGER NULL , + survey_source_value VARCHAR(100) NULL , + survey_source_concept_id INTEGER NULL , + survey_source_identifier VARCHAR(100) NULL , + validated_survey_concept_id INTEGER NULL , validated_survey_source_value VARCHAR(100) NULL , - survey_version_number VARCHAR(20) NULL , - visit_occurrence_id BIGINT NULL , - visit_detail_id BIGINT NULL , - response_to_visit_occurrence_id BIGINT NULL + survey_version_number VARCHAR(20) NULL , + visit_occurrence_id BIGINT NULL , + visit_detail_id BIGINT NULL , + response_visit_occurrence_id BIGINT NULL ) ; @@ -567,10 +552,10 @@ CREATE TABLE survey_conduct --Table added --HINT DISTRIBUTE ON RANDOM CREATE TABLE fact_relationship ( - domain_concept_id_1 INTEGER NOT NULL , - fact_id_1 BIGINT NOT NULL , - domain_concept_id_2 INTEGER NOT NULL , - fact_id_2 BIGINT NOT NULL , + domain_concept_id_1 INTEGER NOT NULL , + fact_id_1 BIGINT NOT NULL , + domain_concept_id_2 INTEGER NOT NULL , + fact_id_2 BIGINT NOT NULL , relationship_concept_id INTEGER NOT NULL ) ; @@ -587,31 +572,31 @@ Standardized health system data --HINT DISTRIBUTE ON RANDOM CREATE TABLE location ( - location_id BIGINT 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 , - country VARCHAR(100) NULL , + location_id BIGINT 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 , + country VARCHAR(100) NULL , location_source_value VARCHAR(50) NULL , - latitude FLOAT NULL , - longitude FLOAT NULL + latitude FLOAT NULL , + longitude FLOAT NULL ) ; --HINT DISTRIBUTE ON RANDOM -CREATE TABLE location_history --Table added +CREATE TABLE location_history ( - location_history_id BIGINT NOT NULL , - location_id BIGINT NOT NULL , - relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion - domain_id VARCHAR(50) NOT NULL , - entity_id BIGINT NOT NULL , - start_date DATE NOT NULL , - end_date DATE NULL + location_history_id BIGINT NOT NULL , + location_id BIGINT NOT NULL , + relationship_type_concept_id INTEGER NULL , + domain_id VARCHAR(50) NOT NULL , + entity_id BIGINT NOT NULL , + start_date DATE NOT NULL , + end_date DATE NULL ) ; @@ -619,12 +604,12 @@ CREATE TABLE location_history --Table added --HINT DISTRIBUTE ON RANDOM CREATE TABLE care_site ( - care_site_id BIGINT NOT NULL , - care_site_name VARCHAR(255) NULL , - place_of_service_concept_id INTEGER NULL , - location_id BIGINT NULL , - care_site_source_value VARCHAR(50) NULL , - place_of_service_source_value VARCHAR(50) NULL + care_site_id BIGINT NOT NULL , + care_site_name VARCHAR(255) NULL , + place_of_service_concept_id INTEGER NULL , + location_id BIGINT NULL , + care_site_source_value VARCHAR(50) NULL , + place_of_service_source_value VARCHAR(50) NULL ) ; @@ -632,19 +617,19 @@ CREATE TABLE care_site --HINT DISTRIBUTE ON RANDOM CREATE TABLE provider ( - provider_id BIGINT NOT NULL , - provider_name VARCHAR(255) NULL , - NPI VARCHAR(20) NULL , - DEA VARCHAR(20) NULL , - specialty_concept_id INTEGER NULL , - care_site_id BIGINT 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 + provider_id BIGINT NOT NULL , + provider_name VARCHAR(255) NULL , + NPI VARCHAR(20) NULL , + DEA VARCHAR(20) NULL , + specialty_concept_id INTEGER NULL , + care_site_id BIGINT 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 ) ; @@ -659,27 +644,27 @@ Standardized health economics --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period ( - payer_plan_period_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - contract_person_id BIGINT NULL , - payer_plan_period_start_date DATE NOT NULL , - payer_plan_period_end_date DATE NOT NULL , - payer_concept_id INTEGER NULL , - plan_concept_id INTEGER NULL , - contract_concept_id INTEGER NULL , - sponsor_concept_id INTEGER NULL , - stop_reason_concept_id INTEGER NULL , - payer_source_value VARCHAR(50) NULL , - payer_source_concept_id INTEGER NULL , - plan_source_value VARCHAR(50) NULL , - plan_source_concept_id INTEGER NULL , - contract_source_value VARCHAR(50) NULL , - contract_source_concept_id INTEGER NULL , - sponsor_source_value VARCHAR(50) NULL , - sponsor_source_concept_id INTEGER NULL , - family_source_value VARCHAR(50) NULL , - stop_reason_source_value VARCHAR(50) NULL , - stop_reason_source_concept_id INTEGER NULL + payer_plan_period_id BIGINT NOT NULL , + person_id BIGINT NOT NULL , + contract_person_id BIGINT NULL , + payer_plan_period_start_date DATE NOT NULL , + payer_plan_period_end_date DATE NOT NULL , + payer_concept_id INTEGER NULL , + plan_concept_id INTEGER NULL , + contract_concept_id INTEGER NULL , + sponsor_concept_id INTEGER NULL , + stop_reason_concept_id INTEGER NULL , + payer_source_value VARCHAR(50) NULL , + payer_source_concept_id INTEGER NULL , + plan_source_value VARCHAR(50) NULL , + plan_source_concept_id INTEGER NULL , + contract_source_value VARCHAR(50) NULL , + contract_source_concept_id INTEGER NULL , + sponsor_source_value VARCHAR(50) NULL , + sponsor_source_concept_id INTEGER NULL , + family_source_value VARCHAR(50) NULL , + stop_reason_source_value VARCHAR(50) NULL , + stop_reason_source_concept_id INTEGER NULL ) ; @@ -687,25 +672,24 @@ CREATE TABLE payer_plan_period --HINT DISTRIBUTE ON KEY(person_id) CREATE TABLE cost ( - cost_id BIGINT NOT NULL , - person_id BIGINT NOT NULL, - cost_event_id BIGINT NOT NULL , - cost_domain_id VARCHAR(20) NOT NULL , ---cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/ - cost_concept_id INTEGER NOT NULL , - cost_type_concept_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - cost FLOAT NULL , - incurred_date DATE NOT NULL , - billed_date DATE NULL , - paid_date DATE NULL , - revenue_code_concept_id INTEGER NULL , - drg_concept_id INTEGER NULL , - cost_source_value VARCHAR(50) NULL , - cost_source_concept_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL , - drg_source_value VARCHAR(3) NULL , - payer_plan_period_id BIGINT NULL + cost_id BIGINT NOT NULL , + person_id BIGINT NOT NULL, + cost_event_id BIGINT NOT NULL , + cost_event_field_concept_id INTEGER NOT NULL , + cost_concept_id INTEGER NOT NULL , + cost_type_concept_id INTEGER NOT NULL , + currency_concept_id INTEGER NULL , + cost FLOAT NULL , + incurred_date DATE NOT NULL , + billed_date DATE NULL , + paid_date DATE NULL , + revenue_code_concept_id INTEGER NULL , + drg_concept_id INTEGER NULL , + cost_source_value VARCHAR(50) NULL , + cost_source_concept_id INTEGER NULL , + revenue_code_source_value VARCHAR(50) NULL , + drg_source_value VARCHAR(3) NULL , + payer_plan_period_id BIGINT NULL ) ; @@ -717,41 +701,16 @@ Standardized derived elements ************************/ ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort -( - cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL -) -; - - ---HINT DISTRIBUTE_ON_KEY(subject_id) -CREATE TABLE cohort_attribute -( - cohort_definition_id BIGINT NOT NULL , - subject_id BIGINT NOT NULL , - cohort_start_date DATE NOT NULL , - cohort_end_date DATE NOT NULL , - attribute_definition_id BIGINT NOT NULL , - value_as_number FLOAT NULL , - value_as_concept_id INTEGER NULL -) -; - - --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_era ( - drug_era_id BIGINT NOT NULL , - person_id BIGINT 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 + drug_era_id BIGINT NOT NULL , + person_id BIGINT 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 ) ; @@ -759,12 +718,12 @@ CREATE TABLE drug_era --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE dose_era ( - dose_era_id BIGINT NOT NULL , - person_id BIGINT 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_id BIGINT NOT NULL , + person_id BIGINT 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 ) ; @@ -773,11 +732,11 @@ CREATE TABLE dose_era --HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_era ( - condition_era_id BIGINT NOT NULL , - person_id BIGINT NOT NULL , - condition_concept_id INTEGER NOT NULL , - condition_era_start_date DATE NOT NULL , - condition_era_end_date DATE NOT NULL , + condition_era_id BIGINT NOT NULL , + person_id BIGINT 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 sql server pk indexes.txt b/Sql Server/OMOP CDM sql server pk indexes.txt index e1b91e6..f61b4c1 100644 --- a/Sql Server/OMOP CDM sql server pk indexes.txt +++ b/Sql Server/OMOP CDM sql server pk indexes.txt @@ -77,10 +77,6 @@ ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMA 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); - /************************** @@ -127,7 +123,7 @@ ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ; -ALTER TABLE survey ADD CONSTRAINT xpk_survey PRIMARY KEY NONCLUSTERED ( survey_occurrence_id ) ; +ALTER TABLE survey_conduct ADD CONSTRAINT xpk_survey PRIMARY KEY NONCLUSTERED ( survey_conduct_id ) ; /************************ @@ -139,7 +135,7 @@ Standardized health system data ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ; -ALTER TABLE location_history ADD CONSTRAINT xpk_location_history PRIMARY KEY NONCLUSTERED ( location_history_id ) ; --Assuming this should be added +ALTER TABLE location_history ADD CONSTRAINT xpk_location_history PRIMARY KEY NONCLUSTERED ( location_history_id ) ; ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ; @@ -165,10 +161,6 @@ 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 ) ; @@ -225,10 +217,6 @@ CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_cod 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); - /************************** @@ -292,7 +280,7 @@ 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 CLUSTERED INDEX idx_survey_person_id ON survey (person_id ASC); +CREATE CLUSTERED INDEX idx_survey_person_id ON survey_conduct (person_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); @@ -328,13 +316,7 @@ 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); +REATE 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); diff --git a/Sql Server/README.md b/Sql Server/README.md index c3162a7..a1a5673 100644 --- a/Sql Server/README.md +++ b/Sql Server/README.md @@ -16,3 +16,5 @@ In order to create your instantiation of the Common Data Model, we recommend fol 5. Execute the script `OMOP CDM sql server constraints.txt` to add the foreign key constraints. 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. + +6. Repeat steps 1-3, executing the script `OMOP CDM Results sql server ddl.txt` to create the results schema