diff --git a/Impala/OMOP_CDM_ddl_Impala.sql b/Impala/OMOP_CDM_ddl_Impala.sql index c5c3779..1702d2d 100644 --- a/Impala/OMOP_CDM_ddl_Impala.sql +++ b/Impala/OMOP_CDM_ddl_Impala.sql @@ -17,16 +17,16 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### - # # ## ## # # # # # # # # ## ## # # # ## # # - # # # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # - # # # # # # # # # # # # # # # ### # ### # # - # # # # # # # # # # # # # # # # # ### # ### # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### + ####### # # ####### ###### ##### ###### # # ####### ##### + # # ## ## # # # # # # # # ## ## # # # # # + # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### + # # # # # # # # # # # # # # # ### # + # # # # # # # # # # # # # # # # # ### # + ####### # # ####### # ##### ###### # # ## ##### ### ####### -script to create OMOP common data model, version 5.1.0 for Hadoop (Hive/Impala) database +script to create OMOP common data model, version 5.2 for Hadoop (Hive/Impala) database Based on the PostgreSQL version, with the following changes: * NULL/NOT NULL is not used. @@ -248,7 +248,7 @@ CREATE TABLE person ( year_of_birth INTEGER, month_of_birth INTEGER, day_of_birth INTEGER, - time_of_birth VARCHAR(10), + birth_datetime VARCHAR(10), race_concept_id INTEGER, ethnicity_concept_id INTEGER, location_id INTEGER, @@ -364,6 +364,7 @@ CREATE TABLE drug_exposure ( drug_concept_id INTEGER, drug_exposure_start_date VARCHAR(8), -- DATE drug_exposure_end_date VARCHAR(8), -- DATE + verbatim_end_date VARCHAR(8), --DATE drug_type_concept_id INTEGER, stop_reason VARCHAR(20), refills INTEGER, diff --git a/Impala/OMOP_Parquet.sql b/Impala/OMOP_Parquet.sql index 62eabcc..cd4e615 100644 --- a/Impala/OMOP_Parquet.sql +++ b/Impala/OMOP_Parquet.sql @@ -220,7 +220,7 @@ SELECT person_id, drug_concept_id, TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_date, - TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date, TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(verbatim_end_date AS STRING), 1, 4), SUBSTR(CAST(verbatim_end_date AS STRING), 5, 2), SUBSTR(CAST(verbatim_end_date AS STRING), 7, 2)), 'UTC') AS verbatim_end_date, drug_type_concept_id, stop_reason, refills, diff --git a/Impala/OMOP_Parquet_v5.2.sql b/Impala/OMOP_Parquet_v5.2.sql new file mode 100644 index 0000000..a262c3b --- /dev/null +++ b/Impala/OMOP_Parquet_v5.2.sql @@ -0,0 +1,491 @@ +-- Use the search/replace regex in an editor to fix DATE columns: +-- ([^ ]+) VARCHAR\(8\), \-\- DATE +-- TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST($1 AS STRING), 1, 4), SUBSTR(CAST($1 AS STRING), 5, 2), SUBSTR(CAST($1 AS STRING), 7, 2)), 'UTC') AS $1, + +CREATE TABLE omop_cdm_parquet.concept +STORED AS PARQUET +AS +SELECT + concept_id, + concept_name, + domain_id, + vocabulary_id, + concept_class_id, + standard_concept, + concept_code, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date, + nullif(invalid_reason, '') AS invalid_reason +FROM omop_cdm.concept; + +CREATE TABLE omop_cdm_parquet.vocabulary +STORED AS PARQUET +AS +SELECT * from omop_cdm.vocabulary; + +CREATE TABLE omop_cdm_parquet.domain +STORED AS PARQUET +AS +SELECT * from omop_cdm.domain; + +CREATE TABLE omop_cdm_parquet.concept_class +STORED AS PARQUET +AS +SELECT * from omop_cdm.concept_class; + +CREATE TABLE omop_cdm_parquet.concept_relationship +STORED AS PARQUET +AS +SELECT + concept_id_1, + concept_id_2, + relationship_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date, + nullif(invalid_reason, '') AS invalid_reason +FROM omop_cdm.concept_relationship; + +CREATE TABLE omop_cdm_parquet.relationship +STORED AS PARQUET +AS +SELECT * from omop_cdm.relationship; + +CREATE TABLE omop_cdm_parquet.concept_synonym +STORED AS PARQUET +AS +SELECT * from omop_cdm.concept_synonym; + +CREATE TABLE omop_cdm_parquet.concept_ancestor +STORED AS PARQUET +AS +SELECT * from omop_cdm.concept_ancestor; + +CREATE TABLE omop_cdm_parquet.source_to_concept_map +STORED AS PARQUET +AS +SELECT + source_code, + source_concept_id, + source_vocabulary_id, + source_code_description, + target_concept_id, + target_vocabulary_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date, + nullif(invalid_reason, '') AS invalid_reason +FROM omop_cdm.source_to_concept_map; + +CREATE TABLE omop_cdm_parquet.drug_strength +STORED AS PARQUET +AS +SELECT + drug_concept_id, + ingredient_concept_id, + amount_value, -- NUMERIC + amount_unit_concept_id, + numerator_value, -- NUMERIC + numerator_unit_concept_id, + denominator_value, -- NUMERIC + denominator_unit_concept_id, + box_size, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date, + nullif(invalid_reason, '') AS invalid_reason +FROM omop_cdm.drug_strength; + +CREATE TABLE omop_cdm_parquet.cohort_definition +STORED AS PARQUET +AS +SELECT + cohort_definition_id, + cohort_definition_name, + cohort_definition_description, -- TEXT + definition_type_concept_id, + cohort_definition_syntax, -- TEXT + subject_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_initiation_date AS STRING), 1, 4), SUBSTR(CAST(cohort_initiation_date AS STRING), 5, 2), SUBSTR(CAST(cohort_initiation_date AS STRING), 7, 2)), 'UTC') AS cohort_initiation_date +FROM omop_cdm.cohort_definition; + +CREATE TABLE omop_cdm_parquet.attribute_definition +STORED AS PARQUET +AS +SELECT * from omop_cdm.attribute_definition; + +CREATE TABLE omop_cdm_parquet.cdm_source +STORED AS PARQUET +AS +SELECT + cdm_source_name, + cdm_source_abbreviation, + cdm_holder, + source_description, -- TEXT + source_documentation_reference, + cdm_etl_reference, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(source_release_date AS STRING), 1, 4), SUBSTR(CAST(source_release_date AS STRING), 5, 2), SUBSTR(CAST(source_release_date AS STRING), 7, 2)), 'UTC') AS source_release_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cdm_release_date AS STRING), 1, 4), SUBSTR(CAST(cdm_release_date AS STRING), 5, 2), SUBSTR(CAST(cdm_release_date AS STRING), 7, 2)), 'UTC') AS cdm_release_date, + cdm_version, + vocabulary_version +FROM omop_cdm.cdm_source; + +CREATE TABLE omop_cdm_parquet.person +STORED AS PARQUET +AS +SELECT + person_id, + gender_concept_id, + year_of_birth, + month_of_birth, + day_of_birth, + TO_UTC_TIMESTAMP(CONCAT_WS('-', CAST(year_of_birth AS STRING), SUBSTR(CONCAT('0', CAST(month_of_birth AS STRING)), -2), SUBSTR(CONCAT('0', CAST(day_of_birth AS STRING)), -2)), 'UTC') AS birth_datetime, + race_concept_id, + ethnicity_concept_id, + location_id, + provider_id, + care_site_id, + person_source_value, + gender_source_value, + gender_source_concept_id, + race_source_value, + race_source_concept_id, + ethnicity_source_value, + ethnicity_source_concept_id +FROM omop_cdm.person; + +CREATE TABLE omop_cdm_parquet.observation_period +STORED AS PARQUET +AS +SELECT + observation_period_id, + person_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_datetime, + period_type_concept_id +FROM omop_cdm.observation_period; + +CREATE TABLE omop_cdm_parquet.specimen +STORED AS PARQUET +AS +SELECT + specimen_id, + person_id, + specimen_concept_id, + specimen_type_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_datetime, + quantity, -- NUMERIC + unit_concept_id, + anatomic_site_concept_id, + disease_status_concept_id, + specimen_source_id, + specimen_source_value, + unit_source_value, + anatomic_site_source_value, + disease_status_source_value +FROM omop_cdm.specimen; + +CREATE TABLE omop_cdm_parquet.death +STORED AS PARQUET +AS +SELECT + person_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_datetime, + death_type_concept_id, + cause_concept_id, + cause_source_value, + cause_source_concept_id +FROM omop_cdm.death; + +CREATE TABLE omop_cdm_parquet.visit_occurrence +STORED AS PARQUET +AS +SELECT + visit_occurrence_id, + person_id, + visit_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_datetime, + visit_type_concept_id, + provider_id, + care_site_id, + visit_source_value, + visit_source_concept_id +FROM omop_cdm.visit_occurrence; + +CREATE TABLE omop_cdm_parquet.procedure_occurrence +STORED AS PARQUET +AS +SELECT + procedure_occurrence_id, + person_id, + procedure_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_datetime, + procedure_type_concept_id, + modifier_concept_id, + quantity, + provider_id, + visit_occurrence_id, + procedure_source_value, + procedure_source_concept_id, + qualifier_source_value +FROM omop_cdm.procedure_occurrence; + +CREATE TABLE omop_cdm_parquet.drug_exposure +STORED AS PARQUET +AS +SELECT + drug_exposure_id, + person_id, + drug_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(verbatim_end_date AS STRING), 1, 4), SUBSTR(CAST(verbatim_end_date AS STRING), 5, 2), SUBSTR(CAST(verbatim_end_date AS STRING), 7, 2)), 'UTC') AS verbatim_end_date, + drug_type_concept_id, + stop_reason, + refills, + quantity, -- NUMERIC + days_supply, + sig, -- TEXT + route_concept_id, + effective_drug_dose, -- NUMERIC + dose_unit_concept_id, + lot_number, + provider_id, + visit_occurrence_id, + drug_source_value, + drug_source_concept_id, + route_source_value, + dose_unit_source_value +FROM omop_cdm.drug_exposure; + +CREATE TABLE omop_cdm_parquet.device_exposure +STORED AS PARQUET +AS +SELECT + device_exposure_id, + person_id, + device_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_datetime, + device_type_concept_id, + unique_device_id, + quantity, + provider_id, + visit_occurrence_id, + device_source_value, + device_source_concept_id +FROM omop_cdm.device_exposure; + +CREATE TABLE omop_cdm_parquet.condition_occurrence +STORED AS PARQUET +AS +SELECT + condition_occurrence_id, + person_id, + condition_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_datetime, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_datetime, + condition_type_concept_id, + stop_reason, + provider_id, + visit_occurrence_id, + condition_source_value, + condition_source_concept_id +FROM omop_cdm.condition_occurrence; + +CREATE TABLE omop_cdm_parquet.measurement +STORED AS PARQUET +AS +SELECT + measurement_id, + person_id, + measurement_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_datetime, + measurement_type_concept_id, + operator_concept_id, + value_as_number, -- NUMERIC + value_as_concept_id, + unit_concept_id, + range_low, -- NUMERIC + range_high, -- NUMERIC + provider_id, + visit_occurrence_id, + measurement_source_value, + measurement_source_concept_id, + unit_source_value, + value_source_value +FROM omop_cdm.measurement; + +CREATE TABLE omop_cdm_parquet.note +STORED AS PARQUET +AS +SELECT + note_id, + person_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_datetime, + note_type_concept_id, + note_text, -- TEXT + provider_id, + visit_occurrence_id, + note_source_value +FROM omop_cdm.note; + +CREATE TABLE omop_cdm_parquet.observation +STORED AS PARQUET +AS +SELECT + observation_id, + person_id, + observation_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_datetime, + observation_type_concept_id, + value_as_number, -- NUMERIC + value_as_string, + value_as_concept_id, + qualifier_concept_id, + unit_concept_id, + provider_id, + visit_occurrence_id, + observation_source_value, + observation_source_concept_id , + unit_source_value, + qualifier_source_value +FROM omop_cdm.observation; + +CREATE TABLE omop_cdm_parquet.fact_relationship +STORED AS PARQUET +AS +SELECT * from omop_cdm.fact_relationship; + +CREATE TABLE omop_cdm_parquet.`location` +STORED AS PARQUET +AS +SELECT * from omop_cdm.`location`; + +CREATE TABLE omop_cdm_parquet.care_site +STORED AS PARQUET +AS +SELECT * from omop_cdm.care_site; + +CREATE TABLE omop_cdm_parquet.provider +STORED AS PARQUET +AS +SELECT * from omop_cdm.provider; + +CREATE TABLE omop_cdm_parquet.payer_plan_period +STORED AS PARQUET +AS +SELECT + payer_plan_period_id, + person_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_start_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_end_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_end_date, + payer_source_value, + plan_source_value, + family_source_value +FROM omop_cdm.payer_plan_period; + + +/* The individual cost tables are being phased out and will disappear soon + +CREATE TABLE omop_cdm_parquet.visit_cost +STORED AS PARQUET +AS +SELECT * from omop_cdm.visit_cost; + +CREATE TABLE omop_cdm_parquet.procedure_cost +STORED AS PARQUET +AS +SELECT * from omop_cdm.procedure_cost; + +CREATE TABLE omop_cdm_parquet.drug_cost +STORED AS PARQUET +AS +SELECT * from omop_cdm.drug_cost; + +CREATE TABLE omop_cdm_parquet.device_cost +STORED AS PARQUET +AS +SELECT * from omop_cdm.device_cost; +*/ + +CREATE TABLE omop_cdm_parquet.cost +STORED AS PARQUET +AS +SELECT * from omop_cdm.cost; + +CREATE TABLE omop_cdm_parquet.cohort +STORED AS PARQUET +AS +SELECT + cohort_definition_id, + subject_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date +FROM omop_cdm.cohort; + +CREATE TABLE omop_cdm_parquet.cohort_attribute +STORED AS PARQUET +AS +SELECT + cohort_definition_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date, + subject_id, + attribute_definition_id, + value_as_number, -- NUMERIC + value_as_concept_id +FROM omop_cdm.cohort_attribute; + +CREATE TABLE omop_cdm_parquet.drug_era +STORED AS PARQUET +AS +SELECT + drug_era_id, + person_id, + drug_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_start_date AS STRING), 7, 2)), 'UTC') AS drug_era_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_end_date AS STRING), 7, 2)), 'UTC') AS drug_era_end_date, + drug_exposure_count, + gap_days +FROM omop_cdm.drug_era; + +CREATE TABLE omop_cdm_parquet.dose_era +STORED AS PARQUET +AS +SELECT + dose_era_id, + person_id, + drug_concept_id, + unit_concept_id, + dose_value, -- NUMERIC + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_start_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_start_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_start_date AS STRING), 7, 2)), 'UTC') AS dose_era_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_end_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_end_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_end_date AS STRING), 7, 2)), 'UTC') AS dose_era_end_date +FROM omop_cdm.dose_era; + +CREATE TABLE omop_cdm_parquet.condition_era +STORED AS PARQUET +AS +SELECT + condition_era_id, + person_id, + condition_concept_id, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_start_date AS STRING), 7, 2)), 'UTC') AS condition_era_start_date, + TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_end_date AS STRING), 7, 2)), 'UTC') AS condition_era_end_date, + condition_occurrence_count +FROM omop_cdm.condition_era; + diff --git a/Oracle/OMOP CDM constraints - Oracle.sql b/Oracle/OMOP CDM constraints - Oracle.sql index 85868aa..2617a69 100644 --- a/Oracle/OMOP CDM constraints - Oracle.sql +++ b/Oracle/OMOP CDM constraints - Oracle.sql @@ -17,19 +17,19 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ##### - # # ## ## # # # # # # # # ## ## # # # ## # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # ### # ### # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ##### #### # # #### # # # # # # # # # #### + ####### # # ####### ###### ##### ###### # # ####### ##### ##### + # # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### #### + # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # #### + # # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # # + # # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # #### -script to create constraints within OMOP common data model, version 5.1.0 for Oracle database +script to create constraints within OMOP common data model, version 5.2 for Oracle database -last revised: 12 Oct 2014 +last revised: 14 July 2017 author: Patrick Ryan diff --git a/Oracle/OMOP CDM ddl - Oracle.sql b/Oracle/OMOP CDM ddl - Oracle.sql index 76ec451..6fb019e 100644 --- a/Oracle/OMOP CDM ddl - Oracle.sql +++ b/Oracle/OMOP CDM ddl - Oracle.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### - # # ## ## # # # # # # # # ## ## # # # ## # # - # # # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # - # # # # # # # # # # # # # # # ### # ### # # - # # # # # # # # # # # # # # # # # ### # ### # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### + ####### # # ####### ###### ##### ###### # # ####### ##### + # # ## ## # # # # # # # # ## ## # # # # # + # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### + # # # # # # # # # # # # # # # ### # + # # # # # # # # # # # # # # # # # ### # + ####### # # ####### # ##### ###### # # ## ##### ### ####### -script to create OMOP common data model, version 5.1.0 for Oracle database +script to create OMOP common data model, version 5.2 for Oracle database -last revised: 1-May-2016 +last revised: 14 July 2017 Authors: Patrick Ryan, Christian Reich @@ -344,10 +344,11 @@ CREATE TABLE drug_exposure person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_exposure_start_date DATE NOT NULL , - drug_exposure_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime TIMESTAMP WITH TIME ZONE NULL , - drug_type_concept_id INTEGER NOT NULL , + drug_exposure_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL , + drug_exposure_end_date DATE NOT NULL , + drug_exposure_end_datetime TIMESTAMP WITH TIME ZONE NULL , + verbatim_end_date DATE NULL , + drug_type_concept_id INTEGER NOT NULL , stop_reason VARCHAR(20) NULL , refills INTEGER NULL , quantity FLOAT NULL , diff --git a/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql b/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql index 1d24c9d..7be6f35 100644 --- a/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql +++ b/Oracle/OMOP CDM indexes required - Oracle - With constraints.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ### - # # ## ## # # # # # # # # ## ## # # # ## # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # ### # ### # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ### # # ##### ###### # # ###### #### + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### #### -script to create the required indexes within OMOP common data model, version 5.1.0 for Oracle database +script to create the required indexes within OMOP common data model, version 5.2 for Oracle database -last revised: 12 Oct 2014 +last revised: 17 July 2017 author: Patrick Ryan diff --git a/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql b/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql index 73ed627..53646f1 100644 --- a/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql +++ b/Oracle/OMOP CDM indexes required - Oracle - Without constraints.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ### - # # ## ## # # # # # # # # ## ## # # # ## # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # ### # ### # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ### # # ##### ###### # # ###### #### + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### #### -script to create the required indexes within OMOP common data model, version 5.1.0 for Oracle database +script to create the required indexes within OMOP common data model, version 5.2 for Oracle database -last revised: 12 Oct 2014 +last revised: 14 July 2017 author: Patrick Ryan diff --git a/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql b/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql index f4842e3..bb960a6 100644 --- a/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql +++ b/PostgreSQL/OMOP CDM constraints - PostgreSQL.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ##### - # # ## ## # # # # # # # # ## ## # # # ## # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # ### # ### # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ##### #### # # #### # # # # # # # # # #### + ####### # # ####### ###### ##### ###### # # ####### ##### ##### + # # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### #### + # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # #### + # # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # # + # # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # #### -script to create constraints within OMOP common data model, version 5.1.0 for PostgreSQL database +script to create constraints within OMOP common data model, version 5.2 for PostgreSQL database -last revised: 12 Oct 2014 +last revised: 14 July 2017 author: Patrick Ryan diff --git a/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql b/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql index fb0bd18..686c78d 100644 --- a/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql +++ b/PostgreSQL/OMOP CDM ddl - PostgreSQL.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### - # # ## ## # # # # # # # # ## ## # # # ## # # - # # # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # - # # # # # # # # # # # # # # # ### # ### # # - # # # # # # # # # # # # # # # # # ### # ### # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### + ####### # # ####### ###### ##### ###### # # ####### ##### + # # ## ## # # # # # # # # ## ## # # # # # + # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### + # # # # # # # # # # # # # # # ### # + # # # # # # # # # # # # # # # # # ### # + ####### # # ####### # ##### ###### # # ## ##### ### ####### -script to create OMOP common data model, version 5.1.0 for PostgreSQL database +script to create OMOP common data model, version 5.2 for PostgreSQL database -last revised: 1-May-2016 +last revised: 14 July 2017 Authors: Patrick Ryan, Christian Reich @@ -344,10 +344,11 @@ CREATE TABLE drug_exposure person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_exposure_start_date DATE NOT NULL , - drug_exposure_start_datetime TIMESTAMP NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime TIMESTAMP NULL , - drug_type_concept_id INTEGER NOT NULL , + drug_exposure_start_datetime TIMESTAMP NOT 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 , diff --git a/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql b/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql index 837e003..694e850 100644 --- a/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql +++ b/PostgreSQL/OMOP CDM indexes required - PostgreSQL.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ### - # # ## ## # # # # # # # # ## ## # # # ## # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # ### # ### # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ### # # ##### ###### # # ###### #### + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### #### -script to create the required indexes within OMOP common data model, version 5.1.0 for PostgreSQL database +script to create the required indexes within OMOP common data model, version 5.2 for PostgreSQL database -last revised: 12 Oct 2014 +last revised: 14 July 2017 author: Patrick Ryan diff --git a/README.md b/README.md index 19f459c..cc49e5c 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,17 @@ -Common Data Model v5.1.1 +Common Data Model v5.2 ================= -See full CDM specification file on our github [wiki](https://github.com/OHDSI/CommonDataModel/wiki) or in the [CDM V5.1.1 PDF](https://github.com/OHDSI/CommonDataModel/blob/master/OMOP_CDM_v5_1_1.pdf) +See full CDM specification file on our github [wiki](https://github.com/OHDSI/CommonDataModel/wiki) or in the [CDM V5.2 PDF](**link needed**) -Release Notes for v5.1.1 + +Release Notes for v5.2.0 ============= -This version has a small bug-fix for impala to make it compatible with ATLAS cohort generation. +This version is based on the CDM working group proposals: +* [#71](https://github.com/OHDSI/CommonDataModel/issues/71) + * Adds the field VERBATIM_END_DATE to DRUG_EXPOSURE and makes DRUG_EXPOSURE_END_DATE a required field -Release Notes for v5.1.0 -============= -This version is based on the CDM working group proposal [#60](https://github.com/OHDSI/CommonDataModel/issues/60) and [#59](https://github.com/OHDSI/CommonDataModel/issues/59) and is **backwards compatibile with v5.0.1**. The proposed and accepted changes include adding a datetime field to every table that had a date column and adding field DENOMINATOR_VALUE to the DRUG_STRENGTH table. These were the new columns added: +and is **backwards compatibile with v5.0.1**. The proposed and accepted changes include adding a datetime field to every table that had a date column and adding field DENOMINATOR_VALUE to the DRUG_STRENGTH table. These were the new columns added: -**PERSON** -* birth_datetime, not required - -**SPECIMEN** -* specimen_datetime, not required - -**DEATH** -* death_datetime, not required - -**VISIT_OCCURRENCE** -* visit_start_datetime, not required -* visit_end_datetime, not required - -**PROCEDURE_OCCURRENCE** -* procedure_datetime, not required - -**DRUG_EXPOSURE** -* drug_exposure_start_datetime, not required -* drug_exposure_end_datetime, not required - -**DRUG_STRENGTH** -* DENOMINATOR_VALUE, not required - -**DEVICE_EXPOSURE** -* device_exposure_start_datetime, not required -* device_exposure_end_datetime, not required - -**CONDITION_OCCURRENCE** -* condition_start_datetime, not required -* condition_end_datetime, not required - -**MEASUREMENT** -* measurement_datetime as time, not required - -**OBSERVATION** -* observation_datetime, not required - -**NOTE** -* note_datetime, not required - -There are additional changes listed on the [OHDSI wiki](http://www.ohdsi.org/web/wiki/doku.php?id=documentation:next_cdm) that have been accepted but are not listed in this version because after being accepted they were never added to the DDL. Version 5.1.0 as it is now is being used by members of the community and any changes would cause problems so the additional accepted proposals will be added in subsequent versions. --------- diff --git a/Sql Server/OMOP CDM constraints - SQL Server.sql b/Sql Server/OMOP CDM constraints - SQL Server.sql index a79f20f..90c3378 100644 --- a/Sql Server/OMOP CDM constraints - SQL Server.sql +++ b/Sql Server/OMOP CDM constraints - SQL Server.sql @@ -17,13 +17,13 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ##### - # # ## ## # # # # # # # # ## ## # # # ## # # # # #### # # #### ##### ##### ## # # # ##### #### - # # # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # #### # # # # # # # # # # #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # # ##### ###### # # # # # # - # # # # # # # # # # # # # # # # # ### # ### # # # # # # # ## # # # # # # # # # ## # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ##### #### # # #### # # # # # # # # # #### + ####### # # ####### ###### ##### ###### # # ####### ##### ##### + # # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### #### + # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # #### + # # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # # + # # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # #### script to create constraints within OMOP common data model, version 5.1.0 for SQL Server database diff --git a/Sql Server/OMOP CDM ddl - SQL Server.sql b/Sql Server/OMOP CDM ddl - SQL Server.sql index 20f4f27..f3ad7bf 100644 --- a/Sql Server/OMOP CDM ddl - SQL Server.sql +++ b/Sql Server/OMOP CDM ddl - SQL Server.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### - # # ## ## # # # # # # # # ## ## # # # ## # # - # # # # # # # # # # # # # # # # # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # - # # # # # # # # # # # # # # # ### # ### # # - # # # # # # # # # # # # # # # # # ### # ### # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### + ####### # # ####### ###### ##### ###### # # ####### ##### + # # ## ## # # # # # # # # ## ## # # # # # + # # # # # # # # # # # # # # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### + # # # # # # # # # # # # # # # ### # + # # # # # # # # # # # # # # # # # ### # + ####### # # ####### # ##### ###### # # ## ##### ### ####### -script to create OMOP common data model, version 5.1.0 for SQL Server database +script to create OMOP common data model, version 5.2 for SQL Server database -last revised: 1-May-2016 +last revised: 14-July-2017 Authors: Patrick Ryan, Christian Reich @@ -227,9 +227,9 @@ CREATE TABLE person person_id INTEGER NOT NULL , gender_concept_id INTEGER NOT NULL , year_of_birth INTEGER NOT NULL , - month_of_birth INTEGER NULL, + month_of_birth INTEGER NULL, day_of_birth INTEGER NULL, - birth_datetime DATETIME2 NULL, + birth_datetime DATETIME2 NULL, race_concept_id INTEGER NOT NULL, ethnicity_concept_id INTEGER NOT NULL, location_id INTEGER NULL, @@ -239,8 +239,8 @@ CREATE TABLE person 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, + race_source_concept_id INTEGER NULL, + ethnicity_source_value VARCHAR(50) NULL, ethnicity_source_concept_id INTEGER NULL ) ; @@ -254,10 +254,10 @@ CREATE TABLE observation_period observation_period_id INTEGER NOT NULL , person_id INTEGER NOT NULL , observation_period_start_date DATE NOT NULL , - observation_period_start_datetime DATETIME2 NOT NULL , + observation_period_start_datetime DATETIME2 NOT NULL , observation_period_end_date DATE NOT NULL , - observation_period_end_datetime DATETIME2 NOT NULL , - period_type_concept_id INTEGER NOT NULL + observation_period_end_datetime DATETIME2 NOT NULL , + period_type_concept_id INTEGER NOT NULL ) ; @@ -270,15 +270,15 @@ CREATE TABLE specimen specimen_concept_id INTEGER NOT NULL , specimen_type_concept_id INTEGER NOT NULL , specimen_date DATE NOT NULL , - specimen_datetime DATETIME2 NULL , + specimen_datetime DATETIME2 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_id VARCHAR(50) NULL , specimen_source_value VARCHAR(50) NULL , unit_source_value VARCHAR(50) NULL , - anatomic_site_source_value VARCHAR(50) NULL , + anatomic_site_source_value VARCHAR(50) NULL , disease_status_source_value VARCHAR(50) NULL ) ; @@ -323,16 +323,16 @@ CREATE TABLE 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 DATETIME2 NOT NULL , + procedure_date DATE NOT NULL , + procedure_datetime DATETIME2 NOT 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 , - procedure_source_value VARCHAR(50) NULL , + procedure_source_value VARCHAR(50) NULL , procedure_source_concept_id INTEGER NULL , - qualifier_source_value VARCHAR(50) NULL + qualifier_source_value VARCHAR(50) NULL ) ; @@ -344,9 +344,10 @@ CREATE TABLE drug_exposure person_id INTEGER NOT NULL , drug_concept_id INTEGER NOT NULL , drug_exposure_start_date DATE NOT NULL , - drug_exposure_start_datetime DATETIME2 NOT NULL , - drug_exposure_end_date DATE NULL , - drug_exposure_end_datetime DATETIME2 NULL , + drug_exposure_start_datetime DATETIME2 NOT NULL , + drug_exposure_end_date DATE NOT NULL , + drug_exposure_end_datetime DATETIME2 NULL , + verbatim_end_date DATE NULL , drug_type_concept_id INTEGER NOT NULL , stop_reason VARCHAR(20) NULL , refills INTEGER NULL , @@ -356,27 +357,27 @@ CREATE TABLE drug_exposure route_concept_id INTEGER NULL , effective_drug_dose FLOAT NULL , dose_unit_concept_id INTEGER NULL , - lot_number VARCHAR(50) NULL , + lot_number VARCHAR(50) NULL , provider_id INTEGER NULL , visit_occurrence_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 + drug_source_concept_id INTEGER NULL , + route_source_value VARCHAR(50) NULL , + dose_unit_source_value VARCHAR(50) NULL ) ; CREATE TABLE device_exposure ( - device_exposure_id INTEGER NOT NULL , + 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 DATETIME2 NOT NULL , + device_exposure_start_date DATE NOT NULL , + device_exposure_start_datetime DATETIME2 NOT NULL , device_exposure_end_date DATE NULL , - device_exposure_end_datetime DATETIME2 NULL , - device_type_concept_id INTEGER NOT NULL , + device_exposure_end_datetime DATETIME2 NULL , + device_type_concept_id INTEGER NOT NULL , unique_device_id VARCHAR(50) NULL , quantity INTEGER NULL , provider_id INTEGER NULL , @@ -393,14 +394,14 @@ CREATE TABLE condition_occurrence person_id INTEGER NOT NULL , condition_concept_id INTEGER NOT NULL , condition_start_date DATE NOT NULL , - condition_start_datetime DATETIME2 NOT NULL , - condition_end_date DATE NULL , - condition_end_datetime DATETIME2 NULL , + condition_start_datetime DATETIME2 NOT NULL , + condition_end_date DATE NULL , + condition_end_datetime DATETIME2 NULL , condition_type_concept_id INTEGER NOT NULL , stop_reason VARCHAR(20) NULL , provider_id INTEGER NULL , visit_occurrence_id INTEGER NULL , - condition_source_value VARCHAR(50) NULL , + condition_source_value VARCHAR(50) NULL , condition_source_concept_id INTEGER NULL ) ; @@ -409,24 +410,24 @@ CREATE TABLE condition_occurrence CREATE TABLE measurement ( - measurement_id INTEGER NOT NULL , + measurement_id INTEGER NOT NULL , person_id INTEGER NOT NULL , - measurement_concept_id INTEGER NOT NULL , + measurement_concept_id INTEGER NOT NULL , measurement_date DATE NOT NULL , - measurement_datetime DATETIME2 NULL , + measurement_datetime DATETIME2 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 , + range_high FLOAT NULL , provider_id INTEGER NULL , visit_occurrence_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 + value_source_value VARCHAR(50) NULL ) ; @@ -437,7 +438,7 @@ CREATE TABLE note note_id INTEGER NOT NULL , person_id INTEGER NOT NULL , note_date DATE NOT NULL , - note_datetime DATETIME2 NULL , + note_datetime DATETIME2 NULL , note_type_concept_id INTEGER NOT NULL , note_text VARCHAR(MAX) NOT NULL , provider_id INTEGER NULL , @@ -562,85 +563,6 @@ CREATE TABLE payer_plan_period ; -/* The individual cost tables are being phased out and will disappear - -CREATE TABLE visit_cost - ( - visit_cost_id INTEGER NOT NULL , - visit_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE procedure_cost - ( - procedure_cost_id INTEGER NOT NULL , - procedure_occurrence_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - revenue_code_concept_id INTEGER NULL , - payer_plan_period_id INTEGER NULL , - revenue_code_source_value VARCHAR(50) NULL - ) -; - - - -CREATE TABLE drug_cost - ( - drug_cost_id INTEGER NOT NULL , - drug_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - ingredient_cost FLOAT NULL , - dispensing_fee FLOAT NULL , - average_wholesale_price FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; - - - -CREATE TABLE device_cost - ( - device_cost_id INTEGER NOT NULL , - device_exposure_id INTEGER NOT NULL , - currency_concept_id INTEGER NULL , - paid_copay FLOAT NULL , - paid_coinsurance FLOAT NULL , - paid_toward_deductible FLOAT NULL , - paid_by_payer FLOAT NULL , - paid_by_coordination_benefits FLOAT NULL , - total_out_of_pocket FLOAT NULL , - total_paid FLOAT NULL , - payer_plan_period_id INTEGER NULL - ) -; -*/ - - CREATE TABLE cost ( cost_id INTEGER NOT NULL , diff --git a/Sql Server/OMOP CDM indexes required - SQL Server.sql b/Sql Server/OMOP CDM indexes required - SQL Server.sql index ae42eb1..45279cc 100644 --- a/Sql Server/OMOP CDM indexes required - SQL Server.sql +++ b/Sql Server/OMOP CDM indexes required - SQL Server.sql @@ -17,18 +17,18 @@ /************************ - ####### # # ####### ###### ##### ###### # # ####### # ### ### - # # ## ## # # # # # # # # ## ## # # # ## # # # # # ##### ###### # # ###### #### - # # # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # - # # # # # # # ###### # # # # # # # # ###### # # # # # # # # # ##### ## ##### #### - # # # # # # # # # # # # # # # ### # ### # # # # # # # # # ## # # - # # # # # # # # # # # # # # # # # ### # ### # # # # ## # # # # # # # # - ####### # # ####### # ##### ###### # # ## ##### ### ##### ### ### ### # # ##### ###### # # ###### #### + ####### # # ####### ###### ##### ###### # # ####### ##### ### + # # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### #### + # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # + # # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### #### + # # # # # # # # # # # # # # # ### # # # # # # # # ## # # + # # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # # + ####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### #### -script to create the required indexes within OMOP common data model, version 5.1.0 for SQL Server database +script to create the required indexes within OMOP common data model, version 5.2 for SQL Server database -last revised: 12 Oct 2014 +last revised: 14-July-2017 author: Patrick Ryan