updating for recent SqlRender supported dialects
This commit is contained in:
parent
8c18f01274
commit
a029324c48
|
@ -15,4 +15,3 @@ ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
extras/codeToRun.R
|
extras/codeToRun.R
|
||||||
output/
|
output/
|
||||||
ddl/
|
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
--duckdb 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--duckdb 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 TIMESTAMP NULL,
|
||||||
|
race_concept_id integer NOT NULL,
|
||||||
|
ethnicity_concept_id integer NOT NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
person_source_value varchar(50) NULL,
|
||||||
|
gender_source_value varchar(50) NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value varchar(50) NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value varchar(50) NULL,
|
||||||
|
ethnicity_source_concept_id integer NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
visit_end_date date NOT NULL,
|
||||||
|
visit_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
visit_detail_end_date date NOT NULL,
|
||||||
|
visit_detail_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
condition_end_date date NULL,
|
||||||
|
condition_end_datetime TIMESTAMP NULL,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason varchar(20) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value varchar(50) NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
drug_exposure_end_date date NOT NULL,
|
||||||
|
drug_exposure_end_datetime TIMESTAMP NULL,
|
||||||
|
verbatim_end_date date NULL,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason varchar(20) NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity NUMERIC NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number varchar(50) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value varchar(50) NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value varchar(50) NULL,
|
||||||
|
dose_unit_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
device_exposure_end_date date NULL,
|
||||||
|
device_exposure_end_datetime TIMESTAMP NULL,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id varchar(50) NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value varchar(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 TIMESTAMP NULL,
|
||||||
|
measurement_time varchar(10) NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number NUMERIC NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low NUMERIC NULL,
|
||||||
|
range_high NUMERIC NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value varchar(50) NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value varchar(50) NULL,
|
||||||
|
value_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number NUMERIC NULL,
|
||||||
|
value_as_string varchar(60) NULL,
|
||||||
|
value_as_concept_id Integer NULL,
|
||||||
|
qualifier_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id 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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title varchar(250) NULL,
|
||||||
|
note_text TEXT 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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
quantity NUMERIC NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id varchar(50) NULL,
|
||||||
|
specimen_source_value varchar(50) NULL,
|
||||||
|
unit_source_value varchar(50) NULL,
|
||||||
|
anatomic_site_source_value varchar(50) NULL,
|
||||||
|
disease_status_source_value varchar(50) NULL );
|
||||||
|
--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 NUMERIC NULL,
|
||||||
|
total_cost NUMERIC NULL,
|
||||||
|
total_paid NUMERIC NULL,
|
||||||
|
paid_by_payer NUMERIC NULL,
|
||||||
|
paid_by_patient NUMERIC NULL,
|
||||||
|
paid_patient_copay NUMERIC NULL,
|
||||||
|
paid_patient_coinsurance NUMERIC NULL,
|
||||||
|
paid_patient_deductible NUMERIC NULL,
|
||||||
|
paid_by_primary NUMERIC NULL,
|
||||||
|
paid_ingredient_cost NUMERIC NULL,
|
||||||
|
paid_dispensing_fee NUMERIC NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed NUMERIC 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 NUMERIC 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 TIMESTAMP 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 TEXT NULL,
|
||||||
|
source_documentation_reference varchar(255) NULL,
|
||||||
|
cdm_etl_reference varchar(255) NULL,
|
||||||
|
source_release_date date NULL,
|
||||||
|
cdm_release_date date NULL,
|
||||||
|
cdm_version varchar(10) NULL,
|
||||||
|
vocabulary_version varchar(20) NULL );
|
||||||
|
--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 NUMERIC NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value NUMERIC NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value NUMERIC NULL,
|
||||||
|
denominator_unit_concept_id integer NULL,
|
||||||
|
box_size integer NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason varchar(1) NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
cohort_definition_name varchar(255) NOT NULL,
|
||||||
|
cohort_definition_description TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
|
||||||
|
attribute_definition_id integer NOT NULL,
|
||||||
|
attribute_name varchar(255) NOT NULL,
|
||||||
|
attribute_description TEXT NULL,
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax TEXT NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*duckdb 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_vocabluary_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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--duckdb 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);
|
|
@ -0,0 +1,158 @@
|
||||||
|
--hive 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--hive 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 TIMESTAMP,
|
||||||
|
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),
|
||||||
|
gender_source_value VARCHAR(50),
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value VARCHAR(50),
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
observation_period_end_date TIMESTAMP,
|
||||||
|
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 TIMESTAMP,
|
||||||
|
visit_start_datetime TIMESTAMP,
|
||||||
|
visit_end_date TIMESTAMP,
|
||||||
|
visit_end_datetime TIMESTAMP,
|
||||||
|
visit_type_concept_id Integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_source_value VARCHAR(50),
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitting_source_concept_id integer NULL,
|
||||||
|
admitting_source_value VARCHAR(50),
|
||||||
|
discharge_to_concept_id integer NULL,
|
||||||
|
discharge_to_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
visit_detail_start_datetime TIMESTAMP,
|
||||||
|
visit_detail_end_date TIMESTAMP,
|
||||||
|
visit_detail_end_datetime TIMESTAMP,
|
||||||
|
visit_detail_type_concept_id integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_detail_source_value VARCHAR(50),
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitting_source_value VARCHAR(50),
|
||||||
|
admitting_source_concept_id Integer NULL,
|
||||||
|
discharge_to_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
condition_start_datetime TIMESTAMP,
|
||||||
|
condition_end_date TIMESTAMP,
|
||||||
|
condition_end_datetime TIMESTAMP,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason VARCHAR(20),
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value VARCHAR(50),
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
drug_exposure_start_datetime TIMESTAMP,
|
||||||
|
drug_exposure_end_date TIMESTAMP,
|
||||||
|
drug_exposure_end_datetime TIMESTAMP,
|
||||||
|
verbatim_end_date TIMESTAMP,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason VARCHAR(20),
|
||||||
|
refills integer NULL,
|
||||||
|
quantity FLOAT,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig VARCHAR(MAX),
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number VARCHAR(50),
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value VARCHAR(50),
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value VARCHAR(50),
|
||||||
|
dose_unit_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
procedure_datetime TIMESTAMP,
|
||||||
|
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),
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
device_exposure_start_datetime TIMESTAMP,
|
||||||
|
device_exposure_end_date TIMESTAMP,
|
||||||
|
device_exposure_end_datetime TIMESTAMP,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id VARCHAR(50),
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
measurement_datetime TIMESTAMP,
|
||||||
|
measurement_time VARCHAR(10),
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number FLOAT,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low FLOAT,
|
||||||
|
range_high FLOAT,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value VARCHAR(50),
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
value_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
observation_datetime TIMESTAMP,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number FLOAT,
|
||||||
|
value_as_string VARCHAR(60),
|
||||||
|
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),
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
qualifier_source_value VARCHAR(50) );
|
||||||
|
--HINT DISTRIBUTE ON KEY (person_id)
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DEATH (
|
||||||
|
person_id integer NOT NULL,
|
||||||
|
death_date TIMESTAMP,
|
||||||
|
death_datetime TIMESTAMP,
|
||||||
|
death_type_concept_id integer NULL,
|
||||||
|
cause_concept_id integer NULL,
|
||||||
|
cause_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
note_datetime TIMESTAMP,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title VARCHAR(250),
|
||||||
|
note_text VARCHAR(MAX),
|
||||||
|
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) );
|
||||||
|
--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),
|
||||||
|
"offset" VARCHAR(50),
|
||||||
|
lexical_variant VARCHAR(250),
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system VARCHAR(250),
|
||||||
|
nlp_date TIMESTAMP,
|
||||||
|
nlp_datetime TIMESTAMP,
|
||||||
|
term_exists VARCHAR(1),
|
||||||
|
term_temporal VARCHAR(50),
|
||||||
|
term_modifiers VARCHAR(2000) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
specimen_datetime TIMESTAMP,
|
||||||
|
quantity FLOAT,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id VARCHAR(50),
|
||||||
|
specimen_source_value VARCHAR(50),
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
anatomic_site_source_value VARCHAR(50),
|
||||||
|
disease_status_source_value VARCHAR(50) );
|
||||||
|
--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),
|
||||||
|
address_2 VARCHAR(50),
|
||||||
|
city VARCHAR(50),
|
||||||
|
state VARCHAR(2),
|
||||||
|
zip VARCHAR(9),
|
||||||
|
county VARCHAR(20),
|
||||||
|
location_source_value VARCHAR(50) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name VARCHAR(255),
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value VARCHAR(50),
|
||||||
|
place_of_service_source_value VARCHAR(50) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name VARCHAR(255),
|
||||||
|
npi VARCHAR(20),
|
||||||
|
dea VARCHAR(20),
|
||||||
|
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),
|
||||||
|
specialty_source_value VARCHAR(50),
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
payer_plan_period_end_date TIMESTAMP,
|
||||||
|
payer_concept_id integer NULL,
|
||||||
|
payer_source_value VARCHAR(50),
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value VARCHAR(50),
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value VARCHAR(50),
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value VARCHAR(50),
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value VARCHAR(50),
|
||||||
|
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),
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge FLOAT,
|
||||||
|
total_cost FLOAT,
|
||||||
|
total_paid FLOAT,
|
||||||
|
paid_by_payer FLOAT,
|
||||||
|
paid_by_patient FLOAT,
|
||||||
|
paid_patient_copay FLOAT,
|
||||||
|
paid_patient_coinsurance FLOAT,
|
||||||
|
paid_patient_deductible FLOAT,
|
||||||
|
paid_by_primary FLOAT,
|
||||||
|
paid_ingredient_cost FLOAT,
|
||||||
|
paid_dispensing_fee FLOAT,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed FLOAT,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value VARCHAR(50),
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value VARCHAR(3) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
drug_era_end_date TIMESTAMP,
|
||||||
|
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,
|
||||||
|
dose_era_start_date TIMESTAMP,
|
||||||
|
dose_era_end_date TIMESTAMP );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
condition_era_end_date TIMESTAMP,
|
||||||
|
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),
|
||||||
|
value_as_string VARCHAR(250),
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
metadata_date TIMESTAMP,
|
||||||
|
metadata_datetime TIMESTAMP );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CDM_SOURCE (
|
||||||
|
cdm_source_name VARCHAR(255),
|
||||||
|
cdm_source_abbreviation VARCHAR(25),
|
||||||
|
cdm_holder VARCHAR(255),
|
||||||
|
source_description VARCHAR(MAX),
|
||||||
|
source_documentation_reference VARCHAR(255),
|
||||||
|
cdm_etl_reference VARCHAR(255),
|
||||||
|
source_release_date TIMESTAMP,
|
||||||
|
cdm_release_date TIMESTAMP,
|
||||||
|
cdm_version VARCHAR(10),
|
||||||
|
vocabulary_version VARCHAR(20) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name VARCHAR(255),
|
||||||
|
domain_id VARCHAR(20),
|
||||||
|
vocabulary_id VARCHAR(20),
|
||||||
|
concept_class_id VARCHAR(20),
|
||||||
|
standard_concept VARCHAR(1),
|
||||||
|
concept_code VARCHAR(50),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id VARCHAR(20),
|
||||||
|
vocabulary_name VARCHAR(255),
|
||||||
|
vocabulary_reference VARCHAR(255),
|
||||||
|
vocabulary_version VARCHAR(255),
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id VARCHAR(20),
|
||||||
|
domain_name VARCHAR(255),
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id VARCHAR(20),
|
||||||
|
concept_class_name VARCHAR(255),
|
||||||
|
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),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id VARCHAR(20),
|
||||||
|
relationship_name VARCHAR(255),
|
||||||
|
is_hierarchical VARCHAR(1),
|
||||||
|
defines_ancestry VARCHAR(1),
|
||||||
|
reverse_relationship_id VARCHAR(20),
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id VARCHAR(20),
|
||||||
|
source_code_description VARCHAR(255),
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id VARCHAR(20),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value FLOAT,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value FLOAT,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value FLOAT,
|
||||||
|
denominator_unit_concept_id integer NULL,
|
||||||
|
box_size integer NULL,
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
cohort_definition_name VARCHAR(255),
|
||||||
|
cohort_definition_description VARCHAR(MAX),
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax VARCHAR(MAX),
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date TIMESTAMP );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
|
||||||
|
attribute_definition_id integer NOT NULL,
|
||||||
|
attribute_name VARCHAR(255),
|
||||||
|
attribute_description VARCHAR(MAX),
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax VARCHAR(MAX) );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*hive 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
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
--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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--hive CDM Primary Key Constraints for OMOP Common Data Model 5.3
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PERSON ADD CONSTRAINT xpk_PERSON PRIMARY KEY NONCLUSTERED (person_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION_PERIOD ADD CONSTRAINT xpk_OBSERVATION_PERIOD PRIMARY KEY NONCLUSTERED (observation_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT xpk_VISIT_OCCURRENCE PRIMARY KEY NONCLUSTERED (visit_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT xpk_VISIT_DETAIL PRIMARY KEY NONCLUSTERED (visit_detail_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_OCCURRENCE ADD CONSTRAINT xpk_CONDITION_OCCURRENCE PRIMARY KEY NONCLUSTERED (condition_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_EXPOSURE ADD CONSTRAINT xpk_DRUG_EXPOSURE PRIMARY KEY NONCLUSTERED (drug_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROCEDURE_OCCURRENCE ADD CONSTRAINT xpk_PROCEDURE_OCCURRENCE PRIMARY KEY NONCLUSTERED (procedure_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DEVICE_EXPOSURE ADD CONSTRAINT xpk_DEVICE_EXPOSURE PRIMARY KEY NONCLUSTERED (device_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT xpk_MEASUREMENT PRIMARY KEY NONCLUSTERED (measurement_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT xpk_OBSERVATION PRIMARY KEY NONCLUSTERED (observation_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT xpk_NOTE PRIMARY KEY NONCLUSTERED (note_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE_NLP ADD CONSTRAINT xpk_NOTE_NLP PRIMARY KEY NONCLUSTERED (note_nlp_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.SPECIMEN ADD CONSTRAINT xpk_SPECIMEN PRIMARY KEY NONCLUSTERED (specimen_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.LOCATION ADD CONSTRAINT xpk_LOCATION PRIMARY KEY NONCLUSTERED (location_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CARE_SITE ADD CONSTRAINT xpk_CARE_SITE PRIMARY KEY NONCLUSTERED (care_site_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROVIDER ADD CONSTRAINT xpk_PROVIDER PRIMARY KEY NONCLUSTERED (provider_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PAYER_PLAN_PERIOD ADD CONSTRAINT xpk_PAYER_PLAN_PERIOD PRIMARY KEY NONCLUSTERED (payer_plan_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.COST ADD CONSTRAINT xpk_COST PRIMARY KEY NONCLUSTERED (cost_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_ERA ADD CONSTRAINT xpk_DRUG_ERA PRIMARY KEY NONCLUSTERED (drug_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY NONCLUSTERED (dose_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOMAIN ADD CONSTRAINT xpk_DOMAIN PRIMARY KEY NONCLUSTERED (domain_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT_CLASS ADD CONSTRAINT xpk_CONCEPT_CLASS PRIMARY KEY NONCLUSTERED (concept_class_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.RELATIONSHIP ADD CONSTRAINT xpk_RELATIONSHIP PRIMARY KEY NONCLUSTERED (relationship_id);
|
|
@ -0,0 +1,158 @@
|
||||||
|
--snowflake 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--snowflake 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 TIMESTAMP NULL,
|
||||||
|
race_concept_id integer NOT NULL,
|
||||||
|
ethnicity_concept_id integer NOT NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
person_source_value varchar(50) NULL,
|
||||||
|
gender_source_value varchar(50) NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value varchar(50) NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value varchar(50) NULL,
|
||||||
|
ethnicity_source_concept_id integer NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
visit_end_date date NOT NULL,
|
||||||
|
visit_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
visit_detail_end_date date NOT NULL,
|
||||||
|
visit_detail_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
condition_end_date date NULL,
|
||||||
|
condition_end_datetime TIMESTAMP NULL,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason varchar(20) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value varchar(50) NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
drug_exposure_end_date date NOT NULL,
|
||||||
|
drug_exposure_end_datetime TIMESTAMP 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 TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number varchar(50) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value varchar(50) NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value varchar(50) NULL,
|
||||||
|
dose_unit_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
device_exposure_end_date date NULL,
|
||||||
|
device_exposure_end_datetime TIMESTAMP NULL,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id varchar(50) NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value varchar(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 TIMESTAMP 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 TIMESTAMP 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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title varchar(250) NULL,
|
||||||
|
note_text TEXT 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 TIMESTAMP 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 TIMESTAMP 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 TIMESTAMP 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 TEXT NULL,
|
||||||
|
source_documentation_reference varchar(255) NULL,
|
||||||
|
cdm_etl_reference varchar(255) NULL,
|
||||||
|
source_release_date date NULL,
|
||||||
|
cdm_release_date date NULL,
|
||||||
|
cdm_version varchar(10) NULL,
|
||||||
|
vocabulary_version varchar(20) NULL );
|
||||||
|
--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 TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
|
||||||
|
attribute_definition_id integer NOT NULL,
|
||||||
|
attribute_name varchar(255) NOT NULL,
|
||||||
|
attribute_description TEXT NULL,
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax TEXT NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*snowflake 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
|
||||||
|
************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
-- snowflake does not support indexes
|
||||||
|
--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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--snowflake 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);
|
|
@ -0,0 +1,158 @@
|
||||||
|
--sqlite 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--sqlite 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 REAL 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 TEXT NULL,
|
||||||
|
gender_source_value TEXT NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value TEXT NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value TEXT 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 REAL NULL,
|
||||||
|
visit_end_date date NOT NULL,
|
||||||
|
visit_end_datetime REAL NULL,
|
||||||
|
visit_type_concept_id Integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_source_value TEXT NULL,
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitting_source_concept_id integer NULL,
|
||||||
|
admitting_source_value TEXT NULL,
|
||||||
|
discharge_to_concept_id integer NULL,
|
||||||
|
discharge_to_source_value TEXT 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 REAL NULL,
|
||||||
|
visit_detail_end_date date NOT NULL,
|
||||||
|
visit_detail_end_datetime REAL NULL,
|
||||||
|
visit_detail_type_concept_id integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_detail_source_value TEXT NULL,
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitting_source_value TEXT NULL,
|
||||||
|
admitting_source_concept_id Integer NULL,
|
||||||
|
discharge_to_source_value TEXT 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 REAL NULL,
|
||||||
|
condition_end_date date NULL,
|
||||||
|
condition_end_datetime REAL NULL,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value TEXT NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value TEXT 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 REAL NULL,
|
||||||
|
drug_exposure_end_date date NOT NULL,
|
||||||
|
drug_exposure_end_datetime REAL NULL,
|
||||||
|
verbatim_end_date date NULL,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason TEXT NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value TEXT NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value TEXT NULL,
|
||||||
|
dose_unit_source_value TEXT 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 REAL 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 TEXT NULL,
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value TEXT 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 REAL NULL,
|
||||||
|
device_exposure_end_date date NULL,
|
||||||
|
device_exposure_end_datetime REAL NULL,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id TEXT NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value TEXT 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 REAL NULL,
|
||||||
|
measurement_time TEXT NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low REAL NULL,
|
||||||
|
range_high REAL NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value TEXT NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
value_source_value TEXT 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 REAL NULL,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_string TEXT 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 TEXT NULL,
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
qualifier_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON KEY (person_id)
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DEATH (
|
||||||
|
person_id integer NOT NULL,
|
||||||
|
death_date date NOT NULL,
|
||||||
|
death_datetime REAL NULL,
|
||||||
|
death_type_concept_id integer NULL,
|
||||||
|
cause_concept_id integer NULL,
|
||||||
|
cause_source_value TEXT 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 REAL NULL,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title TEXT NULL,
|
||||||
|
note_text TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
"offset" TEXT NULL,
|
||||||
|
lexical_variant TEXT NOT NULL,
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system TEXT NULL,
|
||||||
|
nlp_date date NOT NULL,
|
||||||
|
nlp_datetime REAL NULL,
|
||||||
|
term_exists TEXT NULL,
|
||||||
|
term_temporal TEXT NULL,
|
||||||
|
term_modifiers TEXT 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 REAL NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id TEXT NULL,
|
||||||
|
specimen_source_value TEXT NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
anatomic_site_source_value TEXT NULL,
|
||||||
|
disease_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
address_2 TEXT NULL,
|
||||||
|
city TEXT NULL,
|
||||||
|
state TEXT NULL,
|
||||||
|
zip TEXT NULL,
|
||||||
|
county TEXT NULL,
|
||||||
|
location_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name TEXT NULL,
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value TEXT NULL,
|
||||||
|
place_of_service_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name TEXT NULL,
|
||||||
|
npi TEXT NULL,
|
||||||
|
dea TEXT NULL,
|
||||||
|
specialty_concept_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
year_of_birth integer NULL,
|
||||||
|
gender_concept_id integer NULL,
|
||||||
|
provider_source_value TEXT NULL,
|
||||||
|
specialty_source_value TEXT NULL,
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value TEXT 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 TEXT NULL,
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value TEXT NULL,
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value TEXT NULL,
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value TEXT NULL,
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value TEXT 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 TEXT NOT NULL,
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge REAL NULL,
|
||||||
|
total_cost REAL NULL,
|
||||||
|
total_paid REAL NULL,
|
||||||
|
paid_by_payer REAL NULL,
|
||||||
|
paid_by_patient REAL NULL,
|
||||||
|
paid_patient_copay REAL NULL,
|
||||||
|
paid_patient_coinsurance REAL NULL,
|
||||||
|
paid_patient_deductible REAL NULL,
|
||||||
|
paid_by_primary REAL NULL,
|
||||||
|
paid_ingredient_cost REAL NULL,
|
||||||
|
paid_dispensing_fee REAL NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed REAL NULL,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value TEXT NULL,
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value TEXT 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 REAL 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 TEXT NOT NULL,
|
||||||
|
value_as_string TEXT NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
metadata_date date NULL,
|
||||||
|
metadata_datetime REAL NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CDM_SOURCE (
|
||||||
|
cdm_source_name TEXT NOT NULL,
|
||||||
|
cdm_source_abbreviation TEXT NULL,
|
||||||
|
cdm_holder TEXT NULL,
|
||||||
|
source_description TEXT NULL,
|
||||||
|
source_documentation_reference TEXT NULL,
|
||||||
|
cdm_etl_reference TEXT NULL,
|
||||||
|
source_release_date date NULL,
|
||||||
|
cdm_release_date date NULL,
|
||||||
|
cdm_version TEXT NULL,
|
||||||
|
vocabulary_version TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name TEXT NOT NULL,
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
standard_concept TEXT NULL,
|
||||||
|
concept_code TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
vocabulary_name TEXT NOT NULL,
|
||||||
|
vocabulary_reference TEXT NOT NULL,
|
||||||
|
vocabulary_version TEXT NULL,
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
domain_name TEXT NOT NULL,
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
concept_class_name TEXT 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 TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id TEXT NOT NULL,
|
||||||
|
relationship_name TEXT NOT NULL,
|
||||||
|
is_hierarchical TEXT NOT NULL,
|
||||||
|
defines_ancestry TEXT NOT NULL,
|
||||||
|
reverse_relationship_id TEXT 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id TEXT NOT NULL,
|
||||||
|
source_code_description TEXT NULL,
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value REAL NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value REAL NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value REAL 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 TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
cohort_definition_name TEXT NOT NULL,
|
||||||
|
cohort_definition_description TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
|
||||||
|
attribute_definition_id integer NOT NULL,
|
||||||
|
attribute_name TEXT NOT NULL,
|
||||||
|
attribute_description TEXT NULL,
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax TEXT NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*sqlite 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 person (person_id ASC);
|
||||||
|
CREATE INDEX idx_gender ON person (gender_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_period_id_1 ON observation_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_person_id_1 ON visit_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_concept_id_1 ON visit_occurrence (visit_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_person_id_1 ON visit_detail (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_concept_id_1 ON visit_detail (visit_detail_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_occ_id ON visit_detail (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_condition_person_id_1 ON condition_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_concept_id_1 ON condition_occurrence (condition_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_visit_id_1 ON condition_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_drug_person_id_1 ON drug_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_concept_id_1 ON drug_exposure (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_visit_id_1 ON drug_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_person_id_1 ON procedure_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_concept_id_1 ON procedure_occurrence (procedure_concept_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_visit_id_1 ON procedure_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_device_person_id_1 ON device_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_device_concept_id_1 ON device_exposure (device_concept_id ASC);
|
||||||
|
CREATE INDEX idx_device_visit_id_1 ON device_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_person_id_1 ON measurement (person_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_concept_id_1 ON measurement (measurement_concept_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_visit_id_1 ON measurement (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_observation_person_id_1 ON observation (person_id ASC);
|
||||||
|
CREATE INDEX idx_observation_concept_id_1 ON observation (observation_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_visit_id_1 ON observation (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_death_person_id_1 ON death (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_person_id_1 ON note (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_concept_id_1 ON note (note_type_concept_id ASC);
|
||||||
|
CREATE INDEX idx_note_visit_id_1 ON note (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_note_id_1 ON note_nlp (note_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_concept_id_1 ON note_nlp (note_nlp_concept_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_person_id_1 ON specimen (person_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_concept_id_1 ON specimen (specimen_concept_id ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id1 ON fact_relationship (domain_concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id2 ON fact_relationship (domain_concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id3 ON fact_relationship (relationship_concept_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_location_id_1 ON location (location_id ASC);
|
||||||
|
CREATE INDEX idx_care_site_id_1 ON care_site (care_site_id ASC);
|
||||||
|
CREATE INDEX idx_provider_id_1 ON provider (provider_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_period_person_id_1 ON payer_plan_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_cost_event_id ON cost (cost_event_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_drug_era_person_id_1 ON drug_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_era_concept_id_1 ON drug_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_person_id_1 ON dose_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_concept_id_1 ON dose_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_person_id_1 ON condition_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_concept_id_1 ON condition_era (condition_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_metadata_concept_id_1 ON metadata (metadata_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_concept_concept_id ON concept (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
|
||||||
|
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_domain_domain_id ON domain (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_3 ON source_to_concept_map (target_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_1 ON source_to_concept_map (source_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_2 ON source_to_concept_map (target_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_c ON source_to_concept_map (source_code ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
|
||||||
|
--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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--sqlite 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);
|
|
@ -0,0 +1,158 @@
|
||||||
|
--sqlite extended 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--sqlite extended 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 TEXT NULL,
|
||||||
|
gender_source_value TEXT NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value TEXT NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value TEXT 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 TEXT NULL,
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitting_source_concept_id integer NULL,
|
||||||
|
admitting_source_value TEXT NULL,
|
||||||
|
discharge_to_concept_id integer NULL,
|
||||||
|
discharge_to_source_value TEXT 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 TEXT NULL,
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitting_source_value TEXT NULL,
|
||||||
|
admitting_source_concept_id Integer NULL,
|
||||||
|
discharge_to_source_value TEXT 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 TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value TEXT NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value TEXT NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value TEXT NULL,
|
||||||
|
dose_unit_source_value TEXT 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 TEXT NULL,
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value TEXT 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 TEXT NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value TEXT 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 TEXT NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low REAL NULL,
|
||||||
|
range_high REAL NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value TEXT NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
value_source_value TEXT 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 REAL NULL,
|
||||||
|
value_as_string TEXT 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 TEXT NULL,
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
qualifier_source_value TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
note_text TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
"offset" TEXT NULL,
|
||||||
|
lexical_variant TEXT NOT NULL,
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system TEXT NULL,
|
||||||
|
nlp_date date NOT NULL,
|
||||||
|
nlp_datetime datetime NULL,
|
||||||
|
term_exists TEXT NULL,
|
||||||
|
term_temporal TEXT NULL,
|
||||||
|
term_modifiers TEXT 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 REAL NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id TEXT NULL,
|
||||||
|
specimen_source_value TEXT NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
anatomic_site_source_value TEXT NULL,
|
||||||
|
disease_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
address_2 TEXT NULL,
|
||||||
|
city TEXT NULL,
|
||||||
|
state TEXT NULL,
|
||||||
|
zip TEXT NULL,
|
||||||
|
county TEXT NULL,
|
||||||
|
location_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name TEXT NULL,
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value TEXT NULL,
|
||||||
|
place_of_service_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name TEXT NULL,
|
||||||
|
npi TEXT NULL,
|
||||||
|
dea TEXT NULL,
|
||||||
|
specialty_concept_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
year_of_birth integer NULL,
|
||||||
|
gender_concept_id integer NULL,
|
||||||
|
provider_source_value TEXT NULL,
|
||||||
|
specialty_source_value TEXT NULL,
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value TEXT 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 TEXT NULL,
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value TEXT NULL,
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value TEXT NULL,
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value TEXT NULL,
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value TEXT 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 TEXT NOT NULL,
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge REAL NULL,
|
||||||
|
total_cost REAL NULL,
|
||||||
|
total_paid REAL NULL,
|
||||||
|
paid_by_payer REAL NULL,
|
||||||
|
paid_by_patient REAL NULL,
|
||||||
|
paid_patient_copay REAL NULL,
|
||||||
|
paid_patient_coinsurance REAL NULL,
|
||||||
|
paid_patient_deductible REAL NULL,
|
||||||
|
paid_by_primary REAL NULL,
|
||||||
|
paid_ingredient_cost REAL NULL,
|
||||||
|
paid_dispensing_fee REAL NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed REAL NULL,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value TEXT NULL,
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value TEXT 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 REAL 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 TEXT NOT NULL,
|
||||||
|
value_as_string TEXT 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 TEXT NOT NULL,
|
||||||
|
cdm_source_abbreviation TEXT NULL,
|
||||||
|
cdm_holder TEXT NULL,
|
||||||
|
source_description TEXT NULL,
|
||||||
|
source_documentation_reference TEXT NULL,
|
||||||
|
cdm_etl_reference TEXT NULL,
|
||||||
|
source_release_date date NULL,
|
||||||
|
cdm_release_date date NULL,
|
||||||
|
cdm_version TEXT NULL,
|
||||||
|
vocabulary_version TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name TEXT NOT NULL,
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
standard_concept TEXT NULL,
|
||||||
|
concept_code TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
vocabulary_name TEXT NOT NULL,
|
||||||
|
vocabulary_reference TEXT NOT NULL,
|
||||||
|
vocabulary_version TEXT NULL,
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
domain_name TEXT NOT NULL,
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
concept_class_name TEXT 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 TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id TEXT NOT NULL,
|
||||||
|
relationship_name TEXT NOT NULL,
|
||||||
|
is_hierarchical TEXT NOT NULL,
|
||||||
|
defines_ancestry TEXT NOT NULL,
|
||||||
|
reverse_relationship_id TEXT 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id TEXT NOT NULL,
|
||||||
|
source_code_description TEXT NULL,
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value REAL NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value REAL NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value REAL 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 TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
cohort_definition_name TEXT NOT NULL,
|
||||||
|
cohort_definition_description TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.ATTRIBUTE_DEFINITION (
|
||||||
|
attribute_definition_id integer NOT NULL,
|
||||||
|
attribute_name TEXT NOT NULL,
|
||||||
|
attribute_description TEXT NULL,
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax TEXT NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*sqlite extended 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 person (person_id ASC);
|
||||||
|
CREATE INDEX idx_gender ON person (gender_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_period_id_1 ON observation_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_person_id_1 ON visit_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_concept_id_1 ON visit_occurrence (visit_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_person_id_1 ON visit_detail (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_concept_id_1 ON visit_detail (visit_detail_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_occ_id ON visit_detail (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_condition_person_id_1 ON condition_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_concept_id_1 ON condition_occurrence (condition_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_visit_id_1 ON condition_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_drug_person_id_1 ON drug_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_concept_id_1 ON drug_exposure (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_visit_id_1 ON drug_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_person_id_1 ON procedure_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_concept_id_1 ON procedure_occurrence (procedure_concept_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_visit_id_1 ON procedure_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_device_person_id_1 ON device_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_device_concept_id_1 ON device_exposure (device_concept_id ASC);
|
||||||
|
CREATE INDEX idx_device_visit_id_1 ON device_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_person_id_1 ON measurement (person_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_concept_id_1 ON measurement (measurement_concept_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_visit_id_1 ON measurement (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_observation_person_id_1 ON observation (person_id ASC);
|
||||||
|
CREATE INDEX idx_observation_concept_id_1 ON observation (observation_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_visit_id_1 ON observation (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_death_person_id_1 ON death (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_person_id_1 ON note (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_concept_id_1 ON note (note_type_concept_id ASC);
|
||||||
|
CREATE INDEX idx_note_visit_id_1 ON note (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_note_id_1 ON note_nlp (note_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_concept_id_1 ON note_nlp (note_nlp_concept_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_person_id_1 ON specimen (person_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_concept_id_1 ON specimen (specimen_concept_id ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id1 ON fact_relationship (domain_concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id2 ON fact_relationship (domain_concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id3 ON fact_relationship (relationship_concept_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_location_id_1 ON location (location_id ASC);
|
||||||
|
CREATE INDEX idx_care_site_id_1 ON care_site (care_site_id ASC);
|
||||||
|
CREATE INDEX idx_provider_id_1 ON provider (provider_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_period_person_id_1 ON payer_plan_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_cost_event_id ON cost (cost_event_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_drug_era_person_id_1 ON drug_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_era_concept_id_1 ON drug_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_person_id_1 ON dose_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_concept_id_1 ON dose_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_person_id_1 ON condition_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_concept_id_1 ON condition_era (condition_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_metadata_concept_id_1 ON metadata (metadata_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_concept_concept_id ON concept (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
|
||||||
|
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_domain_domain_id ON domain (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_3 ON source_to_concept_map (target_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_1 ON source_to_concept_map (source_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_2 ON source_to_concept_map (target_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_c ON source_to_concept_map (source_code ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
|
||||||
|
--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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--sqlite extended 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);
|
|
@ -0,0 +1,158 @@
|
||||||
|
--synapse 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);
|
|
@ -0,0 +1,471 @@
|
||||||
|
--synapse 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(8000) 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(8000) 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(8000) 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(8000) NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax VARCHAR(8000) 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(8000) NULL,
|
||||||
|
attribute_type_concept_id integer NOT NULL,
|
||||||
|
attribute_syntax VARCHAR(8000) NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*synapse 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 CLUSTERED INDEX idx_person_id ON @cdmDatabaseSchema.person (person_id ASC);
|
||||||
|
CREATE INDEX idx_gender ON @cdmDatabaseSchema.person (gender_concept_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_observation_period_id_1 ON @cdmDatabaseSchema.observation_period (person_id ASC);
|
||||||
|
CREATE CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED INDEX idx_death_person_id_1 ON @cdmDatabaseSchema.death (person_id ASC);
|
||||||
|
CREATE CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED INDEX idx_location_id_1 ON @cdmDatabaseSchema.location (location_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_care_site_id_1 ON @cdmDatabaseSchema.care_site (care_site_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_provider_id_1 ON @cdmDatabaseSchema.provider (provider_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
CREATE CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED 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 CLUSTERED INDEX idx_metadata_concept_id_1 ON @cdmDatabaseSchema.metadata (metadata_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
CREATE CLUSTERED 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_vocabluary_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 CLUSTERED INDEX idx_vocabulary_vocabulary_id ON @cdmDatabaseSchema.vocabulary (vocabulary_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_domain_domain_id ON @cdmDatabaseSchema.domain (domain_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_concept_class_class_id ON @cdmDatabaseSchema.concept_class (concept_class_id ASC);
|
||||||
|
CREATE CLUSTERED 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 CLUSTERED INDEX idx_relationship_rel_id ON @cdmDatabaseSchema.relationship (relationship_id ASC);
|
||||||
|
CREATE CLUSTERED INDEX idx_concept_synonym_id ON @cdmDatabaseSchema.concept_synonym (concept_id ASC);
|
||||||
|
CREATE CLUSTERED 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 CLUSTERED 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 CLUSTERED 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);
|
|
@ -0,0 +1,27 @@
|
||||||
|
--synapse CDM Primary Key Constraints for OMOP Common Data Model 5.3
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PERSON ADD CONSTRAINT xpk_PERSON PRIMARY KEY NONCLUSTERED (person_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION_PERIOD ADD CONSTRAINT xpk_OBSERVATION_PERIOD PRIMARY KEY NONCLUSTERED (observation_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT xpk_VISIT_OCCURRENCE PRIMARY KEY NONCLUSTERED (visit_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT xpk_VISIT_DETAIL PRIMARY KEY NONCLUSTERED (visit_detail_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_OCCURRENCE ADD CONSTRAINT xpk_CONDITION_OCCURRENCE PRIMARY KEY NONCLUSTERED (condition_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_EXPOSURE ADD CONSTRAINT xpk_DRUG_EXPOSURE PRIMARY KEY NONCLUSTERED (drug_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROCEDURE_OCCURRENCE ADD CONSTRAINT xpk_PROCEDURE_OCCURRENCE PRIMARY KEY NONCLUSTERED (procedure_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DEVICE_EXPOSURE ADD CONSTRAINT xpk_DEVICE_EXPOSURE PRIMARY KEY NONCLUSTERED (device_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT xpk_MEASUREMENT PRIMARY KEY NONCLUSTERED (measurement_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT xpk_OBSERVATION PRIMARY KEY NONCLUSTERED (observation_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT xpk_NOTE PRIMARY KEY NONCLUSTERED (note_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE_NLP ADD CONSTRAINT xpk_NOTE_NLP PRIMARY KEY NONCLUSTERED (note_nlp_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.SPECIMEN ADD CONSTRAINT xpk_SPECIMEN PRIMARY KEY NONCLUSTERED (specimen_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.LOCATION ADD CONSTRAINT xpk_LOCATION PRIMARY KEY NONCLUSTERED (location_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CARE_SITE ADD CONSTRAINT xpk_CARE_SITE PRIMARY KEY NONCLUSTERED (care_site_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROVIDER ADD CONSTRAINT xpk_PROVIDER PRIMARY KEY NONCLUSTERED (provider_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PAYER_PLAN_PERIOD ADD CONSTRAINT xpk_PAYER_PLAN_PERIOD PRIMARY KEY NONCLUSTERED (payer_plan_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.COST ADD CONSTRAINT xpk_COST PRIMARY KEY NONCLUSTERED (cost_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_ERA ADD CONSTRAINT xpk_DRUG_ERA PRIMARY KEY NONCLUSTERED (drug_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY NONCLUSTERED (dose_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOMAIN ADD CONSTRAINT xpk_DOMAIN PRIMARY KEY NONCLUSTERED (domain_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT_CLASS ADD CONSTRAINT xpk_CONCEPT_CLASS PRIMARY KEY NONCLUSTERED (concept_class_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.RELATIONSHIP ADD CONSTRAINT xpk_RELATIONSHIP PRIMARY KEY NONCLUSTERED (relationship_id);
|
|
@ -0,0 +1,177 @@
|
||||||
|
--duckdb 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);
|
|
@ -0,0 +1,511 @@
|
||||||
|
--duckdb 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 TIMESTAMP NULL,
|
||||||
|
race_concept_id integer NOT NULL,
|
||||||
|
ethnicity_concept_id integer NOT NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
person_source_value varchar(50) NULL,
|
||||||
|
gender_source_value varchar(50) NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value varchar(50) NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value varchar(50) NULL,
|
||||||
|
ethnicity_source_concept_id integer NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
visit_end_date date NOT NULL,
|
||||||
|
visit_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
visit_detail_end_date date NOT NULL,
|
||||||
|
visit_detail_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
condition_end_date date NULL,
|
||||||
|
condition_end_datetime TIMESTAMP NULL,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason varchar(20) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value varchar(50) NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
drug_exposure_end_date date NOT NULL,
|
||||||
|
drug_exposure_end_datetime TIMESTAMP NULL,
|
||||||
|
verbatim_end_date date NULL,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason varchar(20) NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity NUMERIC NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number varchar(50) NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value varchar(50) NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value varchar(50) NULL,
|
||||||
|
dose_unit_source_value varchar(50) NULL );
|
||||||
|
--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 TIMESTAMP NULL,
|
||||||
|
procedure_end_date date NULL,
|
||||||
|
procedure_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
device_exposure_end_date date NULL,
|
||||||
|
device_exposure_end_datetime TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
measurement_time varchar(10) NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number NUMERIC NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low NUMERIC NULL,
|
||||||
|
range_high NUMERIC NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value varchar(50) NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value varchar(50) NULL,
|
||||||
|
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 TIMESTAMP NULL,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number NUMERIC NULL,
|
||||||
|
value_as_string varchar(60) NULL,
|
||||||
|
value_as_concept_id Integer NULL,
|
||||||
|
qualifier_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id 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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title varchar(250) NULL,
|
||||||
|
note_text TEXT 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 TIMESTAMP 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 TIMESTAMP NULL,
|
||||||
|
quantity NUMERIC NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id varchar(50) NULL,
|
||||||
|
specimen_source_value varchar(50) NULL,
|
||||||
|
unit_source_value varchar(50) NULL,
|
||||||
|
anatomic_site_source_value varchar(50) NULL,
|
||||||
|
disease_status_source_value varchar(50) NULL );
|
||||||
|
--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 NUMERIC NULL,
|
||||||
|
longitude NUMERIC 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 NUMERIC NULL,
|
||||||
|
total_cost NUMERIC NULL,
|
||||||
|
total_paid NUMERIC NULL,
|
||||||
|
paid_by_payer NUMERIC NULL,
|
||||||
|
paid_by_patient NUMERIC NULL,
|
||||||
|
paid_patient_copay NUMERIC NULL,
|
||||||
|
paid_patient_coinsurance NUMERIC NULL,
|
||||||
|
paid_patient_deductible NUMERIC NULL,
|
||||||
|
paid_by_primary NUMERIC NULL,
|
||||||
|
paid_ingredient_cost NUMERIC NULL,
|
||||||
|
paid_dispensing_fee NUMERIC NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed NUMERIC 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 NUMERIC 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 TIMESTAMP NULL,
|
||||||
|
episode_end_date date NULL,
|
||||||
|
episode_end_datetime TIMESTAMP 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 NUMERIC NULL,
|
||||||
|
metadata_date date NULL,
|
||||||
|
metadata_datetime TIMESTAMP 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 TEXT 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 NUMERIC NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value NUMERIC NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value NUMERIC NULL,
|
||||||
|
denominator_unit_concept_id integer NULL,
|
||||||
|
box_size integer NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason varchar(1) NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @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 TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*duckdb 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_vocabluary_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);
|
|
@ -0,0 +1,29 @@
|
||||||
|
--duckdb 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);
|
|
@ -0,0 +1,177 @@
|
||||||
|
--hive 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);
|
|
@ -0,0 +1,511 @@
|
||||||
|
--hive 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 TIMESTAMP,
|
||||||
|
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),
|
||||||
|
gender_source_value VARCHAR(50),
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value VARCHAR(50),
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
observation_period_end_date TIMESTAMP,
|
||||||
|
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 TIMESTAMP,
|
||||||
|
visit_start_datetime TIMESTAMP,
|
||||||
|
visit_end_date TIMESTAMP,
|
||||||
|
visit_end_datetime TIMESTAMP,
|
||||||
|
visit_type_concept_id Integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_source_value VARCHAR(50),
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitted_from_concept_id integer NULL,
|
||||||
|
admitted_from_source_value VARCHAR(50),
|
||||||
|
discharged_to_concept_id integer NULL,
|
||||||
|
discharged_to_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
visit_detail_start_datetime TIMESTAMP,
|
||||||
|
visit_detail_end_date TIMESTAMP,
|
||||||
|
visit_detail_end_datetime TIMESTAMP,
|
||||||
|
visit_detail_type_concept_id integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_detail_source_value VARCHAR(50),
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitted_from_concept_id Integer NULL,
|
||||||
|
admitted_from_source_value VARCHAR(50),
|
||||||
|
discharged_to_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
condition_start_datetime TIMESTAMP,
|
||||||
|
condition_end_date TIMESTAMP,
|
||||||
|
condition_end_datetime TIMESTAMP,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason VARCHAR(20),
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value VARCHAR(50),
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
drug_exposure_start_datetime TIMESTAMP,
|
||||||
|
drug_exposure_end_date TIMESTAMP,
|
||||||
|
drug_exposure_end_datetime TIMESTAMP,
|
||||||
|
verbatim_end_date TIMESTAMP,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason VARCHAR(20),
|
||||||
|
refills integer NULL,
|
||||||
|
quantity FLOAT,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig VARCHAR(MAX),
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number VARCHAR(50),
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value VARCHAR(50),
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value VARCHAR(50),
|
||||||
|
dose_unit_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
procedure_datetime TIMESTAMP,
|
||||||
|
procedure_end_date TIMESTAMP,
|
||||||
|
procedure_end_datetime TIMESTAMP,
|
||||||
|
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),
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value VARCHAR(50) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
device_exposure_start_datetime TIMESTAMP,
|
||||||
|
device_exposure_end_date TIMESTAMP,
|
||||||
|
device_exposure_end_datetime TIMESTAMP,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id VARCHAR(255),
|
||||||
|
production_id VARCHAR(255),
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value VARCHAR(50),
|
||||||
|
device_source_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
measurement_datetime TIMESTAMP,
|
||||||
|
measurement_time VARCHAR(10),
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number FLOAT,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low FLOAT,
|
||||||
|
range_high FLOAT,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value VARCHAR(50),
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
unit_source_concept_id integer NULL,
|
||||||
|
value_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
observation_datetime TIMESTAMP,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number FLOAT,
|
||||||
|
value_as_string VARCHAR(60),
|
||||||
|
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),
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
qualifier_source_value VARCHAR(50),
|
||||||
|
value_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
death_datetime TIMESTAMP,
|
||||||
|
death_type_concept_id integer NULL,
|
||||||
|
cause_concept_id integer NULL,
|
||||||
|
cause_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
note_datetime TIMESTAMP,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title VARCHAR(250),
|
||||||
|
note_text VARCHAR(MAX),
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
"offset" VARCHAR(50),
|
||||||
|
lexical_variant VARCHAR(250),
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system VARCHAR(250),
|
||||||
|
nlp_date TIMESTAMP,
|
||||||
|
nlp_datetime TIMESTAMP,
|
||||||
|
term_exists VARCHAR(1),
|
||||||
|
term_temporal VARCHAR(50),
|
||||||
|
term_modifiers VARCHAR(2000) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
specimen_datetime TIMESTAMP,
|
||||||
|
quantity FLOAT,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id VARCHAR(50),
|
||||||
|
specimen_source_value VARCHAR(50),
|
||||||
|
unit_source_value VARCHAR(50),
|
||||||
|
anatomic_site_source_value VARCHAR(50),
|
||||||
|
disease_status_source_value VARCHAR(50) );
|
||||||
|
--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),
|
||||||
|
address_2 VARCHAR(50),
|
||||||
|
city VARCHAR(50),
|
||||||
|
state VARCHAR(2),
|
||||||
|
zip VARCHAR(9),
|
||||||
|
county VARCHAR(20),
|
||||||
|
location_source_value VARCHAR(50),
|
||||||
|
country_concept_id integer NULL,
|
||||||
|
country_source_value VARCHAR(80),
|
||||||
|
latitude FLOAT,
|
||||||
|
longitude FLOAT );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name VARCHAR(255),
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value VARCHAR(50),
|
||||||
|
place_of_service_source_value VARCHAR(50) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name VARCHAR(255),
|
||||||
|
npi VARCHAR(20),
|
||||||
|
dea VARCHAR(20),
|
||||||
|
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),
|
||||||
|
specialty_source_value VARCHAR(50),
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value VARCHAR(50),
|
||||||
|
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 TIMESTAMP,
|
||||||
|
payer_plan_period_end_date TIMESTAMP,
|
||||||
|
payer_concept_id integer NULL,
|
||||||
|
payer_source_value VARCHAR(50),
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value VARCHAR(50),
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value VARCHAR(50),
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value VARCHAR(50),
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value VARCHAR(50),
|
||||||
|
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),
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge FLOAT,
|
||||||
|
total_cost FLOAT,
|
||||||
|
total_paid FLOAT,
|
||||||
|
paid_by_payer FLOAT,
|
||||||
|
paid_by_patient FLOAT,
|
||||||
|
paid_patient_copay FLOAT,
|
||||||
|
paid_patient_coinsurance FLOAT,
|
||||||
|
paid_patient_deductible FLOAT,
|
||||||
|
paid_by_primary FLOAT,
|
||||||
|
paid_ingredient_cost FLOAT,
|
||||||
|
paid_dispensing_fee FLOAT,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed FLOAT,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value VARCHAR(50),
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value VARCHAR(3) );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
drug_era_end_date TIMESTAMP,
|
||||||
|
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,
|
||||||
|
dose_era_start_date TIMESTAMP,
|
||||||
|
dose_era_end_date TIMESTAMP );
|
||||||
|
--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 TIMESTAMP,
|
||||||
|
condition_era_end_date TIMESTAMP,
|
||||||
|
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 TIMESTAMP,
|
||||||
|
episode_start_datetime TIMESTAMP,
|
||||||
|
episode_end_date TIMESTAMP,
|
||||||
|
episode_end_datetime TIMESTAMP,
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
value_as_string VARCHAR(250),
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
value_as_number FLOAT,
|
||||||
|
metadata_date TIMESTAMP,
|
||||||
|
metadata_datetime TIMESTAMP );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CDM_SOURCE (
|
||||||
|
cdm_source_name VARCHAR(255),
|
||||||
|
cdm_source_abbreviation VARCHAR(25),
|
||||||
|
cdm_holder VARCHAR(255),
|
||||||
|
source_description VARCHAR(MAX),
|
||||||
|
source_documentation_reference VARCHAR(255),
|
||||||
|
cdm_etl_reference VARCHAR(255),
|
||||||
|
source_release_date TIMESTAMP,
|
||||||
|
cdm_release_date TIMESTAMP,
|
||||||
|
cdm_version VARCHAR(10),
|
||||||
|
cdm_version_concept_id integer NOT NULL,
|
||||||
|
vocabulary_version VARCHAR(20) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name VARCHAR(255),
|
||||||
|
domain_id VARCHAR(20),
|
||||||
|
vocabulary_id VARCHAR(20),
|
||||||
|
concept_class_id VARCHAR(20),
|
||||||
|
standard_concept VARCHAR(1),
|
||||||
|
concept_code VARCHAR(50),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id VARCHAR(20),
|
||||||
|
vocabulary_name VARCHAR(255),
|
||||||
|
vocabulary_reference VARCHAR(255),
|
||||||
|
vocabulary_version VARCHAR(255),
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id VARCHAR(20),
|
||||||
|
domain_name VARCHAR(255),
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id VARCHAR(20),
|
||||||
|
concept_class_name VARCHAR(255),
|
||||||
|
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),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id VARCHAR(20),
|
||||||
|
relationship_name VARCHAR(255),
|
||||||
|
is_hierarchical VARCHAR(1),
|
||||||
|
defines_ancestry VARCHAR(1),
|
||||||
|
reverse_relationship_id VARCHAR(20),
|
||||||
|
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),
|
||||||
|
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),
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id VARCHAR(20),
|
||||||
|
source_code_description VARCHAR(255),
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id VARCHAR(20),
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value FLOAT,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value FLOAT,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value FLOAT,
|
||||||
|
denominator_unit_concept_id integer NULL,
|
||||||
|
box_size integer NULL,
|
||||||
|
valid_start_date TIMESTAMP,
|
||||||
|
valid_end_date TIMESTAMP,
|
||||||
|
invalid_reason VARCHAR(1) );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
subject_id integer NOT NULL,
|
||||||
|
cohort_start_date TIMESTAMP,
|
||||||
|
cohort_end_date TIMESTAMP );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.COHORT_DEFINITION (
|
||||||
|
cohort_definition_id integer NOT NULL,
|
||||||
|
cohort_definition_name VARCHAR(255),
|
||||||
|
cohort_definition_description VARCHAR(MAX),
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax VARCHAR(MAX),
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date TIMESTAMP );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*hive 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
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
-- hive does not support indexes
|
||||||
|
--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);
|
|
@ -0,0 +1,29 @@
|
||||||
|
--hive CDM Primary Key Constraints for OMOP Common Data Model 5.4
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PERSON ADD CONSTRAINT xpk_PERSON PRIMARY KEY NONCLUSTERED (person_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION_PERIOD ADD CONSTRAINT xpk_OBSERVATION_PERIOD PRIMARY KEY NONCLUSTERED (observation_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_OCCURRENCE ADD CONSTRAINT xpk_VISIT_OCCURRENCE PRIMARY KEY NONCLUSTERED (visit_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VISIT_DETAIL ADD CONSTRAINT xpk_VISIT_DETAIL PRIMARY KEY NONCLUSTERED (visit_detail_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_OCCURRENCE ADD CONSTRAINT xpk_CONDITION_OCCURRENCE PRIMARY KEY NONCLUSTERED (condition_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_EXPOSURE ADD CONSTRAINT xpk_DRUG_EXPOSURE PRIMARY KEY NONCLUSTERED (drug_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROCEDURE_OCCURRENCE ADD CONSTRAINT xpk_PROCEDURE_OCCURRENCE PRIMARY KEY NONCLUSTERED (procedure_occurrence_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DEVICE_EXPOSURE ADD CONSTRAINT xpk_DEVICE_EXPOSURE PRIMARY KEY NONCLUSTERED (device_exposure_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.MEASUREMENT ADD CONSTRAINT xpk_MEASUREMENT PRIMARY KEY NONCLUSTERED (measurement_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.OBSERVATION ADD CONSTRAINT xpk_OBSERVATION PRIMARY KEY NONCLUSTERED (observation_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE ADD CONSTRAINT xpk_NOTE PRIMARY KEY NONCLUSTERED (note_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.NOTE_NLP ADD CONSTRAINT xpk_NOTE_NLP PRIMARY KEY NONCLUSTERED (note_nlp_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.SPECIMEN ADD CONSTRAINT xpk_SPECIMEN PRIMARY KEY NONCLUSTERED (specimen_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.LOCATION ADD CONSTRAINT xpk_LOCATION PRIMARY KEY NONCLUSTERED (location_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CARE_SITE ADD CONSTRAINT xpk_CARE_SITE PRIMARY KEY NONCLUSTERED (care_site_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PROVIDER ADD CONSTRAINT xpk_PROVIDER PRIMARY KEY NONCLUSTERED (provider_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.PAYER_PLAN_PERIOD ADD CONSTRAINT xpk_PAYER_PLAN_PERIOD PRIMARY KEY NONCLUSTERED (payer_plan_period_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.COST ADD CONSTRAINT xpk_COST PRIMARY KEY NONCLUSTERED (cost_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DRUG_ERA ADD CONSTRAINT xpk_DRUG_ERA PRIMARY KEY NONCLUSTERED (drug_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOSE_ERA ADD CONSTRAINT xpk_DOSE_ERA PRIMARY KEY NONCLUSTERED (dose_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONDITION_ERA ADD CONSTRAINT xpk_CONDITION_ERA PRIMARY KEY NONCLUSTERED (condition_era_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.EPISODE ADD CONSTRAINT xpk_EPISODE PRIMARY KEY NONCLUSTERED (episode_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.METADATA ADD CONSTRAINT xpk_METADATA PRIMARY KEY NONCLUSTERED (metadata_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT ADD CONSTRAINT xpk_CONCEPT PRIMARY KEY NONCLUSTERED (concept_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.VOCABULARY ADD CONSTRAINT xpk_VOCABULARY PRIMARY KEY NONCLUSTERED (vocabulary_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.DOMAIN ADD CONSTRAINT xpk_DOMAIN PRIMARY KEY NONCLUSTERED (domain_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.CONCEPT_CLASS ADD CONSTRAINT xpk_CONCEPT_CLASS PRIMARY KEY NONCLUSTERED (concept_class_id);
|
||||||
|
ALTER TABLE @cdmDatabaseSchema.RELATIONSHIP ADD CONSTRAINT xpk_RELATIONSHIP PRIMARY KEY NONCLUSTERED (relationship_id);
|
|
@ -0,0 +1,177 @@
|
||||||
|
--sqlite 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);
|
|
@ -0,0 +1,511 @@
|
||||||
|
--sqlite 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 REAL 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 TEXT NULL,
|
||||||
|
gender_source_value TEXT NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value TEXT NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value TEXT 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 REAL NULL,
|
||||||
|
visit_end_date date NOT NULL,
|
||||||
|
visit_end_datetime REAL NULL,
|
||||||
|
visit_type_concept_id Integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_source_value TEXT NULL,
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitted_from_concept_id integer NULL,
|
||||||
|
admitted_from_source_value TEXT NULL,
|
||||||
|
discharged_to_concept_id integer NULL,
|
||||||
|
discharged_to_source_value TEXT 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 REAL NULL,
|
||||||
|
visit_detail_end_date date NOT NULL,
|
||||||
|
visit_detail_end_datetime REAL NULL,
|
||||||
|
visit_detail_type_concept_id integer NOT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
visit_detail_source_value TEXT NULL,
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitted_from_concept_id Integer NULL,
|
||||||
|
admitted_from_source_value TEXT NULL,
|
||||||
|
discharged_to_source_value TEXT 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 REAL NULL,
|
||||||
|
condition_end_date date NULL,
|
||||||
|
condition_end_datetime REAL NULL,
|
||||||
|
condition_type_concept_id integer NOT NULL,
|
||||||
|
condition_status_concept_id integer NULL,
|
||||||
|
stop_reason TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value TEXT NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value TEXT 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 REAL NULL,
|
||||||
|
drug_exposure_end_date date NOT NULL,
|
||||||
|
drug_exposure_end_datetime REAL NULL,
|
||||||
|
verbatim_end_date date NULL,
|
||||||
|
drug_type_concept_id integer NOT NULL,
|
||||||
|
stop_reason TEXT NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value TEXT NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value TEXT NULL,
|
||||||
|
dose_unit_source_value TEXT 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 REAL NULL,
|
||||||
|
procedure_end_date date NULL,
|
||||||
|
procedure_end_datetime REAL 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 TEXT NULL,
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value TEXT 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 REAL NULL,
|
||||||
|
device_exposure_end_date date NULL,
|
||||||
|
device_exposure_end_datetime REAL NULL,
|
||||||
|
device_type_concept_id integer NOT NULL,
|
||||||
|
unique_device_id TEXT NULL,
|
||||||
|
production_id TEXT NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value TEXT NULL,
|
||||||
|
device_source_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT 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 REAL NULL,
|
||||||
|
measurement_time TEXT NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low REAL NULL,
|
||||||
|
range_high REAL NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value TEXT NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
unit_source_concept_id integer NULL,
|
||||||
|
value_source_value TEXT 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 REAL NULL,
|
||||||
|
observation_type_concept_id integer NOT NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_string TEXT 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 TEXT NULL,
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
qualifier_source_value TEXT NULL,
|
||||||
|
value_source_value TEXT 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 REAL NULL,
|
||||||
|
death_type_concept_id integer NULL,
|
||||||
|
cause_concept_id integer NULL,
|
||||||
|
cause_source_value TEXT 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 REAL NULL,
|
||||||
|
note_type_concept_id integer NOT NULL,
|
||||||
|
note_class_concept_id integer NOT NULL,
|
||||||
|
note_title TEXT NULL,
|
||||||
|
note_text TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
"offset" TEXT NULL,
|
||||||
|
lexical_variant TEXT NOT NULL,
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system TEXT NULL,
|
||||||
|
nlp_date date NOT NULL,
|
||||||
|
nlp_datetime REAL NULL,
|
||||||
|
term_exists TEXT NULL,
|
||||||
|
term_temporal TEXT NULL,
|
||||||
|
term_modifiers TEXT 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 REAL NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id TEXT NULL,
|
||||||
|
specimen_source_value TEXT NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
anatomic_site_source_value TEXT NULL,
|
||||||
|
disease_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
address_2 TEXT NULL,
|
||||||
|
city TEXT NULL,
|
||||||
|
state TEXT NULL,
|
||||||
|
zip TEXT NULL,
|
||||||
|
county TEXT NULL,
|
||||||
|
location_source_value TEXT NULL,
|
||||||
|
country_concept_id integer NULL,
|
||||||
|
country_source_value TEXT NULL,
|
||||||
|
latitude REAL NULL,
|
||||||
|
longitude REAL NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name TEXT NULL,
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value TEXT NULL,
|
||||||
|
place_of_service_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name TEXT NULL,
|
||||||
|
npi TEXT NULL,
|
||||||
|
dea TEXT NULL,
|
||||||
|
specialty_concept_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
year_of_birth integer NULL,
|
||||||
|
gender_concept_id integer NULL,
|
||||||
|
provider_source_value TEXT NULL,
|
||||||
|
specialty_source_value TEXT NULL,
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value TEXT 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 TEXT NULL,
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value TEXT NULL,
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value TEXT NULL,
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value TEXT NULL,
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value TEXT 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 TEXT NOT NULL,
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge REAL NULL,
|
||||||
|
total_cost REAL NULL,
|
||||||
|
total_paid REAL NULL,
|
||||||
|
paid_by_payer REAL NULL,
|
||||||
|
paid_by_patient REAL NULL,
|
||||||
|
paid_patient_copay REAL NULL,
|
||||||
|
paid_patient_coinsurance REAL NULL,
|
||||||
|
paid_patient_deductible REAL NULL,
|
||||||
|
paid_by_primary REAL NULL,
|
||||||
|
paid_ingredient_cost REAL NULL,
|
||||||
|
paid_dispensing_fee REAL NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed REAL NULL,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value TEXT NULL,
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value TEXT 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 REAL 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 REAL NULL,
|
||||||
|
episode_end_date date NULL,
|
||||||
|
episode_end_datetime REAL 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
value_as_string TEXT NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
metadata_date date NULL,
|
||||||
|
metadata_datetime REAL NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CDM_SOURCE (
|
||||||
|
cdm_source_name TEXT NOT NULL,
|
||||||
|
cdm_source_abbreviation TEXT NOT NULL,
|
||||||
|
cdm_holder TEXT NOT NULL,
|
||||||
|
source_description TEXT NULL,
|
||||||
|
source_documentation_reference TEXT NULL,
|
||||||
|
cdm_etl_reference TEXT NULL,
|
||||||
|
source_release_date date NOT NULL,
|
||||||
|
cdm_release_date date NOT NULL,
|
||||||
|
cdm_version TEXT NULL,
|
||||||
|
cdm_version_concept_id integer NOT NULL,
|
||||||
|
vocabulary_version TEXT NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name TEXT NOT NULL,
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
standard_concept TEXT NULL,
|
||||||
|
concept_code TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
vocabulary_name TEXT NOT NULL,
|
||||||
|
vocabulary_reference TEXT NULL,
|
||||||
|
vocabulary_version TEXT NULL,
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
domain_name TEXT NOT NULL,
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
concept_class_name TEXT 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 TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id TEXT NOT NULL,
|
||||||
|
relationship_name TEXT NOT NULL,
|
||||||
|
is_hierarchical TEXT NOT NULL,
|
||||||
|
defines_ancestry TEXT NOT NULL,
|
||||||
|
reverse_relationship_id TEXT 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id TEXT NOT NULL,
|
||||||
|
source_code_description TEXT NULL,
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value REAL NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value REAL NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value REAL 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
cohort_definition_description TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*sqlite 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 person (person_id ASC);
|
||||||
|
CREATE INDEX idx_gender ON person (gender_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_period_id_1 ON observation_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_person_id_1 ON visit_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_concept_id_1 ON visit_occurrence (visit_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_person_id_1 ON visit_detail (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_concept_id_1 ON visit_detail (visit_detail_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_occ_id ON visit_detail (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_condition_person_id_1 ON condition_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_concept_id_1 ON condition_occurrence (condition_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_visit_id_1 ON condition_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_drug_person_id_1 ON drug_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_concept_id_1 ON drug_exposure (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_visit_id_1 ON drug_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_person_id_1 ON procedure_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_concept_id_1 ON procedure_occurrence (procedure_concept_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_visit_id_1 ON procedure_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_device_person_id_1 ON device_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_device_concept_id_1 ON device_exposure (device_concept_id ASC);
|
||||||
|
CREATE INDEX idx_device_visit_id_1 ON device_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_person_id_1 ON measurement (person_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_concept_id_1 ON measurement (measurement_concept_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_visit_id_1 ON measurement (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_observation_person_id_1 ON observation (person_id ASC);
|
||||||
|
CREATE INDEX idx_observation_concept_id_1 ON observation (observation_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_visit_id_1 ON observation (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_death_person_id_1 ON death (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_person_id_1 ON note (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_concept_id_1 ON note (note_type_concept_id ASC);
|
||||||
|
CREATE INDEX idx_note_visit_id_1 ON note (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_note_id_1 ON note_nlp (note_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_concept_id_1 ON note_nlp (note_nlp_concept_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_person_id_1 ON specimen (person_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_concept_id_1 ON specimen (specimen_concept_id ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id1 ON fact_relationship (domain_concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id2 ON fact_relationship (domain_concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id3 ON fact_relationship (relationship_concept_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_location_id_1 ON location (location_id ASC);
|
||||||
|
CREATE INDEX idx_care_site_id_1 ON care_site (care_site_id ASC);
|
||||||
|
CREATE INDEX idx_provider_id_1 ON provider (provider_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_period_person_id_1 ON payer_plan_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_cost_event_id ON cost (cost_event_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_drug_era_person_id_1 ON drug_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_era_concept_id_1 ON drug_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_person_id_1 ON dose_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_concept_id_1 ON dose_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_person_id_1 ON condition_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_concept_id_1 ON condition_era (condition_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_metadata_concept_id_1 ON metadata (metadata_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_concept_concept_id ON concept (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
|
||||||
|
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_domain_domain_id ON domain (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_3 ON source_to_concept_map (target_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_1 ON source_to_concept_map (source_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_2 ON source_to_concept_map (target_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_c ON source_to_concept_map (source_code ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
|
||||||
|
--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);
|
|
@ -0,0 +1,29 @@
|
||||||
|
--sqlite 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);
|
|
@ -0,0 +1,177 @@
|
||||||
|
--sqlite extended 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);
|
|
@ -0,0 +1,511 @@
|
||||||
|
--sqlite extended 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 TEXT NULL,
|
||||||
|
gender_source_value TEXT NULL,
|
||||||
|
gender_source_concept_id integer NULL,
|
||||||
|
race_source_value TEXT NULL,
|
||||||
|
race_source_concept_id integer NULL,
|
||||||
|
ethnicity_source_value TEXT 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 TEXT NULL,
|
||||||
|
visit_source_concept_id integer NULL,
|
||||||
|
admitted_from_concept_id integer NULL,
|
||||||
|
admitted_from_source_value TEXT NULL,
|
||||||
|
discharged_to_concept_id integer NULL,
|
||||||
|
discharged_to_source_value TEXT 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 TEXT NULL,
|
||||||
|
visit_detail_source_concept_id Integer NULL,
|
||||||
|
admitted_from_concept_id Integer NULL,
|
||||||
|
admitted_from_source_value TEXT NULL,
|
||||||
|
discharged_to_source_value TEXT 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 TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
condition_source_value TEXT NULL,
|
||||||
|
condition_source_concept_id integer NULL,
|
||||||
|
condition_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
refills integer NULL,
|
||||||
|
quantity REAL NULL,
|
||||||
|
days_supply integer NULL,
|
||||||
|
sig TEXT NULL,
|
||||||
|
route_concept_id integer NULL,
|
||||||
|
lot_number TEXT NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
drug_source_value TEXT NULL,
|
||||||
|
drug_source_concept_id integer NULL,
|
||||||
|
route_source_value TEXT NULL,
|
||||||
|
dose_unit_source_value TEXT 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 TEXT NULL,
|
||||||
|
procedure_source_concept_id integer NULL,
|
||||||
|
modifier_source_value TEXT 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 TEXT NULL,
|
||||||
|
production_id TEXT NULL,
|
||||||
|
quantity integer NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
device_source_value TEXT NULL,
|
||||||
|
device_source_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT 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 TEXT NULL,
|
||||||
|
measurement_type_concept_id integer NOT NULL,
|
||||||
|
operator_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
range_low REAL NULL,
|
||||||
|
range_high REAL NULL,
|
||||||
|
provider_id integer NULL,
|
||||||
|
visit_occurrence_id integer NULL,
|
||||||
|
visit_detail_id integer NULL,
|
||||||
|
measurement_source_value TEXT NULL,
|
||||||
|
measurement_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
unit_source_concept_id integer NULL,
|
||||||
|
value_source_value TEXT 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 REAL NULL,
|
||||||
|
value_as_string TEXT 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 TEXT NULL,
|
||||||
|
observation_source_concept_id integer NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
qualifier_source_value TEXT NULL,
|
||||||
|
value_source_value TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
note_text TEXT 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 TEXT 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 TEXT NULL,
|
||||||
|
"offset" TEXT NULL,
|
||||||
|
lexical_variant TEXT NOT NULL,
|
||||||
|
note_nlp_concept_id integer NULL,
|
||||||
|
note_nlp_source_concept_id integer NULL,
|
||||||
|
nlp_system TEXT NULL,
|
||||||
|
nlp_date date NOT NULL,
|
||||||
|
nlp_datetime datetime NULL,
|
||||||
|
term_exists TEXT NULL,
|
||||||
|
term_temporal TEXT NULL,
|
||||||
|
term_modifiers TEXT 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 REAL NULL,
|
||||||
|
unit_concept_id integer NULL,
|
||||||
|
anatomic_site_concept_id integer NULL,
|
||||||
|
disease_status_concept_id integer NULL,
|
||||||
|
specimen_source_id TEXT NULL,
|
||||||
|
specimen_source_value TEXT NULL,
|
||||||
|
unit_source_value TEXT NULL,
|
||||||
|
anatomic_site_source_value TEXT NULL,
|
||||||
|
disease_status_source_value TEXT 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 TEXT NULL,
|
||||||
|
address_2 TEXT NULL,
|
||||||
|
city TEXT NULL,
|
||||||
|
state TEXT NULL,
|
||||||
|
zip TEXT NULL,
|
||||||
|
county TEXT NULL,
|
||||||
|
location_source_value TEXT NULL,
|
||||||
|
country_concept_id integer NULL,
|
||||||
|
country_source_value TEXT NULL,
|
||||||
|
latitude REAL NULL,
|
||||||
|
longitude REAL NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CARE_SITE (
|
||||||
|
care_site_id integer NOT NULL,
|
||||||
|
care_site_name TEXT NULL,
|
||||||
|
place_of_service_concept_id integer NULL,
|
||||||
|
location_id integer NULL,
|
||||||
|
care_site_source_value TEXT NULL,
|
||||||
|
place_of_service_source_value TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.PROVIDER (
|
||||||
|
provider_id integer NOT NULL,
|
||||||
|
provider_name TEXT NULL,
|
||||||
|
npi TEXT NULL,
|
||||||
|
dea TEXT NULL,
|
||||||
|
specialty_concept_id integer NULL,
|
||||||
|
care_site_id integer NULL,
|
||||||
|
year_of_birth integer NULL,
|
||||||
|
gender_concept_id integer NULL,
|
||||||
|
provider_source_value TEXT NULL,
|
||||||
|
specialty_source_value TEXT NULL,
|
||||||
|
specialty_source_concept_id integer NULL,
|
||||||
|
gender_source_value TEXT 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 TEXT NULL,
|
||||||
|
payer_source_concept_id integer NULL,
|
||||||
|
plan_concept_id integer NULL,
|
||||||
|
plan_source_value TEXT NULL,
|
||||||
|
plan_source_concept_id integer NULL,
|
||||||
|
sponsor_concept_id integer NULL,
|
||||||
|
sponsor_source_value TEXT NULL,
|
||||||
|
sponsor_source_concept_id integer NULL,
|
||||||
|
family_source_value TEXT NULL,
|
||||||
|
stop_reason_concept_id integer NULL,
|
||||||
|
stop_reason_source_value TEXT 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 TEXT NOT NULL,
|
||||||
|
cost_type_concept_id integer NOT NULL,
|
||||||
|
currency_concept_id integer NULL,
|
||||||
|
total_charge REAL NULL,
|
||||||
|
total_cost REAL NULL,
|
||||||
|
total_paid REAL NULL,
|
||||||
|
paid_by_payer REAL NULL,
|
||||||
|
paid_by_patient REAL NULL,
|
||||||
|
paid_patient_copay REAL NULL,
|
||||||
|
paid_patient_coinsurance REAL NULL,
|
||||||
|
paid_patient_deductible REAL NULL,
|
||||||
|
paid_by_primary REAL NULL,
|
||||||
|
paid_ingredient_cost REAL NULL,
|
||||||
|
paid_dispensing_fee REAL NULL,
|
||||||
|
payer_plan_period_id integer NULL,
|
||||||
|
amount_allowed REAL NULL,
|
||||||
|
revenue_code_concept_id integer NULL,
|
||||||
|
revenue_code_source_value TEXT NULL,
|
||||||
|
drg_concept_id integer NULL,
|
||||||
|
drg_source_value TEXT 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 REAL 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
value_as_string TEXT NULL,
|
||||||
|
value_as_concept_id integer NULL,
|
||||||
|
value_as_number REAL NULL,
|
||||||
|
metadata_date date NULL,
|
||||||
|
metadata_datetime datetime NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CDM_SOURCE (
|
||||||
|
cdm_source_name TEXT NOT NULL,
|
||||||
|
cdm_source_abbreviation TEXT NOT NULL,
|
||||||
|
cdm_holder TEXT NOT NULL,
|
||||||
|
source_description TEXT NULL,
|
||||||
|
source_documentation_reference TEXT NULL,
|
||||||
|
cdm_etl_reference TEXT NULL,
|
||||||
|
source_release_date date NOT NULL,
|
||||||
|
cdm_release_date date NOT NULL,
|
||||||
|
cdm_version TEXT NULL,
|
||||||
|
cdm_version_concept_id integer NOT NULL,
|
||||||
|
vocabulary_version TEXT NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT (
|
||||||
|
concept_id integer NOT NULL,
|
||||||
|
concept_name TEXT NOT NULL,
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
standard_concept TEXT NULL,
|
||||||
|
concept_code TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.VOCABULARY (
|
||||||
|
vocabulary_id TEXT NOT NULL,
|
||||||
|
vocabulary_name TEXT NOT NULL,
|
||||||
|
vocabulary_reference TEXT NULL,
|
||||||
|
vocabulary_version TEXT NULL,
|
||||||
|
vocabulary_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DOMAIN (
|
||||||
|
domain_id TEXT NOT NULL,
|
||||||
|
domain_name TEXT NOT NULL,
|
||||||
|
domain_concept_id integer NOT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.CONCEPT_CLASS (
|
||||||
|
concept_class_id TEXT NOT NULL,
|
||||||
|
concept_class_name TEXT 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 TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.RELATIONSHIP (
|
||||||
|
relationship_id TEXT NOT NULL,
|
||||||
|
relationship_name TEXT NOT NULL,
|
||||||
|
is_hierarchical TEXT NOT NULL,
|
||||||
|
defines_ancestry TEXT NOT NULL,
|
||||||
|
reverse_relationship_id TEXT 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
source_concept_id integer NOT NULL,
|
||||||
|
source_vocabulary_id TEXT NOT NULL,
|
||||||
|
source_code_description TEXT NULL,
|
||||||
|
target_concept_id integer NOT NULL,
|
||||||
|
target_vocabulary_id TEXT NOT NULL,
|
||||||
|
valid_start_date date NOT NULL,
|
||||||
|
valid_end_date date NOT NULL,
|
||||||
|
invalid_reason TEXT NULL );
|
||||||
|
--HINT DISTRIBUTE ON RANDOM
|
||||||
|
CREATE TABLE @cdmDatabaseSchema.DRUG_STRENGTH (
|
||||||
|
drug_concept_id integer NOT NULL,
|
||||||
|
ingredient_concept_id integer NOT NULL,
|
||||||
|
amount_value REAL NULL,
|
||||||
|
amount_unit_concept_id integer NULL,
|
||||||
|
numerator_value REAL NULL,
|
||||||
|
numerator_unit_concept_id integer NULL,
|
||||||
|
denominator_value REAL 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 TEXT 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 TEXT NOT NULL,
|
||||||
|
cohort_definition_description TEXT NULL,
|
||||||
|
definition_type_concept_id integer NOT NULL,
|
||||||
|
cohort_definition_syntax TEXT NULL,
|
||||||
|
subject_concept_id integer NOT NULL,
|
||||||
|
cohort_initiation_date date NULL );
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*sqlite extended 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 person (person_id ASC);
|
||||||
|
CREATE INDEX idx_gender ON person (gender_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_period_id_1 ON observation_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_person_id_1 ON visit_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_concept_id_1 ON visit_occurrence (visit_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_person_id_1 ON visit_detail (person_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_concept_id_1 ON visit_detail (visit_detail_concept_id ASC);
|
||||||
|
CREATE INDEX idx_visit_det_occ_id ON visit_detail (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_condition_person_id_1 ON condition_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_concept_id_1 ON condition_occurrence (condition_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_visit_id_1 ON condition_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_drug_person_id_1 ON drug_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_concept_id_1 ON drug_exposure (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_visit_id_1 ON drug_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_person_id_1 ON procedure_occurrence (person_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_concept_id_1 ON procedure_occurrence (procedure_concept_id ASC);
|
||||||
|
CREATE INDEX idx_procedure_visit_id_1 ON procedure_occurrence (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_device_person_id_1 ON device_exposure (person_id ASC);
|
||||||
|
CREATE INDEX idx_device_concept_id_1 ON device_exposure (device_concept_id ASC);
|
||||||
|
CREATE INDEX idx_device_visit_id_1 ON device_exposure (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_person_id_1 ON measurement (person_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_concept_id_1 ON measurement (measurement_concept_id ASC);
|
||||||
|
CREATE INDEX idx_measurement_visit_id_1 ON measurement (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_observation_person_id_1 ON observation (person_id ASC);
|
||||||
|
CREATE INDEX idx_observation_concept_id_1 ON observation (observation_concept_id ASC);
|
||||||
|
CREATE INDEX idx_observation_visit_id_1 ON observation (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_death_person_id_1 ON death (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_person_id_1 ON note (person_id ASC);
|
||||||
|
CREATE INDEX idx_note_concept_id_1 ON note (note_type_concept_id ASC);
|
||||||
|
CREATE INDEX idx_note_visit_id_1 ON note (visit_occurrence_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_note_id_1 ON note_nlp (note_id ASC);
|
||||||
|
CREATE INDEX idx_note_nlp_concept_id_1 ON note_nlp (note_nlp_concept_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_person_id_1 ON specimen (person_id ASC);
|
||||||
|
CREATE INDEX idx_specimen_concept_id_1 ON specimen (specimen_concept_id ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id1 ON fact_relationship (domain_concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id2 ON fact_relationship (domain_concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_fact_relationship_id3 ON fact_relationship (relationship_concept_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health system data
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_location_id_1 ON location (location_id ASC);
|
||||||
|
CREATE INDEX idx_care_site_id_1 ON care_site (care_site_id ASC);
|
||||||
|
CREATE INDEX idx_provider_id_1 ON provider (provider_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized health economics
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_period_person_id_1 ON payer_plan_period (person_id ASC);
|
||||||
|
CREATE INDEX idx_cost_event_id ON cost (cost_event_id ASC);
|
||||||
|
/************************
|
||||||
|
Standardized derived elements
|
||||||
|
************************/
|
||||||
|
CREATE INDEX idx_drug_era_person_id_1 ON drug_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_drug_era_concept_id_1 ON drug_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_person_id_1 ON dose_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_dose_era_concept_id_1 ON dose_era (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_person_id_1 ON condition_era (person_id ASC);
|
||||||
|
CREATE INDEX idx_condition_era_concept_id_1 ON condition_era (condition_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized meta-data
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_metadata_concept_id_1 ON metadata (metadata_concept_id ASC);
|
||||||
|
/**************************
|
||||||
|
Standardized vocabularies
|
||||||
|
***************************/
|
||||||
|
CREATE INDEX idx_concept_concept_id ON concept (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
|
||||||
|
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_domain_domain_id ON domain (domain_id ASC);
|
||||||
|
CREATE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
|
||||||
|
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
|
||||||
|
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
|
||||||
|
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_3 ON source_to_concept_map (target_concept_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_1 ON source_to_concept_map (source_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_2 ON source_to_concept_map (target_vocabulary_id ASC);
|
||||||
|
CREATE INDEX idx_source_to_concept_map_c ON source_to_concept_map (source_code ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
|
||||||
|
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
|
||||||
|
--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);
|
|
@ -0,0 +1,29 @@
|
||||||
|
--sqlite extended 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);
|
Loading…
Reference in New Issue