diff --git a/extras/v60_v54_conversion/compare_column_attributes.sql b/extras/archive/v60_v54_conversion/compare_column_attributes.sql similarity index 100% rename from extras/v60_v54_conversion/compare_column_attributes.sql rename to extras/archive/v60_v54_conversion/compare_column_attributes.sql diff --git a/extras/v60_v54_conversion/compare_column_names.sql b/extras/archive/v60_v54_conversion/compare_column_names.sql similarity index 100% rename from extras/v60_v54_conversion/compare_column_names.sql rename to extras/archive/v60_v54_conversion/compare_column_names.sql diff --git a/extras/v60_v54_conversion/output_of_compare_column_attributes.txt b/extras/archive/v60_v54_conversion/output_of_compare_column_attributes.txt similarity index 100% rename from extras/v60_v54_conversion/output_of_compare_column_attributes.txt rename to extras/archive/v60_v54_conversion/output_of_compare_column_attributes.txt diff --git a/extras/v60_v54_conversion/output_of_compare_column_names.txt b/extras/archive/v60_v54_conversion/output_of_compare_column_names.txt similarity index 100% rename from extras/v60_v54_conversion/output_of_compare_column_names.txt rename to extras/archive/v60_v54_conversion/output_of_compare_column_names.txt diff --git a/extras/v60_v54_conversion/redshift_v60_v54_migration.sql b/extras/archive/v60_v54_conversion/redshift_v60_v54_migration.sql similarity index 100% rename from extras/v60_v54_conversion/redshift_v60_v54_migration.sql rename to extras/archive/v60_v54_conversion/redshift_v60_v54_migration.sql diff --git a/extras/migration/v52_to_v53/README.md b/extras/migration/v52_to_v53/README.md new file mode 100644 index 00000000..9def2f39 --- /dev/null +++ b/extras/migration/v52_to_v53/README.md @@ -0,0 +1,6 @@ +# v5.2 to v5.3 CDM conversion + +The *_migration.sql scripts in this folder migrate a v5.2 CDM to a v5.3 CDM. +These scripts follow the migration pattern already used in this repository and cover +the structural deltas reflected by the historical v5.2 DDLs and the v5.3 DDLs under inst/ddl. +Please replace @cdmDatabaseSchema with your schema name. diff --git a/extras/migration/v52_to_v53/bigquery_migration.sql b/extras/migration/v52_to_v53/bigquery_migration.sql new file mode 100644 index 00000000..20b4231f --- /dev/null +++ b/extras/migration/v52_to_v53/bigquery_migration.sql @@ -0,0 +1,96 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 BigQuery-compatible schema deltas in this repository. +-- BigQuery SQL references: +-- https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language +-- +-- VISIT_DETAIL + +create table @cdmDatabaseSchema.visit_detail ( + visit_detail_id INT64 not null, + person_id INT64 not null, + visit_detail_concept_id INT64 not null, + visit_detail_start_date date not null, + visit_detail_start_datetime DATETIME, + visit_detail_end_date date not null, + visit_detail_end_datetime DATETIME, + visit_detail_type_concept_id INT64 not null, + provider_id INT64, + care_site_id INT64, + visit_detail_source_value STRING, + visit_detail_source_concept_id INT64, + admitting_source_value STRING, + admitting_source_concept_id INT64, + discharge_to_source_value STRING, + discharge_to_concept_id INT64, + preceding_visit_detail_id INT64, + visit_detail_parent_id INT64, + visit_occurrence_id INT64 not null +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence alter column condition_start_datetime drop not null; +alter table @cdmDatabaseSchema.condition_occurrence add column visit_detail_id int64; + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure alter column drug_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.drug_exposure add column visit_detail_id int64; + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence rename to procedure_occurrence_v52; +create table @cdmDatabaseSchema.procedure_occurrence as +select + * except(qualifier_source_value), + cast(null as int64) as visit_detail_id, + qualifier_source_value as modifier_source_value +from @cdmDatabaseSchema.procedure_occurrence_v52; + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure alter column device_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.device_exposure add column visit_detail_id int64; + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add column measurement_time string; +alter table @cdmDatabaseSchema.measurement add column visit_detail_id int64; + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add column visit_detail_id int64; + +-- DEATH +alter table @cdmDatabaseSchema.death alter column death_type_concept_id drop not null; + +-- NOTE +alter table @cdmDatabaseSchema.note add column visit_detail_id int64; + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add column payer_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column payer_source_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_source_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_value string; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_concept_id int64; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_value string; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_concept_id int64; + +-- COST +alter table @cdmDatabaseSchema.cost rename to cost_v52; +create table @cdmDatabaseSchema.cost as +select + * except(reveue_code_source_value), + reveue_code_source_value as revenue_code_source_value +from @cdmDatabaseSchema.cost_v52; + +-- METADATA +create table @cdmDatabaseSchema.metadata ( + metadata_concept_id INT64 not null, + metadata_type_concept_id INT64 not null, + name STRING not null, + value_as_string STRING, + value_as_concept_id INT64, + metadata_date DATE, + metadata_datetime DATETIME +); + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/impala_migration.sql b/extras/migration/v52_to_v53/impala_migration.sql new file mode 100644 index 00000000..fea09dd3 --- /dev/null +++ b/extras/migration/v52_to_v53/impala_migration.sql @@ -0,0 +1,85 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 Impala DDLs in this repository. +-- Impala SQL references: +-- https://docs.cloudera.com/documentation/enterprise/latest/topics/impala_alter_table.html +-- +-- VISIT_DETAIL + +create table @cdmDatabaseSchema.visit_detail ( + visit_detail_id INT, + person_id INT, + visit_detail_concept_id INT, + 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 INT, + 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 INT +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence add columns (visit_detail_id int); + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure add columns (visit_detail_id int); + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence change qualifier_source_value modifier_source_value varchar(50); +alter table @cdmDatabaseSchema.procedure_occurrence add columns (visit_detail_id int); + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure change device_source_value device_source_value varchar(50); +alter table @cdmDatabaseSchema.device_exposure add columns (visit_detail_id int); + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add columns (measurement_time varchar(10)); +alter table @cdmDatabaseSchema.measurement add columns (visit_detail_id int); + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add columns (visit_detail_id int); + +-- NOTE +alter table @cdmDatabaseSchema.note add columns (visit_detail_id int); + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp change note_nlp_id note_nlp_id int; +alter table @cdmDatabaseSchema.note_nlp change `offset` `offset` varchar(50); + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add columns (payer_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (payer_source_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (plan_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (plan_source_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (sponsor_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (sponsor_source_value varchar(50)); +alter table @cdmDatabaseSchema.payer_plan_period add columns (sponsor_source_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (stop_reason_concept_id int); +alter table @cdmDatabaseSchema.payer_plan_period add columns (stop_reason_source_value varchar(50)); +alter table @cdmDatabaseSchema.payer_plan_period add columns (stop_reason_source_concept_id int); + +-- COST +alter table @cdmDatabaseSchema.cost change reveue_code_source_value revenue_code_source_value varchar(50); + +-- METADATA +create table @cdmDatabaseSchema.metadata ( + metadata_concept_id INT, + metadata_type_concept_id INT, + name VARCHAR(250), + value_as_string VARCHAR(250), + value_as_concept_id integer NULL, + metadata_date TIMESTAMP, + metadata_datetime TIMESTAMP +); + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/netezza_migration.sql b/extras/migration/v52_to_v53/netezza_migration.sql new file mode 100644 index 00000000..6c0b4034 --- /dev/null +++ b/extras/migration/v52_to_v53/netezza_migration.sql @@ -0,0 +1,99 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 Netezza DDLs in this repository. +-- Netezza SQL references: +-- https://www.ibm.com/docs/en/psfa +-- +-- VISIT_DETAIL + +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 +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence alter column condition_start_datetime drop not null; +alter table @cdmDatabaseSchema.condition_occurrence add column visit_detail_id integer null; + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure alter column drug_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.drug_exposure add column visit_detail_id integer null; + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence alter column procedure_datetime drop not null; +alter table @cdmDatabaseSchema.procedure_occurrence rename column qualifier_source_value to modifier_source_value; +alter table @cdmDatabaseSchema.procedure_occurrence add column visit_detail_id integer null; + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure alter column device_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.device_exposure alter column device_source_value set data type varchar(50); +alter table @cdmDatabaseSchema.device_exposure add column visit_detail_id integer null; + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add column measurement_time varchar(10) null; +alter table @cdmDatabaseSchema.measurement add column visit_detail_id integer null; + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add column visit_detail_id integer null; + +-- DEATH +alter table @cdmDatabaseSchema.death alter column death_type_concept_id drop not null; + +-- NOTE +alter table @cdmDatabaseSchema.note add column visit_detail_id integer null; + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp alter column note_nlp_id set data type integer; +alter table @cdmDatabaseSchema.note_nlp alter column "offset" set data type varchar(50); + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add column payer_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column payer_source_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_source_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_value varchar(50) null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_concept_id integer null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_value varchar(50) null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_concept_id integer null; + +-- COST +alter table @cdmDatabaseSchema.cost rename column reveue_code_source_value to revenue_code_source_value; + +-- METADATA +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 +); + +-- VOCABULARY +update @cdmDatabaseSchema.vocabulary +set vocabulary_reference = '' +where vocabulary_reference is null; + +alter table @cdmDatabaseSchema.vocabulary alter column vocabulary_reference set not null; + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/oracle_migration.sql b/extras/migration/v52_to_v53/oracle_migration.sql new file mode 100644 index 00000000..c6dc4ad8 --- /dev/null +++ b/extras/migration/v52_to_v53/oracle_migration.sql @@ -0,0 +1,99 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 Oracle DDLs in this repository. +-- Oracle SQL references: +-- https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ALTER-TABLE.html +-- +-- VISIT_DETAIL + +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 varchar2(50) NULL, + visit_detail_source_concept_id integer NULL, + admitting_source_value varchar2(50) NULL, + admitting_source_concept_id integer NULL, + discharge_to_source_value varchar2(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 +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence modify (condition_start_datetime timestamp null); +alter table @cdmDatabaseSchema.condition_occurrence add (visit_detail_id number default null); + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure modify (drug_exposure_start_datetime timestamp null); +alter table @cdmDatabaseSchema.drug_exposure add (visit_detail_id number default null); + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence modify (procedure_datetime timestamp null); +alter table @cdmDatabaseSchema.procedure_occurrence rename column qualifier_source_value to modifier_source_value; +alter table @cdmDatabaseSchema.procedure_occurrence add (visit_detail_id number default null); + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure modify (device_exposure_start_datetime timestamp null); +alter table @cdmDatabaseSchema.device_exposure modify (device_source_value varchar2(50)); +alter table @cdmDatabaseSchema.device_exposure add (visit_detail_id number default null); + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add (measurement_time varchar2(10) default null); +alter table @cdmDatabaseSchema.measurement add (visit_detail_id number default null); + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add (visit_detail_id number default null); + +-- DEATH +alter table @cdmDatabaseSchema.death modify (death_type_concept_id number null); + +-- NOTE +alter table @cdmDatabaseSchema.note add (visit_detail_id number default null); + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp modify (note_nlp_id number); +alter table @cdmDatabaseSchema.note_nlp modify ("offset" varchar2(50)); + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add (payer_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (payer_source_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (plan_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (plan_source_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (sponsor_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (sponsor_source_value varchar2(50) default null); +alter table @cdmDatabaseSchema.payer_plan_period add (sponsor_source_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (stop_reason_concept_id number default null); +alter table @cdmDatabaseSchema.payer_plan_period add (stop_reason_source_value varchar2(50) default null); +alter table @cdmDatabaseSchema.payer_plan_period add (stop_reason_source_concept_id number default null); + +-- COST +alter table @cdmDatabaseSchema.cost rename column reveue_code_source_value to revenue_code_source_value; + +-- METADATA +create table @cdmDatabaseSchema.metadata ( + metadata_concept_id integer NOT NULL, + metadata_type_concept_id integer NOT NULL, + name varchar2(250) NOT NULL, + value_as_string varchar2(250) NULL, + value_as_concept_id integer NULL, + metadata_date date NULL, + metadata_datetime TIMESTAMP NULL +); + +-- VOCABULARY +update @cdmDatabaseSchema.vocabulary +set vocabulary_reference = '' +where vocabulary_reference is null; + +alter table @cdmDatabaseSchema.vocabulary modify (vocabulary_reference varchar2(255) not null); + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/postgresql_migration.sql b/extras/migration/v52_to_v53/postgresql_migration.sql new file mode 100644 index 00000000..9b679ba4 --- /dev/null +++ b/extras/migration/v52_to_v53/postgresql_migration.sql @@ -0,0 +1,99 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 PostgreSQL DDLs in this repository. +-- PostgreSQL SQL references: +-- https://www.postgresql.org/docs/current/sql-altertable.html +-- +-- VISIT_DETAIL + +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 +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence alter column condition_start_datetime drop not null; +alter table @cdmDatabaseSchema.condition_occurrence add column visit_detail_id integer default null; + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure alter column drug_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.drug_exposure add column visit_detail_id integer default null; + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence alter column procedure_datetime drop not null; +alter table @cdmDatabaseSchema.procedure_occurrence rename column qualifier_source_value to modifier_source_value; +alter table @cdmDatabaseSchema.procedure_occurrence add column visit_detail_id integer default null; + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure alter column device_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.device_exposure alter column device_source_value type varchar(50); +alter table @cdmDatabaseSchema.device_exposure add column visit_detail_id integer default null; + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add column measurement_time varchar(10) default null; +alter table @cdmDatabaseSchema.measurement add column visit_detail_id integer default null; + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add column visit_detail_id integer default null; + +-- DEATH +alter table @cdmDatabaseSchema.death alter column death_type_concept_id drop not null; + +-- NOTE +alter table @cdmDatabaseSchema.note add column visit_detail_id integer default null; + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp alter column note_nlp_id type integer; +alter table @cdmDatabaseSchema.note_nlp alter column "offset" type varchar(50); + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add column payer_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column payer_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_value varchar(50) default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_value varchar(50) default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_concept_id integer default null; + +-- COST +alter table @cdmDatabaseSchema.cost rename column reveue_code_source_value to revenue_code_source_value; + +-- METADATA +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 +); + +-- VOCABULARY +update @cdmDatabaseSchema.vocabulary +set vocabulary_reference = '' +where vocabulary_reference is null; + +alter table @cdmDatabaseSchema.vocabulary alter column vocabulary_reference set not null; + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/redshift_migration.sql b/extras/migration/v52_to_v53/redshift_migration.sql new file mode 100644 index 00000000..4fe542f6 --- /dev/null +++ b/extras/migration/v52_to_v53/redshift_migration.sql @@ -0,0 +1,99 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 Redshift DDLs in this repository. +-- Redshift SQL references: +-- https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html +-- +-- VISIT_DETAIL + +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 +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence alter column condition_start_datetime drop not null; +alter table @cdmDatabaseSchema.condition_occurrence add column visit_detail_id integer default null; + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure alter column drug_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.drug_exposure add column visit_detail_id integer default null; + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence alter column procedure_datetime drop not null; +alter table @cdmDatabaseSchema.procedure_occurrence rename column qualifier_source_value to modifier_source_value; +alter table @cdmDatabaseSchema.procedure_occurrence add column visit_detail_id integer default null; + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure alter column device_exposure_start_datetime drop not null; +alter table @cdmDatabaseSchema.device_exposure alter column device_source_value type varchar(50); +alter table @cdmDatabaseSchema.device_exposure add column visit_detail_id integer default null; + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add column measurement_time varchar(10) default null; +alter table @cdmDatabaseSchema.measurement add column visit_detail_id integer default null; + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add column visit_detail_id integer default null; + +-- DEATH +alter table @cdmDatabaseSchema.death alter column death_type_concept_id drop not null; + +-- NOTE +alter table @cdmDatabaseSchema.note add column visit_detail_id integer default null; + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp alter column note_nlp_id type integer; +alter table @cdmDatabaseSchema.note_nlp alter column "offset" type varchar(50); + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add column payer_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column payer_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column plan_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_value varchar(50) default null; +alter table @cdmDatabaseSchema.payer_plan_period add column sponsor_source_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_concept_id integer default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_value varchar(50) default null; +alter table @cdmDatabaseSchema.payer_plan_period add column stop_reason_source_concept_id integer default null; + +-- COST +alter table @cdmDatabaseSchema.cost rename column reveue_code_source_value to revenue_code_source_value; + +-- METADATA +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 +); + +-- VOCABULARY +update @cdmDatabaseSchema.vocabulary +set vocabulary_reference = '' +where vocabulary_reference is null; + +alter table @cdmDatabaseSchema.vocabulary alter column vocabulary_reference set not null; + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/migration/v52_to_v53/sqlserver_migration.sql b/extras/migration/v52_to_v53/sqlserver_migration.sql new file mode 100644 index 00000000..2232fbc8 --- /dev/null +++ b/extras/migration/v52_to_v53/sqlserver_migration.sql @@ -0,0 +1,99 @@ +-- Derived from the OMOP CDM v5.2 and v5.3 SQL Server DDLs in this repository. +-- SQL Server SQL references: +-- https://learn.microsoft.com/sql/t-sql/statements/alter-table-transact-sql +-- +-- VISIT_DETAIL + +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 +); + +-- CONDITION_OCCURRENCE +alter table @cdmDatabaseSchema.condition_occurrence alter column condition_start_datetime datetime null; +alter table @cdmDatabaseSchema.condition_occurrence add visit_detail_id int null; + +-- DRUG_EXPOSURE +alter table @cdmDatabaseSchema.drug_exposure alter column drug_exposure_start_datetime datetime null; +alter table @cdmDatabaseSchema.drug_exposure add visit_detail_id int null; + +-- PROCEDURE_OCCURRENCE +alter table @cdmDatabaseSchema.procedure_occurrence alter column procedure_datetime datetime null; +EXEC sp_rename '@cdmDatabaseSchema.procedure_occurrence.qualifier_source_value', 'modifier_source_value', 'COLUMN'; +alter table @cdmDatabaseSchema.procedure_occurrence add visit_detail_id int null; + +-- DEVICE_EXPOSURE +alter table @cdmDatabaseSchema.device_exposure alter column device_exposure_start_datetime datetime null; +alter table @cdmDatabaseSchema.device_exposure alter column device_source_value varchar(50) null; +alter table @cdmDatabaseSchema.device_exposure add visit_detail_id int null; + +-- MEASUREMENT +alter table @cdmDatabaseSchema.measurement add measurement_time varchar(10) null; +alter table @cdmDatabaseSchema.measurement add visit_detail_id int null; + +-- OBSERVATION +alter table @cdmDatabaseSchema.observation add visit_detail_id int null; + +-- DEATH +alter table @cdmDatabaseSchema.death alter column death_type_concept_id int null; + +-- NOTE +alter table @cdmDatabaseSchema.note add visit_detail_id int null; + +-- NOTE_NLP +alter table @cdmDatabaseSchema.note_nlp alter column note_nlp_id int not null; +alter table @cdmDatabaseSchema.note_nlp alter column "offset" varchar(50) null; + +-- PAYER_PLAN_PERIOD +alter table @cdmDatabaseSchema.payer_plan_period add payer_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add payer_source_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add plan_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add plan_source_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add sponsor_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add sponsor_source_value varchar(50) null; +alter table @cdmDatabaseSchema.payer_plan_period add sponsor_source_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add stop_reason_concept_id int null; +alter table @cdmDatabaseSchema.payer_plan_period add stop_reason_source_value varchar(50) null; +alter table @cdmDatabaseSchema.payer_plan_period add stop_reason_source_concept_id int null; + +-- COST +EXEC sp_rename '@cdmDatabaseSchema.cost.reveue_code_source_value', 'revenue_code_source_value', 'COLUMN'; + +-- METADATA +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 +); + +-- VOCABULARY +update @cdmDatabaseSchema.vocabulary +set vocabulary_reference = '' +where vocabulary_reference is null; + +alter table @cdmDatabaseSchema.vocabulary alter column vocabulary_reference varchar(255) not null; + +-- TABLES REMOVED IN v5.3 +drop table @cdmDatabaseSchema.cohort_attribute; +drop table @cdmDatabaseSchema.cohort; diff --git a/extras/v53_v54_conversion/README.txt b/extras/migration/v53_to_v54/README.md similarity index 61% rename from extras/v53_v54_conversion/README.txt rename to extras/migration/v53_to_v54/README.md index f621330e..4118a9d5 100644 --- a/extras/v53_v54_conversion/README.txt +++ b/extras/migration/v53_to_v54/README.md @@ -1,13 +1,6 @@ +# v5.3 to v5.4 CDM conversion -README ------- - -v5.3 to v5.4 CDM conversion - -NOTES ------ - -The *_v53_to_v54_migration.sql scripts are SQL scripts that migrate a v5.3 CDM to a v5.4 CDM. +The *_migration.sql scripts are SQL scripts that migrate a v5.3 CDM to a v5.4 CDM. The changes implemented are found here: http://ohdsi.github.io/CommonDataModel/cdm54Changes.html. Please replace @cdmDatabaseSchema with your schema name. Links to database documentation are included in each script to facilitate debugging. \ No newline at end of file diff --git a/extras/v53_v54_conversion/bigquery_migration.sql b/extras/migration/v53_to_v54/bigquery_migration.sql similarity index 100% rename from extras/v53_v54_conversion/bigquery_migration.sql rename to extras/migration/v53_to_v54/bigquery_migration.sql diff --git a/extras/v53_v54_conversion/impala_migration.sql b/extras/migration/v53_to_v54/impala_migration.sql similarity index 100% rename from extras/v53_v54_conversion/impala_migration.sql rename to extras/migration/v53_to_v54/impala_migration.sql diff --git a/extras/v53_v54_conversion/netezza_migration.sql b/extras/migration/v53_to_v54/netezza_migration.sql similarity index 100% rename from extras/v53_v54_conversion/netezza_migration.sql rename to extras/migration/v53_to_v54/netezza_migration.sql diff --git a/extras/v53_v54_conversion/oracle_migration.sql b/extras/migration/v53_to_v54/oracle_migration.sql similarity index 100% rename from extras/v53_v54_conversion/oracle_migration.sql rename to extras/migration/v53_to_v54/oracle_migration.sql diff --git a/extras/v53_v54_conversion/postgresql_migration.sql b/extras/migration/v53_to_v54/postgresql_migration.sql similarity index 100% rename from extras/v53_v54_conversion/postgresql_migration.sql rename to extras/migration/v53_to_v54/postgresql_migration.sql diff --git a/extras/v53_v54_conversion/redshift_migration.sql b/extras/migration/v53_to_v54/redshift_migration.sql similarity index 100% rename from extras/v53_v54_conversion/redshift_migration.sql rename to extras/migration/v53_to_v54/redshift_migration.sql diff --git a/extras/v53_v54_conversion/sqlserver_migration.sql b/extras/migration/v53_to_v54/sqlserver_migration.sql similarity index 100% rename from extras/v53_v54_conversion/sqlserver_migration.sql rename to extras/migration/v53_to_v54/sqlserver_migration.sql diff --git a/extras/migration/v54_to_v55/README.md b/extras/migration/v54_to_v55/README.md new file mode 100644 index 00000000..3bb885d2 --- /dev/null +++ b/extras/migration/v54_to_v55/README.md @@ -0,0 +1,6 @@ +# v5.4 to v5.5 CDM conversion + +The *_migration.sql scripts in this folder migrate a v5.4 CDM to a v5.5 CDM. +These scripts follow the migration pattern already used in this repository and cover +the structural deltas reflected in the v5.4 and v5.5 DDLs under inst/ddl. +Please replace @cdmDatabaseSchema with your schema name. diff --git a/extras/migration/v54_to_v55/bigquery_migration.sql b/extras/migration/v54_to_v55/bigquery_migration.sql new file mode 100644 index 00000000..86d7ac8a --- /dev/null +++ b/extras/migration/v54_to_v55/bigquery_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 BigQuery DDLs in this repository. +-- BigQuery SQL references: +-- https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add column value_as_source_concept_id int64; + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add column value_as_date date; +alter table @cdmDatabaseSchema.observation add column unit_source_concept_id int64; +alter table @cdmDatabaseSchema.observation add column value_as_source_concept_id int64; + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add column visit_occurrence_id int64; +alter table @cdmDatabaseSchema.specimen add column visit_detail_id int64; + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add column cdm_release_identifier string; + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id INT64 not null, + drug_concept_id INT64 not null, + amount INT64, + box_size INT64 +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id INT64, + concept_category STRING, + reuse_status STRING +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 INT64 not null, + concept_id_2 INT64 not null, + relationship_id STRING not null, + relationship_predicate_id STRING, + relationship_group INT64, + mapping_source STRING, + confidence FLOAT64, + mapping_tool STRING, + mapper STRING, + reviewer STRING +); diff --git a/extras/migration/v54_to_v55/impala_migration.sql b/extras/migration/v54_to_v55/impala_migration.sql new file mode 100644 index 00000000..2e852807 --- /dev/null +++ b/extras/migration/v54_to_v55/impala_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 Impala DDLs in this repository. +-- Impala SQL references: +-- https://docs.cloudera.com/documentation/enterprise/latest/topics/impala_alter_table.html +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add columns (value_as_source_concept_id int); + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add columns (value_as_date timestamp); +alter table @cdmDatabaseSchema.observation add columns (unit_source_concept_id int); +alter table @cdmDatabaseSchema.observation add columns (value_as_source_concept_id int); + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add columns (visit_occurrence_id int); +alter table @cdmDatabaseSchema.specimen add columns (visit_detail_id int); + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add columns (cdm_release_identifier varchar(255)); + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id int, + drug_concept_id int, + amount int, + box_size int +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id int, + concept_category varchar(20), + reuse_status varchar(20) +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 int, + concept_id_2 int, + relationship_id varchar(20), + relationship_predicate_id varchar(20), + relationship_group int, + mapping_source varchar(50), + confidence float, + mapping_tool varchar(50), + mapper varchar(50), + reviewer varchar(50) +); diff --git a/extras/migration/v54_to_v55/netezza_migration.sql b/extras/migration/v54_to_v55/netezza_migration.sql new file mode 100644 index 00000000..5acb0943 --- /dev/null +++ b/extras/migration/v54_to_v55/netezza_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 Netezza DDLs in this repository. +-- Netezza SQL references: +-- https://www.ibm.com/docs/en/psfa +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add column value_as_source_concept_id integer null; + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add column value_as_date date null; +alter table @cdmDatabaseSchema.observation add column unit_source_concept_id integer null; +alter table @cdmDatabaseSchema.observation add column value_as_source_concept_id integer null; + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add column visit_occurrence_id integer null; +alter table @cdmDatabaseSchema.specimen add column visit_detail_id integer null; + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add column cdm_release_identifier varchar(255) null; + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id integer NOT NULL, + drug_concept_id integer NOT NULL, + amount integer NULL, + box_size integer NULL +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id integer NULL, + concept_category varchar(20) NULL, + reuse_status varchar(20) NULL +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + relationship_predicate_id varchar(20) NULL, + relationship_group integer NULL, + mapping_source varchar(50) NULL, + confidence float NULL, + mapping_tool varchar(50) NULL, + mapper varchar(50) NULL, + reviewer varchar(50) NULL +); diff --git a/extras/migration/v54_to_v55/oracle_migration.sql b/extras/migration/v54_to_v55/oracle_migration.sql new file mode 100644 index 00000000..56a697eb --- /dev/null +++ b/extras/migration/v54_to_v55/oracle_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 Oracle DDLs in this repository. +-- Oracle SQL references: +-- https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/ALTER-TABLE.html +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add (value_as_source_concept_id number default null); + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add (value_as_date date default null); +alter table @cdmDatabaseSchema.observation add (unit_source_concept_id number default null); +alter table @cdmDatabaseSchema.observation add (value_as_source_concept_id number default null); + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add (visit_occurrence_id number default null); +alter table @cdmDatabaseSchema.specimen add (visit_detail_id number default null); + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add (cdm_release_identifier varchar2(255) default null); + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id number NOT NULL, + drug_concept_id number NOT NULL, + amount number NULL, + box_size number NULL +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id number NULL, + concept_category varchar2(20) NULL, + reuse_status varchar2(20) NULL +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 number NOT NULL, + concept_id_2 number NOT NULL, + relationship_id varchar2(20) NOT NULL, + relationship_predicate_id varchar2(20) NULL, + relationship_group number NULL, + mapping_source varchar2(50) NULL, + confidence float NULL, + mapping_tool varchar2(50) NULL, + mapper varchar2(50) NULL, + reviewer varchar2(50) NULL +); diff --git a/extras/migration/v54_to_v55/postgresql_migration.sql b/extras/migration/v54_to_v55/postgresql_migration.sql new file mode 100644 index 00000000..b40efd50 --- /dev/null +++ b/extras/migration/v54_to_v55/postgresql_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 PostgreSQL DDLs in this repository. +-- PostgreSQL SQL references: +-- https://www.postgresql.org/docs/current/sql-altertable.html +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add column value_as_source_concept_id integer default null; + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add column value_as_date date default null; +alter table @cdmDatabaseSchema.observation add column unit_source_concept_id integer default null; +alter table @cdmDatabaseSchema.observation add column value_as_source_concept_id integer default null; + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add column visit_occurrence_id integer default null; +alter table @cdmDatabaseSchema.specimen add column visit_detail_id integer default null; + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add column cdm_release_identifier varchar(255) default null; + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id integer NOT NULL, + drug_concept_id integer NOT NULL, + amount integer NULL, + box_size integer NULL +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id integer NULL, + concept_category varchar(20) NULL, + reuse_status varchar(20) NULL +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + relationship_predicate_id varchar(20) NULL, + relationship_group integer NULL, + mapping_source varchar(50) NULL, + confidence numeric NULL, + mapping_tool varchar(50) NULL, + mapper varchar(50) NULL, + reviewer varchar(50) NULL +); diff --git a/extras/migration/v54_to_v55/redshift_migration.sql b/extras/migration/v54_to_v55/redshift_migration.sql new file mode 100644 index 00000000..eb92e660 --- /dev/null +++ b/extras/migration/v54_to_v55/redshift_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 Redshift DDLs in this repository. +-- Redshift SQL references: +-- https://docs.aws.amazon.com/redshift/latest/dg/r_ALTER_TABLE.html +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add column value_as_source_concept_id integer default null; + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add column value_as_date date default null; +alter table @cdmDatabaseSchema.observation add column unit_source_concept_id integer default null; +alter table @cdmDatabaseSchema.observation add column value_as_source_concept_id integer default null; + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add column visit_occurrence_id integer default null; +alter table @cdmDatabaseSchema.specimen add column visit_detail_id integer default null; + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add column cdm_release_identifier varchar(255) default null; + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id integer NOT NULL, + drug_concept_id integer NOT NULL, + amount integer NULL, + box_size integer NULL +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id integer NULL, + concept_category varchar(20) NULL, + reuse_status varchar(20) NULL +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 integer NOT NULL, + concept_id_2 integer NOT NULL, + relationship_id varchar(20) NOT NULL, + relationship_predicate_id varchar(20) NULL, + relationship_group integer NULL, + mapping_source varchar(50) NULL, + confidence float NULL, + mapping_tool varchar(50) NULL, + mapper varchar(50) NULL, + reviewer varchar(50) NULL +); diff --git a/extras/migration/v54_to_v55/sqlserver_migration.sql b/extras/migration/v54_to_v55/sqlserver_migration.sql new file mode 100644 index 00000000..57503488 --- /dev/null +++ b/extras/migration/v54_to_v55/sqlserver_migration.sql @@ -0,0 +1,58 @@ +-- Derived from the OMOP CDM v5.4 and v5.5 SQL Server DDLs in this repository. +-- SQL Server SQL references: +-- https://learn.microsoft.com/sql/t-sql/statements/alter-table-transact-sql +-- +-- MEASUREMENT +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.measurement add value_as_source_concept_id int null; + +-- OBSERVATION +-- + value_as_date +-- + unit_source_concept_id +-- + value_as_source_concept_id + +alter table @cdmDatabaseSchema.observation add value_as_date date null; +alter table @cdmDatabaseSchema.observation add unit_source_concept_id int null; +alter table @cdmDatabaseSchema.observation add value_as_source_concept_id int null; + +-- SPECIMEN +-- + visit_occurrence_id +-- + visit_detail_id + +alter table @cdmDatabaseSchema.specimen add visit_occurrence_id int null; +alter table @cdmDatabaseSchema.specimen add visit_detail_id int null; + +-- CDM_SOURCE +-- + cdm_release_identifier + +alter table @cdmDatabaseSchema.cdm_source add cdm_release_identifier varchar(255) null; + +-- PACK_CONTENT +create table @cdmDatabaseSchema.pack_content ( + pack_concept_id int NOT NULL, + drug_concept_id int NOT NULL, + amount int NULL, + box_size int NULL +); + +-- CONCEPT_METADATA +create table @cdmDatabaseSchema.concept_metadata ( + concept_id int NULL, + concept_category varchar(20) NULL, + reuse_status varchar(20) NULL +); + +-- CONCEPT_RELATIONSHIP_METADATA +create table @cdmDatabaseSchema.concept_relationship_metadata ( + concept_id_1 int NOT NULL, + concept_id_2 int NOT NULL, + relationship_id varchar(20) NOT NULL, + relationship_predicate_id varchar(20) NULL, + relationship_group int NULL, + mapping_source varchar(50) NULL, + confidence float NULL, + mapping_tool varchar(50) NULL, + mapper varchar(50) NULL, + reviewer varchar(50) NULL +); diff --git a/inst/csv/OMOP_CDMv5.5_Field_Level.csv b/inst/csv/OMOP_CDMv5.5_Field_Level.csv index 933f3e59..b36043a6 100644 --- a/inst/csv/OMOP_CDMv5.5_Field_Level.csv +++ b/inst/csv/OMOP_CDMv5.5_Field_Level.csv @@ -168,7 +168,7 @@ measurement,measurement_source_concept_id,FALSE,integer,"This is the concept rep measurement,unit_source_value,FALSE,varchar(50),This field contains the exact value from the source data that represents the unit of measurement used.,This value corresponds to a standardized CONCEPT_ID found in UNIT_CONCEPT_ID and in the 'Unit' domain within the Standardized Vocabularies. The original code is retained here for reference purposes.,FALSE,FALSE,NA,NA,NA,NA measurement,unit_source_concept_id,FALSE,integer,"""This is the concept representing the UNIT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Measurement necessary for a given analytic use case. Consider using UNIT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the UNIT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA measurement,value_source_value,FALSE,varchar(50),This field houses the verbatim result value of the Measurement from the source data .,"If both a continuous and categorical result are given in the source data such that both VALUE_AS_NUMBER and VALUE_AS_CONCEPT_ID are both included, store the verbatim value that was mapped to VALUE_AS_CONCEPT_ID here.",FALSE,FALSE,NA,NA,NA,NA -measurement,value_as_source_concept_Id,FALSE,integer,"This is the concept representing the VALUE_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using VALUE_AS_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the VALUE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA +measurement,value_as_source_concept_id,FALSE,integer,"This is the concept representing the VALUE_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using VALUE_AS_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the VALUE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA measurement,measurement_event_id,FALSE,integer,"If the Measurement record is related to another record in the database, this field is the primary key of the linked record.","Put the primary key of the linked record, if applicable, here.",FALSE,FALSE,NA,NA,NA,NA measurement,meas_event_field_concept_id,FALSE,integer,"If the Measurement record is related to another record in the database, this field is the CONCEPT_ID that identifies which table the primary key of the linked record came from.",Put the CONCEPT_ID that identifies which table and field the MEASUREMENT_EVENT_ID came from.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA observation,observation_id,TRUE,integer,The unique key given to an Observation record for a Person. Refer to the ETL for how duplicate Observations during the same Visit were handled.,Each instance of an observation present in the source data should be assigned this unique key.,TRUE,FALSE,NA,NA,NA,NA @@ -192,7 +192,7 @@ observation,unit_source_value,FALSE,varchar(50),This field houses the verbatim v observation,unit_source_concept_id,FALSE,integer,"""This is the concept representing the UNIT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using UNIT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the UNIT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA observation,qualifier_source_value,FALSE,varchar(50),This field houses the verbatim value from the source data representing the qualifier of the Observation that occurred.,This code is mapped to a Standard Concept in the Standardized Vocabularies and the original code is stored here for reference.,FALSE,FALSE,NA,NA,NA,NA observation,value_source_value,FALSE,varchar(50),This field houses the verbatim result value of the Observation from the source data. Do not get confused with the Observation_source_value which captures source value of the observation mapped to observation_concept_id. This field is the observation result value from the source.,"If the observation_source_value was a question, for example, or an observation that requires a result then this field is the answer/ result from the source data. Store the verbatim value that represents the result of the observation_source_value.",FALSE,FALSE,NA,NA,NA,NA -observation,value_as_source_concept_Id,FALSE,integer,"This is the concept representing the VALUE_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using VALUE_AS_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the VALUE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA +observation,value_as_source_concept_id,FALSE,integer,"This is the concept representing the VALUE_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using VALUE_AS_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the VALUE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA observation,observation_event_id,FALSE,integer,"If the Observation record is related to another record in the database, this field is the primary key of the linked record.","Put the primary key of the linked record, if applicable, here. See the [ETL Conventions for the OBSERVATION](https://ohdsi.github.io/CommonDataModel/cdm54.html#observation) table for more details.",FALSE,FALSE,NA,NA,NA,NA observation,obs_event_field_concept_id,FALSE,integer,"If the Observation record is related to another record in the database, this field is the CONCEPT_ID that identifies which table the primary key of the linked record came from.",Put the CONCEPT_ID that identifies which table and field the OBSERVATION_EVENT_ID came from.,FALSE,TRUE,CONCEPT,CONCEPT_ID,NA,NA death,person_id,TRUE,integer,NA,NA,FALSE,TRUE,PERSON,PERSON_ID,NA,NA diff --git a/site/_quarto.yml b/site/_quarto.yml index dae6d6f4..38025438 100644 --- a/site/_quarto.yml +++ b/site/_quarto.yml @@ -60,6 +60,8 @@ website: href: cdm54ToolingSupport.qmd - text: "CDM v5.5" href: cdm55.qmd + - text: " - Changes from CDM v5.4" + href: cdm55Changes.qmd - text: "CDM Additions" icon: plus-square menu: diff --git a/site/cdm53Changes.qmd b/site/cdm53Changes.qmd new file mode 100644 index 00000000..3477cb70 --- /dev/null +++ b/site/cdm53Changes.qmd @@ -0,0 +1,138 @@ +--- +title: "Changes v5.2 → v5.3" +format: + html: + toc: true + toc-location: left +--- + +For a full description of each table and field listed here, please see the [CDM v5.3 specification](cdm53.qmd). + +Notation: + +- a **+** indicates an **addition** to the model, either a table or field. +- a **→** indicates an **alteration** either in naming or specification. +- a **-** indicates a **subtraction** from the model, either a table or field. + +## Summary + +- **18** fields added to existing OMOP tables, all non-required. +- **2** tables added to the model: `VISIT_DETAIL` and `METADATA`. +- Visit-level provenance was expanded across clinical event tables with the addition of `visit_detail_id`. + +## PROCEDURE_OCCURRENCE +- **+** `visit_detail_id` +- `qualifier_source_value` **→** `modifier_source_value` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## DRUG_EXPOSURE +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## DEVICE_EXPOSURE +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## CONDITION_OCCURRENCE +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## MEASUREMENT +- **+** `measurement_time` +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| measurement_time | varchar(10) | No | No | No | +| visit_detail_id | integer | No | No | Yes | + +## OBSERVATION +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## NOTE +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | No | No | Yes | + +## NOTE_NLP +- `note_nlp_id` **→** Changed from `big integer` to `integer` +- `nlp_date_time` **→** `nlp_datetime` + +## PAYER_PLAN_PERIOD +- **+** `payer_concept_id` +- **+** `payer_source_concept_id` +- **+** `plan_concept_id` +- **+** `plan_source_concept_id` +- **+** `sponsor_concept_id` +- **+** `sponsor_source_value` +- **+** `sponsor_source_concept_id` +- **+** `stop_reason_concept_id` +- **+** `stop_reason_source_value` +- **+** `stop_reason_source_concept_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| payer_concept_id | integer | No | No | Yes | +| payer_source_concept_id | integer | No | No | Yes | +| plan_concept_id | integer | No | No | Yes | +| plan_source_concept_id | integer | No | No | Yes | +| sponsor_concept_id | integer | No | No | Yes | +| sponsor_source_value | varchar(50) | No | No | No | +| sponsor_source_concept_id | integer | No | No | Yes | +| stop_reason_concept_id | integer | No | No | Yes | +| stop_reason_source_value | varchar(50) | No | No | No | +| stop_reason_source_concept_id | integer | No | No | Yes | + +## **+** VISIT_DETAIL + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_detail_id | integer | Yes | Yes | No | +| person_id | integer | Yes | No | Yes | +| visit_detail_concept_id | integer | Yes | No | Yes | +| visit_detail_start_date | date | Yes | No | No | +| visit_detail_start_datetime | datetime | No | No | No | +| visit_detail_end_date | date | Yes | No | No | +| visit_detail_end_datetime | datetime | No | No | No | +| visit_detail_type_concept_id | integer | Yes | No | Yes | +| provider_id | integer | No | No | Yes | +| care_site_id | integer | No | No | Yes | +| visit_detail_source_value | varchar(50) | No | No | No | +| visit_detail_source_concept_id | integer | No | No | Yes | +| admitting_source_value | varchar(50) | No | No | No | +| admitting_source_concept_id | integer | No | No | Yes | +| discharge_to_source_value | varchar(50) | No | No | No | +| discharge_to_concept_id | integer | No | No | Yes | +| preceding_visit_detail_id | integer | No | No | Yes | +| visit_detail_parent_id | integer | No | No | Yes | +| visit_occurrence_id | integer | Yes | No | Yes | + +## **+** METADATA + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| metadata_concept_id | integer | Yes | No | Yes | +| metadata_type_concept_id | integer | Yes | No | Yes | +| name | varchar(250) | Yes | No | No | +| value_as_string | varchar(250) | No | No | No | +| value_as_concept_id | integer | No | No | Yes | +| metadata_date | date | No | No | No | +| metadata_datetime | datetime | No | No | No | diff --git a/site/cdm54Changes.qmd b/site/cdm54Changes.qmd index 300189cb..f47c6678 100644 --- a/site/cdm54Changes.qmd +++ b/site/cdm54Changes.qmd @@ -1,185 +1,165 @@ --- -title: "Changes by Table" +title: "Changes v5.3 → v5.4" format: html: toc: true toc-location: left --- -*from CDM v5.3 -> CDM v5.4* -For a full description of each table and field listed here, please see the [CDM specification](https://ohdsi.github.io/CommonDataModel/cdm54.html). +For a full description of each table and field listed here, please see the [CDM v5.4 specification](cdm54.qmd). Notation: -- a **\+** indicates an addition to the model, either a table or field -- a **->** indicates an alteration either in naming or specification -- a **-** indicates a subtraction from the model, either a table or field +- a **+** indicates an **addition** to the model, either a table or field. +- a **→** indicates an **alteration** either in naming or specification. +- a **-** indicates a **subtraction** from the model, either a table or field. -## PERSON -- No change +## Summary -## OBSERVATION_PERIOD -- No change +- **8** fields renamed. +- **8** field definitions changed. +- **21** fields added to existing tables, all non-required except for one (metadata_id). +- **3** tables added: `EPISODE`, `EPISODE_EVENT` and `COHORT`. +- **1** table removed: `ATTRIBUTE_DEFINITION`. ## VISIT_OCCURRENCE -- Admitting_source_concept_id -> **Admitted_from_concept_id** -- Admitting_source_value -> **Admitted_from_source_value** -- Discharge_to_concept_id -> **Discharged_to_concept_id** -- Discharge_to_source_value -> **Discharged_to_source_value** +- `admitting_source_concept_id` **→** `admitted_from_concept_id` +- `admitting_source_value` **→** `admitted_from_source_value` +- `discharge_to_concept_id` **→** `discharged_to_concept_id` +- `discharge_to_source_value` **→** `discharged_to_source_value` ## VISIT_DETAIL -- Admitting_source_concept_id -> **Admitted_from_concept_id** -- Admitting_source_value -> **Admitted_from_source_value** -- Discharge_to_concept_id -> **Discharged_to_concept_id** -- Discharge_to_source_value -> **Discharged_to_source_value** -- Visit_detail_parent_id -> **Parent_visit_detail_id** - -## CONDITION_OCCURRENCE -- No change - -## DRUG_EXPOSURE -- No change +- `admitting_source_concept_id` **→** `admitted_from_concept_id` +- `admitting_source_value` **→** `admitted_from_source_value` +- `discharge_to_concept_id` **→** `discharged_to_concept_id` +- `discharge_to_source_value` **→** `discharged_to_source_value` +- `visit_detail_parent_id` **→** `parent_visit_detail_id` ## PROCEDURE_OCCURRENCE -- \+ **Procedure_end_date** -- \+ **Procedure_end_datetime** +- **+** `procedure_end_date` +- **+** `procedure_end_datetime` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| procedure_end_date | date | No | No | No | +| procedure_end_datetime | datetime | No | No | No | ## DEVICE_EXPOSURE -- Unique_device_id -> **Changed to varchar(255)** -- \+ **Production_id** -- \+ **Unit_concept_id** -- \+ **Unit_source_value** -- \+ **Unit_source_concept_id** +- `unique_device_id` **→** Changed to `varchar(255)` +- **+** `production_id` +- **+** `unit_concept_id` +- **+** `unit_source_value` +- **+** `unit_source_concept_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| production_id | varchar(255) | No | No | No | +| unit_concept_id | integer | No | No | Yes | +| unit_source_value | varchar(50) | No | No | No | +| unit_source_concept_id | integer | No | No | Yes | ## MEASUREMENT -- \+ **Unit_source_concept_id** -- \+ **Measurement_event_id** -- \+ **Meas_event_field_concept_id** +- **+** `unit_source_concept_id` +- **+** `measurement_event_id` +- **+** `meas_event_field_concept_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| unit_source_concept_id | integer | No | No | Yes | +| measurement_event_id | integer | No | No | No | +| meas_event_field_concept_id | integer | No | No | Yes | ## OBSERVATION -- \+ **Value_source_value** -- \+ **Observation_event_id** -- \+ **Obs_event_field_concept_id** +- **+** `value_source_value` +- **+** `observation_event_id` +- **+** `obs_event_field_concept_id` -## DEATH -- No change +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| value_source_value | varchar(50) | No | No | No | +| observation_event_id | integer | No | No | No | +| obs_event_field_concept_id | integer | No | No | Yes | ## NOTE -- \+ **Note_event_id** -- \+ **Note_event_field_concept_id** +- **+** `note_event_id` +- **+** `note_event_field_concept_id` -## NOTE_NLP -- No change - -## SPECIMEN -- No change - -## FACT_RELATIONSHIP -- No change +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| note_event_id | integer | No | No | No | +| note_event_field_concept_id | integer | No | No | Yes | ## LOCATION -- \+ **Country_concept_id** -- \+ **Country_source_value** -- \+ **Latitude** -- \+ **Longitude** - -## CARE_SITE -- No change - -## PAYER_PLAN_PERIOD -- No change - -## PROVIDER -- No change - -## COST -- No change - -## DRUG_ERA -- No change - -## DOSE_ERA -- No change - -## CONDITION_ERA -- No change - -## \+ EPISODE - -| EPISODE | -|----------------------------------| -| episode_id | -| person_id | -| episode_concept_id | -| episode_start_date | -| episode_start_datetime | -| episode_end_date | -| episode_end_datetime | -| episode_parent_id | -| episode_number | -| episode_object_concept_id | -| episode_type_concept_id | -| episode_source_value | -| episode_source_concept_id | - -## \+ EPISODE_EVENT - -| EPISODE_EVENT | -|------------------------------------| -| episode_id | -| event_id | -| episode_event_field_concept_id | +- **+** `country_concept_id` +- **+** `country_source_value` +- **+** `latitude` +- **+** `longitude` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| country_concept_id | integer | No | No | Yes | +| country_source_value | varchar(80) | No | No | No | +| latitude | float | No | No | No | +| longitude | float | No | No | No | + +## **+** EPISODE + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| episode_id | integer | Yes | Yes | No | +| person_id | integer | Yes | No | Yes | +| episode_concept_id | integer | Yes | No | Yes | +| episode_start_date | date | Yes | No | No | +| episode_start_datetime | datetime | No | No | No | +| episode_end_date | date | No | No | No | +| episode_end_datetime | datetime | No | No | No | +| episode_parent_id | integer | No | No | Yes | +| episode_number | integer | No | No | No | +| episode_object_concept_id | integer | Yes | No | Yes | +| episode_type_concept_id | integer | Yes | No | Yes | +| episode_source_value | varchar(50) | No | No | No | +| episode_source_concept_id | integer | No | No | Yes | + +## **+** EPISODE_EVENT + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| episode_id | integer | Yes | No | Yes | +| event_id | integer | Yes | No | No | +| episode_event_field_concept_id | integer | Yes | No | Yes | ## METADATA -- \+ **Metadata_id** -- \+ **Value_as_number** +- **+** `metadata_id` +- **+** `value_as_number` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| metadata_id | integer | Yes | Yes | No | +| value_as_number | float | No | No | No | ## CDM_SOURCE -- Cdm_source_name -> **Mandatory field** -- Cdm_source_abbreviation -> **Mandatory field** -- Cdm_holder -> **Mandatory field** -- Source_release_date -> **Mandatory field** -- Cdm_release_date -> **Mandatory field** -- \+ **Cdm_version_concept_id** +- `cdm_source_name` **→** Mandatory field +- `cdm_source_abbreviation` **→** Mandatory field +- `cdm_holder` **→** Mandatory field +- `source_release_date` **→** Mandatory field +- `cdm_release_date` **→** Mandatory field +- **+** `cdm_version_concept_id` -## CONCEPT -- No change +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| cdm_version_concept_id | integer | Yes | No | Yes | ## VOCABULARY -- Vocabulary_reference -> **Non-mandatory field** -- Vocabulary_version -> **Non-mandatory field** - -## DOMAIN -- No change - -## CONCEPT_CLASS -- No change - -## CONCEPT_RELATIONSHIP -- No change - -## RELATIONSHIP -- No change - -## CONCEPT_SYNONYM -- No change - -## CONCEPT_ANCESTOR -- No change - -## SOURCE_TO_CONCEPT_MAP -- No change - -## DRUG_STRENGTH -- No change +- `vocabulary_reference` **→** Non-mandatory field +- `vocabulary_version` **→** Non-mandatory field -## - ATTRIBUTE_DEFINITION +## **-** ATTRIBUTE_DEFINITION -## \+ COHORT +## **+** COHORT -| COHORT | -|------------------------------------| -| cohort_definition_id | -| subject_id | -| cohort_start_date | -| cohort_end_date | +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| cohort_definition_id | integer | Yes | No | No | +| subject_id | integer | Yes | No | No | +| cohort_start_date | date | Yes | No | No | +| cohort_end_date | date | Yes | No | No | diff --git a/site/cdm55Changes.qmd b/site/cdm55Changes.qmd new file mode 100644 index 00000000..c0a9fdad --- /dev/null +++ b/site/cdm55Changes.qmd @@ -0,0 +1,92 @@ +--- +title: "Changes v5.4 → v5.5" +format: + html: + toc: true + toc-location: left +--- + +For a full description of each table and field listed here, please see the [CDM v5.5 specification](cdm55.qmd). + +Notation: + +- a **+** indicates an **addition** to the model, either a table or field. +- a **→** indicates an **alteration** either in naming or specification. +- a **-** indicates a **subtraction** from the model, either a table or field. + +## Summary + +- **7** fields added to existing OMOP tables, all non-required. +- **3** tables added, all to store vocabulary metadata. +- **2** table/field definitions changed. +- **No** fields or tables have been removed or renamed. + +## MEASUREMENT +- **+** `value_as_source_concept_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| value_as_source_concept_id | integer | No | No | Yes | + +## OBSERVATION +- **+** `value_as_date` +- **+** `unit_source_concept_id` +- **+** `value_as_source_concept_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| value_as_date | date | No | No | No | +| unit_source_concept_id | integer | No | No | Yes | +| value_as_source_concept_id | integer | No | No | Yes | + +## SPECIMEN +- **+** `visit_occurrence_id` +- **+** `visit_detail_id` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| visit_occurrence_id | integer | No | No | Yes | +| visit_detail_id | integer | No | No | Yes | + +## CDM_SOURCE +- **→** Table description updated to describe that tooling expects one record with database metadata +- **+** `cdm_release_identifier` + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| cdm_release_identifier | varchar(255) | No | No | No | + +## VOCABULARY +- `vocabulary_id` **→** Unique constraint added + +## **+** PACK_CONTENT + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| pack_concept_id | integer | Yes | No | Yes | +| drug_concept_id | integer | Yes | No | Yes | +| amount | integer | No | No | No | +| box_size | integer | No | No | No | + +## **+** CONCEPT_METADATA + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| concept_id | integer | No | No | Yes | +| concept_category | varchar(20) | No | No | No | +| reuse_status | varchar(20) | No | No | No | + +## **+** CONCEPT_RELATIONSHIP_METADATA + +| Field | Datatype | Required | Primary Key | Foreign Key | +|---|---|---|---|---| +| concept_id_1 | integer | Yes | No | Yes | +| concept_id_2 | integer | Yes | No | Yes | +| relationship_id | varchar(20) | Yes | No | Yes | +| relationship_predicate_id | varchar(20) | No | No | No | +| relationship_group | integer | No | No | No | +| mapping_source | varchar(50) | No | No | No | +| confidence | float | No | No | No | +| mapping_tool | varchar(50) | No | No | No | +| mapper | varchar(50) | No | No | No | +| reviewer | varchar(50) | No | No | No |