From b68423f178765ccb354786c6738ae2333212b8aa Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 1 Jul 2024 15:09:38 +0200 Subject: [PATCH 01/12] default DDL for IRIS --- .../5.4/iris/OMOPCDM_iris_5.4_constraints.sql | 177 ++++++ .../iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql | 511 ++++++++++++++++++ .../5.4/iris/OMOPCDM_iris_5.4_indices.sql | 98 ++++ .../iris/OMOPCDM_iris_5.4_primary_keys.sql | 29 + 4 files changed, 815 insertions(+) create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql new file mode 100644 index 0000000..d4278a8 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql @@ -0,0 +1,177 @@ +--iris CDM Foreign Key Constraints for OMOP Common Data Model 5.4 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_concept_id FOREIGN KEY (race_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_concept_id FOREIGN KEY (ethnicity_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_source_concept_id FOREIGN KEY (race_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_source_concept_id FOREIGN KEY (ethnicity_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_period_type_concept_id FOREIGN KEY (period_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_concept_id FOREIGN KEY (visit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_type_concept_id FOREIGN KEY (visit_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_source_concept_id FOREIGN KEY (visit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_concept_id FOREIGN KEY (visit_detail_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_type_concept_id FOREIGN KEY (visit_detail_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_source_concept_id FOREIGN KEY (visit_detail_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_type_concept_id FOREIGN KEY (condition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_status_concept_id FOREIGN KEY (condition_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_source_concept_id FOREIGN KEY (condition_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_type_concept_id FOREIGN KEY (drug_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_route_concept_id FOREIGN KEY (route_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_source_concept_id FOREIGN KEY (drug_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_concept_id FOREIGN KEY (procedure_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_type_concept_id FOREIGN KEY (procedure_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_modifier_concept_id FOREIGN KEY (modifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_source_concept_id FOREIGN KEY (procedure_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_concept_id FOREIGN KEY (device_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_type_concept_id FOREIGN KEY (device_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_source_concept_id FOREIGN KEY (device_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_concept_id FOREIGN KEY (measurement_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_type_concept_id FOREIGN KEY (measurement_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_operator_concept_id FOREIGN KEY (operator_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_type_concept_id FOREIGN KEY (observation_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_qualifier_concept_id FOREIGN KEY (qualifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_concept_id FOREIGN KEY (cause_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_source_concept_id FOREIGN KEY (cause_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_encoding_concept_id FOREIGN KEY (encoding_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept_id FOREIGN KEY (section_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_concept_id FOREIGN KEY (note_nlp_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_source_concept_id FOREIGN KEY (note_nlp_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_concept_id FOREIGN KEY (specimen_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_type_concept_id FOREIGN KEY (specimen_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_anatomic_site_concept_id FOREIGN KEY (anatomic_site_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_disease_status_concept_id FOREIGN KEY (disease_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_1 FOREIGN KEY (domain_concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_2 FOREIGN KEY (domain_concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT fpk_location_country_concept_id FOREIGN KEY (country_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_place_of_service_concept_id FOREIGN KEY (place_of_service_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_concept_id FOREIGN KEY (specialty_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_source_concept_id FOREIGN KEY (specialty_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_concept_id FOREIGN KEY (payer_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_source_concept_id FOREIGN KEY (payer_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_concept_id FOREIGN KEY (plan_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_source_concept_id FOREIGN KEY (plan_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_concept_id FOREIGN KEY (sponsor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_source_concept_id FOREIGN KEY (sponsor_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_concept_id FOREIGN KEY (stop_reason_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_source_concept_id FOREIGN KEY (stop_reason_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_domain_id FOREIGN KEY (cost_domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_type_concept_id FOREIGN KEY (cost_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_currency_concept_id FOREIGN KEY (currency_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_revenue_code_concept_id FOREIGN KEY (revenue_code_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_drg_concept_id FOREIGN KEY (drg_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode_event ADD CONSTRAINT fpk_episode_event_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID); +ALTER TABLE @cdmDatabaseSchema.episode_event ADD CONSTRAINT fpk_episode_event_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cdm_source ADD CONSTRAINT fpk_cdm_source_cdm_version_concept_id FOREIGN KEY (cdm_version_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_domain_id FOREIGN KEY (domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_vocabulary_id FOREIGN KEY (vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_concept_class_id FOREIGN KEY (concept_class_id) REFERENCES @cdmDatabaseSchema.CONCEPT_CLASS (CONCEPT_CLASS_ID); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT fpk_vocabulary_vocabulary_concept_id FOREIGN KEY (vocabulary_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT fpk_domain_domain_concept_id FOREIGN KEY (domain_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT fpk_concept_class_concept_class_concept_id FOREIGN KEY (concept_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_1 FOREIGN KEY (concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_2 FOREIGN KEY (concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_relationship_id FOREIGN KEY (relationship_id) REFERENCES @cdmDatabaseSchema.RELATIONSHIP (RELATIONSHIP_ID); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT fpk_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept_id FOREIGN KEY (concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_ancestor_concept_id FOREIGN KEY (ancestor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_descendant_concept_id FOREIGN KEY (descendant_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_source_concept_id FOREIGN KEY (source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_concept_id FOREIGN KEY (target_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_vocabulary_id FOREIGN KEY (target_vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_ingredient_concept_id FOREIGN KEY (ingredient_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_amount_unit_concept_id FOREIGN KEY (amount_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_numerator_unit_concept_id FOREIGN KEY (numerator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_denominator_unit_concept_id FOREIGN KEY (denominator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql new file mode 100644 index 0000000..7782926 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql @@ -0,0 +1,511 @@ +--iris CDM DDL Specification for OMOP Common Data Model 5.4 +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.person ( + person_id integer NOT NULL, + gender_concept_id integer NOT NULL, + year_of_birth integer NOT NULL, + month_of_birth integer NULL, + day_of_birth integer NULL, + birth_datetime datetime NULL, + race_concept_id integer NOT NULL, + ethnicity_concept_id integer NOT NULL, + location_id integer NULL, + provider_id integer NULL, + care_site_id integer NULL, + person_source_value varchar(50) NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL, + race_source_value varchar(50) NULL, + race_source_concept_id integer NULL, + ethnicity_source_value varchar(50) NULL, + ethnicity_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation_period ( + observation_period_id integer NOT NULL, + person_id integer NOT NULL, + observation_period_start_date date NOT NULL, + observation_period_end_date date NOT NULL, + period_type_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_occurrence ( + visit_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + visit_concept_id integer NOT NULL, + visit_start_date date NOT NULL, + visit_start_datetime datetime NULL, + visit_end_date date NOT NULL, + visit_end_datetime datetime NULL, + visit_type_concept_id Integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_source_value varchar(50) NULL, + visit_source_concept_id integer NULL, + admitted_from_concept_id integer NULL, + admitted_from_source_value varchar(50) NULL, + discharged_to_concept_id integer NULL, + discharged_to_source_value varchar(50) NULL, + preceding_visit_occurrence_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_detail ( + visit_detail_id integer NOT NULL, + person_id integer NOT NULL, + visit_detail_concept_id integer NOT NULL, + visit_detail_start_date date NOT NULL, + visit_detail_start_datetime datetime NULL, + visit_detail_end_date date NOT NULL, + visit_detail_end_datetime datetime NULL, + visit_detail_type_concept_id integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_detail_source_value varchar(50) NULL, + visit_detail_source_concept_id Integer NULL, + admitted_from_concept_id Integer NULL, + admitted_from_source_value varchar(50) NULL, + discharged_to_source_value varchar(50) NULL, + discharged_to_concept_id integer NULL, + preceding_visit_detail_id integer NULL, + parent_visit_detail_id integer NULL, + visit_occurrence_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_occurrence ( + condition_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_start_date date NOT NULL, + condition_start_datetime datetime NULL, + condition_end_date date NULL, + condition_end_datetime datetime NULL, + condition_type_concept_id integer NOT NULL, + condition_status_concept_id integer NULL, + stop_reason varchar(20) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + condition_source_value varchar(50) NULL, + condition_source_concept_id integer NULL, + condition_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_exposure ( + drug_exposure_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_exposure_start_date date NOT NULL, + drug_exposure_start_datetime datetime NULL, + drug_exposure_end_date date NOT NULL, + drug_exposure_end_datetime datetime NULL, + verbatim_end_date date NULL, + drug_type_concept_id integer NOT NULL, + stop_reason varchar(20) NULL, + refills integer NULL, + quantity float NULL, + days_supply integer NULL, + sig varchar(MAX) NULL, + route_concept_id integer NULL, + lot_number varchar(50) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + drug_source_value varchar(50) NULL, + drug_source_concept_id integer NULL, + route_source_value varchar(50) NULL, + dose_unit_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.procedure_occurrence ( + procedure_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + procedure_concept_id integer NOT NULL, + procedure_date date NOT NULL, + procedure_datetime datetime NULL, + procedure_end_date date NULL, + procedure_end_datetime datetime NULL, + procedure_type_concept_id integer NOT NULL, + modifier_concept_id integer NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + procedure_source_value varchar(50) NULL, + procedure_source_concept_id integer NULL, + modifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.device_exposure ( + device_exposure_id integer NOT NULL, + person_id integer NOT NULL, + device_concept_id integer NOT NULL, + device_exposure_start_date date NOT NULL, + device_exposure_start_datetime datetime NULL, + device_exposure_end_date date NULL, + device_exposure_end_datetime datetime NULL, + device_type_concept_id integer NOT NULL, + unique_device_id varchar(255) NULL, + production_id varchar(255) NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + device_source_value varchar(50) NULL, + device_source_concept_id integer NULL, + unit_concept_id integer NULL, + unit_source_value varchar(50) NULL, + unit_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.measurement ( + measurement_id integer NOT NULL, + person_id integer NOT NULL, + measurement_concept_id integer NOT NULL, + measurement_date date NOT NULL, + measurement_datetime datetime NULL, + measurement_time varchar(10) NULL, + measurement_type_concept_id integer NOT NULL, + operator_concept_id integer NULL, + value_as_number float NULL, + value_as_concept_id integer NULL, + unit_concept_id integer NULL, + range_low float NULL, + range_high float NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + measurement_source_value varchar(50) NULL, + measurement_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + unit_source_concept_id integer NULL, + value_source_value varchar(50) NULL, + measurement_event_id integer NULL, + meas_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation ( + observation_id integer NOT NULL, + person_id integer NOT NULL, + observation_concept_id integer NOT NULL, + observation_date date NOT NULL, + observation_datetime datetime NULL, + observation_type_concept_id integer NOT NULL, + value_as_number float NULL, + value_as_string varchar(60) NULL, + value_as_concept_id Integer NULL, + qualifier_concept_id integer NULL, + unit_concept_id integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + observation_source_value varchar(50) NULL, + observation_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + qualifier_source_value varchar(50) NULL, + value_source_value varchar(50) NULL, + observation_event_id integer NULL, + obs_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.death ( + person_id integer NOT NULL, + death_date date NOT NULL, + death_datetime datetime NULL, + death_type_concept_id integer 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 @cdmDatabaseSchema.note ( + note_id integer NOT NULL, + person_id integer NOT NULL, + note_date date NOT NULL, + note_datetime datetime NULL, + note_type_concept_id integer NOT NULL, + note_class_concept_id integer NOT NULL, + note_title varchar(250) NULL, + note_text varchar(MAX) NOT NULL, + encoding_concept_id integer NOT NULL, + language_concept_id integer NOT NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + note_source_value varchar(50) NULL, + note_event_id integer NULL, + note_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.note_nlp ( + note_nlp_id integer NOT NULL, + note_id integer NOT NULL, + section_concept_id integer NULL, + snippet varchar(250) NULL, + "offset" varchar(50) NULL, + lexical_variant varchar(250) NOT NULL, + note_nlp_concept_id integer NULL, + note_nlp_source_concept_id integer NULL, + nlp_system varchar(250) NULL, + nlp_date date NOT NULL, + nlp_datetime datetime NULL, + term_exists varchar(1) NULL, + term_temporal varchar(50) NULL, + term_modifiers varchar(2000) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.specimen ( + specimen_id integer NOT NULL, + person_id integer NOT NULL, + specimen_concept_id integer NOT NULL, + specimen_type_concept_id integer NOT NULL, + specimen_date date NOT NULL, + specimen_datetime datetime NULL, + quantity float NULL, + unit_concept_id integer NULL, + anatomic_site_concept_id integer NULL, + disease_status_concept_id integer NULL, + specimen_source_id varchar(50) NULL, + specimen_source_value varchar(50) NULL, + unit_source_value varchar(50) NULL, + anatomic_site_source_value varchar(50) NULL, + disease_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.fact_relationship ( + domain_concept_id_1 integer NOT NULL, + fact_id_1 integer NOT NULL, + domain_concept_id_2 integer NOT NULL, + fact_id_2 integer NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.location ( + location_id integer NOT NULL, + address_1 varchar(50) NULL, + address_2 varchar(50) NULL, + city varchar(50) NULL, + state varchar(2) NULL, + zip varchar(9) NULL, + county varchar(20) NULL, + location_source_value varchar(50) NULL, + country_concept_id integer NULL, + country_source_value varchar(80) NULL, + latitude float NULL, + longitude float NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.care_site ( + care_site_id integer NOT NULL, + care_site_name varchar(255) NULL, + place_of_service_concept_id integer NULL, + location_id integer NULL, + care_site_source_value varchar(50) NULL, + place_of_service_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.provider ( + provider_id integer NOT NULL, + provider_name varchar(255) NULL, + npi varchar(20) NULL, + dea varchar(20) NULL, + specialty_concept_id integer NULL, + care_site_id integer NULL, + year_of_birth integer NULL, + gender_concept_id integer NULL, + provider_source_value varchar(50) NULL, + specialty_source_value varchar(50) NULL, + specialty_source_concept_id integer NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.payer_plan_period ( + payer_plan_period_id integer NOT NULL, + person_id integer NOT NULL, + payer_plan_period_start_date date NOT NULL, + payer_plan_period_end_date date NOT NULL, + payer_concept_id integer NULL, + payer_source_value varchar(50) NULL, + payer_source_concept_id integer NULL, + plan_concept_id integer NULL, + plan_source_value varchar(50) NULL, + plan_source_concept_id integer NULL, + sponsor_concept_id integer NULL, + sponsor_source_value varchar(50) NULL, + sponsor_source_concept_id integer NULL, + family_source_value varchar(50) NULL, + stop_reason_concept_id integer NULL, + stop_reason_source_value varchar(50) NULL, + stop_reason_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cost ( + cost_id integer NOT NULL, + cost_event_id integer NOT NULL, + cost_domain_id varchar(20) NOT NULL, + cost_type_concept_id integer NOT NULL, + currency_concept_id integer NULL, + total_charge float NULL, + total_cost float NULL, + total_paid float NULL, + paid_by_payer float NULL, + paid_by_patient float NULL, + paid_patient_copay float NULL, + paid_patient_coinsurance float NULL, + paid_patient_deductible float NULL, + paid_by_primary float NULL, + paid_ingredient_cost float NULL, + paid_dispensing_fee float NULL, + payer_plan_period_id integer NULL, + amount_allowed float NULL, + revenue_code_concept_id integer NULL, + revenue_code_source_value varchar(50) NULL, + drg_concept_id integer NULL, + drg_source_value varchar(3) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_era ( + drug_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_era_start_date date NOT NULL, + drug_era_end_date date NOT NULL, + drug_exposure_count integer NULL, + gap_days integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.dose_era ( + dose_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + unit_concept_id integer NOT NULL, + dose_value float NOT NULL, + dose_era_start_date date NOT NULL, + dose_era_end_date date NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_era ( + condition_era_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_era_start_date date NOT NULL, + condition_era_end_date date NOT NULL, + condition_occurrence_count integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.episode ( + episode_id integer NOT NULL, + person_id integer NOT NULL, + episode_concept_id integer NOT NULL, + episode_start_date date NOT NULL, + episode_start_datetime datetime NULL, + episode_end_date date NULL, + episode_end_datetime datetime NULL, + episode_parent_id integer NULL, + episode_number integer NULL, + episode_object_concept_id integer NOT NULL, + episode_type_concept_id integer NOT NULL, + episode_source_value varchar(50) NULL, + episode_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.episode_event ( + episode_id integer NOT NULL, + event_id integer NOT NULL, + episode_event_field_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.metadata ( + metadata_id integer NOT NULL, + metadata_concept_id integer NOT NULL, + metadata_type_concept_id integer NOT NULL, + name varchar(250) NOT NULL, + value_as_string varchar(250) NULL, + value_as_concept_id integer NULL, + value_as_number float NULL, + metadata_date date NULL, + metadata_datetime datetime NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cdm_source ( + cdm_source_name varchar(255) NOT NULL, + cdm_source_abbreviation varchar(25) NOT NULL, + cdm_holder varchar(255) NOT NULL, + source_description varchar(MAX) NULL, + source_documentation_reference varchar(255) NULL, + cdm_etl_reference varchar(255) NULL, + source_release_date date NOT NULL, + cdm_release_date date NOT NULL, + cdm_version varchar(10) NULL, + cdm_version_concept_id integer NOT NULL, + vocabulary_version varchar(20) NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept ( + concept_id integer NOT NULL, + concept_name varchar(255) NOT NULL, + domain_id varchar(20) NOT NULL, + vocabulary_id varchar(20) NOT NULL, + concept_class_id varchar(20) NOT NULL, + standard_concept varchar(1) NULL, + concept_code varchar(50) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.vocabulary ( + vocabulary_id varchar(20) NOT NULL, + vocabulary_name varchar(255) NOT NULL, + vocabulary_reference varchar(255) NULL, + vocabulary_version varchar(255) NULL, + vocabulary_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema."DOMAIN" ( + domain_id varchar(20) NOT NULL, + domain_name varchar(255) NOT NULL, + domain_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_class ( + concept_class_id varchar(20) NOT NULL, + concept_class_name varchar(255) NOT NULL, + concept_class_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_relationship ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.relationship ( + relationship_id varchar(20) NOT NULL, + relationship_name varchar(255) NOT NULL, + is_hierarchical varchar(1) NOT NULL, + defines_ancestry varchar(1) NOT NULL, + reverse_relationship_id varchar(20) NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_synonym ( + concept_id integer NOT NULL, + concept_synonym_name varchar(1000) NOT NULL, + language_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_ancestor ( + ancestor_concept_id integer NOT NULL, + descendant_concept_id integer NOT NULL, + min_levels_of_separation integer NOT NULL, + max_levels_of_separation integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.source_to_concept_map ( + source_code varchar(50) NOT NULL, + source_concept_id integer NOT NULL, + source_vocabulary_id varchar(20) NOT NULL, + source_code_description varchar(255) NULL, + target_concept_id integer NOT NULL, + target_vocabulary_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.drug_strength ( + drug_concept_id integer NOT NULL, + ingredient_concept_id integer NOT NULL, + amount_value float NULL, + amount_unit_concept_id integer NULL, + numerator_value float NULL, + numerator_unit_concept_id integer NULL, + denominator_value float NULL, + denominator_unit_concept_id integer NULL, + box_size integer NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cohort ( + cohort_definition_id integer NOT NULL, + subject_id integer NOT NULL, + cohort_start_date date NOT NULL, + cohort_end_date date NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.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 ); \ No newline at end of file diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql new file mode 100644 index 0000000..4dea586 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql @@ -0,0 +1,98 @@ +/*iris OMOP CDM Indices + There are no unique indices created because it is assumed that the primary key constraints have been run prior to + implementing indices. +*/ +/************************ +Standardized clinical data +************************/ +CREATE INDEX idx_person_id ON @cdmDatabaseSchema.person (person_id ASC); +CREATE INDEX idx_gender ON @cdmDatabaseSchema.person (gender_concept_id ASC); +CREATE INDEX idx_observation_period_id_1 ON @cdmDatabaseSchema.observation_period (person_id ASC); +CREATE INDEX idx_visit_person_id_1 ON @cdmDatabaseSchema.visit_occurrence (person_id ASC); +CREATE INDEX idx_visit_concept_id_1 ON @cdmDatabaseSchema.visit_occurrence (visit_concept_id ASC); +CREATE INDEX idx_visit_det_person_id_1 ON @cdmDatabaseSchema.visit_detail (person_id ASC); +CREATE INDEX idx_visit_det_concept_id_1 ON @cdmDatabaseSchema.visit_detail (visit_detail_concept_id ASC); +CREATE INDEX idx_visit_det_occ_id ON @cdmDatabaseSchema.visit_detail (visit_occurrence_id ASC); +CREATE INDEX idx_condition_person_id_1 ON @cdmDatabaseSchema.condition_occurrence (person_id ASC); +CREATE INDEX idx_condition_concept_id_1 ON @cdmDatabaseSchema.condition_occurrence (condition_concept_id ASC); +CREATE INDEX idx_condition_visit_id_1 ON @cdmDatabaseSchema.condition_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_drug_person_id_1 ON @cdmDatabaseSchema.drug_exposure (person_id ASC); +CREATE INDEX idx_drug_concept_id_1 ON @cdmDatabaseSchema.drug_exposure (drug_concept_id ASC); +CREATE INDEX idx_drug_visit_id_1 ON @cdmDatabaseSchema.drug_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_procedure_person_id_1 ON @cdmDatabaseSchema.procedure_occurrence (person_id ASC); +CREATE INDEX idx_procedure_concept_id_1 ON @cdmDatabaseSchema.procedure_occurrence (procedure_concept_id ASC); +CREATE INDEX idx_procedure_visit_id_1 ON @cdmDatabaseSchema.procedure_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_device_person_id_1 ON @cdmDatabaseSchema.device_exposure (person_id ASC); +CREATE INDEX idx_device_concept_id_1 ON @cdmDatabaseSchema.device_exposure (device_concept_id ASC); +CREATE INDEX idx_device_visit_id_1 ON @cdmDatabaseSchema.device_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_measurement_person_id_1 ON @cdmDatabaseSchema.measurement (person_id ASC); +CREATE INDEX idx_measurement_concept_id_1 ON @cdmDatabaseSchema.measurement (measurement_concept_id ASC); +CREATE INDEX idx_measurement_visit_id_1 ON @cdmDatabaseSchema.measurement (visit_occurrence_id ASC); +CREATE INDEX idx_observation_person_id_1 ON @cdmDatabaseSchema.observation (person_id ASC); +CREATE INDEX idx_observation_concept_id_1 ON @cdmDatabaseSchema.observation (observation_concept_id ASC); +CREATE INDEX idx_observation_visit_id_1 ON @cdmDatabaseSchema.observation (visit_occurrence_id ASC); +CREATE INDEX idx_death_person_id_1 ON @cdmDatabaseSchema.death (person_id ASC); +CREATE INDEX idx_note_person_id_1 ON @cdmDatabaseSchema.note (person_id ASC); +CREATE INDEX idx_note_concept_id_1 ON @cdmDatabaseSchema.note (note_type_concept_id ASC); +CREATE INDEX idx_note_visit_id_1 ON @cdmDatabaseSchema.note (visit_occurrence_id ASC); +CREATE INDEX idx_note_nlp_note_id_1 ON @cdmDatabaseSchema.note_nlp (note_id ASC); +CREATE INDEX idx_note_nlp_concept_id_1 ON @cdmDatabaseSchema.note_nlp (note_nlp_concept_id ASC); +CREATE INDEX idx_specimen_person_id_1 ON @cdmDatabaseSchema.specimen (person_id ASC); +CREATE INDEX idx_specimen_concept_id_1 ON @cdmDatabaseSchema.specimen (specimen_concept_id ASC); +CREATE INDEX idx_fact_relationship_id1 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_1 ASC); +CREATE INDEX idx_fact_relationship_id2 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_2 ASC); +CREATE INDEX idx_fact_relationship_id3 ON @cdmDatabaseSchema.fact_relationship (relationship_concept_id ASC); +/************************ +Standardized health system data +************************/ +CREATE INDEX idx_location_id_1 ON @cdmDatabaseSchema.location (location_id ASC); +CREATE INDEX idx_care_site_id_1 ON @cdmDatabaseSchema.care_site (care_site_id ASC); +CREATE INDEX idx_provider_id_1 ON @cdmDatabaseSchema.provider (provider_id ASC); +/************************ +Standardized health economics +************************/ +CREATE INDEX idx_period_person_id_1 ON @cdmDatabaseSchema.payer_plan_period (person_id ASC); +CREATE INDEX idx_cost_event_id ON @cdmDatabaseSchema.cost (cost_event_id ASC); +/************************ +Standardized derived elements +************************/ +CREATE INDEX idx_drug_era_person_id_1 ON @cdmDatabaseSchema.drug_era (person_id ASC); +CREATE INDEX idx_drug_era_concept_id_1 ON @cdmDatabaseSchema.drug_era (drug_concept_id ASC); +CREATE INDEX idx_dose_era_person_id_1 ON @cdmDatabaseSchema.dose_era (person_id ASC); +CREATE INDEX idx_dose_era_concept_id_1 ON @cdmDatabaseSchema.dose_era (drug_concept_id ASC); +CREATE INDEX idx_condition_era_person_id_1 ON @cdmDatabaseSchema.condition_era (person_id ASC); +CREATE INDEX idx_condition_era_concept_id_1 ON @cdmDatabaseSchema.condition_era (condition_concept_id ASC); +/************************** +Standardized meta-data +***************************/ +CREATE INDEX idx_metadata_concept_id_1 ON @cdmDatabaseSchema.metadata (metadata_concept_id ASC); +/************************** +Standardized vocabularies +***************************/ +CREATE INDEX idx_concept_concept_id ON @cdmDatabaseSchema.concept (concept_id ASC); +CREATE INDEX idx_concept_code ON @cdmDatabaseSchema.concept (concept_code ASC); +CREATE INDEX idx_concept_vocabulary_id ON @cdmDatabaseSchema.concept (vocabulary_id ASC); +CREATE INDEX idx_concept_domain_id ON @cdmDatabaseSchema.concept (domain_id ASC); +CREATE INDEX idx_concept_class_id ON @cdmDatabaseSchema.concept (concept_class_id ASC); +CREATE INDEX idx_vocabulary_vocabulary_id ON @cdmDatabaseSchema.vocabulary (vocabulary_id ASC); +CREATE INDEX idx_domain_domain_id ON @cdmDatabaseSchema."DOMAIN" (domain_id ASC); +CREATE INDEX idx_concept_class_class_id ON @cdmDatabaseSchema.concept_class (concept_class_id ASC); +CREATE INDEX idx_concept_relationship_id_1 ON @cdmDatabaseSchema.concept_relationship (concept_id_1 ASC); +CREATE INDEX idx_concept_relationship_id_2 ON @cdmDatabaseSchema.concept_relationship (concept_id_2 ASC); +CREATE INDEX idx_concept_relationship_id_3 ON @cdmDatabaseSchema.concept_relationship (relationship_id ASC); +CREATE INDEX idx_relationship_rel_id ON @cdmDatabaseSchema.relationship (relationship_id ASC); +CREATE INDEX idx_concept_synonym_id ON @cdmDatabaseSchema.concept_synonym (concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_1 ON @cdmDatabaseSchema.concept_ancestor (ancestor_concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_2 ON @cdmDatabaseSchema.concept_ancestor (descendant_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_3 ON @cdmDatabaseSchema.source_to_concept_map (target_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_1 ON @cdmDatabaseSchema.source_to_concept_map (source_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_2 ON @cdmDatabaseSchema.source_to_concept_map (target_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_c ON @cdmDatabaseSchema.source_to_concept_map (source_code ASC); +CREATE INDEX idx_drug_strength_id_1 ON @cdmDatabaseSchema.drug_strength (drug_concept_id ASC); +CREATE INDEX idx_drug_strength_id_2 ON @cdmDatabaseSchema.drug_strength (ingredient_concept_id ASC); +--Additional v6.0 indices +--CREATE CLUSTERED INDEX idx_survey_person_id_1 ON @cdmDatabaseSchema.survey_conduct (person_id ASC); +--CREATE CLUSTERED INDEX idx_episode_person_id_1 ON @cdmDatabaseSchema.episode (person_id ASC); +--CREATE INDEX idx_episode_concept_id_1 ON @cdmDatabaseSchema.episode (episode_concept_id ASC); +--CREATE CLUSTERED INDEX idx_episode_event_id_1 ON @cdmDatabaseSchema.episode_event (episode_id ASC); +--CREATE INDEX idx_ee_field_concept_id_1 ON @cdmDatabaseSchema.episode_event (event_field_concept_id ASC); diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql new file mode 100644 index 0000000..bed7975 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql @@ -0,0 +1,29 @@ +--iris CDM Primary Key Constraints for OMOP Common Data Model 5.4 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT xpk_person PRIMARY KEY (person_id); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY (observation_period_id); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY (visit_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY (visit_detail_id); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY (condition_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY (drug_exposure_id); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY (procedure_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY (device_exposure_id); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY (measurement_id); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT xpk_observation PRIMARY KEY (observation_id); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT xpk_note PRIMARY KEY (note_id); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY (note_nlp_id); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY (specimen_id); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT xpk_location PRIMARY KEY (location_id); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY (care_site_id); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT xpk_provider PRIMARY KEY (provider_id); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY (payer_plan_period_id); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT xpk_cost PRIMARY KEY (cost_id); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY (drug_era_id); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY (dose_era_id); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY (condition_era_id); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT xpk_episode PRIMARY KEY (episode_id); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT xpk_metadata PRIMARY KEY (metadata_id); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); From afe69e3bf30ad2181fd9ece7eac995335b28472b Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 8 Jul 2024 08:35:55 +0200 Subject: [PATCH 02/12] fix directory structure --- ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_constraints.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_ddl.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_indices.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_primary_keys.sql | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_constraints.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_ddl.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_indices.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_primary_keys.sql (100%) diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql From cfaf26b6f0e5a5de028fc0c57867207e32f62b18 Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 8 Jul 2024 08:36:11 +0200 Subject: [PATCH 03/12] add 5.3 DDL --- ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql | 158 ++++++ ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql | 471 ++++++++++++++++++ ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql | 98 ++++ .../iris/OMOPCDM_iris_5.3_primary_keys.sql | 27 + 4 files changed, 754 insertions(+) create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql new file mode 100644 index 0000000..b5be6cd --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql @@ -0,0 +1,158 @@ +--iris CDM Foreign Key Constraints for OMOP Common Data Model 5.3 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_concept_id FOREIGN KEY (race_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_concept_id FOREIGN KEY (ethnicity_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_source_concept_id FOREIGN KEY (race_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_source_concept_id FOREIGN KEY (ethnicity_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_period_type_concept_id FOREIGN KEY (period_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_concept_id FOREIGN KEY (visit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_type_concept_id FOREIGN KEY (visit_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_source_concept_id FOREIGN KEY (visit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_admitting_source_concept_id FOREIGN KEY (admitting_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_concept_id FOREIGN KEY (visit_detail_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_type_concept_id FOREIGN KEY (visit_detail_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_source_concept_id FOREIGN KEY (visit_detail_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_admitting_source_concept_id FOREIGN KEY (admitting_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_type_concept_id FOREIGN KEY (condition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_status_concept_id FOREIGN KEY (condition_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_source_concept_id FOREIGN KEY (condition_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_type_concept_id FOREIGN KEY (drug_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_route_concept_id FOREIGN KEY (route_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_source_concept_id FOREIGN KEY (drug_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_concept_id FOREIGN KEY (procedure_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_type_concept_id FOREIGN KEY (procedure_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_modifier_concept_id FOREIGN KEY (modifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_concept_id FOREIGN KEY (device_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_type_concept_id FOREIGN KEY (device_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_source_concept_id FOREIGN KEY (device_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_concept_id FOREIGN KEY (measurement_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_type_concept_id FOREIGN KEY (measurement_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_operator_concept_id FOREIGN KEY (operator_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_type_concept_id FOREIGN KEY (observation_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_qualifier_concept_id FOREIGN KEY (qualifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_concept_id FOREIGN KEY (cause_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_source_concept_id FOREIGN KEY (cause_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_encoding_concept_id FOREIGN KEY (encoding_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept_id FOREIGN KEY (section_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_concept_id FOREIGN KEY (note_nlp_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_source_concept_id FOREIGN KEY (note_nlp_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_concept_id FOREIGN KEY (specimen_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_type_concept_id FOREIGN KEY (specimen_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_anatomic_site_concept_id FOREIGN KEY (anatomic_site_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_disease_status_concept_id FOREIGN KEY (disease_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_1 FOREIGN KEY (domain_concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_2 FOREIGN KEY (domain_concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_place_of_service_concept_id FOREIGN KEY (place_of_service_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_concept_id FOREIGN KEY (specialty_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_source_concept_id FOREIGN KEY (specialty_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_concept_id FOREIGN KEY (payer_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_source_concept_id FOREIGN KEY (payer_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_concept_id FOREIGN KEY (plan_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_source_concept_id FOREIGN KEY (plan_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_concept_id FOREIGN KEY (sponsor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_source_concept_id FOREIGN KEY (sponsor_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_concept_id FOREIGN KEY (stop_reason_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_source_concept_id FOREIGN KEY (stop_reason_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_domain_id FOREIGN KEY (cost_domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_type_concept_id FOREIGN KEY (cost_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_currency_concept_id FOREIGN KEY (currency_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_revenue_code_concept_id FOREIGN KEY (revenue_code_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_drg_concept_id FOREIGN KEY (drg_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_domain_id FOREIGN KEY (domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_vocabulary_id FOREIGN KEY (vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_concept_class_id FOREIGN KEY (concept_class_id) REFERENCES @cdmDatabaseSchema.CONCEPT_CLASS (CONCEPT_CLASS_ID); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT fpk_vocabulary_vocabulary_concept_id FOREIGN KEY (vocabulary_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT fpk_domain_domain_concept_id FOREIGN KEY (domain_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT fpk_concept_class_concept_class_concept_id FOREIGN KEY (concept_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_1 FOREIGN KEY (concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_2 FOREIGN KEY (concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_relationship_id FOREIGN KEY (relationship_id) REFERENCES @cdmDatabaseSchema.RELATIONSHIP (RELATIONSHIP_ID); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT fpk_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept_id FOREIGN KEY (concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_ancestor_concept_id FOREIGN KEY (ancestor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_descendant_concept_id FOREIGN KEY (descendant_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_source_concept_id FOREIGN KEY (source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_concept_id FOREIGN KEY (target_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_vocabulary_id FOREIGN KEY (target_vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_ingredient_concept_id FOREIGN KEY (ingredient_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_amount_unit_concept_id FOREIGN KEY (amount_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_numerator_unit_concept_id FOREIGN KEY (numerator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_denominator_unit_concept_id FOREIGN KEY (denominator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.attribute_definition ADD CONSTRAINT fpk_attribute_definition_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql new file mode 100644 index 0000000..0a6bc5e --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql @@ -0,0 +1,471 @@ +--iris CDM DDL Specification for OMOP Common Data Model 5.3 +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.person ( + person_id integer NOT NULL, + gender_concept_id integer NOT NULL, + year_of_birth integer NOT NULL, + month_of_birth integer NULL, + day_of_birth integer NULL, + birth_datetime datetime NULL, + race_concept_id integer NOT NULL, + ethnicity_concept_id integer NOT NULL, + location_id integer NULL, + provider_id integer NULL, + care_site_id integer NULL, + person_source_value varchar(50) NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL, + race_source_value varchar(50) NULL, + race_source_concept_id integer NULL, + ethnicity_source_value varchar(50) NULL, + ethnicity_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation_period ( + observation_period_id integer NOT NULL, + person_id integer NOT NULL, + observation_period_start_date date NOT NULL, + observation_period_end_date date NOT NULL, + period_type_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_occurrence ( + visit_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + visit_concept_id integer NOT NULL, + visit_start_date date NOT NULL, + visit_start_datetime datetime NULL, + visit_end_date date NOT NULL, + visit_end_datetime datetime NULL, + visit_type_concept_id Integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_source_value varchar(50) NULL, + visit_source_concept_id integer NULL, + admitting_source_concept_id integer NULL, + admitting_source_value varchar(50) NULL, + discharge_to_concept_id integer NULL, + discharge_to_source_value varchar(50) NULL, + preceding_visit_occurrence_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_detail ( + visit_detail_id integer NOT NULL, + person_id integer NOT NULL, + visit_detail_concept_id integer NOT NULL, + visit_detail_start_date date NOT NULL, + visit_detail_start_datetime datetime NULL, + visit_detail_end_date date NOT NULL, + visit_detail_end_datetime datetime NULL, + visit_detail_type_concept_id integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_detail_source_value varchar(50) NULL, + visit_detail_source_concept_id Integer NULL, + admitting_source_value Varchar(50) NULL, + admitting_source_concept_id Integer NULL, + discharge_to_source_value Varchar(50) NULL, + discharge_to_concept_id integer NULL, + preceding_visit_detail_id integer NULL, + visit_detail_parent_id integer NULL, + visit_occurrence_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_occurrence ( + condition_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_start_date date NOT NULL, + condition_start_datetime datetime NULL, + condition_end_date date NULL, + condition_end_datetime datetime NULL, + condition_type_concept_id integer NOT NULL, + condition_status_concept_id integer NULL, + stop_reason varchar(20) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + condition_source_value varchar(50) NULL, + condition_source_concept_id integer NULL, + condition_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_exposure ( + drug_exposure_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_exposure_start_date date NOT NULL, + drug_exposure_start_datetime datetime NULL, + drug_exposure_end_date date NOT NULL, + drug_exposure_end_datetime datetime NULL, + verbatim_end_date date NULL, + drug_type_concept_id integer NOT NULL, + stop_reason varchar(20) NULL, + refills integer NULL, + quantity float NULL, + days_supply integer NULL, + sig varchar(MAX) NULL, + route_concept_id integer NULL, + lot_number varchar(50) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + drug_source_value varchar(50) NULL, + drug_source_concept_id integer NULL, + route_source_value varchar(50) NULL, + dose_unit_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.procedure_occurrence ( + procedure_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + procedure_concept_id integer NOT NULL, + procedure_date date NOT NULL, + procedure_datetime datetime NULL, + procedure_type_concept_id integer NOT NULL, + modifier_concept_id integer NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + procedure_source_value varchar(50) NULL, + procedure_source_concept_id integer NULL, + modifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.device_exposure ( + device_exposure_id integer NOT NULL, + person_id integer NOT NULL, + device_concept_id integer NOT NULL, + device_exposure_start_date date NOT NULL, + device_exposure_start_datetime datetime NULL, + device_exposure_end_date date NULL, + device_exposure_end_datetime datetime NULL, + device_type_concept_id integer NOT NULL, + unique_device_id varchar(50) NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + device_source_value varchar(50) NULL, + device_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.measurement ( + measurement_id integer NOT NULL, + person_id integer NOT NULL, + measurement_concept_id integer NOT NULL, + measurement_date date NOT NULL, + measurement_datetime datetime NULL, + measurement_time varchar(10) NULL, + measurement_type_concept_id integer NOT NULL, + operator_concept_id integer NULL, + value_as_number float NULL, + value_as_concept_id integer NULL, + unit_concept_id integer NULL, + range_low float NULL, + range_high float NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + measurement_source_value varchar(50) NULL, + measurement_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + value_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation ( + observation_id integer NOT NULL, + person_id integer NOT NULL, + observation_concept_id integer NOT NULL, + observation_date date NOT NULL, + observation_datetime datetime NULL, + observation_type_concept_id integer NOT NULL, + value_as_number float NULL, + value_as_string varchar(60) NULL, + value_as_concept_id Integer NULL, + qualifier_concept_id integer NULL, + unit_concept_id integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + observation_source_value varchar(50) NULL, + observation_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + qualifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.death ( + person_id integer NOT NULL, + death_date date NOT NULL, + death_datetime datetime NULL, + death_type_concept_id integer 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 @cdmDatabaseSchema.note ( + note_id integer NOT NULL, + person_id integer NOT NULL, + note_date date NOT NULL, + note_datetime datetime NULL, + note_type_concept_id integer NOT NULL, + note_class_concept_id integer NOT NULL, + note_title varchar(250) NULL, + note_text varchar(MAX) NOT NULL, + encoding_concept_id integer NOT NULL, + language_concept_id integer NOT NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + note_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.note_nlp ( + note_nlp_id integer NOT NULL, + note_id integer NOT NULL, + section_concept_id integer NULL, + snippet varchar(250) NULL, + "offset" varchar(50) NULL, + lexical_variant varchar(250) NOT NULL, + note_nlp_concept_id integer NULL, + note_nlp_source_concept_id integer NULL, + nlp_system varchar(250) NULL, + nlp_date date NOT NULL, + nlp_datetime datetime NULL, + term_exists varchar(1) NULL, + term_temporal varchar(50) NULL, + term_modifiers varchar(2000) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.specimen ( + specimen_id integer NOT NULL, + person_id integer NOT NULL, + specimen_concept_id integer NOT NULL, + specimen_type_concept_id integer NOT NULL, + specimen_date date NOT NULL, + specimen_datetime datetime NULL, + quantity float NULL, + unit_concept_id integer NULL, + anatomic_site_concept_id integer NULL, + disease_status_concept_id integer NULL, + specimen_source_id varchar(50) NULL, + specimen_source_value varchar(50) NULL, + unit_source_value varchar(50) NULL, + anatomic_site_source_value varchar(50) NULL, + disease_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.fact_relationship ( + domain_concept_id_1 integer NOT NULL, + fact_id_1 integer NOT NULL, + domain_concept_id_2 integer NOT NULL, + fact_id_2 integer NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.location ( + location_id integer NOT NULL, + address_1 varchar(50) NULL, + address_2 varchar(50) NULL, + city varchar(50) NULL, + state varchar(2) NULL, + zip varchar(9) NULL, + county varchar(20) NULL, + location_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.care_site ( + care_site_id integer NOT NULL, + care_site_name varchar(255) NULL, + place_of_service_concept_id integer NULL, + location_id integer NULL, + care_site_source_value varchar(50) NULL, + place_of_service_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.provider ( + provider_id integer NOT NULL, + provider_name varchar(255) NULL, + npi varchar(20) NULL, + dea varchar(20) NULL, + specialty_concept_id integer NULL, + care_site_id integer NULL, + year_of_birth integer NULL, + gender_concept_id integer NULL, + provider_source_value varchar(50) NULL, + specialty_source_value varchar(50) NULL, + specialty_source_concept_id integer NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.payer_plan_period ( + payer_plan_period_id integer NOT NULL, + person_id integer NOT NULL, + payer_plan_period_start_date date NOT NULL, + payer_plan_period_end_date date NOT NULL, + payer_concept_id integer NULL, + payer_source_value varchar(50) NULL, + payer_source_concept_id integer NULL, + plan_concept_id integer NULL, + plan_source_value varchar(50) NULL, + plan_source_concept_id integer NULL, + sponsor_concept_id integer NULL, + sponsor_source_value varchar(50) NULL, + sponsor_source_concept_id integer NULL, + family_source_value varchar(50) NULL, + stop_reason_concept_id integer NULL, + stop_reason_source_value varchar(50) NULL, + stop_reason_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cost ( + cost_id integer NOT NULL, + cost_event_id integer NOT NULL, + cost_domain_id varchar(20) NOT NULL, + cost_type_concept_id integer NOT NULL, + currency_concept_id integer NULL, + total_charge float NULL, + total_cost float NULL, + total_paid float NULL, + paid_by_payer float NULL, + paid_by_patient float NULL, + paid_patient_copay float NULL, + paid_patient_coinsurance float NULL, + paid_patient_deductible float NULL, + paid_by_primary float NULL, + paid_ingredient_cost float NULL, + paid_dispensing_fee float NULL, + payer_plan_period_id integer NULL, + amount_allowed float NULL, + revenue_code_concept_id integer NULL, + revenue_code_source_value varchar(50) NULL, + drg_concept_id integer NULL, + drg_source_value varchar(3) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_era ( + drug_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_era_start_date date NOT NULL, + drug_era_end_date date NOT NULL, + drug_exposure_count integer NULL, + gap_days integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.dose_era ( + dose_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + unit_concept_id integer NOT NULL, + dose_value float NOT NULL, + dose_era_start_date date NOT NULL, + dose_era_end_date date NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_era ( + condition_era_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_era_start_date date NOT NULL, + condition_era_end_date date NOT NULL, + condition_occurrence_count integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.metadata ( + metadata_concept_id integer NOT NULL, + metadata_type_concept_id integer NOT NULL, + name varchar(250) NOT NULL, + value_as_string varchar(250) NULL, + value_as_concept_id integer NULL, + metadata_date date NULL, + metadata_datetime datetime NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cdm_source ( + cdm_source_name varchar(255) NOT NULL, + cdm_source_abbreviation varchar(25) NULL, + cdm_holder varchar(255) NULL, + source_description varchar(MAX) NULL, + source_documentation_reference varchar(255) NULL, + cdm_etl_reference varchar(255) NULL, + source_release_date date NULL, + cdm_release_date date NULL, + cdm_version varchar(10) NULL, + vocabulary_version varchar(20) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept ( + concept_id integer NOT NULL, + concept_name varchar(255) NOT NULL, + domain_id varchar(20) NOT NULL, + vocabulary_id varchar(20) NOT NULL, + concept_class_id varchar(20) NOT NULL, + standard_concept varchar(1) NULL, + concept_code varchar(50) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.vocabulary ( + vocabulary_id varchar(20) NOT NULL, + vocabulary_name varchar(255) NOT NULL, + vocabulary_reference varchar(255) NOT NULL, + vocabulary_version varchar(255) NULL, + vocabulary_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema."DOMAIN" ( + domain_id varchar(20) NOT NULL, + domain_name varchar(255) NOT NULL, + domain_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_class ( + concept_class_id varchar(20) NOT NULL, + concept_class_name varchar(255) NOT NULL, + concept_class_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_relationship ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.relationship ( + relationship_id varchar(20) NOT NULL, + relationship_name varchar(255) NOT NULL, + is_hierarchical varchar(1) NOT NULL, + defines_ancestry varchar(1) NOT NULL, + reverse_relationship_id varchar(20) NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_synonym ( + concept_id integer NOT NULL, + concept_synonym_name varchar(1000) NOT NULL, + language_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_ancestor ( + ancestor_concept_id integer NOT NULL, + descendant_concept_id integer NOT NULL, + min_levels_of_separation integer NOT NULL, + max_levels_of_separation integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.source_to_concept_map ( + source_code varchar(50) NOT NULL, + source_concept_id integer NOT NULL, + source_vocabulary_id varchar(20) NOT NULL, + source_code_description varchar(255) NULL, + target_concept_id integer NOT NULL, + target_vocabulary_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.drug_strength ( + drug_concept_id integer NOT NULL, + ingredient_concept_id integer NOT NULL, + amount_value float NULL, + amount_unit_concept_id integer NULL, + numerator_value float NULL, + numerator_unit_concept_id integer NULL, + denominator_value float NULL, + denominator_unit_concept_id integer NULL, + box_size integer NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.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 ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.attribute_definition ( + attribute_definition_id integer NOT NULL, + attribute_name varchar(255) NOT NULL, + attribute_description varchar(MAX) NULL, + attribute_type_concept_id integer NOT NULL, + attribute_syntax varchar(MAX) NULL ); \ No newline at end of file diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql new file mode 100644 index 0000000..4dea586 --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql @@ -0,0 +1,98 @@ +/*iris OMOP CDM Indices + There are no unique indices created because it is assumed that the primary key constraints have been run prior to + implementing indices. +*/ +/************************ +Standardized clinical data +************************/ +CREATE INDEX idx_person_id ON @cdmDatabaseSchema.person (person_id ASC); +CREATE INDEX idx_gender ON @cdmDatabaseSchema.person (gender_concept_id ASC); +CREATE INDEX idx_observation_period_id_1 ON @cdmDatabaseSchema.observation_period (person_id ASC); +CREATE INDEX idx_visit_person_id_1 ON @cdmDatabaseSchema.visit_occurrence (person_id ASC); +CREATE INDEX idx_visit_concept_id_1 ON @cdmDatabaseSchema.visit_occurrence (visit_concept_id ASC); +CREATE INDEX idx_visit_det_person_id_1 ON @cdmDatabaseSchema.visit_detail (person_id ASC); +CREATE INDEX idx_visit_det_concept_id_1 ON @cdmDatabaseSchema.visit_detail (visit_detail_concept_id ASC); +CREATE INDEX idx_visit_det_occ_id ON @cdmDatabaseSchema.visit_detail (visit_occurrence_id ASC); +CREATE INDEX idx_condition_person_id_1 ON @cdmDatabaseSchema.condition_occurrence (person_id ASC); +CREATE INDEX idx_condition_concept_id_1 ON @cdmDatabaseSchema.condition_occurrence (condition_concept_id ASC); +CREATE INDEX idx_condition_visit_id_1 ON @cdmDatabaseSchema.condition_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_drug_person_id_1 ON @cdmDatabaseSchema.drug_exposure (person_id ASC); +CREATE INDEX idx_drug_concept_id_1 ON @cdmDatabaseSchema.drug_exposure (drug_concept_id ASC); +CREATE INDEX idx_drug_visit_id_1 ON @cdmDatabaseSchema.drug_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_procedure_person_id_1 ON @cdmDatabaseSchema.procedure_occurrence (person_id ASC); +CREATE INDEX idx_procedure_concept_id_1 ON @cdmDatabaseSchema.procedure_occurrence (procedure_concept_id ASC); +CREATE INDEX idx_procedure_visit_id_1 ON @cdmDatabaseSchema.procedure_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_device_person_id_1 ON @cdmDatabaseSchema.device_exposure (person_id ASC); +CREATE INDEX idx_device_concept_id_1 ON @cdmDatabaseSchema.device_exposure (device_concept_id ASC); +CREATE INDEX idx_device_visit_id_1 ON @cdmDatabaseSchema.device_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_measurement_person_id_1 ON @cdmDatabaseSchema.measurement (person_id ASC); +CREATE INDEX idx_measurement_concept_id_1 ON @cdmDatabaseSchema.measurement (measurement_concept_id ASC); +CREATE INDEX idx_measurement_visit_id_1 ON @cdmDatabaseSchema.measurement (visit_occurrence_id ASC); +CREATE INDEX idx_observation_person_id_1 ON @cdmDatabaseSchema.observation (person_id ASC); +CREATE INDEX idx_observation_concept_id_1 ON @cdmDatabaseSchema.observation (observation_concept_id ASC); +CREATE INDEX idx_observation_visit_id_1 ON @cdmDatabaseSchema.observation (visit_occurrence_id ASC); +CREATE INDEX idx_death_person_id_1 ON @cdmDatabaseSchema.death (person_id ASC); +CREATE INDEX idx_note_person_id_1 ON @cdmDatabaseSchema.note (person_id ASC); +CREATE INDEX idx_note_concept_id_1 ON @cdmDatabaseSchema.note (note_type_concept_id ASC); +CREATE INDEX idx_note_visit_id_1 ON @cdmDatabaseSchema.note (visit_occurrence_id ASC); +CREATE INDEX idx_note_nlp_note_id_1 ON @cdmDatabaseSchema.note_nlp (note_id ASC); +CREATE INDEX idx_note_nlp_concept_id_1 ON @cdmDatabaseSchema.note_nlp (note_nlp_concept_id ASC); +CREATE INDEX idx_specimen_person_id_1 ON @cdmDatabaseSchema.specimen (person_id ASC); +CREATE INDEX idx_specimen_concept_id_1 ON @cdmDatabaseSchema.specimen (specimen_concept_id ASC); +CREATE INDEX idx_fact_relationship_id1 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_1 ASC); +CREATE INDEX idx_fact_relationship_id2 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_2 ASC); +CREATE INDEX idx_fact_relationship_id3 ON @cdmDatabaseSchema.fact_relationship (relationship_concept_id ASC); +/************************ +Standardized health system data +************************/ +CREATE INDEX idx_location_id_1 ON @cdmDatabaseSchema.location (location_id ASC); +CREATE INDEX idx_care_site_id_1 ON @cdmDatabaseSchema.care_site (care_site_id ASC); +CREATE INDEX idx_provider_id_1 ON @cdmDatabaseSchema.provider (provider_id ASC); +/************************ +Standardized health economics +************************/ +CREATE INDEX idx_period_person_id_1 ON @cdmDatabaseSchema.payer_plan_period (person_id ASC); +CREATE INDEX idx_cost_event_id ON @cdmDatabaseSchema.cost (cost_event_id ASC); +/************************ +Standardized derived elements +************************/ +CREATE INDEX idx_drug_era_person_id_1 ON @cdmDatabaseSchema.drug_era (person_id ASC); +CREATE INDEX idx_drug_era_concept_id_1 ON @cdmDatabaseSchema.drug_era (drug_concept_id ASC); +CREATE INDEX idx_dose_era_person_id_1 ON @cdmDatabaseSchema.dose_era (person_id ASC); +CREATE INDEX idx_dose_era_concept_id_1 ON @cdmDatabaseSchema.dose_era (drug_concept_id ASC); +CREATE INDEX idx_condition_era_person_id_1 ON @cdmDatabaseSchema.condition_era (person_id ASC); +CREATE INDEX idx_condition_era_concept_id_1 ON @cdmDatabaseSchema.condition_era (condition_concept_id ASC); +/************************** +Standardized meta-data +***************************/ +CREATE INDEX idx_metadata_concept_id_1 ON @cdmDatabaseSchema.metadata (metadata_concept_id ASC); +/************************** +Standardized vocabularies +***************************/ +CREATE INDEX idx_concept_concept_id ON @cdmDatabaseSchema.concept (concept_id ASC); +CREATE INDEX idx_concept_code ON @cdmDatabaseSchema.concept (concept_code ASC); +CREATE INDEX idx_concept_vocabulary_id ON @cdmDatabaseSchema.concept (vocabulary_id ASC); +CREATE INDEX idx_concept_domain_id ON @cdmDatabaseSchema.concept (domain_id ASC); +CREATE INDEX idx_concept_class_id ON @cdmDatabaseSchema.concept (concept_class_id ASC); +CREATE INDEX idx_vocabulary_vocabulary_id ON @cdmDatabaseSchema.vocabulary (vocabulary_id ASC); +CREATE INDEX idx_domain_domain_id ON @cdmDatabaseSchema."DOMAIN" (domain_id ASC); +CREATE INDEX idx_concept_class_class_id ON @cdmDatabaseSchema.concept_class (concept_class_id ASC); +CREATE INDEX idx_concept_relationship_id_1 ON @cdmDatabaseSchema.concept_relationship (concept_id_1 ASC); +CREATE INDEX idx_concept_relationship_id_2 ON @cdmDatabaseSchema.concept_relationship (concept_id_2 ASC); +CREATE INDEX idx_concept_relationship_id_3 ON @cdmDatabaseSchema.concept_relationship (relationship_id ASC); +CREATE INDEX idx_relationship_rel_id ON @cdmDatabaseSchema.relationship (relationship_id ASC); +CREATE INDEX idx_concept_synonym_id ON @cdmDatabaseSchema.concept_synonym (concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_1 ON @cdmDatabaseSchema.concept_ancestor (ancestor_concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_2 ON @cdmDatabaseSchema.concept_ancestor (descendant_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_3 ON @cdmDatabaseSchema.source_to_concept_map (target_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_1 ON @cdmDatabaseSchema.source_to_concept_map (source_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_2 ON @cdmDatabaseSchema.source_to_concept_map (target_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_c ON @cdmDatabaseSchema.source_to_concept_map (source_code ASC); +CREATE INDEX idx_drug_strength_id_1 ON @cdmDatabaseSchema.drug_strength (drug_concept_id ASC); +CREATE INDEX idx_drug_strength_id_2 ON @cdmDatabaseSchema.drug_strength (ingredient_concept_id ASC); +--Additional v6.0 indices +--CREATE CLUSTERED INDEX idx_survey_person_id_1 ON @cdmDatabaseSchema.survey_conduct (person_id ASC); +--CREATE CLUSTERED INDEX idx_episode_person_id_1 ON @cdmDatabaseSchema.episode (person_id ASC); +--CREATE INDEX idx_episode_concept_id_1 ON @cdmDatabaseSchema.episode (episode_concept_id ASC); +--CREATE CLUSTERED INDEX idx_episode_event_id_1 ON @cdmDatabaseSchema.episode_event (episode_id ASC); +--CREATE INDEX idx_ee_field_concept_id_1 ON @cdmDatabaseSchema.episode_event (event_field_concept_id ASC); diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql new file mode 100644 index 0000000..cfd1e92 --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql @@ -0,0 +1,27 @@ +--iris CDM Primary Key Constraints for OMOP Common Data Model 5.3 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT xpk_person PRIMARY KEY (person_id); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY (observation_period_id); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY (visit_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY (visit_detail_id); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY (condition_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY (drug_exposure_id); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY (procedure_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY (device_exposure_id); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY (measurement_id); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT xpk_observation PRIMARY KEY (observation_id); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT xpk_note PRIMARY KEY (note_id); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY (note_nlp_id); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY (specimen_id); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT xpk_location PRIMARY KEY (location_id); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY (care_site_id); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT xpk_provider PRIMARY KEY (provider_id); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY (payer_plan_period_id); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT xpk_cost PRIMARY KEY (cost_id); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY (drug_era_id); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY (dose_era_id); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY (condition_era_id); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); From 42f645f909561a55eb259ec158d81051fb0cf56d Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 1 Jul 2024 15:09:38 +0200 Subject: [PATCH 04/12] default DDL for IRIS --- .../5.4/iris/OMOPCDM_iris_5.4_constraints.sql | 177 ++++++ .../iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql | 511 ++++++++++++++++++ .../5.4/iris/OMOPCDM_iris_5.4_indices.sql | 98 ++++ .../iris/OMOPCDM_iris_5.4_primary_keys.sql | 29 + 4 files changed, 815 insertions(+) create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql create mode 100644 ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql new file mode 100644 index 0000000..d4278a8 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql @@ -0,0 +1,177 @@ +--iris CDM Foreign Key Constraints for OMOP Common Data Model 5.4 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_concept_id FOREIGN KEY (race_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_concept_id FOREIGN KEY (ethnicity_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_source_concept_id FOREIGN KEY (race_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_source_concept_id FOREIGN KEY (ethnicity_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_period_type_concept_id FOREIGN KEY (period_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_concept_id FOREIGN KEY (visit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_type_concept_id FOREIGN KEY (visit_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_source_concept_id FOREIGN KEY (visit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_concept_id FOREIGN KEY (visit_detail_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_type_concept_id FOREIGN KEY (visit_detail_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_source_concept_id FOREIGN KEY (visit_detail_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_admitted_from_concept_id FOREIGN KEY (admitted_from_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_discharged_to_concept_id FOREIGN KEY (discharged_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_parent_visit_detail_id FOREIGN KEY (parent_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_type_concept_id FOREIGN KEY (condition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_status_concept_id FOREIGN KEY (condition_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_source_concept_id FOREIGN KEY (condition_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_type_concept_id FOREIGN KEY (drug_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_route_concept_id FOREIGN KEY (route_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_source_concept_id FOREIGN KEY (drug_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_concept_id FOREIGN KEY (procedure_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_type_concept_id FOREIGN KEY (procedure_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_modifier_concept_id FOREIGN KEY (modifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_source_concept_id FOREIGN KEY (procedure_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_concept_id FOREIGN KEY (device_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_type_concept_id FOREIGN KEY (device_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_source_concept_id FOREIGN KEY (device_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_concept_id FOREIGN KEY (measurement_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_type_concept_id FOREIGN KEY (measurement_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_operator_concept_id FOREIGN KEY (operator_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_source_concept_id FOREIGN KEY (unit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_meas_event_field_concept_id FOREIGN KEY (meas_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_type_concept_id FOREIGN KEY (observation_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_qualifier_concept_id FOREIGN KEY (qualifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_obs_event_field_concept_id FOREIGN KEY (obs_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_concept_id FOREIGN KEY (cause_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_source_concept_id FOREIGN KEY (cause_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_encoding_concept_id FOREIGN KEY (encoding_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_event_field_concept_id FOREIGN KEY (note_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept_id FOREIGN KEY (section_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_concept_id FOREIGN KEY (note_nlp_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_source_concept_id FOREIGN KEY (note_nlp_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_concept_id FOREIGN KEY (specimen_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_type_concept_id FOREIGN KEY (specimen_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_anatomic_site_concept_id FOREIGN KEY (anatomic_site_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_disease_status_concept_id FOREIGN KEY (disease_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_1 FOREIGN KEY (domain_concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_2 FOREIGN KEY (domain_concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT fpk_location_country_concept_id FOREIGN KEY (country_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_place_of_service_concept_id FOREIGN KEY (place_of_service_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_concept_id FOREIGN KEY (specialty_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_source_concept_id FOREIGN KEY (specialty_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_concept_id FOREIGN KEY (payer_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_source_concept_id FOREIGN KEY (payer_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_concept_id FOREIGN KEY (plan_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_source_concept_id FOREIGN KEY (plan_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_concept_id FOREIGN KEY (sponsor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_source_concept_id FOREIGN KEY (sponsor_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_concept_id FOREIGN KEY (stop_reason_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_source_concept_id FOREIGN KEY (stop_reason_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_domain_id FOREIGN KEY (cost_domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_type_concept_id FOREIGN KEY (cost_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_currency_concept_id FOREIGN KEY (currency_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_revenue_code_concept_id FOREIGN KEY (revenue_code_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_drg_concept_id FOREIGN KEY (drg_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_concept_id FOREIGN KEY (episode_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_object_concept_id FOREIGN KEY (episode_object_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_type_concept_id FOREIGN KEY (episode_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT fpk_episode_episode_source_concept_id FOREIGN KEY (episode_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.episode_event ADD CONSTRAINT fpk_episode_event_episode_id FOREIGN KEY (episode_id) REFERENCES @cdmDatabaseSchema.EPISODE (EPISODE_ID); +ALTER TABLE @cdmDatabaseSchema.episode_event ADD CONSTRAINT fpk_episode_event_episode_event_field_concept_id FOREIGN KEY (episode_event_field_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cdm_source ADD CONSTRAINT fpk_cdm_source_cdm_version_concept_id FOREIGN KEY (cdm_version_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_domain_id FOREIGN KEY (domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_vocabulary_id FOREIGN KEY (vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_concept_class_id FOREIGN KEY (concept_class_id) REFERENCES @cdmDatabaseSchema.CONCEPT_CLASS (CONCEPT_CLASS_ID); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT fpk_vocabulary_vocabulary_concept_id FOREIGN KEY (vocabulary_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT fpk_domain_domain_concept_id FOREIGN KEY (domain_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT fpk_concept_class_concept_class_concept_id FOREIGN KEY (concept_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_1 FOREIGN KEY (concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_2 FOREIGN KEY (concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_relationship_id FOREIGN KEY (relationship_id) REFERENCES @cdmDatabaseSchema.RELATIONSHIP (RELATIONSHIP_ID); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT fpk_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept_id FOREIGN KEY (concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_ancestor_concept_id FOREIGN KEY (ancestor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_descendant_concept_id FOREIGN KEY (descendant_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_source_concept_id FOREIGN KEY (source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_concept_id FOREIGN KEY (target_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_vocabulary_id FOREIGN KEY (target_vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_ingredient_concept_id FOREIGN KEY (ingredient_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_amount_unit_concept_id FOREIGN KEY (amount_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_numerator_unit_concept_id FOREIGN KEY (numerator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_denominator_unit_concept_id FOREIGN KEY (denominator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql new file mode 100644 index 0000000..7782926 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql @@ -0,0 +1,511 @@ +--iris CDM DDL Specification for OMOP Common Data Model 5.4 +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.person ( + person_id integer NOT NULL, + gender_concept_id integer NOT NULL, + year_of_birth integer NOT NULL, + month_of_birth integer NULL, + day_of_birth integer NULL, + birth_datetime datetime NULL, + race_concept_id integer NOT NULL, + ethnicity_concept_id integer NOT NULL, + location_id integer NULL, + provider_id integer NULL, + care_site_id integer NULL, + person_source_value varchar(50) NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL, + race_source_value varchar(50) NULL, + race_source_concept_id integer NULL, + ethnicity_source_value varchar(50) NULL, + ethnicity_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation_period ( + observation_period_id integer NOT NULL, + person_id integer NOT NULL, + observation_period_start_date date NOT NULL, + observation_period_end_date date NOT NULL, + period_type_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_occurrence ( + visit_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + visit_concept_id integer NOT NULL, + visit_start_date date NOT NULL, + visit_start_datetime datetime NULL, + visit_end_date date NOT NULL, + visit_end_datetime datetime NULL, + visit_type_concept_id Integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_source_value varchar(50) NULL, + visit_source_concept_id integer NULL, + admitted_from_concept_id integer NULL, + admitted_from_source_value varchar(50) NULL, + discharged_to_concept_id integer NULL, + discharged_to_source_value varchar(50) NULL, + preceding_visit_occurrence_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_detail ( + visit_detail_id integer NOT NULL, + person_id integer NOT NULL, + visit_detail_concept_id integer NOT NULL, + visit_detail_start_date date NOT NULL, + visit_detail_start_datetime datetime NULL, + visit_detail_end_date date NOT NULL, + visit_detail_end_datetime datetime NULL, + visit_detail_type_concept_id integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_detail_source_value varchar(50) NULL, + visit_detail_source_concept_id Integer NULL, + admitted_from_concept_id Integer NULL, + admitted_from_source_value varchar(50) NULL, + discharged_to_source_value varchar(50) NULL, + discharged_to_concept_id integer NULL, + preceding_visit_detail_id integer NULL, + parent_visit_detail_id integer NULL, + visit_occurrence_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_occurrence ( + condition_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_start_date date NOT NULL, + condition_start_datetime datetime NULL, + condition_end_date date NULL, + condition_end_datetime datetime NULL, + condition_type_concept_id integer NOT NULL, + condition_status_concept_id integer NULL, + stop_reason varchar(20) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + condition_source_value varchar(50) NULL, + condition_source_concept_id integer NULL, + condition_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_exposure ( + drug_exposure_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_exposure_start_date date NOT NULL, + drug_exposure_start_datetime datetime NULL, + drug_exposure_end_date date NOT NULL, + drug_exposure_end_datetime datetime NULL, + verbatim_end_date date NULL, + drug_type_concept_id integer NOT NULL, + stop_reason varchar(20) NULL, + refills integer NULL, + quantity float NULL, + days_supply integer NULL, + sig varchar(MAX) NULL, + route_concept_id integer NULL, + lot_number varchar(50) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + drug_source_value varchar(50) NULL, + drug_source_concept_id integer NULL, + route_source_value varchar(50) NULL, + dose_unit_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.procedure_occurrence ( + procedure_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + procedure_concept_id integer NOT NULL, + procedure_date date NOT NULL, + procedure_datetime datetime NULL, + procedure_end_date date NULL, + procedure_end_datetime datetime NULL, + procedure_type_concept_id integer NOT NULL, + modifier_concept_id integer NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + procedure_source_value varchar(50) NULL, + procedure_source_concept_id integer NULL, + modifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.device_exposure ( + device_exposure_id integer NOT NULL, + person_id integer NOT NULL, + device_concept_id integer NOT NULL, + device_exposure_start_date date NOT NULL, + device_exposure_start_datetime datetime NULL, + device_exposure_end_date date NULL, + device_exposure_end_datetime datetime NULL, + device_type_concept_id integer NOT NULL, + unique_device_id varchar(255) NULL, + production_id varchar(255) NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + device_source_value varchar(50) NULL, + device_source_concept_id integer NULL, + unit_concept_id integer NULL, + unit_source_value varchar(50) NULL, + unit_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.measurement ( + measurement_id integer NOT NULL, + person_id integer NOT NULL, + measurement_concept_id integer NOT NULL, + measurement_date date NOT NULL, + measurement_datetime datetime NULL, + measurement_time varchar(10) NULL, + measurement_type_concept_id integer NOT NULL, + operator_concept_id integer NULL, + value_as_number float NULL, + value_as_concept_id integer NULL, + unit_concept_id integer NULL, + range_low float NULL, + range_high float NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + measurement_source_value varchar(50) NULL, + measurement_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + unit_source_concept_id integer NULL, + value_source_value varchar(50) NULL, + measurement_event_id integer NULL, + meas_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation ( + observation_id integer NOT NULL, + person_id integer NOT NULL, + observation_concept_id integer NOT NULL, + observation_date date NOT NULL, + observation_datetime datetime NULL, + observation_type_concept_id integer NOT NULL, + value_as_number float NULL, + value_as_string varchar(60) NULL, + value_as_concept_id Integer NULL, + qualifier_concept_id integer NULL, + unit_concept_id integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + observation_source_value varchar(50) NULL, + observation_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + qualifier_source_value varchar(50) NULL, + value_source_value varchar(50) NULL, + observation_event_id integer NULL, + obs_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.death ( + person_id integer NOT NULL, + death_date date NOT NULL, + death_datetime datetime NULL, + death_type_concept_id integer 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 @cdmDatabaseSchema.note ( + note_id integer NOT NULL, + person_id integer NOT NULL, + note_date date NOT NULL, + note_datetime datetime NULL, + note_type_concept_id integer NOT NULL, + note_class_concept_id integer NOT NULL, + note_title varchar(250) NULL, + note_text varchar(MAX) NOT NULL, + encoding_concept_id integer NOT NULL, + language_concept_id integer NOT NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + note_source_value varchar(50) NULL, + note_event_id integer NULL, + note_event_field_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.note_nlp ( + note_nlp_id integer NOT NULL, + note_id integer NOT NULL, + section_concept_id integer NULL, + snippet varchar(250) NULL, + "offset" varchar(50) NULL, + lexical_variant varchar(250) NOT NULL, + note_nlp_concept_id integer NULL, + note_nlp_source_concept_id integer NULL, + nlp_system varchar(250) NULL, + nlp_date date NOT NULL, + nlp_datetime datetime NULL, + term_exists varchar(1) NULL, + term_temporal varchar(50) NULL, + term_modifiers varchar(2000) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.specimen ( + specimen_id integer NOT NULL, + person_id integer NOT NULL, + specimen_concept_id integer NOT NULL, + specimen_type_concept_id integer NOT NULL, + specimen_date date NOT NULL, + specimen_datetime datetime NULL, + quantity float NULL, + unit_concept_id integer NULL, + anatomic_site_concept_id integer NULL, + disease_status_concept_id integer NULL, + specimen_source_id varchar(50) NULL, + specimen_source_value varchar(50) NULL, + unit_source_value varchar(50) NULL, + anatomic_site_source_value varchar(50) NULL, + disease_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.fact_relationship ( + domain_concept_id_1 integer NOT NULL, + fact_id_1 integer NOT NULL, + domain_concept_id_2 integer NOT NULL, + fact_id_2 integer NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.location ( + location_id integer NOT NULL, + address_1 varchar(50) NULL, + address_2 varchar(50) NULL, + city varchar(50) NULL, + state varchar(2) NULL, + zip varchar(9) NULL, + county varchar(20) NULL, + location_source_value varchar(50) NULL, + country_concept_id integer NULL, + country_source_value varchar(80) NULL, + latitude float NULL, + longitude float NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.care_site ( + care_site_id integer NOT NULL, + care_site_name varchar(255) NULL, + place_of_service_concept_id integer NULL, + location_id integer NULL, + care_site_source_value varchar(50) NULL, + place_of_service_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.provider ( + provider_id integer NOT NULL, + provider_name varchar(255) NULL, + npi varchar(20) NULL, + dea varchar(20) NULL, + specialty_concept_id integer NULL, + care_site_id integer NULL, + year_of_birth integer NULL, + gender_concept_id integer NULL, + provider_source_value varchar(50) NULL, + specialty_source_value varchar(50) NULL, + specialty_source_concept_id integer NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.payer_plan_period ( + payer_plan_period_id integer NOT NULL, + person_id integer NOT NULL, + payer_plan_period_start_date date NOT NULL, + payer_plan_period_end_date date NOT NULL, + payer_concept_id integer NULL, + payer_source_value varchar(50) NULL, + payer_source_concept_id integer NULL, + plan_concept_id integer NULL, + plan_source_value varchar(50) NULL, + plan_source_concept_id integer NULL, + sponsor_concept_id integer NULL, + sponsor_source_value varchar(50) NULL, + sponsor_source_concept_id integer NULL, + family_source_value varchar(50) NULL, + stop_reason_concept_id integer NULL, + stop_reason_source_value varchar(50) NULL, + stop_reason_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cost ( + cost_id integer NOT NULL, + cost_event_id integer NOT NULL, + cost_domain_id varchar(20) NOT NULL, + cost_type_concept_id integer NOT NULL, + currency_concept_id integer NULL, + total_charge float NULL, + total_cost float NULL, + total_paid float NULL, + paid_by_payer float NULL, + paid_by_patient float NULL, + paid_patient_copay float NULL, + paid_patient_coinsurance float NULL, + paid_patient_deductible float NULL, + paid_by_primary float NULL, + paid_ingredient_cost float NULL, + paid_dispensing_fee float NULL, + payer_plan_period_id integer NULL, + amount_allowed float NULL, + revenue_code_concept_id integer NULL, + revenue_code_source_value varchar(50) NULL, + drg_concept_id integer NULL, + drg_source_value varchar(3) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_era ( + drug_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_era_start_date date NOT NULL, + drug_era_end_date date NOT NULL, + drug_exposure_count integer NULL, + gap_days integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.dose_era ( + dose_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + unit_concept_id integer NOT NULL, + dose_value float NOT NULL, + dose_era_start_date date NOT NULL, + dose_era_end_date date NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_era ( + condition_era_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_era_start_date date NOT NULL, + condition_era_end_date date NOT NULL, + condition_occurrence_count integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.episode ( + episode_id integer NOT NULL, + person_id integer NOT NULL, + episode_concept_id integer NOT NULL, + episode_start_date date NOT NULL, + episode_start_datetime datetime NULL, + episode_end_date date NULL, + episode_end_datetime datetime NULL, + episode_parent_id integer NULL, + episode_number integer NULL, + episode_object_concept_id integer NOT NULL, + episode_type_concept_id integer NOT NULL, + episode_source_value varchar(50) NULL, + episode_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.episode_event ( + episode_id integer NOT NULL, + event_id integer NOT NULL, + episode_event_field_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.metadata ( + metadata_id integer NOT NULL, + metadata_concept_id integer NOT NULL, + metadata_type_concept_id integer NOT NULL, + name varchar(250) NOT NULL, + value_as_string varchar(250) NULL, + value_as_concept_id integer NULL, + value_as_number float NULL, + metadata_date date NULL, + metadata_datetime datetime NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cdm_source ( + cdm_source_name varchar(255) NOT NULL, + cdm_source_abbreviation varchar(25) NOT NULL, + cdm_holder varchar(255) NOT NULL, + source_description varchar(MAX) NULL, + source_documentation_reference varchar(255) NULL, + cdm_etl_reference varchar(255) NULL, + source_release_date date NOT NULL, + cdm_release_date date NOT NULL, + cdm_version varchar(10) NULL, + cdm_version_concept_id integer NOT NULL, + vocabulary_version varchar(20) NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept ( + concept_id integer NOT NULL, + concept_name varchar(255) NOT NULL, + domain_id varchar(20) NOT NULL, + vocabulary_id varchar(20) NOT NULL, + concept_class_id varchar(20) NOT NULL, + standard_concept varchar(1) NULL, + concept_code varchar(50) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.vocabulary ( + vocabulary_id varchar(20) NOT NULL, + vocabulary_name varchar(255) NOT NULL, + vocabulary_reference varchar(255) NULL, + vocabulary_version varchar(255) NULL, + vocabulary_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema."DOMAIN" ( + domain_id varchar(20) NOT NULL, + domain_name varchar(255) NOT NULL, + domain_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_class ( + concept_class_id varchar(20) NOT NULL, + concept_class_name varchar(255) NOT NULL, + concept_class_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_relationship ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.relationship ( + relationship_id varchar(20) NOT NULL, + relationship_name varchar(255) NOT NULL, + is_hierarchical varchar(1) NOT NULL, + defines_ancestry varchar(1) NOT NULL, + reverse_relationship_id varchar(20) NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_synonym ( + concept_id integer NOT NULL, + concept_synonym_name varchar(1000) NOT NULL, + language_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_ancestor ( + ancestor_concept_id integer NOT NULL, + descendant_concept_id integer NOT NULL, + min_levels_of_separation integer NOT NULL, + max_levels_of_separation integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.source_to_concept_map ( + source_code varchar(50) NOT NULL, + source_concept_id integer NOT NULL, + source_vocabulary_id varchar(20) NOT NULL, + source_code_description varchar(255) NULL, + target_concept_id integer NOT NULL, + target_vocabulary_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.drug_strength ( + drug_concept_id integer NOT NULL, + ingredient_concept_id integer NOT NULL, + amount_value float NULL, + amount_unit_concept_id integer NULL, + numerator_value float NULL, + numerator_unit_concept_id integer NULL, + denominator_value float NULL, + denominator_unit_concept_id integer NULL, + box_size integer NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cohort ( + cohort_definition_id integer NOT NULL, + subject_id integer NOT NULL, + cohort_start_date date NOT NULL, + cohort_end_date date NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.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 ); \ No newline at end of file diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql new file mode 100644 index 0000000..4dea586 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql @@ -0,0 +1,98 @@ +/*iris OMOP CDM Indices + There are no unique indices created because it is assumed that the primary key constraints have been run prior to + implementing indices. +*/ +/************************ +Standardized clinical data +************************/ +CREATE INDEX idx_person_id ON @cdmDatabaseSchema.person (person_id ASC); +CREATE INDEX idx_gender ON @cdmDatabaseSchema.person (gender_concept_id ASC); +CREATE INDEX idx_observation_period_id_1 ON @cdmDatabaseSchema.observation_period (person_id ASC); +CREATE INDEX idx_visit_person_id_1 ON @cdmDatabaseSchema.visit_occurrence (person_id ASC); +CREATE INDEX idx_visit_concept_id_1 ON @cdmDatabaseSchema.visit_occurrence (visit_concept_id ASC); +CREATE INDEX idx_visit_det_person_id_1 ON @cdmDatabaseSchema.visit_detail (person_id ASC); +CREATE INDEX idx_visit_det_concept_id_1 ON @cdmDatabaseSchema.visit_detail (visit_detail_concept_id ASC); +CREATE INDEX idx_visit_det_occ_id ON @cdmDatabaseSchema.visit_detail (visit_occurrence_id ASC); +CREATE INDEX idx_condition_person_id_1 ON @cdmDatabaseSchema.condition_occurrence (person_id ASC); +CREATE INDEX idx_condition_concept_id_1 ON @cdmDatabaseSchema.condition_occurrence (condition_concept_id ASC); +CREATE INDEX idx_condition_visit_id_1 ON @cdmDatabaseSchema.condition_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_drug_person_id_1 ON @cdmDatabaseSchema.drug_exposure (person_id ASC); +CREATE INDEX idx_drug_concept_id_1 ON @cdmDatabaseSchema.drug_exposure (drug_concept_id ASC); +CREATE INDEX idx_drug_visit_id_1 ON @cdmDatabaseSchema.drug_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_procedure_person_id_1 ON @cdmDatabaseSchema.procedure_occurrence (person_id ASC); +CREATE INDEX idx_procedure_concept_id_1 ON @cdmDatabaseSchema.procedure_occurrence (procedure_concept_id ASC); +CREATE INDEX idx_procedure_visit_id_1 ON @cdmDatabaseSchema.procedure_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_device_person_id_1 ON @cdmDatabaseSchema.device_exposure (person_id ASC); +CREATE INDEX idx_device_concept_id_1 ON @cdmDatabaseSchema.device_exposure (device_concept_id ASC); +CREATE INDEX idx_device_visit_id_1 ON @cdmDatabaseSchema.device_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_measurement_person_id_1 ON @cdmDatabaseSchema.measurement (person_id ASC); +CREATE INDEX idx_measurement_concept_id_1 ON @cdmDatabaseSchema.measurement (measurement_concept_id ASC); +CREATE INDEX idx_measurement_visit_id_1 ON @cdmDatabaseSchema.measurement (visit_occurrence_id ASC); +CREATE INDEX idx_observation_person_id_1 ON @cdmDatabaseSchema.observation (person_id ASC); +CREATE INDEX idx_observation_concept_id_1 ON @cdmDatabaseSchema.observation (observation_concept_id ASC); +CREATE INDEX idx_observation_visit_id_1 ON @cdmDatabaseSchema.observation (visit_occurrence_id ASC); +CREATE INDEX idx_death_person_id_1 ON @cdmDatabaseSchema.death (person_id ASC); +CREATE INDEX idx_note_person_id_1 ON @cdmDatabaseSchema.note (person_id ASC); +CREATE INDEX idx_note_concept_id_1 ON @cdmDatabaseSchema.note (note_type_concept_id ASC); +CREATE INDEX idx_note_visit_id_1 ON @cdmDatabaseSchema.note (visit_occurrence_id ASC); +CREATE INDEX idx_note_nlp_note_id_1 ON @cdmDatabaseSchema.note_nlp (note_id ASC); +CREATE INDEX idx_note_nlp_concept_id_1 ON @cdmDatabaseSchema.note_nlp (note_nlp_concept_id ASC); +CREATE INDEX idx_specimen_person_id_1 ON @cdmDatabaseSchema.specimen (person_id ASC); +CREATE INDEX idx_specimen_concept_id_1 ON @cdmDatabaseSchema.specimen (specimen_concept_id ASC); +CREATE INDEX idx_fact_relationship_id1 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_1 ASC); +CREATE INDEX idx_fact_relationship_id2 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_2 ASC); +CREATE INDEX idx_fact_relationship_id3 ON @cdmDatabaseSchema.fact_relationship (relationship_concept_id ASC); +/************************ +Standardized health system data +************************/ +CREATE INDEX idx_location_id_1 ON @cdmDatabaseSchema.location (location_id ASC); +CREATE INDEX idx_care_site_id_1 ON @cdmDatabaseSchema.care_site (care_site_id ASC); +CREATE INDEX idx_provider_id_1 ON @cdmDatabaseSchema.provider (provider_id ASC); +/************************ +Standardized health economics +************************/ +CREATE INDEX idx_period_person_id_1 ON @cdmDatabaseSchema.payer_plan_period (person_id ASC); +CREATE INDEX idx_cost_event_id ON @cdmDatabaseSchema.cost (cost_event_id ASC); +/************************ +Standardized derived elements +************************/ +CREATE INDEX idx_drug_era_person_id_1 ON @cdmDatabaseSchema.drug_era (person_id ASC); +CREATE INDEX idx_drug_era_concept_id_1 ON @cdmDatabaseSchema.drug_era (drug_concept_id ASC); +CREATE INDEX idx_dose_era_person_id_1 ON @cdmDatabaseSchema.dose_era (person_id ASC); +CREATE INDEX idx_dose_era_concept_id_1 ON @cdmDatabaseSchema.dose_era (drug_concept_id ASC); +CREATE INDEX idx_condition_era_person_id_1 ON @cdmDatabaseSchema.condition_era (person_id ASC); +CREATE INDEX idx_condition_era_concept_id_1 ON @cdmDatabaseSchema.condition_era (condition_concept_id ASC); +/************************** +Standardized meta-data +***************************/ +CREATE INDEX idx_metadata_concept_id_1 ON @cdmDatabaseSchema.metadata (metadata_concept_id ASC); +/************************** +Standardized vocabularies +***************************/ +CREATE INDEX idx_concept_concept_id ON @cdmDatabaseSchema.concept (concept_id ASC); +CREATE INDEX idx_concept_code ON @cdmDatabaseSchema.concept (concept_code ASC); +CREATE INDEX idx_concept_vocabulary_id ON @cdmDatabaseSchema.concept (vocabulary_id ASC); +CREATE INDEX idx_concept_domain_id ON @cdmDatabaseSchema.concept (domain_id ASC); +CREATE INDEX idx_concept_class_id ON @cdmDatabaseSchema.concept (concept_class_id ASC); +CREATE INDEX idx_vocabulary_vocabulary_id ON @cdmDatabaseSchema.vocabulary (vocabulary_id ASC); +CREATE INDEX idx_domain_domain_id ON @cdmDatabaseSchema."DOMAIN" (domain_id ASC); +CREATE INDEX idx_concept_class_class_id ON @cdmDatabaseSchema.concept_class (concept_class_id ASC); +CREATE INDEX idx_concept_relationship_id_1 ON @cdmDatabaseSchema.concept_relationship (concept_id_1 ASC); +CREATE INDEX idx_concept_relationship_id_2 ON @cdmDatabaseSchema.concept_relationship (concept_id_2 ASC); +CREATE INDEX idx_concept_relationship_id_3 ON @cdmDatabaseSchema.concept_relationship (relationship_id ASC); +CREATE INDEX idx_relationship_rel_id ON @cdmDatabaseSchema.relationship (relationship_id ASC); +CREATE INDEX idx_concept_synonym_id ON @cdmDatabaseSchema.concept_synonym (concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_1 ON @cdmDatabaseSchema.concept_ancestor (ancestor_concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_2 ON @cdmDatabaseSchema.concept_ancestor (descendant_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_3 ON @cdmDatabaseSchema.source_to_concept_map (target_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_1 ON @cdmDatabaseSchema.source_to_concept_map (source_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_2 ON @cdmDatabaseSchema.source_to_concept_map (target_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_c ON @cdmDatabaseSchema.source_to_concept_map (source_code ASC); +CREATE INDEX idx_drug_strength_id_1 ON @cdmDatabaseSchema.drug_strength (drug_concept_id ASC); +CREATE INDEX idx_drug_strength_id_2 ON @cdmDatabaseSchema.drug_strength (ingredient_concept_id ASC); +--Additional v6.0 indices +--CREATE CLUSTERED INDEX idx_survey_person_id_1 ON @cdmDatabaseSchema.survey_conduct (person_id ASC); +--CREATE CLUSTERED INDEX idx_episode_person_id_1 ON @cdmDatabaseSchema.episode (person_id ASC); +--CREATE INDEX idx_episode_concept_id_1 ON @cdmDatabaseSchema.episode (episode_concept_id ASC); +--CREATE CLUSTERED INDEX idx_episode_event_id_1 ON @cdmDatabaseSchema.episode_event (episode_id ASC); +--CREATE INDEX idx_ee_field_concept_id_1 ON @cdmDatabaseSchema.episode_event (event_field_concept_id ASC); diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql new file mode 100644 index 0000000..bed7975 --- /dev/null +++ b/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql @@ -0,0 +1,29 @@ +--iris CDM Primary Key Constraints for OMOP Common Data Model 5.4 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT xpk_person PRIMARY KEY (person_id); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY (observation_period_id); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY (visit_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY (visit_detail_id); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY (condition_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY (drug_exposure_id); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY (procedure_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY (device_exposure_id); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY (measurement_id); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT xpk_observation PRIMARY KEY (observation_id); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT xpk_note PRIMARY KEY (note_id); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY (note_nlp_id); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY (specimen_id); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT xpk_location PRIMARY KEY (location_id); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY (care_site_id); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT xpk_provider PRIMARY KEY (provider_id); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY (payer_plan_period_id); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT xpk_cost PRIMARY KEY (cost_id); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY (drug_era_id); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY (dose_era_id); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY (condition_era_id); +ALTER TABLE @cdmDatabaseSchema.episode ADD CONSTRAINT xpk_episode PRIMARY KEY (episode_id); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT xpk_metadata PRIMARY KEY (metadata_id); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); From 61dc576fcb7610c9697e16748794556cb868f72e Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 8 Jul 2024 08:35:55 +0200 Subject: [PATCH 05/12] fix directory structure --- ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_constraints.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_ddl.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_indices.sql | 0 ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_primary_keys.sql | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_constraints.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_ddl.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_indices.sql (100%) rename ddl/5.4/iris/{5.4/iris => }/OMOPCDM_iris_5.4_primary_keys.sql (100%) diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_constraints.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_ddl.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_indices.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql diff --git a/ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql b/ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql similarity index 100% rename from ddl/5.4/iris/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql rename to ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql From 677d0c9bdea56a7e1d73acc32d8feb7ce9b9af70 Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Mon, 8 Jul 2024 08:36:11 +0200 Subject: [PATCH 06/12] add 5.3 DDL --- ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql | 158 ++++++ ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql | 471 ++++++++++++++++++ ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql | 98 ++++ .../iris/OMOPCDM_iris_5.3_primary_keys.sql | 27 + 4 files changed, 754 insertions(+) create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql create mode 100644 ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql new file mode 100644 index 0000000..b5be6cd --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql @@ -0,0 +1,158 @@ +--iris CDM Foreign Key Constraints for OMOP Common Data Model 5.3 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_concept_id FOREIGN KEY (race_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_concept_id FOREIGN KEY (ethnicity_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_race_source_concept_id FOREIGN KEY (race_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT fpk_person_ethnicity_source_concept_id FOREIGN KEY (ethnicity_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT fpk_observation_period_period_type_concept_id FOREIGN KEY (period_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_concept_id FOREIGN KEY (visit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_type_concept_id FOREIGN KEY (visit_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_visit_source_concept_id FOREIGN KEY (visit_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_admitting_source_concept_id FOREIGN KEY (admitting_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT fpk_visit_occurrence_preceding_visit_occurrence_id FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_concept_id FOREIGN KEY (visit_detail_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_type_concept_id FOREIGN KEY (visit_detail_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_source_concept_id FOREIGN KEY (visit_detail_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_admitting_source_concept_id FOREIGN KEY (admitting_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_discharge_to_concept_id FOREIGN KEY (discharge_to_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_preceding_visit_detail_id FOREIGN KEY (preceding_visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_detail_parent_id FOREIGN KEY (visit_detail_parent_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT fpk_visit_detail_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_type_concept_id FOREIGN KEY (condition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_status_concept_id FOREIGN KEY (condition_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT fpk_condition_occurrence_condition_source_concept_id FOREIGN KEY (condition_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_type_concept_id FOREIGN KEY (drug_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_route_concept_id FOREIGN KEY (route_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT fpk_drug_exposure_drug_source_concept_id FOREIGN KEY (drug_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_concept_id FOREIGN KEY (procedure_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_procedure_type_concept_id FOREIGN KEY (procedure_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT fpk_procedure_occurrence_modifier_concept_id FOREIGN KEY (modifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_concept_id FOREIGN KEY (device_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_type_concept_id FOREIGN KEY (device_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT fpk_device_exposure_device_source_concept_id FOREIGN KEY (device_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_concept_id FOREIGN KEY (measurement_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_type_concept_id FOREIGN KEY (measurement_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_operator_concept_id FOREIGN KEY (operator_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT fpk_measurement_measurement_source_concept_id FOREIGN KEY (measurement_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_concept_id FOREIGN KEY (observation_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_type_concept_id FOREIGN KEY (observation_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_qualifier_concept_id FOREIGN KEY (qualifier_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT fpk_observation_observation_source_concept_id FOREIGN KEY (observation_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_death_type_concept_id FOREIGN KEY (death_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_concept_id FOREIGN KEY (cause_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.death ADD CONSTRAINT fpk_death_cause_source_concept_id FOREIGN KEY (cause_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_type_concept_id FOREIGN KEY (note_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_note_class_concept_id FOREIGN KEY (note_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_encoding_concept_id FOREIGN KEY (encoding_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_provider_id FOREIGN KEY (provider_id) REFERENCES @cdmDatabaseSchema.PROVIDER (PROVIDER_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_occurrence_id FOREIGN KEY (visit_occurrence_id) REFERENCES @cdmDatabaseSchema.VISIT_OCCURRENCE (VISIT_OCCURRENCE_ID); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT fpk_note_visit_detail_id FOREIGN KEY (visit_detail_id) REFERENCES @cdmDatabaseSchema.VISIT_DETAIL (VISIT_DETAIL_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept_id FOREIGN KEY (section_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_concept_id FOREIGN KEY (note_nlp_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT fpk_note_nlp_note_nlp_source_concept_id FOREIGN KEY (note_nlp_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_concept_id FOREIGN KEY (specimen_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_specimen_type_concept_id FOREIGN KEY (specimen_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_anatomic_site_concept_id FOREIGN KEY (anatomic_site_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT fpk_specimen_disease_status_concept_id FOREIGN KEY (disease_status_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_1 FOREIGN KEY (domain_concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_domain_concept_id_2 FOREIGN KEY (domain_concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.fact_relationship ADD CONSTRAINT fpk_fact_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_place_of_service_concept_id FOREIGN KEY (place_of_service_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT fpk_care_site_location_id FOREIGN KEY (location_id) REFERENCES @cdmDatabaseSchema.LOCATION (LOCATION_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_concept_id FOREIGN KEY (specialty_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_care_site_id FOREIGN KEY (care_site_id) REFERENCES @cdmDatabaseSchema.CARE_SITE (CARE_SITE_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_concept_id FOREIGN KEY (gender_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_specialty_source_concept_id FOREIGN KEY (specialty_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT fpk_provider_gender_source_concept_id FOREIGN KEY (gender_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_concept_id FOREIGN KEY (payer_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_payer_source_concept_id FOREIGN KEY (payer_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_concept_id FOREIGN KEY (plan_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_plan_source_concept_id FOREIGN KEY (plan_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_concept_id FOREIGN KEY (sponsor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_sponsor_source_concept_id FOREIGN KEY (sponsor_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_concept_id FOREIGN KEY (stop_reason_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT fpk_payer_plan_period_stop_reason_source_concept_id FOREIGN KEY (stop_reason_source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_domain_id FOREIGN KEY (cost_domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_cost_type_concept_id FOREIGN KEY (cost_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_currency_concept_id FOREIGN KEY (currency_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_revenue_code_concept_id FOREIGN KEY (revenue_code_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT fpk_cost_drg_concept_id FOREIGN KEY (drg_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT fpk_drug_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_person_id FOREIGN KEY (person_id) REFERENCES @cdmDatabaseSchema.PERSON (PERSON_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT fpk_dose_era_unit_concept_id FOREIGN KEY (unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT fpk_condition_era_condition_concept_id FOREIGN KEY (condition_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_concept_id FOREIGN KEY (metadata_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_metadata_type_concept_id FOREIGN KEY (metadata_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.metadata ADD CONSTRAINT fpk_metadata_value_as_concept_id FOREIGN KEY (value_as_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_domain_id FOREIGN KEY (domain_id) REFERENCES @cdmDatabaseSchema."DOMAIN" (DOMAIN_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_vocabulary_id FOREIGN KEY (vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT fpk_concept_concept_class_id FOREIGN KEY (concept_class_id) REFERENCES @cdmDatabaseSchema.CONCEPT_CLASS (CONCEPT_CLASS_ID); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT fpk_vocabulary_vocabulary_concept_id FOREIGN KEY (vocabulary_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT fpk_domain_domain_concept_id FOREIGN KEY (domain_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT fpk_concept_class_concept_class_concept_id FOREIGN KEY (concept_class_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_1 FOREIGN KEY (concept_id_1) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_concept_id_2 FOREIGN KEY (concept_id_2) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_relationship ADD CONSTRAINT fpk_concept_relationship_relationship_id FOREIGN KEY (relationship_id) REFERENCES @cdmDatabaseSchema.RELATIONSHIP (RELATIONSHIP_ID); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT fpk_relationship_relationship_concept_id FOREIGN KEY (relationship_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept_id FOREIGN KEY (concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_synonym ADD CONSTRAINT fpk_concept_synonym_language_concept_id FOREIGN KEY (language_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_ancestor_concept_id FOREIGN KEY (ancestor_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_descendant_concept_id FOREIGN KEY (descendant_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_source_concept_id FOREIGN KEY (source_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_concept_id FOREIGN KEY (target_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_target_vocabulary_id FOREIGN KEY (target_vocabulary_id) REFERENCES @cdmDatabaseSchema.VOCABULARY (VOCABULARY_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_drug_concept_id FOREIGN KEY (drug_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_ingredient_concept_id FOREIGN KEY (ingredient_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_amount_unit_concept_id FOREIGN KEY (amount_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_numerator_unit_concept_id FOREIGN KEY (numerator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.drug_strength ADD CONSTRAINT fpk_drug_strength_denominator_unit_concept_id FOREIGN KEY (denominator_unit_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_definition_type_concept_id FOREIGN KEY (definition_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.cohort_definition ADD CONSTRAINT fpk_cohort_definition_subject_concept_id FOREIGN KEY (subject_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); +ALTER TABLE @cdmDatabaseSchema.attribute_definition ADD CONSTRAINT fpk_attribute_definition_attribute_type_concept_id FOREIGN KEY (attribute_type_concept_id) REFERENCES @cdmDatabaseSchema.CONCEPT (CONCEPT_ID); diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql new file mode 100644 index 0000000..0a6bc5e --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql @@ -0,0 +1,471 @@ +--iris CDM DDL Specification for OMOP Common Data Model 5.3 +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.person ( + person_id integer NOT NULL, + gender_concept_id integer NOT NULL, + year_of_birth integer NOT NULL, + month_of_birth integer NULL, + day_of_birth integer NULL, + birth_datetime datetime NULL, + race_concept_id integer NOT NULL, + ethnicity_concept_id integer NOT NULL, + location_id integer NULL, + provider_id integer NULL, + care_site_id integer NULL, + person_source_value varchar(50) NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL, + race_source_value varchar(50) NULL, + race_source_concept_id integer NULL, + ethnicity_source_value varchar(50) NULL, + ethnicity_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation_period ( + observation_period_id integer NOT NULL, + person_id integer NOT NULL, + observation_period_start_date date NOT NULL, + observation_period_end_date date NOT NULL, + period_type_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_occurrence ( + visit_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + visit_concept_id integer NOT NULL, + visit_start_date date NOT NULL, + visit_start_datetime datetime NULL, + visit_end_date date NOT NULL, + visit_end_datetime datetime NULL, + visit_type_concept_id Integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_source_value varchar(50) NULL, + visit_source_concept_id integer NULL, + admitting_source_concept_id integer NULL, + admitting_source_value varchar(50) NULL, + discharge_to_concept_id integer NULL, + discharge_to_source_value varchar(50) NULL, + preceding_visit_occurrence_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.visit_detail ( + visit_detail_id integer NOT NULL, + person_id integer NOT NULL, + visit_detail_concept_id integer NOT NULL, + visit_detail_start_date date NOT NULL, + visit_detail_start_datetime datetime NULL, + visit_detail_end_date date NOT NULL, + visit_detail_end_datetime datetime NULL, + visit_detail_type_concept_id integer NOT NULL, + provider_id integer NULL, + care_site_id integer NULL, + visit_detail_source_value varchar(50) NULL, + visit_detail_source_concept_id Integer NULL, + admitting_source_value Varchar(50) NULL, + admitting_source_concept_id Integer NULL, + discharge_to_source_value Varchar(50) NULL, + discharge_to_concept_id integer NULL, + preceding_visit_detail_id integer NULL, + visit_detail_parent_id integer NULL, + visit_occurrence_id integer NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_occurrence ( + condition_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_start_date date NOT NULL, + condition_start_datetime datetime NULL, + condition_end_date date NULL, + condition_end_datetime datetime NULL, + condition_type_concept_id integer NOT NULL, + condition_status_concept_id integer NULL, + stop_reason varchar(20) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + condition_source_value varchar(50) NULL, + condition_source_concept_id integer NULL, + condition_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_exposure ( + drug_exposure_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_exposure_start_date date NOT NULL, + drug_exposure_start_datetime datetime NULL, + drug_exposure_end_date date NOT NULL, + drug_exposure_end_datetime datetime NULL, + verbatim_end_date date NULL, + drug_type_concept_id integer NOT NULL, + stop_reason varchar(20) NULL, + refills integer NULL, + quantity float NULL, + days_supply integer NULL, + sig varchar(MAX) NULL, + route_concept_id integer NULL, + lot_number varchar(50) NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + drug_source_value varchar(50) NULL, + drug_source_concept_id integer NULL, + route_source_value varchar(50) NULL, + dose_unit_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.procedure_occurrence ( + procedure_occurrence_id integer NOT NULL, + person_id integer NOT NULL, + procedure_concept_id integer NOT NULL, + procedure_date date NOT NULL, + procedure_datetime datetime NULL, + procedure_type_concept_id integer NOT NULL, + modifier_concept_id integer NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + procedure_source_value varchar(50) NULL, + procedure_source_concept_id integer NULL, + modifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.device_exposure ( + device_exposure_id integer NOT NULL, + person_id integer NOT NULL, + device_concept_id integer NOT NULL, + device_exposure_start_date date NOT NULL, + device_exposure_start_datetime datetime NULL, + device_exposure_end_date date NULL, + device_exposure_end_datetime datetime NULL, + device_type_concept_id integer NOT NULL, + unique_device_id varchar(50) NULL, + quantity integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + device_source_value varchar(50) NULL, + device_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.measurement ( + measurement_id integer NOT NULL, + person_id integer NOT NULL, + measurement_concept_id integer NOT NULL, + measurement_date date NOT NULL, + measurement_datetime datetime NULL, + measurement_time varchar(10) NULL, + measurement_type_concept_id integer NOT NULL, + operator_concept_id integer NULL, + value_as_number float NULL, + value_as_concept_id integer NULL, + unit_concept_id integer NULL, + range_low float NULL, + range_high float NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + measurement_source_value varchar(50) NULL, + measurement_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + value_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.observation ( + observation_id integer NOT NULL, + person_id integer NOT NULL, + observation_concept_id integer NOT NULL, + observation_date date NOT NULL, + observation_datetime datetime NULL, + observation_type_concept_id integer NOT NULL, + value_as_number float NULL, + value_as_string varchar(60) NULL, + value_as_concept_id Integer NULL, + qualifier_concept_id integer NULL, + unit_concept_id integer NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + observation_source_value varchar(50) NULL, + observation_source_concept_id integer NULL, + unit_source_value varchar(50) NULL, + qualifier_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.death ( + person_id integer NOT NULL, + death_date date NOT NULL, + death_datetime datetime NULL, + death_type_concept_id integer 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 @cdmDatabaseSchema.note ( + note_id integer NOT NULL, + person_id integer NOT NULL, + note_date date NOT NULL, + note_datetime datetime NULL, + note_type_concept_id integer NOT NULL, + note_class_concept_id integer NOT NULL, + note_title varchar(250) NULL, + note_text varchar(MAX) NOT NULL, + encoding_concept_id integer NOT NULL, + language_concept_id integer NOT NULL, + provider_id integer NULL, + visit_occurrence_id integer NULL, + visit_detail_id integer NULL, + note_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.note_nlp ( + note_nlp_id integer NOT NULL, + note_id integer NOT NULL, + section_concept_id integer NULL, + snippet varchar(250) NULL, + "offset" varchar(50) NULL, + lexical_variant varchar(250) NOT NULL, + note_nlp_concept_id integer NULL, + note_nlp_source_concept_id integer NULL, + nlp_system varchar(250) NULL, + nlp_date date NOT NULL, + nlp_datetime datetime NULL, + term_exists varchar(1) NULL, + term_temporal varchar(50) NULL, + term_modifiers varchar(2000) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.specimen ( + specimen_id integer NOT NULL, + person_id integer NOT NULL, + specimen_concept_id integer NOT NULL, + specimen_type_concept_id integer NOT NULL, + specimen_date date NOT NULL, + specimen_datetime datetime NULL, + quantity float NULL, + unit_concept_id integer NULL, + anatomic_site_concept_id integer NULL, + disease_status_concept_id integer NULL, + specimen_source_id varchar(50) NULL, + specimen_source_value varchar(50) NULL, + unit_source_value varchar(50) NULL, + anatomic_site_source_value varchar(50) NULL, + disease_status_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.fact_relationship ( + domain_concept_id_1 integer NOT NULL, + fact_id_1 integer NOT NULL, + domain_concept_id_2 integer NOT NULL, + fact_id_2 integer NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.location ( + location_id integer NOT NULL, + address_1 varchar(50) NULL, + address_2 varchar(50) NULL, + city varchar(50) NULL, + state varchar(2) NULL, + zip varchar(9) NULL, + county varchar(20) NULL, + location_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.care_site ( + care_site_id integer NOT NULL, + care_site_name varchar(255) NULL, + place_of_service_concept_id integer NULL, + location_id integer NULL, + care_site_source_value varchar(50) NULL, + place_of_service_source_value varchar(50) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.provider ( + provider_id integer NOT NULL, + provider_name varchar(255) NULL, + npi varchar(20) NULL, + dea varchar(20) NULL, + specialty_concept_id integer NULL, + care_site_id integer NULL, + year_of_birth integer NULL, + gender_concept_id integer NULL, + provider_source_value varchar(50) NULL, + specialty_source_value varchar(50) NULL, + specialty_source_concept_id integer NULL, + gender_source_value varchar(50) NULL, + gender_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.payer_plan_period ( + payer_plan_period_id integer NOT NULL, + person_id integer NOT NULL, + payer_plan_period_start_date date NOT NULL, + payer_plan_period_end_date date NOT NULL, + payer_concept_id integer NULL, + payer_source_value varchar(50) NULL, + payer_source_concept_id integer NULL, + plan_concept_id integer NULL, + plan_source_value varchar(50) NULL, + plan_source_concept_id integer NULL, + sponsor_concept_id integer NULL, + sponsor_source_value varchar(50) NULL, + sponsor_source_concept_id integer NULL, + family_source_value varchar(50) NULL, + stop_reason_concept_id integer NULL, + stop_reason_source_value varchar(50) NULL, + stop_reason_source_concept_id integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cost ( + cost_id integer NOT NULL, + cost_event_id integer NOT NULL, + cost_domain_id varchar(20) NOT NULL, + cost_type_concept_id integer NOT NULL, + currency_concept_id integer NULL, + total_charge float NULL, + total_cost float NULL, + total_paid float NULL, + paid_by_payer float NULL, + paid_by_patient float NULL, + paid_patient_copay float NULL, + paid_patient_coinsurance float NULL, + paid_patient_deductible float NULL, + paid_by_primary float NULL, + paid_ingredient_cost float NULL, + paid_dispensing_fee float NULL, + payer_plan_period_id integer NULL, + amount_allowed float NULL, + revenue_code_concept_id integer NULL, + revenue_code_source_value varchar(50) NULL, + drg_concept_id integer NULL, + drg_source_value varchar(3) NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.drug_era ( + drug_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + drug_era_start_date date NOT NULL, + drug_era_end_date date NOT NULL, + drug_exposure_count integer NULL, + gap_days integer NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.dose_era ( + dose_era_id integer NOT NULL, + person_id integer NOT NULL, + drug_concept_id integer NOT NULL, + unit_concept_id integer NOT NULL, + dose_value float NOT NULL, + dose_era_start_date date NOT NULL, + dose_era_end_date date NOT NULL ); +--HINT DISTRIBUTE ON KEY (person_id) +CREATE TABLE @cdmDatabaseSchema.condition_era ( + condition_era_id integer NOT NULL, + person_id integer NOT NULL, + condition_concept_id integer NOT NULL, + condition_era_start_date date NOT NULL, + condition_era_end_date date NOT NULL, + condition_occurrence_count integer NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.metadata ( + metadata_concept_id integer NOT NULL, + metadata_type_concept_id integer NOT NULL, + name varchar(250) NOT NULL, + value_as_string varchar(250) NULL, + value_as_concept_id integer NULL, + metadata_date date NULL, + metadata_datetime datetime NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.cdm_source ( + cdm_source_name varchar(255) NOT NULL, + cdm_source_abbreviation varchar(25) NULL, + cdm_holder varchar(255) NULL, + source_description varchar(MAX) NULL, + source_documentation_reference varchar(255) NULL, + cdm_etl_reference varchar(255) NULL, + source_release_date date NULL, + cdm_release_date date NULL, + cdm_version varchar(10) NULL, + vocabulary_version varchar(20) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept ( + concept_id integer NOT NULL, + concept_name varchar(255) NOT NULL, + domain_id varchar(20) NOT NULL, + vocabulary_id varchar(20) NOT NULL, + concept_class_id varchar(20) NOT NULL, + standard_concept varchar(1) NULL, + concept_code varchar(50) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.vocabulary ( + vocabulary_id varchar(20) NOT NULL, + vocabulary_name varchar(255) NOT NULL, + vocabulary_reference varchar(255) NOT NULL, + vocabulary_version varchar(255) NULL, + vocabulary_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema."DOMAIN" ( + domain_id varchar(20) NOT NULL, + domain_name varchar(255) NOT NULL, + domain_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_class ( + concept_class_id varchar(20) NOT NULL, + concept_class_name varchar(255) NOT NULL, + concept_class_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_relationship ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.relationship ( + relationship_id varchar(20) NOT NULL, + relationship_name varchar(255) NOT NULL, + is_hierarchical varchar(1) NOT NULL, + defines_ancestry varchar(1) NOT NULL, + reverse_relationship_id varchar(20) NOT NULL, + relationship_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_synonym ( + concept_id integer NOT NULL, + concept_synonym_name varchar(1000) NOT NULL, + language_concept_id integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.concept_ancestor ( + ancestor_concept_id integer NOT NULL, + descendant_concept_id integer NOT NULL, + min_levels_of_separation integer NOT NULL, + max_levels_of_separation integer NOT NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.source_to_concept_map ( + source_code varchar(50) NOT NULL, + source_concept_id integer NOT NULL, + source_vocabulary_id varchar(20) NOT NULL, + source_code_description varchar(255) NULL, + target_concept_id integer NOT NULL, + target_vocabulary_id varchar(20) NOT NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.drug_strength ( + drug_concept_id integer NOT NULL, + ingredient_concept_id integer NOT NULL, + amount_value float NULL, + amount_unit_concept_id integer NULL, + numerator_value float NULL, + numerator_unit_concept_id integer NULL, + denominator_value float NULL, + denominator_unit_concept_id integer NULL, + box_size integer NULL, + valid_start_date date NOT NULL, + valid_end_date date NOT NULL, + invalid_reason varchar(1) NULL ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.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 ); +--HINT DISTRIBUTE ON RANDOM +CREATE TABLE @cdmDatabaseSchema.attribute_definition ( + attribute_definition_id integer NOT NULL, + attribute_name varchar(255) NOT NULL, + attribute_description varchar(MAX) NULL, + attribute_type_concept_id integer NOT NULL, + attribute_syntax varchar(MAX) NULL ); \ No newline at end of file diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql new file mode 100644 index 0000000..4dea586 --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql @@ -0,0 +1,98 @@ +/*iris OMOP CDM Indices + There are no unique indices created because it is assumed that the primary key constraints have been run prior to + implementing indices. +*/ +/************************ +Standardized clinical data +************************/ +CREATE INDEX idx_person_id ON @cdmDatabaseSchema.person (person_id ASC); +CREATE INDEX idx_gender ON @cdmDatabaseSchema.person (gender_concept_id ASC); +CREATE INDEX idx_observation_period_id_1 ON @cdmDatabaseSchema.observation_period (person_id ASC); +CREATE INDEX idx_visit_person_id_1 ON @cdmDatabaseSchema.visit_occurrence (person_id ASC); +CREATE INDEX idx_visit_concept_id_1 ON @cdmDatabaseSchema.visit_occurrence (visit_concept_id ASC); +CREATE INDEX idx_visit_det_person_id_1 ON @cdmDatabaseSchema.visit_detail (person_id ASC); +CREATE INDEX idx_visit_det_concept_id_1 ON @cdmDatabaseSchema.visit_detail (visit_detail_concept_id ASC); +CREATE INDEX idx_visit_det_occ_id ON @cdmDatabaseSchema.visit_detail (visit_occurrence_id ASC); +CREATE INDEX idx_condition_person_id_1 ON @cdmDatabaseSchema.condition_occurrence (person_id ASC); +CREATE INDEX idx_condition_concept_id_1 ON @cdmDatabaseSchema.condition_occurrence (condition_concept_id ASC); +CREATE INDEX idx_condition_visit_id_1 ON @cdmDatabaseSchema.condition_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_drug_person_id_1 ON @cdmDatabaseSchema.drug_exposure (person_id ASC); +CREATE INDEX idx_drug_concept_id_1 ON @cdmDatabaseSchema.drug_exposure (drug_concept_id ASC); +CREATE INDEX idx_drug_visit_id_1 ON @cdmDatabaseSchema.drug_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_procedure_person_id_1 ON @cdmDatabaseSchema.procedure_occurrence (person_id ASC); +CREATE INDEX idx_procedure_concept_id_1 ON @cdmDatabaseSchema.procedure_occurrence (procedure_concept_id ASC); +CREATE INDEX idx_procedure_visit_id_1 ON @cdmDatabaseSchema.procedure_occurrence (visit_occurrence_id ASC); +CREATE INDEX idx_device_person_id_1 ON @cdmDatabaseSchema.device_exposure (person_id ASC); +CREATE INDEX idx_device_concept_id_1 ON @cdmDatabaseSchema.device_exposure (device_concept_id ASC); +CREATE INDEX idx_device_visit_id_1 ON @cdmDatabaseSchema.device_exposure (visit_occurrence_id ASC); +CREATE INDEX idx_measurement_person_id_1 ON @cdmDatabaseSchema.measurement (person_id ASC); +CREATE INDEX idx_measurement_concept_id_1 ON @cdmDatabaseSchema.measurement (measurement_concept_id ASC); +CREATE INDEX idx_measurement_visit_id_1 ON @cdmDatabaseSchema.measurement (visit_occurrence_id ASC); +CREATE INDEX idx_observation_person_id_1 ON @cdmDatabaseSchema.observation (person_id ASC); +CREATE INDEX idx_observation_concept_id_1 ON @cdmDatabaseSchema.observation (observation_concept_id ASC); +CREATE INDEX idx_observation_visit_id_1 ON @cdmDatabaseSchema.observation (visit_occurrence_id ASC); +CREATE INDEX idx_death_person_id_1 ON @cdmDatabaseSchema.death (person_id ASC); +CREATE INDEX idx_note_person_id_1 ON @cdmDatabaseSchema.note (person_id ASC); +CREATE INDEX idx_note_concept_id_1 ON @cdmDatabaseSchema.note (note_type_concept_id ASC); +CREATE INDEX idx_note_visit_id_1 ON @cdmDatabaseSchema.note (visit_occurrence_id ASC); +CREATE INDEX idx_note_nlp_note_id_1 ON @cdmDatabaseSchema.note_nlp (note_id ASC); +CREATE INDEX idx_note_nlp_concept_id_1 ON @cdmDatabaseSchema.note_nlp (note_nlp_concept_id ASC); +CREATE INDEX idx_specimen_person_id_1 ON @cdmDatabaseSchema.specimen (person_id ASC); +CREATE INDEX idx_specimen_concept_id_1 ON @cdmDatabaseSchema.specimen (specimen_concept_id ASC); +CREATE INDEX idx_fact_relationship_id1 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_1 ASC); +CREATE INDEX idx_fact_relationship_id2 ON @cdmDatabaseSchema.fact_relationship (domain_concept_id_2 ASC); +CREATE INDEX idx_fact_relationship_id3 ON @cdmDatabaseSchema.fact_relationship (relationship_concept_id ASC); +/************************ +Standardized health system data +************************/ +CREATE INDEX idx_location_id_1 ON @cdmDatabaseSchema.location (location_id ASC); +CREATE INDEX idx_care_site_id_1 ON @cdmDatabaseSchema.care_site (care_site_id ASC); +CREATE INDEX idx_provider_id_1 ON @cdmDatabaseSchema.provider (provider_id ASC); +/************************ +Standardized health economics +************************/ +CREATE INDEX idx_period_person_id_1 ON @cdmDatabaseSchema.payer_plan_period (person_id ASC); +CREATE INDEX idx_cost_event_id ON @cdmDatabaseSchema.cost (cost_event_id ASC); +/************************ +Standardized derived elements +************************/ +CREATE INDEX idx_drug_era_person_id_1 ON @cdmDatabaseSchema.drug_era (person_id ASC); +CREATE INDEX idx_drug_era_concept_id_1 ON @cdmDatabaseSchema.drug_era (drug_concept_id ASC); +CREATE INDEX idx_dose_era_person_id_1 ON @cdmDatabaseSchema.dose_era (person_id ASC); +CREATE INDEX idx_dose_era_concept_id_1 ON @cdmDatabaseSchema.dose_era (drug_concept_id ASC); +CREATE INDEX idx_condition_era_person_id_1 ON @cdmDatabaseSchema.condition_era (person_id ASC); +CREATE INDEX idx_condition_era_concept_id_1 ON @cdmDatabaseSchema.condition_era (condition_concept_id ASC); +/************************** +Standardized meta-data +***************************/ +CREATE INDEX idx_metadata_concept_id_1 ON @cdmDatabaseSchema.metadata (metadata_concept_id ASC); +/************************** +Standardized vocabularies +***************************/ +CREATE INDEX idx_concept_concept_id ON @cdmDatabaseSchema.concept (concept_id ASC); +CREATE INDEX idx_concept_code ON @cdmDatabaseSchema.concept (concept_code ASC); +CREATE INDEX idx_concept_vocabulary_id ON @cdmDatabaseSchema.concept (vocabulary_id ASC); +CREATE INDEX idx_concept_domain_id ON @cdmDatabaseSchema.concept (domain_id ASC); +CREATE INDEX idx_concept_class_id ON @cdmDatabaseSchema.concept (concept_class_id ASC); +CREATE INDEX idx_vocabulary_vocabulary_id ON @cdmDatabaseSchema.vocabulary (vocabulary_id ASC); +CREATE INDEX idx_domain_domain_id ON @cdmDatabaseSchema."DOMAIN" (domain_id ASC); +CREATE INDEX idx_concept_class_class_id ON @cdmDatabaseSchema.concept_class (concept_class_id ASC); +CREATE INDEX idx_concept_relationship_id_1 ON @cdmDatabaseSchema.concept_relationship (concept_id_1 ASC); +CREATE INDEX idx_concept_relationship_id_2 ON @cdmDatabaseSchema.concept_relationship (concept_id_2 ASC); +CREATE INDEX idx_concept_relationship_id_3 ON @cdmDatabaseSchema.concept_relationship (relationship_id ASC); +CREATE INDEX idx_relationship_rel_id ON @cdmDatabaseSchema.relationship (relationship_id ASC); +CREATE INDEX idx_concept_synonym_id ON @cdmDatabaseSchema.concept_synonym (concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_1 ON @cdmDatabaseSchema.concept_ancestor (ancestor_concept_id ASC); +CREATE INDEX idx_concept_ancestor_id_2 ON @cdmDatabaseSchema.concept_ancestor (descendant_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_3 ON @cdmDatabaseSchema.source_to_concept_map (target_concept_id ASC); +CREATE INDEX idx_source_to_concept_map_1 ON @cdmDatabaseSchema.source_to_concept_map (source_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_2 ON @cdmDatabaseSchema.source_to_concept_map (target_vocabulary_id ASC); +CREATE INDEX idx_source_to_concept_map_c ON @cdmDatabaseSchema.source_to_concept_map (source_code ASC); +CREATE INDEX idx_drug_strength_id_1 ON @cdmDatabaseSchema.drug_strength (drug_concept_id ASC); +CREATE INDEX idx_drug_strength_id_2 ON @cdmDatabaseSchema.drug_strength (ingredient_concept_id ASC); +--Additional v6.0 indices +--CREATE CLUSTERED INDEX idx_survey_person_id_1 ON @cdmDatabaseSchema.survey_conduct (person_id ASC); +--CREATE CLUSTERED INDEX idx_episode_person_id_1 ON @cdmDatabaseSchema.episode (person_id ASC); +--CREATE INDEX idx_episode_concept_id_1 ON @cdmDatabaseSchema.episode (episode_concept_id ASC); +--CREATE CLUSTERED INDEX idx_episode_event_id_1 ON @cdmDatabaseSchema.episode_event (episode_id ASC); +--CREATE INDEX idx_ee_field_concept_id_1 ON @cdmDatabaseSchema.episode_event (event_field_concept_id ASC); diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql b/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql new file mode 100644 index 0000000..cfd1e92 --- /dev/null +++ b/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql @@ -0,0 +1,27 @@ +--iris CDM Primary Key Constraints for OMOP Common Data Model 5.3 +ALTER TABLE @cdmDatabaseSchema.person ADD CONSTRAINT xpk_person PRIMARY KEY (person_id); +ALTER TABLE @cdmDatabaseSchema.observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY (observation_period_id); +ALTER TABLE @cdmDatabaseSchema.visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY (visit_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY (visit_detail_id); +ALTER TABLE @cdmDatabaseSchema.condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY (condition_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY (drug_exposure_id); +ALTER TABLE @cdmDatabaseSchema.procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY (procedure_occurrence_id); +ALTER TABLE @cdmDatabaseSchema.device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY (device_exposure_id); +ALTER TABLE @cdmDatabaseSchema.measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY (measurement_id); +ALTER TABLE @cdmDatabaseSchema.observation ADD CONSTRAINT xpk_observation PRIMARY KEY (observation_id); +ALTER TABLE @cdmDatabaseSchema.note ADD CONSTRAINT xpk_note PRIMARY KEY (note_id); +ALTER TABLE @cdmDatabaseSchema.note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY (note_nlp_id); +ALTER TABLE @cdmDatabaseSchema.specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY (specimen_id); +ALTER TABLE @cdmDatabaseSchema.location ADD CONSTRAINT xpk_location PRIMARY KEY (location_id); +ALTER TABLE @cdmDatabaseSchema.care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY (care_site_id); +ALTER TABLE @cdmDatabaseSchema.provider ADD CONSTRAINT xpk_provider PRIMARY KEY (provider_id); +ALTER TABLE @cdmDatabaseSchema.payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY (payer_plan_period_id); +ALTER TABLE @cdmDatabaseSchema.cost ADD CONSTRAINT xpk_cost PRIMARY KEY (cost_id); +ALTER TABLE @cdmDatabaseSchema.drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY (drug_era_id); +ALTER TABLE @cdmDatabaseSchema.dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY (dose_era_id); +ALTER TABLE @cdmDatabaseSchema.condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY (condition_era_id); +ALTER TABLE @cdmDatabaseSchema.concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id); +ALTER TABLE @cdmDatabaseSchema.vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id); +ALTER TABLE @cdmDatabaseSchema."DOMAIN" ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id); +ALTER TABLE @cdmDatabaseSchema.concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id); +ALTER TABLE @cdmDatabaseSchema.relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id); From 44bc47e5f1a80fe54c6d6145f8255369c7e8b107 Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Wed, 23 Oct 2024 09:56:57 +0200 Subject: [PATCH 07/12] Extend unit tests to cover InterSystems IRIS --- tests/testthat/setup.R | 264 +++++++++++++++++++++-------------------- 1 file changed, 136 insertions(+), 128 deletions(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 90195ac..8547fbd 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,128 +1,136 @@ -testDatabases <- c("postgresql") - -if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { - library(DatabaseConnector) - - if (dir.exists(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { - jdbcDriverFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") - } else { - jdbcDriverFolder <- file.path(tempdir(), "jdbcDrivers") - dir.create(jdbcDriverFolder, showWarnings = FALSE) - DatabaseConnector::downloadJdbcDrivers("all", pathToDriver = jdbcDriverFolder) - - Sys.setenv(DATABASECONNECTOR_JAR_FOLDER = jdbcDriverFolder) - - withr::defer({ - unlink(jdbcDriverFolder, - recursive = TRUE, - force = TRUE) - }, - testthat::teardown_env()) - } -} else { - message("Skipping driver setup because environmental variables not set") -} - -# Helper functions used in tests -getConnectionDetails <- function(dbms) { - switch ( - dbms, - "postgresql" = createConnectionDetails( - dbms = "postgresql", - user = Sys.getenv("CDMDDLBASE_POSTGRESQL_USER"), - password = Sys.getenv("CDMDDLBASE_POSTGRESQL_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_POSTGRESQL_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "redshift" = createConnectionDetails( - dbms = "redshift", - user = Sys.getenv("CDMDDLBASE_REDSHIFT_USER"), - password = Sys.getenv("CDMDDLBASE_REDSHIFT_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_REDSHIFT_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "sql server" = createConnectionDetails( - dbms = "sql server", - user = Sys.getenv("CDMDDLBASE_SQL_SERVER_USER"), - password = Sys.getenv("CDMDDLBASE_SQL_SERVER_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_SQL_SERVER_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "oracle" = createConnectionDetails( - dbms = "oracle", - user = Sys.getenv("CDMDDLBASE_ORACLE_USER"), - password = Sys.getenv("CDMDDLBASE_ORACLE_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_ORACLE_SERVER"), - pathToDriver = jdbcDriverFolder - ) - ) -} - -getSchema <- function(dbms) { - switch ( - dbms, - "postgresql" = Sys.getenv("CDMDDLBASE_POSTGRESQL_SCHEMA"), - "redshift" = Sys.getenv("CDMDDLBASE_REDSHIFT_SCHEMA"), - "sql server" = Sys.getenv("CDMDDLBASE_SQL_SERVER_CDM_SCHEMA"), - "oracle" = Sys.getenv("CDMDDLBASE_ORACLE_CDM_SCHEMA") - ) -} - -listTablesInSchema <- function(connectionDetails, schema) { - stopifnot( - "ConnectionDetails" %in% class(connectionDetails), - class(schema) == "character", - length(schema) == 1 - ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle")) - con <- DatabaseConnector::connect(connectionDetails) - on.exit(DatabaseConnector::disconnect(con)) - dbms <- connectionDetails$dbms - if (dbms %in% c("postgresql", "redshift", "sql server")) { - tables <- - dbGetQuery( - con, - paste0( - "select table_name from information_schema.tables where table_schema = '", - schema, - "'" - ) - )[[1]] - } else if (dbms == "oracle") { - query <- - paste0( - "select table_name from all_tables where owner = '", - toupper(schema), - "' and tablespace_name = 'USERS'" - ) - tables <- dbGetQuery(con, query)[[1]] - } - return(tables) -} - -dropAllTablesFromSchema <- function(connectionDetails, schema) { - stopifnot( - "ConnectionDetails" %in% class(connectionDetails), - class(schema) == "character", - length(schema) == 1 - ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle")) - tableNames <- listTablesInSchema(connectionDetails, schema) - - con <- DatabaseConnector::connect(connectionDetails) - on.exit(DatabaseConnector::disconnect(con)) - dbms <- connectionDetails$dbms - if (dbms %in% c("redshift", "postgresql", "sql server")) { - for (tableName in tableNames) { - DBI::dbExecute(con, paste( - "DROP TABLE IF EXISTS", - paste(schema, tableName, sep = "."), - "CASCADE" - )) - } - } else if (dbms == "oracle") { - for (tableName in tableNames) { - DBI::dbExecute(con, paste("DROP TABLE IF EXISTS", tableName, "CASCADE")) - } - } -} +testDatabases <- c("postgresql") + +if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { + library(DatabaseConnector) + + if (dir.exists(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { + jdbcDriverFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") + } else { + jdbcDriverFolder <- file.path(tempdir(), "jdbcDrivers") + dir.create(jdbcDriverFolder, showWarnings = FALSE) + DatabaseConnector::downloadJdbcDrivers("all", pathToDriver = jdbcDriverFolder) + + Sys.setenv(DATABASECONNECTOR_JAR_FOLDER = jdbcDriverFolder) + + withr::defer({ + unlink(jdbcDriverFolder, + recursive = TRUE, + force = TRUE) + }, + testthat::teardown_env()) + } +} else { + message("Skipping driver setup because environmental variables not set") +} + +# Helper functions used in tests +getConnectionDetails <- function(dbms) { + switch ( + dbms, + "postgresql" = createConnectionDetails( + dbms = "postgresql", + user = Sys.getenv("CDMDDLBASE_POSTGRESQL_USER"), + password = Sys.getenv("CDMDDLBASE_POSTGRESQL_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_POSTGRESQL_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "redshift" = createConnectionDetails( + dbms = "redshift", + user = Sys.getenv("CDMDDLBASE_REDSHIFT_USER"), + password = Sys.getenv("CDMDDLBASE_REDSHIFT_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_REDSHIFT_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "sql server" = createConnectionDetails( + dbms = "sql server", + user = Sys.getenv("CDMDDLBASE_SQL_SERVER_USER"), + password = Sys.getenv("CDMDDLBASE_SQL_SERVER_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_SQL_SERVER_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "oracle" = createConnectionDetails( + dbms = "oracle", + user = Sys.getenv("CDMDDLBASE_ORACLE_USER"), + password = Sys.getenv("CDMDDLBASE_ORACLE_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_ORACLE_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "iris" = createConnectionDetails( + dbms = "iris", + user = Sys.getenv("CDMDDLBASE_IRIS_USER"), + password = Sys.getenv("CDMDDLBASE_IRIS_PASSWORD"), + connectionString = Sys.getenv("CDMDDLBASE_IRIS_URL"), + pathToDriver = jdbcDriverFolder + ) + ) +} + +getSchema <- function(dbms) { + switch ( + dbms, + "postgresql" = Sys.getenv("CDMDDLBASE_POSTGRESQL_SCHEMA"), + "redshift" = Sys.getenv("CDMDDLBASE_REDSHIFT_SCHEMA"), + "sql server" = Sys.getenv("CDMDDLBASE_SQL_SERVER_CDM_SCHEMA"), + "oracle" = Sys.getenv("CDMDDLBASE_ORACLE_CDM_SCHEMA"), + "iris" = Sys.getenv("CDMDDLBASE_IRIS_CDM_SCHEMA") + ) +} + +listTablesInSchema <- function(connectionDetails, schema) { + stopifnot( + "ConnectionDetails" %in% class(connectionDetails), + class(schema) == "character", + length(schema) == 1 + ) + stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + con <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(con)) + dbms <- connectionDetails$dbms + if (dbms %in% c("postgresql", "redshift", "sql server", "iris")) { + tables <- + dbGetQuery( + con, + paste0( + "select table_name from information_schema.tables where table_schema = '", + schema, + "'" + ) + )[[1]] + } else if (dbms == "oracle") { + query <- + paste0( + "select table_name from all_tables where owner = '", + toupper(schema), + "' and tablespace_name = 'USERS'" + ) + tables <- dbGetQuery(con, query)[[1]] + } + return(tables) +} + +dropAllTablesFromSchema <- function(connectionDetails, schema) { + stopifnot( + "ConnectionDetails" %in% class(connectionDetails), + class(schema) == "character", + length(schema) == 1 + ) + stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + tableNames <- listTablesInSchema(connectionDetails, schema) + + con <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(con)) + dbms <- connectionDetails$dbms + if (dbms %in% c("redshift", "postgresql", "sql server", "iris")) { + for (tableName in tableNames) { + DBI::dbExecute(con, paste( + "DROP TABLE IF EXISTS", + paste(schema, tableName, sep = "."), + "CASCADE" + )) + } + } else if (dbms == "oracle") { + for (tableName in tableNames) { + DBI::dbExecute(con, paste("DROP TABLE IF EXISTS", tableName, "CASCADE")) + } + } +} From 31099c4449c78f1d28db4d1ebc71bb2ba52fa38c Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Tue, 7 Jan 2025 17:29:35 +0100 Subject: [PATCH 08/12] fix directory structure --- {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_constraints.sql | 0 {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_ddl.sql | 0 {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_indices.sql | 0 {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql | 0 {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_constraints.sql | 0 {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_ddl.sql | 0 {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_indices.sql | 0 {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_constraints.sql (100%) rename {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_ddl.sql (100%) rename {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_indices.sql (100%) rename {ddl => inst/ddl}/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql (100%) rename {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_constraints.sql (100%) rename {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_ddl.sql (100%) rename {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_indices.sql (100%) rename {ddl => inst/ddl}/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql (100%) diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql b/inst/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql similarity index 100% rename from ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql rename to inst/ddl/5.3/iris/OMOPCDM_iris_5.3_constraints.sql diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql b/inst/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql similarity index 100% rename from ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql rename to inst/ddl/5.3/iris/OMOPCDM_iris_5.3_ddl.sql diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql b/inst/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql similarity index 100% rename from ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql rename to inst/ddl/5.3/iris/OMOPCDM_iris_5.3_indices.sql diff --git a/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql b/inst/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql similarity index 100% rename from ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql rename to inst/ddl/5.3/iris/OMOPCDM_iris_5.3_primary_keys.sql diff --git a/ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql b/inst/ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql similarity index 100% rename from ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql rename to inst/ddl/5.4/iris/OMOPCDM_iris_5.4_constraints.sql diff --git a/ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql b/inst/ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql similarity index 100% rename from ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql rename to inst/ddl/5.4/iris/OMOPCDM_iris_5.4_ddl.sql diff --git a/ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql b/inst/ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql similarity index 100% rename from ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql rename to inst/ddl/5.4/iris/OMOPCDM_iris_5.4_indices.sql diff --git a/ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql b/inst/ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql similarity index 100% rename from ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql rename to inst/ddl/5.4/iris/OMOPCDM_iris_5.4_primary_keys.sql From 898d7a5537b8251bdf2bdf5afbdbfadcfc3f2437 Mon Sep 17 00:00:00 2001 From: Benjamin De Boe Date: Tue, 15 Apr 2025 10:06:17 +0200 Subject: [PATCH 09/12] fix CRLF --- tests/testthat/setup.R | 272 ++++++++++++++++++++--------------------- 1 file changed, 136 insertions(+), 136 deletions(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 8547fbd..59c953b 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,136 +1,136 @@ -testDatabases <- c("postgresql") - -if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { - library(DatabaseConnector) - - if (dir.exists(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { - jdbcDriverFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") - } else { - jdbcDriverFolder <- file.path(tempdir(), "jdbcDrivers") - dir.create(jdbcDriverFolder, showWarnings = FALSE) - DatabaseConnector::downloadJdbcDrivers("all", pathToDriver = jdbcDriverFolder) - - Sys.setenv(DATABASECONNECTOR_JAR_FOLDER = jdbcDriverFolder) - - withr::defer({ - unlink(jdbcDriverFolder, - recursive = TRUE, - force = TRUE) - }, - testthat::teardown_env()) - } -} else { - message("Skipping driver setup because environmental variables not set") -} - -# Helper functions used in tests -getConnectionDetails <- function(dbms) { - switch ( - dbms, - "postgresql" = createConnectionDetails( - dbms = "postgresql", - user = Sys.getenv("CDMDDLBASE_POSTGRESQL_USER"), - password = Sys.getenv("CDMDDLBASE_POSTGRESQL_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_POSTGRESQL_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "redshift" = createConnectionDetails( - dbms = "redshift", - user = Sys.getenv("CDMDDLBASE_REDSHIFT_USER"), - password = Sys.getenv("CDMDDLBASE_REDSHIFT_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_REDSHIFT_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "sql server" = createConnectionDetails( - dbms = "sql server", - user = Sys.getenv("CDMDDLBASE_SQL_SERVER_USER"), - password = Sys.getenv("CDMDDLBASE_SQL_SERVER_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_SQL_SERVER_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "oracle" = createConnectionDetails( - dbms = "oracle", - user = Sys.getenv("CDMDDLBASE_ORACLE_USER"), - password = Sys.getenv("CDMDDLBASE_ORACLE_PASSWORD"), - server = Sys.getenv("CDMDDLBASE_ORACLE_SERVER"), - pathToDriver = jdbcDriverFolder - ), - "iris" = createConnectionDetails( - dbms = "iris", - user = Sys.getenv("CDMDDLBASE_IRIS_USER"), - password = Sys.getenv("CDMDDLBASE_IRIS_PASSWORD"), - connectionString = Sys.getenv("CDMDDLBASE_IRIS_URL"), - pathToDriver = jdbcDriverFolder - ) - ) -} - -getSchema <- function(dbms) { - switch ( - dbms, - "postgresql" = Sys.getenv("CDMDDLBASE_POSTGRESQL_SCHEMA"), - "redshift" = Sys.getenv("CDMDDLBASE_REDSHIFT_SCHEMA"), - "sql server" = Sys.getenv("CDMDDLBASE_SQL_SERVER_CDM_SCHEMA"), - "oracle" = Sys.getenv("CDMDDLBASE_ORACLE_CDM_SCHEMA"), - "iris" = Sys.getenv("CDMDDLBASE_IRIS_CDM_SCHEMA") - ) -} - -listTablesInSchema <- function(connectionDetails, schema) { - stopifnot( - "ConnectionDetails" %in% class(connectionDetails), - class(schema) == "character", - length(schema) == 1 - ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) - con <- DatabaseConnector::connect(connectionDetails) - on.exit(DatabaseConnector::disconnect(con)) - dbms <- connectionDetails$dbms - if (dbms %in% c("postgresql", "redshift", "sql server", "iris")) { - tables <- - dbGetQuery( - con, - paste0( - "select table_name from information_schema.tables where table_schema = '", - schema, - "'" - ) - )[[1]] - } else if (dbms == "oracle") { - query <- - paste0( - "select table_name from all_tables where owner = '", - toupper(schema), - "' and tablespace_name = 'USERS'" - ) - tables <- dbGetQuery(con, query)[[1]] - } - return(tables) -} - -dropAllTablesFromSchema <- function(connectionDetails, schema) { - stopifnot( - "ConnectionDetails" %in% class(connectionDetails), - class(schema) == "character", - length(schema) == 1 - ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) - tableNames <- listTablesInSchema(connectionDetails, schema) - - con <- DatabaseConnector::connect(connectionDetails) - on.exit(DatabaseConnector::disconnect(con)) - dbms <- connectionDetails$dbms - if (dbms %in% c("redshift", "postgresql", "sql server", "iris")) { - for (tableName in tableNames) { - DBI::dbExecute(con, paste( - "DROP TABLE IF EXISTS", - paste(schema, tableName, sep = "."), - "CASCADE" - )) - } - } else if (dbms == "oracle") { - for (tableName in tableNames) { - DBI::dbExecute(con, paste("DROP TABLE IF EXISTS", tableName, "CASCADE")) - } - } -} +testDatabases <- c("postgresql") + +if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { + library(DatabaseConnector) + + if (dir.exists(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"))) { + jdbcDriverFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") + } else { + jdbcDriverFolder <- file.path(tempdir(), "jdbcDrivers") + dir.create(jdbcDriverFolder, showWarnings = FALSE) + DatabaseConnector::downloadJdbcDrivers("all", pathToDriver = jdbcDriverFolder) + + Sys.setenv(DATABASECONNECTOR_JAR_FOLDER = jdbcDriverFolder) + + withr::defer({ + unlink(jdbcDriverFolder, + recursive = TRUE, + force = TRUE) + }, + testthat::teardown_env()) + } +} else { + message("Skipping driver setup because environmental variables not set") +} + +# Helper functions used in tests +getConnectionDetails <- function(dbms) { + switch ( + dbms, + "postgresql" = createConnectionDetails( + dbms = "postgresql", + user = Sys.getenv("CDMDDLBASE_POSTGRESQL_USER"), + password = Sys.getenv("CDMDDLBASE_POSTGRESQL_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_POSTGRESQL_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "redshift" = createConnectionDetails( + dbms = "redshift", + user = Sys.getenv("CDMDDLBASE_REDSHIFT_USER"), + password = Sys.getenv("CDMDDLBASE_REDSHIFT_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_REDSHIFT_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "sql server" = createConnectionDetails( + dbms = "sql server", + user = Sys.getenv("CDMDDLBASE_SQL_SERVER_USER"), + password = Sys.getenv("CDMDDLBASE_SQL_SERVER_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_SQL_SERVER_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "oracle" = createConnectionDetails( + dbms = "oracle", + user = Sys.getenv("CDMDDLBASE_ORACLE_USER"), + password = Sys.getenv("CDMDDLBASE_ORACLE_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_ORACLE_SERVER"), + pathToDriver = jdbcDriverFolder + ), + "iris" = createConnectionDetails( + dbms = "iris", + user = Sys.getenv("CDMDDLBASE_IRIS_USER"), + password = Sys.getenv("CDMDDLBASE_IRIS_PASSWORD"), + connectionString = Sys.getenv("CDMDDLBASE_IRIS_URL"), + pathToDriver = jdbcDriverFolder + ) + ) +} + +getSchema <- function(dbms) { + switch ( + dbms, + "postgresql" = Sys.getenv("CDMDDLBASE_POSTGRESQL_SCHEMA"), + "redshift" = Sys.getenv("CDMDDLBASE_REDSHIFT_SCHEMA"), + "sql server" = Sys.getenv("CDMDDLBASE_SQL_SERVER_CDM_SCHEMA"), + "oracle" = Sys.getenv("CDMDDLBASE_ORACLE_CDM_SCHEMA"), + "iris" = Sys.getenv("CDMDDLBASE_IRIS_CDM_SCHEMA") + ) +} + +listTablesInSchema <- function(connectionDetails, schema) { + stopifnot( + "ConnectionDetails" %in% class(connectionDetails), + class(schema) == "character", + length(schema) == 1 + ) + stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + con <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(con)) + dbms <- connectionDetails$dbms + if (dbms %in% c("postgresql", "redshift", "sql server", "iris")) { + tables <- + dbGetQuery( + con, + paste0( + "select table_name from information_schema.tables where table_schema = '", + schema, + "'" + ) + )[[1]] + } else if (dbms == "oracle") { + query <- + paste0( + "select table_name from all_tables where owner = '", + toupper(schema), + "' and tablespace_name = 'USERS'" + ) + tables <- dbGetQuery(con, query)[[1]] + } + return(tables) +} + +dropAllTablesFromSchema <- function(connectionDetails, schema) { + stopifnot( + "ConnectionDetails" %in% class(connectionDetails), + class(schema) == "character", + length(schema) == 1 + ) + stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + tableNames <- listTablesInSchema(connectionDetails, schema) + + con <- DatabaseConnector::connect(connectionDetails) + on.exit(DatabaseConnector::disconnect(con)) + dbms <- connectionDetails$dbms + if (dbms %in% c("redshift", "postgresql", "sql server", "iris")) { + for (tableName in tableNames) { + DBI::dbExecute(con, paste( + "DROP TABLE IF EXISTS", + paste(schema, tableName, sep = "."), + "CASCADE" + )) + } + } else if (dbms == "oracle") { + for (tableName in tableNames) { + DBI::dbExecute(con, paste("DROP TABLE IF EXISTS", tableName, "CASCADE")) + } + } +} From f663f20b9bda11cba56d50240479580261083dd7 Mon Sep 17 00:00:00 2001 From: Katy Sadowski Date: Wed, 19 Mar 2025 20:25:40 -0400 Subject: [PATCH 10/12] add testthat tests on IRIS --- .github/workflows/R_CMD_check.yaml | 8 ++++++-- CommonDataModel.Rproj | 1 + tests/testthat/setup.R | 14 +++++++------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.github/workflows/R_CMD_check.yaml b/.github/workflows/R_CMD_check.yaml index 4773511..d165a48 100644 --- a/.github/workflows/R_CMD_check.yaml +++ b/.github/workflows/R_CMD_check.yaml @@ -47,6 +47,11 @@ jobs: CDMDDLBASE_ORACLE_PASSWORD: ${{ secrets.CDMDDLBASE_ORACLE_PASSWORD }} CDMDDLBASE_ORACLE_SERVER: ${{ secrets.CDMDDLBASE_ORACLE_SERVER }} CDMDDLBASE_ORACLE_CDM_SCHEMA: ${{ secrets.CDMDDLBASE_ORACLE_CDM_SCHEMA }} + CDM_IRIS_CONNECTION_STRING: ${{ secrets.CDM_IRIS_CONNECTION_STRING }} + CDM_IRIS_USER: ${{ secrets.CDM_IRIS_USER }} + CDM_IRIS_PASSWORD: ${{ secrets.CDM_IRIS_PASSWORD }} + CDM_IRIS_CDM_SCHEMA: ${{ secrets.CDM_IRIS_CDM_SCHEMA }} + CDM_IRIS_OHDSI_SCHEMA: ${{ secrets.CDM_IRIS_OHDSI_SCHEMA }} steps: - uses: actions/checkout@v4 @@ -67,7 +72,7 @@ jobs: - name: Cache R packages if: runner.os != 'Windows' - uses: actions/cache@v3.3.1 + uses: actions/cache@v4 with: path: ${{ env.R_LIBS_USER }} key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} @@ -127,4 +132,3 @@ jobs: if: runner.os == 'macOS' run: covr::codecov() shell: Rscript {0} - diff --git a/CommonDataModel.Rproj b/CommonDataModel.Rproj index ce013e1..dad992d 100644 --- a/CommonDataModel.Rproj +++ b/CommonDataModel.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 54514637-59b4-4d43-83cf-67c54a4f8941 RestoreWorkspace: Default SaveWorkspace: Default diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index 59c953b..cb4e307 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,4 +1,4 @@ -testDatabases <- c("postgresql") +testDatabases <- c("postgres","iris") if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { library(DatabaseConnector) @@ -57,9 +57,9 @@ getConnectionDetails <- function(dbms) { ), "iris" = createConnectionDetails( dbms = "iris", - user = Sys.getenv("CDMDDLBASE_IRIS_USER"), - password = Sys.getenv("CDMDDLBASE_IRIS_PASSWORD"), - connectionString = Sys.getenv("CDMDDLBASE_IRIS_URL"), + user = Sys.getenv("CDM_IRIS_USER"), + password = Sys.getenv("CDM_IRIS_PASSWORD"), + connectionString = Sys.getenv("CDM_IRIS_CONNECTION_STRING"), pathToDriver = jdbcDriverFolder ) ) @@ -72,7 +72,7 @@ getSchema <- function(dbms) { "redshift" = Sys.getenv("CDMDDLBASE_REDSHIFT_SCHEMA"), "sql server" = Sys.getenv("CDMDDLBASE_SQL_SERVER_CDM_SCHEMA"), "oracle" = Sys.getenv("CDMDDLBASE_ORACLE_CDM_SCHEMA"), - "iris" = Sys.getenv("CDMDDLBASE_IRIS_CDM_SCHEMA") + "iris" = Sys.getenv("CDM_IRIS_CDM_SCHEMA") ) } @@ -82,7 +82,7 @@ listTablesInSchema <- function(connectionDetails, schema) { class(schema) == "character", length(schema) == 1 ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + stopifnot(connectionDetails$dbms %in% testDatabases) con <- DatabaseConnector::connect(connectionDetails) on.exit(DatabaseConnector::disconnect(con)) dbms <- connectionDetails$dbms @@ -114,7 +114,7 @@ dropAllTablesFromSchema <- function(connectionDetails, schema) { class(schema) == "character", length(schema) == 1 ) - stopifnot(connectionDetails$dbms %in% c("postgresql", "redshift", "sql server", "oracle", "iris")) + stopifnot(connectionDetails$dbms %in% testDatabases) tableNames <- listTablesInSchema(connectionDetails, schema) con <- DatabaseConnector::connect(connectionDetails) From 75dc8fc5eaf6ef0562e2810ad23e19cdbeacb39d Mon Sep 17 00:00:00 2001 From: Katy Sadowski Date: Tue, 15 Apr 2025 19:49:00 -0400 Subject: [PATCH 11/12] fix postgres spelling --- tests/testthat/setup.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index cb4e307..ceb2000 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -1,4 +1,4 @@ -testDatabases <- c("postgres","iris") +testDatabases <- c("postgresql","iris") if (Sys.getenv("CDM5_POSTGRESQL_SERVER") != "") { library(DatabaseConnector) From d5f2668a9f75e29464bad0300892e0cdc211d533 Mon Sep 17 00:00:00 2001 From: Katy Sadowski Date: Tue, 15 Apr 2025 19:58:06 -0400 Subject: [PATCH 12/12] upgrade actions package --- .github/workflows/R_CMD_check.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/R_CMD_check.yaml b/.github/workflows/R_CMD_check.yaml index d165a48..ed82902 100644 --- a/.github/workflows/R_CMD_check.yaml +++ b/.github/workflows/R_CMD_check.yaml @@ -116,14 +116,14 @@ jobs: - name: Upload check results if: failure() - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ runner.os }}-r${{ matrix.config.r }}-results path: check - name: Upload source package if: success() && runner.os == 'macOS' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: package_tarball path: check/*.tar.gz