Fixes from testers for pdw, redshit, postgres and sql server and survey -> survey_conduct changes.
This commit is contained in:
parent
62207c4309
commit
86dbcec3e0
|
@ -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 ,
|
||||
|
|
|
@ -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 ,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
)
|
||||
;
|
||||
|
@ -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 ,
|
||||
|
|
|
@ -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);
|
||||
|
|
@ -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
|
||||
|
@ -196,7 +188,7 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (car
|
|||
|
||||
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);
|
||||
|
|
|
@ -43,7 +43,9 @@ Standardized vocabulary
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept (concept_id INTEGER 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 ,
|
||||
|
@ -58,7 +60,9 @@ 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,
|
||||
|
@ -68,7 +72,9 @@ 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
|
||||
)
|
||||
|
@ -76,7 +82,9 @@ 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
|
||||
)
|
||||
|
@ -84,7 +92,9 @@ 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,
|
||||
|
@ -95,7 +105,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE relationship (relationship_id VARCHAR(20) 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,
|
||||
|
@ -106,7 +118,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_synonym (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
|
||||
)
|
||||
|
@ -114,7 +128,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_ancestor (ancestor_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,7 +139,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE source_to_concept_map (source_code VARCHAR(50) 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,
|
||||
|
@ -137,7 +155,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_strength (drug_concept_id INTEGER NOT 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,
|
||||
|
@ -153,28 +173,6 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_strength (drug_concept_id
|
|||
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
|
||||
)
|
||||
WITH (DISTRIBUTION = REPLICATE);
|
||||
|
||||
|
||||
/**************************
|
||||
|
||||
Standardized meta-data
|
||||
|
@ -183,8 +181,9 @@ Standardized meta-data
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cdm_source
|
||||
(cdm_source_name VARCHAR(255) NOT 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 ,
|
||||
|
@ -199,8 +198,9 @@ 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 ,
|
||||
|
@ -210,8 +210,8 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE metadata
|
|||
)
|
||||
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,8 +223,9 @@ Standardized clinical data
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE person
|
||||
(person_id BIGINT NOT NULL , --BIGINTs added
|
||||
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,
|
||||
|
@ -247,8 +248,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -258,8 +260,9 @@ WITH (DISTRIBUTION = HASH(person_id));
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE specimen
|
||||
(specimen_id BIGINT 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 ,
|
||||
|
@ -279,21 +282,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -305,7 +296,7 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_occurrence
|
|||
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_concept_id INTEGER NULL ,
|
||||
admitted_from_source_value VARCHAR(50) NULL ,
|
||||
discharge_to_source_value VARCHAR(50) NULL ,
|
||||
discharge_to_concept_id INTEGER NULL ,
|
||||
|
@ -315,8 +306,9 @@ 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,8 +332,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -354,14 +347,15 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE procedure_occurrence
|
|||
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 ,
|
||||
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 ,
|
||||
|
@ -389,8 +383,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -410,8 +405,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -432,8 +428,9 @@ WITH (DISTRIBUTION = HASH(person_id));
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE measurement
|
||||
(measurement_id BIGINT NOT 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 ,
|
||||
|
@ -458,12 +455,12 @@ WITH (DISTRIBUTION = HASH(person_id));
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE note
|
||||
(note_id BIGINT NOT NULL ,
|
||||
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_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 ,
|
||||
|
@ -481,8 +478,9 @@ WITH (DISTRIBUTION = HASH(person_id));
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE note_nlp
|
||||
(note_nlp_id BIGINT NOT 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 ,
|
||||
|
@ -501,8 +499,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation
|
||||
(observation_id BIGINT NOT 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 ,
|
||||
|
@ -520,17 +519,17 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation
|
|||
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*/
|
||||
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 ,
|
||||
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 ,
|
||||
|
@ -554,14 +553,15 @@ IF XACT_STATE() = 1 COMMIT; CREATE TABLE survey_conduct --Table added
|
|||
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
|
||||
)
|
||||
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 ,
|
||||
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 ,
|
||||
|
@ -579,8 +579,9 @@ Standardized health system data
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE location
|
||||
(location_id BIGINT NOT 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 ,
|
||||
|
@ -596,10 +597,11 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE location_history --Table added
|
||||
(location_history_id BIGINT NOT 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 , --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 ,
|
||||
|
@ -609,8 +611,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE care_site
|
||||
(care_site_id BIGINT NOT 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 ,
|
||||
|
@ -621,8 +624,9 @@ WITH (DISTRIBUTION = REPLICATE);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE provider
|
||||
(provider_id BIGINT NOT 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 ,
|
||||
|
@ -647,8 +651,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -674,12 +679,12 @@ WITH (DISTRIBUTION = HASH(person_id));
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON KEY(person_id)
|
||||
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cost
|
||||
(cost_id BIGINT NOT 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_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_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 ,
|
||||
|
@ -705,32 +710,10 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -742,8 +725,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -755,8 +739,9 @@ 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 ,
|
||||
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 ,
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -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
|
||||
|
@ -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);
|
||||
|
|
|
@ -163,19 +163,6 @@ CREATE TABLE drug_strength (
|
|||
;
|
||||
|
||||
|
||||
--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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE attribute_definition (
|
||||
attribute_definition_id INTEGER NOT NULL,
|
||||
|
@ -220,12 +207,12 @@ CREATE TABLE metadata
|
|||
value_as_string TEXT NULL ,
|
||||
value_as_concept_id INTEGER NULL ,
|
||||
metadata_date DATE NULL ,
|
||||
metadata_datetime DATETIME2 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,12 +226,12 @@ 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,
|
||||
day_of_birth INTEGER NULL,
|
||||
birth_datetime DATETIME2 NULL,
|
||||
birth_datetime TIMESTAMP NULL,
|
||||
race_concept_id INTEGER NOT NULL,
|
||||
ethnicity_concept_id INTEGER NOT NULL,
|
||||
location_id INTEGER NULL,
|
||||
|
@ -281,7 +268,7 @@ CREATE TABLE specimen
|
|||
specimen_concept_id INTEGER NOT NULL ,
|
||||
specimen_type_concept_id INTEGER NOT NULL ,
|
||||
specimen_date DATE NULL ,
|
||||
specimen_datetime DATETIME2 NOT NULL ,
|
||||
specimen_datetime TIMESTAMP NOT NULL ,
|
||||
quantity NUMERIC NULL ,
|
||||
unit_concept_id INTEGER NULL ,
|
||||
anatomic_site_concept_id INTEGER NULL ,
|
||||
|
@ -300,7 +287,7 @@ CREATE TABLE death
|
|||
(
|
||||
person_id BIGINT NOT NULL ,
|
||||
death_date DATE NULL ,
|
||||
death_datetime DATETIME2 NOT NULL ,
|
||||
death_datetime TIMESTAMP NOT NULL ,
|
||||
death_type_concept_id INTEGER NOT NULL ,
|
||||
cause_concept_id INTEGER NULL ,
|
||||
cause_source_value VARCHAR(50) NULL,
|
||||
|
@ -316,15 +303,15 @@ CREATE TABLE visit_occurrence
|
|||
person_id BIGINT NOT NULL ,
|
||||
visit_concept_id INTEGER NOT NULL ,
|
||||
visit_start_date DATE NULL ,
|
||||
visit_start_datetime DATETIME2 NOT NULL ,
|
||||
visit_start_datetime TIMESTAMP NOT NULL ,
|
||||
visit_end_date DATE NULL ,
|
||||
visit_end_datetime DATETIME2 NOT 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 , /*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 ,
|
||||
|
@ -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 ,
|
||||
|
@ -366,7 +353,7 @@ CREATE TABLE procedure_occurrence
|
|||
person_id BIGINT NOT NULL ,
|
||||
procedure_concept_id INTEGER NOT NULL ,
|
||||
procedure_date DATE NULL ,
|
||||
procedure_datetime DATETIME2 NOT NULL ,
|
||||
procedure_datetime TIMESTAMP NOT NULL ,
|
||||
procedure_type_concept_id INTEGER NOT NULL ,
|
||||
modifier_concept_id INTEGER NULL ,
|
||||
quantity INTEGER NULL ,
|
||||
|
@ -375,7 +362,7 @@ CREATE TABLE procedure_occurrence
|
|||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -387,9 +374,9 @@ CREATE TABLE drug_exposure
|
|||
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_start_datetime TIMESTAMP NOT NULL ,
|
||||
drug_exposure_end_date DATE NULL ,
|
||||
drug_exposure_end_datetime DATETIME2 NOT 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 ,
|
||||
|
@ -417,9 +404,9 @@ CREATE TABLE device_exposure
|
|||
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_start_datetime TIMESTAMP NOT NULL ,
|
||||
device_exposure_end_date DATE NULL ,
|
||||
device_exposure_end_datetime DATETIME2 NULL ,
|
||||
device_exposure_end_datetime TIMESTAMP NULL ,
|
||||
device_type_concept_id INTEGER NOT NULL ,
|
||||
unique_device_id VARCHAR(50) NULL ,
|
||||
quantity INTEGER NULL ,
|
||||
|
@ -439,9 +426,9 @@ CREATE TABLE condition_occurrence
|
|||
person_id BIGINT NOT NULL ,
|
||||
condition_concept_id INTEGER NOT NULL ,
|
||||
condition_start_date DATE NULL ,
|
||||
condition_start_datetime DATETIME2 NOT NULL ,
|
||||
condition_start_datetime TIMESTAMP NOT NULL ,
|
||||
condition_end_date DATE NULL ,
|
||||
condition_end_datetime DATETIME2 NULL ,
|
||||
condition_end_datetime TIMESTAMP NULL ,
|
||||
condition_type_concept_id INTEGER NOT NULL ,
|
||||
condition_status_concept_id INTEGER NULL ,
|
||||
stop_reason VARCHAR(20) NULL ,
|
||||
|
@ -462,7 +449,7 @@ CREATE TABLE measurement
|
|||
person_id BIGINT NOT NULL ,
|
||||
measurement_concept_id INTEGER NOT NULL ,
|
||||
measurement_date DATE NULL ,
|
||||
measurement_datetime DATETIME2 NOT NULL ,
|
||||
measurement_datetime TIMESTAMP NOT NULL ,
|
||||
measurement_time VARCHAR(10) NULL,
|
||||
measurement_type_concept_id INTEGER NOT NULL ,
|
||||
operator_concept_id INTEGER NULL ,
|
||||
|
@ -487,11 +474,10 @@ 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_event_id BIGINT NULL ,
|
||||
note_event_field_concept_id INTEGER NULL ,
|
||||
note_date DATE NULL ,
|
||||
note_datetime DATETIME2 NOT 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 ,
|
||||
|
@ -518,7 +504,7 @@ CREATE TABLE note_nlp
|
|||
note_nlp_concept_id INTEGER NULL ,
|
||||
nlp_system VARCHAR(250) NULL ,
|
||||
nlp_date DATE NOT NULL ,
|
||||
nlp_datetime DATETIME2 NULL ,
|
||||
nlp_datetime TIMESTAMP NULL ,
|
||||
term_exists VARCHAR(1) NULL ,
|
||||
term_temporal VARCHAR(50) NULL ,
|
||||
term_modifiers VARCHAR(2000) NULL ,
|
||||
|
@ -534,7 +520,7 @@ CREATE TABLE observation
|
|||
person_id BIGINT NOT NULL ,
|
||||
observation_concept_id INTEGER NOT NULL ,
|
||||
observation_date DATE NULL ,
|
||||
observation_datetime DATETIME2 NOT NULL ,
|
||||
observation_datetime TIMESTAMP NOT NULL ,
|
||||
observation_type_concept_id INTEGER NOT NULL ,
|
||||
value_as_number NUMERIC NULL ,
|
||||
value_as_string VARCHAR(60) NULL ,
|
||||
|
@ -548,24 +534,23 @@ CREATE TABLE observation
|
|||
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_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_start_datetime TIMESTAMP NULL ,
|
||||
survey_end_date DATE NULL ,
|
||||
survey_end_datetime DATETIME2 NOT NULL ,
|
||||
survey_end_datetime TIMESTAMP NOT NULL ,
|
||||
provider_id BIGINT NULL ,
|
||||
assisted_concept_id INTEGER NULL ,
|
||||
respondent_type_concept_id INTEGER NULL ,
|
||||
|
@ -583,7 +568,7 @@ CREATE TABLE survey_conduct --Table added
|
|||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -631,7 +616,7 @@ 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
|
||||
relationship_type_concept_id INTEGER NULL ,
|
||||
domain_id VARCHAR(50) NOT NULL ,
|
||||
entity_id BIGINT NOT NULL ,
|
||||
start_date DATE NOT NULL ,
|
||||
|
@ -714,8 +699,7 @@ 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_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 ,
|
||||
|
@ -741,31 +725,6 @@ 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
|
||||
(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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`
|
||||
|
|
|
@ -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;
|
||||
|
|
@ -43,7 +43,8 @@ Standardized vocabulary
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE concept (concept_id INTEGER 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 ,
|
||||
|
@ -58,7 +59,8 @@ 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,
|
||||
|
@ -68,7 +70,8 @@ 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
|
||||
)
|
||||
|
@ -76,7 +79,8 @@ 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
|
||||
)
|
||||
|
@ -84,7 +88,8 @@ 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,
|
||||
|
@ -95,7 +100,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE relationship (relationship_id VARCHAR(20) 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,
|
||||
|
@ -106,7 +112,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE concept_synonym (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
|
||||
)
|
||||
|
@ -114,7 +121,8 @@ 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,7 +131,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE source_to_concept_map (source_code VARCHAR(50) 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,
|
||||
|
@ -137,7 +146,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE drug_strength (drug_concept_id INTEGER NOT 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,
|
||||
|
@ -153,28 +163,6 @@ CREATE TABLE drug_strength (drug_concept_id INTEGER NOT 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
|
||||
)
|
||||
DISTSTYLE ALL;
|
||||
|
||||
|
||||
/**************************
|
||||
|
||||
Standardized meta-data
|
||||
|
@ -183,8 +171,8 @@ Standardized meta-data
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE cdm_source
|
||||
(cdm_source_name VARCHAR(255) NOT 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 ,
|
||||
|
@ -199,8 +187,8 @@ 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 ,
|
||||
|
@ -210,8 +198,8 @@ CREATE TABLE metadata
|
|||
)
|
||||
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,8 +211,8 @@ Standardized clinical data
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE person
|
||||
(person_id BIGINT NOT NULL , --BIGINTs added
|
||||
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,
|
||||
|
@ -247,8 +235,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE observation_period
|
||||
(observation_period_id BIGINT 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 ,
|
||||
|
@ -258,8 +246,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE specimen
|
||||
(specimen_id BIGINT 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 ,
|
||||
|
@ -279,21 +267,8 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -305,7 +280,7 @@ CREATE TABLE visit_occurrence
|
|||
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_concept_id INTEGER NULL ,
|
||||
admitted_from_source_value VARCHAR(50) NULL ,
|
||||
discharge_to_source_value VARCHAR(50) NULL ,
|
||||
discharge_to_concept_id INTEGER NULL ,
|
||||
|
@ -315,8 +290,8 @@ 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,8 +315,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE procedure_occurrence
|
||||
(procedure_occurrence_id BIGINT 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 ,
|
||||
|
@ -354,14 +329,14 @@ CREATE TABLE procedure_occurrence
|
|||
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 ,
|
||||
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 ,
|
||||
|
@ -389,8 +364,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE device_exposure
|
||||
(device_exposure_id BIGINT NOT 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 ,
|
||||
|
@ -410,8 +385,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE condition_occurrence
|
||||
(condition_occurrence_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 ,
|
||||
|
@ -432,8 +407,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE measurement
|
||||
(measurement_id BIGINT NOT NULL ,
|
||||
CREATE TABLE measurement (
|
||||
measurement_id BIGINT NOT NULL ,
|
||||
person_id BIGINT NOT NULL ,
|
||||
measurement_concept_id INTEGER NOT NULL ,
|
||||
measurement_date DATE NULL ,
|
||||
|
@ -458,12 +433,11 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE note
|
||||
(note_id BIGINT NOT NULL ,
|
||||
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_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 ,
|
||||
|
@ -481,8 +455,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE note_nlp
|
||||
(note_nlp_id BIGINT NOT 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 ,
|
||||
|
@ -520,17 +494,16 @@ CREATE TABLE observation
|
|||
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*/
|
||||
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 ,
|
||||
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 ,
|
||||
|
@ -554,14 +527,14 @@ CREATE TABLE survey_conduct --Table added
|
|||
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
|
||||
)
|
||||
DISTKEY(person_id);
|
||||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE fact_relationship
|
||||
(domain_concept_id_1 INTEGER 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 ,
|
||||
|
@ -596,10 +569,10 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE location_history --Table added
|
||||
(location_history_id BIGINT NOT NULL ,
|
||||
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
|
||||
relationship_type_concept_id INTEGER NULL ,
|
||||
domain_id VARCHAR(50) NOT NULL ,
|
||||
entity_id BIGINT NOT NULL ,
|
||||
start_date DATE NOT NULL ,
|
||||
|
@ -609,8 +582,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE care_site
|
||||
(care_site_id BIGINT NOT 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 ,
|
||||
|
@ -621,8 +594,8 @@ DISTSTYLE ALL;
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON RANDOM
|
||||
CREATE TABLE provider
|
||||
(provider_id BIGINT NOT NULL ,
|
||||
CREATE TABLE provider (
|
||||
provider_id BIGINT NOT NULL ,
|
||||
provider_name VARCHAR(255) NULL ,
|
||||
NPI VARCHAR(20) NULL ,
|
||||
DEA VARCHAR(20) NULL ,
|
||||
|
@ -674,12 +647,11 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE ON KEY(person_id)
|
||||
CREATE TABLE cost
|
||||
(cost_id BIGINT NOT NULL ,
|
||||
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_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 ,
|
||||
|
@ -705,32 +677,9 @@ 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 ,
|
||||
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 ,
|
||||
|
@ -742,8 +691,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE dose_era
|
||||
(dose_era_id BIGINT 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 ,
|
||||
|
@ -755,8 +704,8 @@ DISTKEY(person_id);
|
|||
|
||||
|
||||
--HINT DISTRIBUTE_ON_KEY(person_id)
|
||||
CREATE TABLE condition_era
|
||||
(condition_era_id BIGINT 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 ,
|
||||
|
|
|
@ -12,3 +12,5 @@ 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.
|
||||
|
||||
5. Repeat to create the results schema, executing the script `OMOP CDM Results redshift ddl.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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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);
|
||||
|
|
|
@ -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 ,
|
||||
|
@ -524,16 +510,15 @@ CREATE TABLE observation
|
|||
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*/
|
||||
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 ,
|
||||
|
@ -559,7 +544,7 @@ CREATE TABLE survey_conduct --Table added
|
|||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
@ -603,11 +588,11 @@ CREATE TABLE location
|
|||
|
||||
|
||||
--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
|
||||
relationship_type_concept_id INTEGER NULL ,
|
||||
domain_id VARCHAR(50) NOT NULL ,
|
||||
entity_id BIGINT NOT NULL ,
|
||||
start_date DATE NOT NULL ,
|
||||
|
@ -690,8 +675,7 @@ 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_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 ,
|
||||
|
@ -717,31 +701,6 @@ 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
|
||||
(
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue