diff --git a/DDLGeneratr/R/writePrimaryKeys.R b/DDLGeneratr/R/writePrimaryKeys.R new file mode 100644 index 0000000..1adc60a --- /dev/null +++ b/DDLGeneratr/R/writePrimaryKeys.R @@ -0,0 +1,39 @@ +# Copyright 2017 Observational Health Data Sciences and Informatics +# +# This file is part of DDLGeneratr +# +# 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. + +#' Write primary key script +#' +#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server" +#' +#' @export +writePrimaryKeys <- function(targetdialect) { + if(!dir.exists("output")){ + dir.create("output") + } + + if(!dir.exists(paste0("output/",targetdialect))){ + dir.create(paste0("output/",targetdialect)) + } + + sql <- SqlRender::loadRenderTranslateSql(sqlFilename = "OMOP CDM Primary Keys.sql", + packageName = "DDLGeneratr", + dbms = targetdialect, + targetdialect = targetdialect) + + SqlRender::writeSql(sql = sql, + targetFile = paste0("output/",targetdialect,"/OMOP CDM ",targetdialect," primary keys.txt")) + +} diff --git a/DDLGeneratr/codeToRun.R b/DDLGeneratr/codeToRun.R index 6e14aeb..cb788dd 100644 --- a/DDLGeneratr/codeToRun.R +++ b/DDLGeneratr/codeToRun.R @@ -27,14 +27,18 @@ writeIndex("postgresql") writeIndex("pdw") writeIndex("sql server") -# Step 4: Run the following code to create foreign key constraints for Oracle, Postgres, PDW and Sql Server +# Step 4: Run the following code to create primary key constraints for Netezza + +writePrimaryKeys("netezza") + +# Step 5: Run the following code to create foreign key constraints for Oracle, Postgres, PDW and Sql Server writeConstraints("oracle") writeConstraints("postgresql") writeConstraints("pdw") writeConstraints("sql server") -# step 5: Run the following code to create the pdf documentation. It will be written to the reports folder. +# step 6: Run the following code to create the pdf documentation. It will be written to the reports folder. rmarkdown::render("reports/OMOP_CDM_PDF.Rmd", output_format = "pdf_document", diff --git a/DDLGeneratr/inst/sql/sql_server/OMOP CDM Primary Keys.sql b/DDLGeneratr/inst/sql/sql_server/OMOP CDM Primary Keys.sql new file mode 100644 index 0000000..a763bc5 --- /dev/null +++ b/DDLGeneratr/inst/sql/sql_server/OMOP CDM Primary Keys.sql @@ -0,0 +1,174 @@ +/********************************************************************************* +# Copyright 2014 Observational Health Data Sciences and Informatics +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +********************************************************************************/ + +/************************ + + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### #### + + +@targetdialect script to create the required indexes within OMOP common data model, version 5.3 + +last revised: 14-November-2017 + +author: Patrick Ryan, Clair Blacketer + +description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses. + +*************************/ + + +/************************ +************************* +************************* +************************* + +Primary key constraints + +************************* +************************* +************************* +************************/ + + + +/************************ + +Standardized vocabulary + +************************/ + + + +ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY NONCLUSTERED (concept_id); + +ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY NONCLUSTERED (vocabulary_id); + +ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY NONCLUSTERED (domain_id); + +ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY NONCLUSTERED (concept_class_id); + +ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY NONCLUSTERED (concept_id_1,concept_id_2,relationship_id); + +ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY NONCLUSTERED (relationship_id); + +ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY NONCLUSTERED (ancestor_concept_id,descendant_concept_id); + +ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY NONCLUSTERED (source_vocabulary_id,target_concept_id,source_code,valid_end_date); + +ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY NONCLUSTERED (drug_concept_id, ingredient_concept_id); + +ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id); + +ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY NONCLUSTERED (attribute_definition_id); + + +/************************** + +Standardized meta-data + +***************************/ + + + +/************************ + +Standardized clinical data + +************************/ + + +/**PRIMARY KEY NONCLUSTERED constraints**/ + +ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY NONCLUSTERED ( person_id ) ; + +ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY NONCLUSTERED ( observation_period_id ) ; + +ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY NONCLUSTERED ( specimen_id ) ; + +ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY NONCLUSTERED ( person_id ) ; + +ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY NONCLUSTERED ( visit_occurrence_id ) ; + +ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY NONCLUSTERED ( visit_detail_id ) ; + +ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY NONCLUSTERED ( procedure_occurrence_id ) ; + +ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY NONCLUSTERED ( drug_exposure_id ) ; + +ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY NONCLUSTERED ( device_exposure_id ) ; + +ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY NONCLUSTERED ( condition_occurrence_id ) ; + +ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY NONCLUSTERED ( measurement_id ) ; + +ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY NONCLUSTERED ( note_id ) ; + +ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note_nlp_id ) ; + +ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ; + + + + +/************************ + +Standardized health system data + +************************/ + + +ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ; + +ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ; + +ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY NONCLUSTERED ( provider_id ) ; + + + +/************************ + +Standardized health economics + +************************/ + + +ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY NONCLUSTERED ( payer_plan_period_id ) ; + +ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY NONCLUSTERED ( cost_id ) ; + + +/************************ + +Standardized derived elements + +************************/ + +ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ; + +ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ; + +ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY NONCLUSTERED ( drug_era_id ) ; + +ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY NONCLUSTERED ( dose_era_id ) ; + +ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY NONCLUSTERED ( condition_era_id ) ; diff --git a/DDLGeneratr/inst/sql/sql_server/OMOP CDM ddl.sql b/DDLGeneratr/inst/sql/sql_server/OMOP CDM ddl.sql index adb97df..f1ff8f6 100644 --- a/DDLGeneratr/inst/sql/sql_server/OMOP CDM ddl.sql +++ b/DDLGeneratr/inst/sql/sql_server/OMOP CDM ddl.sql @@ -221,7 +221,7 @@ Standardized clinical data ************************/ - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( person_id INTEGER NOT NULL , @@ -246,6 +246,7 @@ CREATE TABLE person ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation_period ( observation_period_id INTEGER NOT NULL , @@ -257,6 +258,7 @@ CREATE TABLE observation_period ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE specimen ( specimen_id INTEGER NOT NULL , @@ -278,7 +280,7 @@ CREATE TABLE specimen ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE death ( person_id INTEGER NOT NULL , @@ -292,6 +294,7 @@ CREATE TABLE death ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_occurrence ( visit_occurrence_id INTEGER NOT NULL , @@ -315,6 +318,7 @@ CREATE TABLE visit_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_detail ( visit_detail_id INTEGER NOT NULL , @@ -340,6 +344,7 @@ CREATE TABLE visit_detail ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE procedure_occurrence ( procedure_occurrence_id INTEGER NOT NULL , @@ -360,6 +365,7 @@ CREATE TABLE procedure_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_exposure ( drug_exposure_id INTEGER NOT NULL , @@ -389,6 +395,7 @@ CREATE TABLE drug_exposure ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE device_exposure ( device_exposure_id INTEGER NOT NULL , @@ -410,6 +417,7 @@ CREATE TABLE device_exposure ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_occurrence ( condition_occurrence_id INTEGER NOT NULL , @@ -432,6 +440,7 @@ CREATE TABLE condition_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE measurement ( measurement_id INTEGER NOT NULL , @@ -458,7 +467,7 @@ CREATE TABLE measurement ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE note ( note_id INTEGER NOT NULL , @@ -500,7 +509,7 @@ CREATE TABLE note_nlp ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation ( observation_id INTEGER NOT NULL , @@ -525,7 +534,6 @@ CREATE TABLE observation ; - CREATE TABLE fact_relationship ( domain_concept_id_1 INTEGER NOT NULL , @@ -538,7 +546,6 @@ CREATE TABLE fact_relationship - /************************ Standardized health system data @@ -546,7 +553,6 @@ Standardized health system data ************************/ - CREATE TABLE location ( location_id INTEGER NOT NULL , @@ -561,7 +567,6 @@ CREATE TABLE location ; - CREATE TABLE care_site ( care_site_id INTEGER NOT NULL , @@ -574,7 +579,6 @@ CREATE TABLE care_site ; - CREATE TABLE provider ( provider_id INTEGER NOT NULL , @@ -594,8 +598,6 @@ CREATE TABLE provider ; - - /************************ Standardized health economics @@ -603,6 +605,7 @@ Standardized health economics ************************/ +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period ( payer_plan_period_id INTEGER NOT NULL , @@ -654,15 +657,14 @@ CREATE TABLE cost ; - - - /************************ Standardized derived elements ************************/ + +--HINT DISTRIBUTE_ON_KEY(subject_id) CREATE TABLE cohort ( cohort_definition_id INTEGER NOT NULL , @@ -673,6 +675,7 @@ CREATE TABLE cohort ; +--HINT DISTRIBUTE_ON_KEY(subject_id) CREATE TABLE cohort_attribute ( cohort_definition_id INTEGER NOT NULL , @@ -686,8 +689,7 @@ CREATE TABLE cohort_attribute ; - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_era ( drug_era_id INTEGER NOT NULL , @@ -701,6 +703,7 @@ CREATE TABLE drug_era ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE dose_era ( dose_era_id INTEGER NOT NULL , @@ -714,8 +717,7 @@ CREATE TABLE dose_era ; - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_era ( condition_era_id INTEGER NOT NULL , @@ -726,10 +728,3 @@ CREATE TABLE condition_era condition_occurrence_count INTEGER NULL ) ; - - - - - - - diff --git a/DDLGeneratr/inst/sql/sql_server/OMOP_CDM_PDF.sql b/DDLGeneratr/inst/sql/sql_server/OMOP_CDM_PDF.sql deleted file mode 100644 index ccf273a..0000000 --- a/DDLGeneratr/inst/sql/sql_server/OMOP_CDM_PDF.sql +++ /dev/null @@ -1,207 +0,0 @@ ---- -title: "OMOP Common Data Model Specifications" -author: "Christian Reich, Patrick Ryan, Rimma Belenkaya, Karthik Natarajan and Clair Blacketer" -date: "`r Sys.Date()`" -output: - pdf_document: - number_sections: yes - toc: yes -linkcolor: blue ---- - -# License - -```{r child = '@mdFilesLocation/License.md'} -``` - -# Background -```{r child = '@mdFilesLocation/Background/Background.md'} -``` - -## The Role of the Common Data Model -```{r child = '@mdFilesLocation/Background/The-Role-of-the-Common-Data-Model.md'} -``` - -## Design Principles -```{r child = '@mdFilesLocation/Background/Design-Principles.md'} -``` - -## Data Model Conventions -```{r child = '@mdFilesLocation/Background/Data-Model-Conventions.md'} -``` - -# Glossary of Terms -```{r child = '@mdFilesLocation/Glossary-of-Terms.md'} -``` - -# Standardized Vocabularies -```{r child = '@mdFilesLocation/StandardizedVocabularies/Standardized-Vocabularies.md'} -``` - -## CONCEPT -```{r child = '@mdFilesLocation/StandardizedVocabularies/CONCEPT.md'} -``` - -## VOCABULARY -```{r child = '@mdFilesLocation/StandardizedVocabularies/VOCABULARY.md'} -``` - -## DOMAIN -```{r child = '@mdFilesLocation/StandardizedVocabularies/DOMAIN.md'} -``` - -## CONCEPT_CLASS -```{r child = '@mdFilesLocation/StandardizedVocabularies/CONCEPT_CLASS.md'} -``` - -## CONCEPT_RELATIONSHIP -```{r child = '@mdFilesLocation/StandardizedVocabularies/CONCEPT_RELATIONSHIP.md'} -``` - -## RELATIONSHIP -```{r child = '@mdFilesLocation/StandardizedVocabularies/RELATIONSHIP.md'} -``` - -## CONCEPT_SYNONYM -```{r child = '@mdFilesLocation/StandardizedVocabularies/CONCEPT_SYNONYM.md'} -``` - -## CONCEPT_ANCESTOR -```{r child = '@mdFilesLocation/StandardizedVocabularies/CONCEPT_ANCESTOR.md'} -``` - -## SOURCE_TO_CONCEPT_MAP -```{r child = '@mdFilesLocation/StandardizedVocabularies/SOURCE_TO_CONCEPT_MAP.md'} -``` - -## DRUG_STRENGTH -```{r child = '@mdFilesLocation/StandardizedVocabularies/DRUG_STRENGTH.md'} -``` - -## COHORT_DEFINITION -```{r child = '@mdFilesLocation/StandardizedVocabularies/COHORT_DEFINITION.md'} -``` - -## ATTRIBUTE_DEFINITION -```{r child = '@mdFilesLocation/StandardizedVocabularies/ATTRIBUTE_DEFINITION.md'} -``` - -# Standardized Metadata -```{r child = '@mdFilesLocation/StandardizedMetadata/Standardized-Metadata.md'} -``` - -## CDM_SOURCE -```{r child = '@mdFilesLocation/StandardizedMetadata/CDM_SOURCE.md'} -``` - -# Standardized Clinical Data Tables -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/Standardized-clinical-Data-Tables.md'} -``` - -## PERSON -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/PERSON.md'} -``` - -## OBSERVATION_PERIOD -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/OBSERVATION_PERIOD.md'} -``` - -## SPECIMEN -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/SPECIMEN.md'} -``` - -## DEATH -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/DEATH.md'} -``` - -## VISIT_OCCURRENCE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/VISIT_OCCURRENCE.md'} -``` - -## PROCEDURE_OCCURRENCE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/PROCEDURE_OCCURRENCE.md'} -``` - -## DRUG_EXPOSURE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/DRUG_EXPOSURE.md'} -``` - -## DEVICE_EXPOSURE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/DEVICE_EXPOSURE.md'} -``` - -## CONDITION_OCCURRENCE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/CONDITION_OCCURRENCE.md'} -``` - -## MEASUREMENT -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/MEASUREMENT.md'} -``` - -## NOTE -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/NOTE.md'} -``` - -## NOTE_NLP -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/NOTE_NLP.md'} -``` - -## OBSERVATION -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/OBSERVATION.md'} -``` - -## FACT_RELATIONSHIP -```{r child = '@mdFilesLocation/StandardizedclinicalDataTables/FACT_RELATIONSHIP.md'} -``` - -# Standardized Health System Data Tables -```{r child = '@mdFilesLocation/StandardizedHealthSystemDataTables/Standardized-Health-System-Data-Tables.md'} -``` - -## LOCATION -```{r child = '@mdFilesLocation/StandardizedHealthSystemDataTables/LOCATION.md'} -``` - -## CARE_SITE -```{r child = '@mdFilesLocation/StandardizedHealthSystemDataTables/CARE_SITE.md'} -``` - -## PROVIDER -```{r child = '@mdFilesLocation/StandardizedHealthSystemDataTables/PROVIDER.md'} -``` - -# Standardized Health Economics Data Tables -```{r child = '@mdFilesLocation/StandardizedHealthEconomicsDataTables/Standardized-Health-Economics-Data-Tables.md'} -``` - -## PAYER_PLAN_PERIOD -```{r child = '@mdFilesLocation/StandardizedHealthEconomicsDataTables/PAYER_PLAN_PERIOD.md'} -``` - -## COST -```{r child = '@mdFilesLocation/StandardizedHealthEconomicsDataTables/COST.md'} -``` - -# Standardized Derived Elements -```{r child = '@mdFilesLocation/StandardizedDerivedElements/Standardized-Derived-Elements.md'} -``` - -## COHORT -```{r child = '@mdFilesLocation/StandardizedDerivedElements/COHORT.md'} -``` - -## COHORT_ATTRIBUTE -```{r child = '@mdFilesLocation/StandardizedDerivedElements/COHORT_ATTRIBUTE.md'} -``` - -## DRUG_ERA -```{r child = '@mdFilesLocation/StandardizedDerivedElements/DRUG_ERA.md'} -``` - -## DOSE_ERA -```{r child = '@mdFilesLocation/StandardizedDerivedElements/DOSE_ERA.md'} -``` - -## CONDITION_ERA -```{r child = '@mdFilesLocation/StandardizedDerivedElements/CONDITION_ERA.md'} -``` diff --git a/DDLGeneratr/output/netezza/OMOP CDM netezza ddl.txt b/DDLGeneratr/output/netezza/OMOP CDM netezza ddl.txt index 6cb25d3..cc56aa0 100644 --- a/DDLGeneratr/output/netezza/OMOP CDM netezza ddl.txt +++ b/DDLGeneratr/output/netezza/OMOP CDM netezza ddl.txt @@ -221,7 +221,7 @@ Standardized clinical data ************************/ - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person ( person_id INTEGER NOT NULL , @@ -246,6 +246,7 @@ CREATE TABLE person ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation_period ( observation_period_id INTEGER NOT NULL , @@ -257,6 +258,7 @@ CREATE TABLE observation_period ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE specimen ( specimen_id INTEGER NOT NULL , @@ -278,7 +280,7 @@ CREATE TABLE specimen ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE death ( person_id INTEGER NOT NULL , @@ -292,6 +294,7 @@ CREATE TABLE death ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_occurrence ( visit_occurrence_id INTEGER NOT NULL , @@ -315,6 +318,7 @@ CREATE TABLE visit_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_detail ( visit_detail_id INTEGER NOT NULL , @@ -340,6 +344,7 @@ CREATE TABLE visit_detail ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE procedure_occurrence ( procedure_occurrence_id INTEGER NOT NULL , @@ -360,6 +365,7 @@ CREATE TABLE procedure_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_exposure ( drug_exposure_id INTEGER NOT NULL , @@ -389,6 +395,7 @@ CREATE TABLE drug_exposure ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE device_exposure ( device_exposure_id INTEGER NOT NULL , @@ -410,6 +417,7 @@ CREATE TABLE device_exposure ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_occurrence ( condition_occurrence_id INTEGER NOT NULL , @@ -432,6 +440,7 @@ CREATE TABLE condition_occurrence ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE measurement ( measurement_id INTEGER NOT NULL , @@ -458,7 +467,7 @@ CREATE TABLE measurement ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE note ( note_id INTEGER NOT NULL , @@ -500,7 +509,7 @@ CREATE TABLE note_nlp ; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation ( observation_id INTEGER NOT NULL , @@ -525,7 +534,6 @@ CREATE TABLE observation ; - CREATE TABLE fact_relationship ( domain_concept_id_1 INTEGER NOT NULL , @@ -538,7 +546,6 @@ CREATE TABLE fact_relationship - /************************ Standardized health system data @@ -546,7 +553,6 @@ Standardized health system data ************************/ - CREATE TABLE location ( location_id INTEGER NOT NULL , @@ -561,7 +567,6 @@ CREATE TABLE location ; - CREATE TABLE care_site ( care_site_id INTEGER NOT NULL , @@ -574,7 +579,6 @@ CREATE TABLE care_site ; - CREATE TABLE provider ( provider_id INTEGER NOT NULL , @@ -594,8 +598,6 @@ CREATE TABLE provider ; - - /************************ Standardized health economics @@ -603,6 +605,7 @@ Standardized health economics ************************/ +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period ( payer_plan_period_id INTEGER NOT NULL , @@ -654,15 +657,14 @@ CREATE TABLE cost ; - - - /************************ Standardized derived elements ************************/ + +--HINT DISTRIBUTE_ON_KEY(subject_id) CREATE TABLE cohort ( cohort_definition_id INTEGER NOT NULL , @@ -673,12 +675,13 @@ CREATE TABLE cohort ; +--HINT DISTRIBUTE_ON_KEY(subject_id) CREATE TABLE cohort_attribute ( cohort_definition_id INTEGER NOT NULL , + subject_id INTEGER NOT NULL , cohort_start_date DATE NOT NULL , cohort_end_date DATE NOT NULL , - subject_id INTEGER NOT NULL , attribute_definition_id INTEGER NOT NULL , value_as_number NUMERIC NULL , value_as_concept_id INTEGER NULL @@ -686,8 +689,7 @@ CREATE TABLE cohort_attribute ; - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_era ( drug_era_id INTEGER NOT NULL , @@ -701,6 +703,7 @@ CREATE TABLE drug_era ; +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE dose_era ( dose_era_id INTEGER NOT NULL , @@ -714,8 +717,7 @@ CREATE TABLE dose_era ; - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_era ( condition_era_id INTEGER NOT NULL , @@ -726,10 +728,3 @@ CREATE TABLE condition_era condition_occurrence_count INTEGER NULL ) ; - - - - - - - diff --git a/DDLGeneratr/output/redshift/OMOP CDM redshift ddl.txt b/DDLGeneratr/output/redshift/OMOP CDM redshift ddl.txt index 4b1cacf..c732058 100644 --- a/DDLGeneratr/output/redshift/OMOP CDM redshift ddl.txt +++ b/DDLGeneratr/output/redshift/OMOP CDM redshift ddl.txt @@ -207,9 +207,9 @@ Standardized clinical data ************************/ - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE person - ( person_id INTEGER NOT NULL , + (person_id INTEGER NOT NULL , gender_concept_id INTEGER NOT NULL , year_of_birth INTEGER NOT NULL , month_of_birth INTEGER NULL, @@ -231,9 +231,10 @@ CREATE TABLE person DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation_period (observation_period_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , observation_period_start_date DATE NOT NULL , observation_period_end_date DATE NOT NULL , period_type_concept_id INTEGER NOT NULL @@ -241,9 +242,10 @@ CREATE TABLE observation_period DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE specimen (specimen_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , specimen_concept_id INTEGER NOT NULL , specimen_type_concept_id INTEGER NOT NULL , specimen_date DATE NOT NULL , @@ -261,9 +263,9 @@ CREATE TABLE specimen DISTKEY(person_id); - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE death - ( person_id INTEGER NOT NULL , + (person_id INTEGER NOT NULL , death_date DATE NOT NULL , death_datetime TIMESTAMP NULL , death_type_concept_id INTEGER NOT NULL , @@ -274,9 +276,10 @@ CREATE TABLE death DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_occurrence (visit_occurrence_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , visit_concept_id INTEGER NOT NULL , visit_start_date DATE NOT NULL , visit_start_datetime TIMESTAMP NULL , @@ -296,9 +299,10 @@ CREATE TABLE visit_occurrence DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE visit_detail (visit_detail_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , visit_detail_concept_id INTEGER NOT NULL , visit_start_date DATE NOT NULL , visit_start_datetime TIMESTAMP NULL , @@ -320,9 +324,10 @@ CREATE TABLE visit_detail DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE procedure_occurrence (procedure_occurrence_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , procedure_concept_id INTEGER NOT NULL , procedure_date DATE NOT NULL , procedure_datetime TIMESTAMP NULL , @@ -339,9 +344,10 @@ CREATE TABLE procedure_occurrence DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_exposure (drug_exposure_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_exposure_start_date DATE NOT NULL , drug_exposure_start_datetime TIMESTAMP NULL , @@ -367,9 +373,10 @@ CREATE TABLE drug_exposure DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE device_exposure (device_exposure_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , device_concept_id INTEGER NOT NULL , device_exposure_start_date DATE NOT NULL , device_exposure_start_datetime TIMESTAMP NULL , @@ -387,9 +394,10 @@ CREATE TABLE device_exposure DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_occurrence (condition_occurrence_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , condition_concept_id INTEGER NOT NULL , condition_start_date DATE NOT NULL , condition_start_datetime TIMESTAMP NULL , @@ -408,9 +416,10 @@ CREATE TABLE condition_occurrence DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE measurement (measurement_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , measurement_concept_id INTEGER NOT NULL , measurement_date DATE NOT NULL , measurement_time VARCHAR(10) NULL , @@ -433,10 +442,10 @@ CREATE TABLE measurement DISTKEY(person_id); - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE note (note_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , note_date DATE NOT NULL , note_datetime TIMESTAMP NULL , note_type_concept_id INTEGER NOT NULL , @@ -473,10 +482,10 @@ CREATE TABLE note_nlp DISTSTYLE ALL; - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE observation (observation_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , observation_concept_id INTEGER NOT NULL , observation_date DATE NOT NULL , observation_datetime TIMESTAMP NULL , @@ -497,7 +506,6 @@ CREATE TABLE observation DISTKEY(person_id); - CREATE TABLE fact_relationship (domain_concept_id_1 INTEGER NOT NULL , fact_id_1 INTEGER NOT NULL , @@ -509,7 +517,6 @@ DISTSTYLE ALL; - /************************ Standardized health system data @@ -517,7 +524,6 @@ Standardized health system data ************************/ - CREATE TABLE location (location_id INTEGER NOT NULL , address_1 VARCHAR(50) NULL , @@ -531,7 +537,6 @@ CREATE TABLE location DISTSTYLE ALL; - CREATE TABLE care_site (care_site_id INTEGER NOT NULL , care_site_name VARCHAR(255) NULL , @@ -543,7 +548,6 @@ CREATE TABLE care_site DISTSTYLE ALL; - CREATE TABLE provider (provider_id INTEGER NOT NULL , provider_name VARCHAR(255) NULL , @@ -562,8 +566,6 @@ CREATE TABLE provider DISTSTYLE ALL; - - /************************ Standardized health economics @@ -571,9 +573,10 @@ Standardized health economics ************************/ +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE payer_plan_period (payer_plan_period_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , payer_plan_period_start_date DATE NOT NULL , payer_plan_period_end_date DATE NOT NULL , payer_concept_id INTEGER NULL , @@ -620,29 +623,29 @@ CREATE TABLE cost DISTSTYLE ALL; - - - /************************ Standardized derived elements ************************/ + +--HINT DISTRIBUTE_ON_KEY(subject_id) CREATE TABLE cohort (cohort_definition_id INTEGER NOT NULL , - subject_id INTEGER NOT NULL , + subject_id INTEGER 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 INTEGER NOT NULL , + subject_id INTEGER NOT NULL , cohort_start_date DATE NOT NULL , cohort_end_date DATE NOT NULL , - subject_id INTEGER NOT NULL , attribute_definition_id INTEGER NOT NULL , value_as_number FLOAT NULL , value_as_concept_id INTEGER NULL @@ -650,11 +653,10 @@ CREATE TABLE cohort_attribute DISTKEY(subject_id); - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE drug_era (drug_era_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_era_start_date DATE NOT NULL , drug_era_end_date DATE NOT NULL , @@ -664,9 +666,10 @@ CREATE TABLE drug_era DISTKEY(person_id); +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE dose_era (dose_era_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , unit_concept_id INTEGER NOT NULL , dose_value FLOAT NOT NULL , @@ -676,21 +679,13 @@ CREATE TABLE dose_era DISTKEY(person_id); - - +--HINT DISTRIBUTE_ON_KEY(person_id) CREATE TABLE condition_era (condition_era_id INTEGER NOT NULL , - person_id INTEGER NOT NULL , + person_id INTEGER NOT NULL , condition_concept_id INTEGER NOT NULL , condition_era_start_date DATE NOT NULL , condition_era_end_date DATE NOT NULL , condition_occurrence_count INTEGER NULL ) DISTKEY(person_id); - - - - - - -