Fixes from testers for pdw, redshit, postgres and sql server and survey -> survey_conduct changes.

This commit is contained in:
clairblacketer 2018-09-25 12:40:53 -04:00
parent 62207c4309
commit 86dbcec3e0
22 changed files with 1720 additions and 1704 deletions

View File

@ -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 ,

View File

@ -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 ,

View File

@ -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);

View File

@ -215,7 +215,7 @@ Standardized clinical data
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id NUMBER(19) NOT NULL , --BIGINTs added
person_id NUMBER(19) NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
@ -309,7 +309,7 @@ CREATE TABLE visit_detail
provider_id NUMBER(19) NULL ,
care_site_id NUMBER(19) NULL ,
discharge_to_concept_id INTEGER NULL ,
admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */
admitted_from_concept_id INTEGER NULL ,
admitted_from_source_value VARCHAR(50) NULL ,
visit_detail_source_value VARCHAR(50) NULL ,
visit_detail_source_concept_id INTEGER NULL ,
@ -509,8 +509,8 @@ CREATE TABLE observation
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL ,
observation_event_id NUMBER(19) NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/
obs_event_field_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/
observation_event_id NUMBER(19) NULL ,
obs_event_field_concept_id INTEGER NULL ,
value_as_datetime TIMESTAMP NULL
)
;
@ -543,7 +543,7 @@ CREATE TABLE survey_conduct --Table added
survey_version_number VARCHAR(20) NULL ,
visit_occurrence_id NUMBER(19) NULL ,
visit_detail_id NUMBER(19) NULL ,
response_visit_occurrence_id NUMBER(19) NULL
response_visit_occurrence_id NUMBER(19) NULL
)
;
@ -591,7 +591,7 @@ CREATE TABLE location_history --Table added
(
location_history_id NUMBER(19) NOT NULL ,
location_id NUMBER(19) NOT NULL ,
relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion
relationship_type_concept_id INTEGER NULL ,
domain_id VARCHAR(50) NOT NULL ,
entity_id NUMBER(19) NOT NULL ,
start_date DATE NOT NULL ,

View File

@ -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);

View File

@ -28,7 +28,7 @@
pdw script to create foreign key, unique, and check constraints within the OMOP common data model, version 6.0
last revised: 30-Aug┌-2018
last revised: 30-Aug-2018
author: Patrick Ryan, Clair Blacketer
@ -86,7 +86,7 @@ ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (re
ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_synonym ADD CONSTRAINT fpk_synonym_language FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id);
@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id);
ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id);
/**************************
Standardized meta-data
@ -194,9 +186,9 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_ visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitted_frome_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
@ -215,7 +207,7 @@ ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitted_from_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_detail_source_concept_id) REFERENCES concept (concept_id);
@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis
ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id);
@ -476,16 +468,6 @@ Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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.

View File

@ -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);

View File

@ -28,7 +28,7 @@
postgresql script to create foreign key, unique, and check constraints within the OMOP common data model, version 6.0
last revised: 30-Aug┌-2018
last revised: 30-Aug-2018
author: Patrick Ryan, Clair Blacketer
@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id);
ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id);
/**************************
Standardized meta-data
@ -194,7 +186,7 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_ visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis
ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id);
@ -476,16 +468,6 @@ Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);

File diff suppressed because it is too large Load Diff

View File

@ -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);

View File

@ -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`

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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`

View File

@ -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);

View File

@ -112,14 +112,6 @@ ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (n
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_subject_concept FOREIGN KEY (subject_concept_id) REFERENCES concept (concept_id);
ALTER TABLE attribute_definition ADD CONSTRAINT fpk_attribute_type_concept FOREIGN KEY (attribute_type_concept_id) REFERENCES concept (concept_id);
/**************************
Standardized meta-data
@ -194,7 +186,7 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (prov
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_ visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
@ -360,29 +352,29 @@ ALTER TABLE observation ADD CONSTRAint fpk_observation_v_detail FOREIGN KEY (vis
ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_concept FOREIGN KEY (survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_assist FOREIGN KEY (assisted_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_respondent_type FOREIGN KEY (respondent_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_timing FOREIGN KEY (timing_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_collection_method FOREIGN KEY (collection_method_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_source FOREIGN KEY (survey_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_validation FOREIGN KEY (validated_survey_concept_id) REFERENCES concept (concept_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_survey_v_detail FOREIGN KEY (visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE survey ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE survey_conduct ADD CONSTRAINT fpk_response_visit FOREIGN KEY (response_to_visit_occurrence_id) REFERENCES visit (visit_occurrence_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id);
@ -476,16 +468,6 @@ Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);

View File

@ -215,7 +215,7 @@ Standardized clinical data
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id BIGINT NOT NULL , --BIGINTs added
person_id BIGINT NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
@ -271,20 +271,6 @@ CREATE TABLE specimen
;
--HINT DISTRIBUTE_ON_KEY(person_id)
/*CREATE TABLE death
(
person_id BIGINT NOT NULL ,
death_date DATE NULL ,
death_datetime DATETIME2 NOT NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;*/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(
@ -300,7 +286,7 @@ CREATE TABLE visit_occurrence
care_site_id BIGINT NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */
admitted_from_concept_id INTEGER NULL ,
admitted_from_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
@ -323,7 +309,7 @@ CREATE TABLE visit_detail
provider_id BIGINT NULL ,
care_site_id BIGINT NULL ,
discharge_to_concept_id INTEGER NULL ,
admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */
admitted_from_concept_id INTEGER NULL ,
admitted_from_source_value VARCHAR(50) NULL ,
visit_detail_source_value VARCHAR(50) NULL ,
visit_detail_source_concept_id INTEGER NULL ,
@ -464,7 +450,7 @@ CREATE TABLE note
note_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
note_event_id BIGINT NULL ,
note_event_domain_id VARCHAR(20) NULL ,
note_event_domain_id VARCHAR(20) NULL ,
note_event_field_concept_id INTEGER NULL ,
note_date DATE NULL ,
note_datetime DATETIME2 NOT NULL ,
@ -506,60 +492,59 @@ CREATE TABLE note_nlp
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(
observation_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NULL ,
observation_datetime DATETIME2 NOT NULL ,
observation_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NULL ,
observation_datetime DATETIME2 NOT NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
observation_source_value VARCHAR(50) NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL ,
observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/
observation_event_domain_id VARCHAR(20) NULL ,
--obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/
value_as_datetime DATETIME2 NULL
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL ,
observation_event_id BIGINT NULL ,
obs_event_field_concept_id INTEGER NULL ,
value_as_datetime DATETIME2 NULL
)
;
--HINT DISTRIBUTE ON KEY(person_id)
CREATE TABLE survey_conduct --Table added
CREATE TABLE survey_conduct
(
survey_conduct_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
survey_concept_id INTEGER NOT NULL ,
survey_start_date DATE NULL ,
survey_start_datetime DATETIME2 NULL ,
survey_end_date DATE NULL ,
survey_end_datetime DATETIME2 NOT NULL ,
provider_id BIGINT NULL ,
assisted_concept_id INTEGER NULL ,
respondent_type_concept_id INTEGER NULL ,
timing_concept_id INTEGER NULL ,
collection_method_concept_id INTEGER NULL ,
assisted_source_value VARCHAR(50) NULL ,
respondent_type_source_value VARCHAR(100) NULL ,
timing_source_value VARCHAR(100) NULL ,
survey_conduct_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
survey_concept_id INTEGER NOT NULL ,
survey_start_date DATE NULL ,
survey_start_datetime DATETIME2 NULL ,
survey_end_date DATE NULL ,
survey_end_datetime DATETIME2 NOT NULL ,
provider_id BIGINT NULL ,
assisted_concept_id INTEGER NULL ,
respondent_type_concept_id INTEGER NULL ,
timing_concept_id INTEGER NULL ,
collection_method_concept_id INTEGER NULL ,
assisted_source_value VARCHAR(50) NULL ,
respondent_type_source_value VARCHAR(100) NULL ,
timing_source_value VARCHAR(100) NULL ,
collection_method_source_value VARCHAR(100) NULL ,
survey_source_value VARCHAR(100) NULL ,
survey_source_concept_id INTEGER NULL ,
survey_source_identifier VARCHAR(100) NULL ,
validated_survey_concept_id INTEGER NULL ,
survey_source_value VARCHAR(100) NULL ,
survey_source_concept_id INTEGER NULL ,
survey_source_identifier VARCHAR(100) NULL ,
validated_survey_concept_id INTEGER NULL ,
validated_survey_source_value VARCHAR(100) NULL ,
survey_version_number VARCHAR(20) NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
response_to_visit_occurrence_id BIGINT NULL
survey_version_number VARCHAR(20) NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
response_visit_occurrence_id BIGINT NULL
)
;
@ -567,10 +552,10 @@ CREATE TABLE survey_conduct --Table added
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 BIGINT NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 BIGINT NOT NULL ,
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 BIGINT NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 BIGINT NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
@ -587,31 +572,31 @@ Standardized health system data
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE location
(
location_id BIGINT NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
country VARCHAR(100) NULL ,
location_id BIGINT NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
country VARCHAR(100) NULL ,
location_source_value VARCHAR(50) NULL ,
latitude FLOAT NULL ,
longitude FLOAT NULL
latitude FLOAT NULL ,
longitude FLOAT NULL
)
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE location_history --Table added
CREATE TABLE location_history
(
location_history_id BIGINT NOT NULL ,
location_id BIGINT NOT NULL ,
relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion
domain_id VARCHAR(50) NOT NULL ,
entity_id BIGINT NOT NULL ,
start_date DATE NOT NULL ,
end_date DATE NULL
location_history_id BIGINT NOT NULL ,
location_id BIGINT NOT NULL ,
relationship_type_concept_id INTEGER NULL ,
domain_id VARCHAR(50) NOT NULL ,
entity_id BIGINT NOT NULL ,
start_date DATE NOT NULL ,
end_date DATE NULL
)
;
@ -619,12 +604,12 @@ CREATE TABLE location_history --Table added
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE care_site
(
care_site_id BIGINT NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id BIGINT NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
care_site_id BIGINT NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id BIGINT NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
@ -632,19 +617,19 @@ CREATE TABLE care_site
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE provider
(
provider_id BIGINT NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id BIGINT NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
provider_id BIGINT NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id BIGINT NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
@ -659,27 +644,27 @@ Standardized health economics
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(
payer_plan_period_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
contract_person_id BIGINT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
contract_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
stop_reason_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
contract_source_value VARCHAR(50) NULL ,
contract_source_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_source_value VARCHAR(50) NULL ,
stop_reason_source_concept_id INTEGER NULL
payer_plan_period_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
contract_person_id BIGINT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
contract_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
stop_reason_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
contract_source_value VARCHAR(50) NULL ,
contract_source_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_source_value VARCHAR(50) NULL ,
stop_reason_source_concept_id INTEGER NULL
)
;
@ -687,25 +672,24 @@ CREATE TABLE payer_plan_period
--HINT DISTRIBUTE ON KEY(person_id)
CREATE TABLE cost
(
cost_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL,
cost_event_id BIGINT NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
--cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/
cost_concept_id INTEGER NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
cost FLOAT NULL ,
incurred_date DATE NOT NULL ,
billed_date DATE NULL ,
paid_date DATE NULL ,
revenue_code_concept_id INTEGER NULL ,
drg_concept_id INTEGER NULL ,
cost_source_value VARCHAR(50) NULL ,
cost_source_concept_id INTEGER NULL ,
revenue_code_source_value VARCHAR(50) NULL ,
drg_source_value VARCHAR(3) NULL ,
payer_plan_period_id BIGINT NULL
cost_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL,
cost_event_id BIGINT NOT NULL ,
cost_event_field_concept_id INTEGER NOT NULL ,
cost_concept_id INTEGER NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
cost FLOAT NULL ,
incurred_date DATE NOT NULL ,
billed_date DATE NULL ,
paid_date DATE NULL ,
revenue_code_concept_id INTEGER NULL ,
drg_concept_id INTEGER NULL ,
cost_source_value VARCHAR(50) NULL ,
cost_source_concept_id INTEGER NULL ,
revenue_code_source_value VARCHAR(50) NULL ,
drg_source_value VARCHAR(3) NULL ,
payer_plan_period_id BIGINT NULL
)
;
@ -717,41 +701,16 @@ Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(
cohort_definition_id BIGINT NOT NULL ,
subject_id BIGINT NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(
cohort_definition_id BIGINT NOT NULL ,
subject_id BIGINT NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id BIGINT NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(
drug_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
drug_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
@ -759,12 +718,12 @@ CREATE TABLE drug_era
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(
dose_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
@ -773,11 +732,11 @@ CREATE TABLE dose_era
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(
condition_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -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);

View File

@ -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