2018-01-03 19:56:42 +00:00
/*********************************************************************************
2018-08-31 01:00:34 +00:00
# Copyright 2018-08 Observational Health Data Sciences and Informatics
2018-01-03 19:56:42 +00:00
#
#
2018-08-31 01:00:34 +00:00
# Licensed under the Apache License, Version 2.0 (the "License");
2018-01-03 19:56:42 +00:00
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
********************************************************************************/
/************************
2018-08-31 01:00:34 +00:00
####### # # ####### ###### ##### ###### # # ##### ###
# # ## ## # # # # # # # # ## ## # # # # # #
# # # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### # #
# # # # # # # # # # # # # # # # ### # #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### ###
2018-01-03 19:56:42 +00:00
2018-08-31 01:00:34 +00:00
redshift script to create OMOP common data model version 6.0
2018-01-03 19:56:42 +00:00
2018-08-31 01:00:34 +00:00
last revised: 27-Aug-2018
2018-01-03 19:56:42 +00:00
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE concept (concept_id INTEGER NOT NULL ,
concept_name VARCHAR(255) NOT NULL ,
domain_id VARCHAR(20) NOT NULL ,
vocabulary_id VARCHAR(20) NOT NULL ,
concept_class_id VARCHAR(20) NOT NULL ,
standard_concept VARCHAR(1) NULL ,
concept_code VARCHAR(50) NOT NULL ,
valid_start_date DATE NOT NULL ,
valid_end_date DATE NOT NULL ,
invalid_reason VARCHAR(1) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE vocabulary (vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
2018-06-14 20:15:03 +00:00
vocabulary_version VARCHAR(255) NOT NULL,
2018-01-03 19:56:42 +00:00
vocabulary_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE domain (domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE concept_class (concept_class_id VARCHAR(20) NOT NULL,
concept_class_name VARCHAR(255) NOT NULL,
concept_class_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE concept_relationship (concept_id_1 INTEGER NOT NULL,
concept_id_2 INTEGER NOT NULL,
relationship_id VARCHAR(20) NOT NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason VARCHAR(1) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE relationship (relationship_id VARCHAR(20) NOT NULL,
relationship_name VARCHAR(255) NOT NULL,
is_hierarchical VARCHAR(1) NOT NULL,
defines_ancestry VARCHAR(1) NOT NULL,
reverse_relationship_id VARCHAR(20) NOT NULL,
relationship_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE concept_synonym (concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE concept_ancestor (ancestor_concept_id INTEGER NOT NULL,
descendant_concept_id INTEGER NOT NULL,
min_levels_of_separation INTEGER NOT NULL,
max_levels_of_separation INTEGER NOT NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE source_to_concept_map (source_code VARCHAR(50) NOT NULL,
source_concept_id INTEGER NOT NULL,
source_vocabulary_id VARCHAR(20) NOT NULL,
source_code_description VARCHAR(255) NULL,
target_concept_id INTEGER NOT NULL,
target_vocabulary_id VARCHAR(20) NOT NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason VARCHAR(1) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE drug_strength (drug_concept_id INTEGER NOT NULL,
ingredient_concept_id INTEGER NOT NULL,
amount_value FLOAT NULL,
amount_unit_concept_id INTEGER NULL,
numerator_value FLOAT NULL,
numerator_unit_concept_id INTEGER NULL,
denominator_value FLOAT NULL,
denominator_unit_concept_id INTEGER NULL,
box_size INTEGER NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason VARCHAR(1) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE cohort_definition (cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description VARCHAR(MAX) NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax VARCHAR(MAX) NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE attribute_definition (attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description VARCHAR(MAX) NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax VARCHAR(MAX) NULL
)
DISTSTYLE ALL;
/**************************
Standardized meta-data
***************************/
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE cdm_source
(cdm_source_name VARCHAR(255) NOT NULL ,
cdm_source_abbreviation VARCHAR(25) NULL ,
cdm_holder VARCHAR(255) NULL ,
source_description VARCHAR(MAX) NULL ,
source_documentation_reference VARCHAR(255) NULL ,
cdm_etl_reference VARCHAR(255) NULL ,
source_release_date DATE NULL ,
cdm_release_date DATE NULL ,
cdm_version VARCHAR(10) NULL ,
vocabulary_version VARCHAR(20) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE metadata
(metadata_concept_id INTEGER NOT NULL ,
metadata_type_concept_id INTEGER NOT NULL ,
name VARCHAR(250) NOT NULL ,
value_as_string VARCHAR(MAX) NULL ,
value_as_concept_id INTEGER NULL ,
metadata_date DATE NULL ,
metadata_datetime TIMESTAMP NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
INSERT INTO metadata (name, value_as_string) --Added cdm version record
VALUES ('CDM Version', '6.0')
;
2018-01-03 19:56:42 +00:00
/************************
Standardized clinical data
************************/
2018-08-31 01:00:34 +00:00
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE person
2018-08-31 01:00:34 +00:00
(person_id BIGINT NOT NULL , --BIGINTs added
2018-01-03 19:56:42 +00:00
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime TIMESTAMP NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE observation_period
2018-08-31 01:00:34 +00:00
(observation_period_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE specimen
2018-08-31 01:00:34 +00:00
(specimen_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
specimen_date DATE NULL ,
specimen_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE death
2018-08-31 01:00:34 +00:00
(person_id BIGINT NOT NULL ,
death_date DATE NULL ,
death_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE visit_occurrence
2018-08-31 01:00:34 +00:00
(visit_occurrence_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
visit_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
visit_start_date DATE NULL ,
visit_start_datetime TIMESTAMP NOT NULL ,
visit_end_date DATE NULL ,
visit_end_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */
admitted_from_source_value VARCHAR(50) NULL ,
2018-01-03 19:56:42 +00:00
discharge_to_source_value VARCHAR(50) NULL ,
2018-08-31 01:00:34 +00:00
discharge_to_concept_id INTEGER NULL ,
2018-01-03 19:56:42 +00:00
preceding_visit_occurrence_id INTEGER NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE visit_detail
2018-08-31 01:00:34 +00:00
(visit_detail_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-06-14 20:15:03 +00:00
visit_detail_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
visit_detail_start_date DATE NULL ,
visit_detail_start_datetime TIMESTAMP NOT NULL ,
visit_detail_end_date DATE NULL ,
visit_detail_end_datetime TIMESTAMP NOT NULL ,
2018-06-14 20:15:03 +00:00
visit_detail_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
admitted_from_concept_id INTEGER NULL , /*Changed from admitting_source_* */
admitted_from_source_value VARCHAR(50) NULL ,
2018-06-14 20:15:03 +00:00
visit_detail_source_value VARCHAR(50) NULL ,
visit_detail_source_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
2018-08-31 01:00:34 +00:00
preceding_visit_detail_id BIGINT NULL ,
visit_detail_parent_id BIGINT NULL ,
visit_occurrence_id BIGINT NOT NULL
2018-01-03 19:56:42 +00:00
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE procedure_occurrence
2018-08-31 01:00:34 +00:00
(procedure_occurrence_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
procedure_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
procedure_date DATE NULL ,
procedure_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
modifier_source_value VARCHAR(50) NULL ,
2018-01-03 19:56:42 +00:00
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE drug_exposure
2018-08-31 01:00:34 +00:00
(drug_exposure_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
drug_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
drug_exposure_start_date DATE NULL ,
drug_exposure_start_datetime TIMESTAMP NOT NULL ,
drug_exposure_end_date DATE NULL ,
drug_exposure_end_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig VARCHAR(MAX) NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
drug_source_value VARCHAR(50) NULL ,
drug_source_concept_id INTEGER NULL ,
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE device_exposure
2018-08-31 01:00:34 +00:00
(device_exposure_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
device_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
device_exposure_start_date DATE NULL ,
device_exposure_start_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE condition_occurrence
2018-08-31 01:00:34 +00:00
(condition_occurrence_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
condition_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
condition_start_date DATE NULL ,
condition_start_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP NULL ,
condition_type_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
condition_status_concept_id INTEGER NULL ,
2018-01-03 19:56:42 +00:00
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
condition_status_source_value VARCHAR(50) NULL
2018-01-03 19:56:42 +00:00
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE measurement
2018-08-31 01:00:34 +00:00
(measurement_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
measurement_concept_id INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
measurement_date DATE NULL ,
measurement_datetime TIMESTAMP NOT NULL ,
2018-06-14 20:15:03 +00:00
measurement_time VARCHAR(10) NULL,
2018-01-03 19:56:42 +00:00
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE note
2018-08-31 01:00:34 +00:00
(note_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
note_event_id BIGINT NULL , --This and the field below added
note_domain_id VARCHAR(20) NULL , --This field may be removed in favor of the one below
--note_event_table_concept_id INTEGER NULL , --This may be added based on 9/4 meeting
note_date DATE NULL ,
note_datetime TIMESTAMP NOT NULL ,
2018-01-03 19:56:42 +00:00
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text VARCHAR(MAX) NULL ,
encoding_concept_id INTEGER NOT NULL ,
language_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
note_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE note_nlp
2018-08-31 01:00:34 +00:00
(note_nlp_id BIGINT NOT NULL ,
note_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
section_concept_id INTEGER NULL ,
snippet VARCHAR(250) NULL ,
"offset" VARCHAR(250) NULL ,
lexical_variant VARCHAR(250) NOT NULL ,
note_nlp_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
2018-08-31 01:00:34 +00:00
term_modifiers VARCHAR(2000) NULL ,
note_nlp_source_concept_id INTEGER NULL
2018-01-03 19:56:42 +00:00
)
DISTSTYLE ALL;
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE observation
2018-08-31 01:00:34 +00:00
(observation_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NULL ,
observation_datetime TIMESTAMP NOT NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL ,
observation_event_id BIGINT NULL , /* This will link back to the event table (SURVEY) on SURVEY_OCCURRENCE_ID, changed name to comply with COST and NOTE*/
observation_event_domain_id VARCHAR(20) NULL ,
--obs_event_table_concept_id INTEGER NULL , /* Changed name to comply with COST and NOTE. Had to use 'obs' for oracle restriction, may be added on 9/4*/
value_as_datetime TIMESTAMP NULL
2018-01-03 19:56:42 +00:00
)
DISTKEY(person_id);
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON KEY(person_id)
CREATE TABLE survey_conduct --Table added
(survey_conduct_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
survey_concept_id INTEGER NOT NULL ,
survey_start_date DATE NULL ,
survey_start_datetime TIMESTAMP NULL ,
survey_end_date DATE NULL ,
survey_end_datetime TIMESTAMP NOT NULL ,
provider_id BIGINT NULL ,
assisted_concept_id INTEGER NULL ,
respondent_type_concept_id INTEGER NULL ,
timing_concept_id INTEGER NULL ,
collection_method_concept_id INTEGER NULL ,
assisted_source_value VARCHAR(50) NULL ,
respondent_type_source_value VARCHAR(100) NULL ,
timing_source_value VARCHAR(100) NULL ,
collection_method_source_value VARCHAR(100) NULL ,
survey_source_value VARCHAR(100) NULL ,
survey_source_concept_id INTEGER NULL ,
survey_source_identifier VARCHAR(100) NULL ,
validated_survey_concept_id INTEGER NULL ,
validated_survey_source_value VARCHAR(100) NULL ,
survey_version_number VARCHAR(20) NULL ,
visit_occurrence_id BIGINT NULL ,
visit_detail_id BIGINT NULL ,
response_to_visit_occurrence_id BIGINT NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE fact_relationship
(domain_concept_id_1 INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
fact_id_1 BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
domain_concept_id_2 INTEGER NOT NULL ,
2018-08-31 01:00:34 +00:00
fact_id_2 BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
relationship_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
/************************
Standardized health system data
************************/
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE location
2018-08-31 01:00:34 +00:00
(location_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
2018-08-31 01:00:34 +00:00
county VARCHAR(20) NULL ,
country VARCHAR(100) NULL ,
location_source_value VARCHAR(50) NULL ,
latitude FLOAT NULL ,
longitude FLOAT NULL
)
DISTSTYLE ALL;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE location_history --Table added
(location_history_id BIGINT NOT NULL ,
location_id BIGINT NOT NULL ,
relationship_type_concept_id INTEGER NULL , --Recent addition based on github discussion
domain_id VARCHAR(50) NOT NULL ,
entity_id BIGINT NOT NULL ,
start_date DATE NOT NULL ,
end_date DATE NULL
2018-01-03 19:56:42 +00:00
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE care_site
2018-08-31 01:00:34 +00:00
(care_site_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
location_id BIGINT NULL ,
2018-01-03 19:56:42 +00:00
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
DISTSTYLE ALL;
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON RANDOM
2018-01-03 19:56:42 +00:00
CREATE TABLE provider
2018-08-31 01:00:34 +00:00
(provider_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
care_site_id BIGINT NULL ,
2018-01-03 19:56:42 +00:00
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
DISTSTYLE ALL;
/************************
Standardized health economics
************************/
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE payer_plan_period
2018-08-31 01:00:34 +00:00
(payer_plan_period_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
contract_person_id BIGINT NULL ,
2018-01-03 19:56:42 +00:00
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
plan_concept_id INTEGER NULL ,
contract_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
stop_reason_concept_id INTEGER NULL ,
2018-01-03 19:56:42 +00:00
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
2018-08-31 01:00:34 +00:00
contract_source_value VARCHAR(50) NULL ,
contract_source_concept_id INTEGER NULL ,
2018-01-03 19:56:42 +00:00
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
2018-08-31 01:00:34 +00:00
stop_reason_source_value VARCHAR(50) NULL ,
2018-01-03 19:56:42 +00:00
stop_reason_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
2018-08-31 01:00:34 +00:00
--HINT DISTRIBUTE ON KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE cost
2018-08-31 01:00:34 +00:00
(cost_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL,
cost_event_id BIGINT NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
--cost_event_table_concept_id INTEGER NOT NULL , /*This is still in discussion and most likely will replace cost_domain_id at 9/4 meeting*/
cost_concept_id INTEGER NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
cost FLOAT NULL ,
incurred_date DATE NOT NULL ,
billed_date DATE NULL ,
paid_date DATE NULL ,
revenue_code_concept_id INTEGER NULL ,
drg_concept_id INTEGER NULL ,
cost_source_value VARCHAR(50) NULL ,
cost_source_concept_id INTEGER NULL ,
revenue_code_source_value VARCHAR(50) NULL ,
drg_source_value VARCHAR(3) NULL ,
payer_plan_period_id BIGINT NULL
2018-01-03 19:56:42 +00:00
)
2018-08-31 01:00:34 +00:00
DISTKEY(person_id);
2018-01-03 19:56:42 +00:00
/************************
Standardized derived elements
************************/
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(subject_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE cohort
2018-08-31 01:00:34 +00:00
(cohort_definition_id BIGINT NOT NULL ,
subject_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
DISTKEY(subject_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(subject_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE cohort_attribute
2018-08-31 01:00:34 +00:00
(cohort_definition_id BIGINT NOT NULL ,
subject_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
2018-08-31 01:00:34 +00:00
attribute_definition_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
DISTKEY(subject_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE drug_era
2018-08-31 01:00:34 +00:00
(drug_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE dose_era
2018-08-31 01:00:34 +00:00
(dose_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
DISTKEY(person_id);
2018-02-07 20:25:57 +00:00
--HINT DISTRIBUTE_ON_KEY(person_id)
2018-01-03 19:56:42 +00:00
CREATE TABLE condition_era
2018-08-31 01:00:34 +00:00
(condition_era_id BIGINT NOT NULL ,
person_id BIGINT NOT NULL ,
2018-01-03 19:56:42 +00:00
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
DISTKEY(person_id);