This commit is contained in:
Clair Blacketer 2018-01-05 19:12:28 -05:00
commit 8f67d55af2
72 changed files with 8211 additions and 6956 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata

View File

@ -0,0 +1,651 @@
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
)
;
create table vocabulary (
vocabulary_id varchar(20) not null,
vocabulary_name varchar(255) not null,
vocabulary_reference varchar(255) not null,
vocabulary_version varchar(255) not null,
vocabulary_concept_id integer not null
)
;
create table domain (
domain_id varchar(20) not null,
domain_name varchar(255) not null,
domain_concept_id integer not null
)
;
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
)
;
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
)
;
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
)
;
create table concept_synonym (
concept_id integer not null,
concept_synonym_name varchar(1000) not null,
language_concept_id integer not null
)
;
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
)
;
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
)
;
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
)
;
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
)
;
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
)
;
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
)
;
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 datetime null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table person
(
person_id integer not null ,
gender_concept_id integer not null ,
year_of_birth integer not null ,
month_of_birth integer null,
day_of_birth integer null,
birth_datetime datetime null,
race_concept_id integer not null,
ethnicity_concept_id integer not null,
location_id integer null,
provider_id integer null,
care_site_id integer null,
person_source_value varchar(50) null,
gender_source_value varchar(50) null,
gender_source_concept_id integer null,
race_source_value varchar(50) null,
race_source_concept_id integer null,
ethnicity_source_value varchar(50) null,
ethnicity_source_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table observation_period
(
observation_period_id integer not null ,
person_id integer not null ,
observation_period_start_date date not null ,
observation_period_end_date date not null ,
period_type_concept_id integer not null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table specimen
(
specimen_id integer not null ,
person_id integer not null ,
specimen_concept_id integer not null ,
specimen_type_concept_id integer not null ,
specimen_date date not null ,
specimen_datetime datetime null ,
quantity float null ,
unit_concept_id integer null ,
anatomic_site_concept_id integer null ,
disease_status_concept_id integer null ,
specimen_source_id varchar(50) null ,
specimen_source_value varchar(50) null ,
unit_source_value varchar(50) null ,
anatomic_site_source_value varchar(50) null ,
disease_status_source_value varchar(50) null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table death
(
person_id integer not null ,
death_date date not null ,
death_datetime datetime null ,
death_type_concept_id integer not null ,
cause_concept_id integer null ,
cause_source_value varchar(50) null,
cause_source_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table visit_occurrence
(
visit_occurrence_id integer not null ,
person_id integer not null ,
visit_concept_id integer not null ,
visit_start_date date not null ,
visit_start_datetime datetime null ,
visit_end_date date not null ,
visit_end_datetime datetime null ,
visit_type_concept_id integer not null ,
provider_id integer null,
care_site_id integer null,
visit_source_value varchar(50) null,
visit_source_concept_id integer null ,
admitting_source_concept_id integer null ,
admitting_source_value varchar(50) null ,
discharge_to_concept_id integer null ,
discharge_to_source_value varchar(50) null ,
preceding_visit_occurrence_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table visit_detail
(
visit_detail_id integer not null ,
person_id integer not null ,
visit_detail_concept_id integer not null ,
visit_start_date date not null ,
visit_start_datetime datetime null ,
visit_end_date date not null ,
visit_end_datetime datetime null ,
visit_type_concept_id integer not null ,
provider_id integer null ,
care_site_id integer null ,
admitting_source_concept_id integer null ,
discharge_to_concept_id integer null ,
preceding_visit_detail_id integer null ,
visit_source_value varchar(50) null ,
visit_source_concept_id integer null ,
admitting_source_value varchar(50) null ,
discharge_to_source_value varchar(50) null ,
visit_detail_parent_id integer null ,
visit_occurrence_id integer not null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table procedure_occurrence
(
procedure_occurrence_id integer not null ,
person_id integer not null ,
procedure_concept_id integer not null ,
procedure_date date not null ,
procedure_datetime datetime null ,
procedure_type_concept_id integer not null ,
modifier_concept_id integer null ,
quantity integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
procedure_source_value varchar(50) null ,
procedure_source_concept_id integer null ,
modifier_source_value varchar(50) null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table drug_exposure
(
drug_exposure_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
drug_exposure_start_date date not null ,
drug_exposure_start_datetime datetime null ,
drug_exposure_end_date date not null ,
drug_exposure_end_datetime datetime null ,
verbatim_end_date date null ,
drug_type_concept_id integer not null ,
stop_reason varchar(20) null ,
refills integer null ,
quantity float null ,
days_supply integer null ,
sig varchar(max) null ,
route_concept_id integer null ,
lot_number varchar(50) null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
drug_source_value varchar(50) null ,
drug_source_concept_id integer null ,
route_source_value varchar(50) null ,
dose_unit_source_value varchar(50) null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table device_exposure
(
device_exposure_id integer not null ,
person_id integer not null ,
device_concept_id integer not null ,
device_exposure_start_date date not null ,
device_exposure_start_datetime datetime null ,
device_exposure_end_date date null ,
device_exposure_end_datetime datetime null ,
device_type_concept_id integer not null ,
unique_device_id varchar(50) null ,
quantity integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
device_source_value varchar(100) null ,
device_source_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table condition_occurrence
(
condition_occurrence_id integer not null ,
person_id integer not null ,
condition_concept_id integer not null ,
condition_start_date date not null ,
condition_start_datetime datetime null ,
condition_end_date date null ,
condition_end_datetime datetime null ,
condition_type_concept_id integer not null ,
stop_reason varchar(20) null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
condition_source_value varchar(50) null ,
condition_source_concept_id integer null ,
condition_status_source_value varchar(50) null ,
condition_status_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table measurement
(
measurement_id integer not null ,
person_id integer not null ,
measurement_concept_id integer not null ,
measurement_date date not null ,
measurement_time varchar(10) null ,
measurement_datetime datetime null ,
measurement_type_concept_id integer not null ,
operator_concept_id integer null ,
value_as_number float null ,
value_as_concept_id integer null ,
unit_concept_id integer null ,
range_low float null ,
range_high float null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
measurement_source_value varchar(50) null ,
measurement_source_concept_id integer null ,
unit_source_value varchar(50) null ,
value_source_value varchar(50) null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table note
(
note_id integer not null ,
person_id integer not null ,
note_date date not null ,
note_datetime datetime null ,
note_type_concept_id integer not null ,
note_class_concept_id integer not null ,
note_title varchar(250) null ,
note_text varchar(max) 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
)
;
create table note_nlp
(
note_nlp_id integer not null ,
note_id integer not null ,
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 ,
note_nlp_source_concept_id integer null ,
nlp_system varchar(250) null ,
nlp_date date not null ,
nlp_datetime datetime null ,
term_exists varchar(1) null ,
term_temporal varchar(50) null ,
term_modifiers varchar(2000) null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table observation
(
observation_id integer not null ,
person_id integer not null ,
observation_concept_id integer not null ,
observation_date date not null ,
observation_datetime datetime null ,
observation_type_concept_id integer not null ,
value_as_number float null ,
value_as_string varchar(60) null ,
value_as_concept_id integer null ,
qualifier_concept_id integer null ,
unit_concept_id integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
visit_detail_id integer null ,
observation_source_value varchar(50) null ,
observation_source_concept_id integer null ,
unit_source_value varchar(50) null ,
qualifier_source_value varchar(50) null
)
;
create table fact_relationship
(
domain_concept_id_1 integer not null ,
fact_id_1 integer not null ,
domain_concept_id_2 integer not null ,
fact_id_2 integer not null ,
relationship_concept_id integer not null
)
;
create table location
(
location_id integer not null ,
address_1 varchar(50) null ,
address_2 varchar(50) null ,
city varchar(50) null ,
state varchar(2) null ,
zip varchar(9) null ,
county varchar(20) null ,
location_source_value varchar(50) null
)
;
create table care_site
(
care_site_id integer not null ,
care_site_name varchar(255) null ,
place_of_service_concept_id integer null ,
location_id integer null ,
care_site_source_value varchar(50) null ,
place_of_service_source_value varchar(50) null
)
;
create table provider
(
provider_id integer not null ,
provider_name varchar(255) null ,
npi varchar(20) null ,
dea varchar(20) null ,
specialty_concept_id integer null ,
care_site_id integer null ,
year_of_birth integer null ,
gender_concept_id integer null ,
provider_source_value varchar(50) null ,
specialty_source_value varchar(50) null ,
specialty_source_concept_id integer null ,
gender_source_value varchar(50) null ,
gender_source_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table payer_plan_period
(
payer_plan_period_id integer not null ,
person_id integer not null ,
payer_plan_period_start_date date not null ,
payer_plan_period_end_date date not null ,
payer_concept_id integer null ,
payer_source_value varchar(50) null ,
payer_source_concept_id integer null ,
plan_concept_id integer null ,
plan_source_value varchar(50) null ,
plan_source_concept_id integer null ,
sponsor_concept_id integer null ,
sponsor_source_value varchar(50) null ,
sponsor_source_concept_id integer null ,
family_source_value varchar(50) null ,
stop_reason_concept_id integer null ,
stop_reason_source_value integer null ,
stop_reason_source_concept_id integer null
)
;
create table cost
(
cost_id integer not null ,
cost_event_id integer not null ,
cost_domain_id varchar(20) not null ,
cost_type_concept_id integer not null ,
currency_concept_id integer null ,
total_charge float null ,
total_cost float null ,
total_paid float null ,
paid_by_payer float null ,
paid_by_patient float null ,
paid_patient_copay float null ,
paid_patient_coinsurance float null ,
paid_patient_deductible float null ,
paid_by_primary float null ,
paid_ingredient_cost float null ,
paid_dispensing_fee float null ,
payer_plan_period_id integer null ,
amount_allowed float null ,
revenue_code_concept_id integer null ,
reveue_code_source_value varchar(50) null,
drg_concept_id integer null,
drg_source_value varchar(3) null
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
create table cohort
(
cohort_definition_id integer not null ,
subject_id integer not null ,
cohort_start_date date not null ,
cohort_end_date date not null
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
create table cohort_attribute
(
cohort_definition_id integer not null ,
subject_id integer not null ,
cohort_start_date date not null ,
cohort_end_date date not null ,
attribute_definition_id integer not null ,
value_as_number float null ,
value_as_concept_id integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table drug_era
(
drug_era_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
drug_era_start_date date not null ,
drug_era_end_date date not null ,
drug_exposure_count integer null ,
gap_days integer null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table dose_era
(
dose_era_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
unit_concept_id integer not null ,
dose_value float not null ,
dose_era_start_date date not null ,
dose_era_end_date date not null
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
create table condition_era
(
condition_era_id integer not null ,
person_id integer not null ,
condition_concept_id integer not null ,
condition_era_start_date date not null ,
condition_era_end_date date not null ,
condition_occurrence_count integer null
)
;

4
BigQuery/README.md Normal file
View File

@ -0,0 +1,4 @@
Common-Data-Model / BigQuery
=================
This folder contains the script for Google BigQuery.

View File

@ -20,7 +20,7 @@ Field|Required|Type|Description
| condition_source_value | No | varchar(50) | The source code for the condition as it appears in the source data. This code is mapped to a standard condition concept in the Standardized Vocabularies and the original code is stored here for reference. |
| condition_source_concept_id | No | integer | A foreign key to a Condition Concept that refers to the code used in the source. |
| condition_status_source_value | No | varchar(50) | The source code for the condition status as it appears in the source data. |
| condition_status_concept_id | No | integer | A foreign key to the predefined concept in the standard vocabulary reflecting the condition status | |
| condition_status_concept_id | No | integer | A foreign key to the predefined Concept in the Standard Vocabulary reflecting the condition status | |
### Conventions
@ -37,5 +37,5 @@ Field|Required|Type|Description
* Condition source codes are typically ICD-9-CM, Read or ICD-10 diagnosis codes from medical claims or discharge status/visit diagnosis codes from EHRs.
* Presently, there is no designated vocabulary, domain, or class that represents condition status. The following concepts from SNOMED are recommended:
* Admitting diagnosis: 4203942
* Final diagnosis: 4230359 <EFBFBD> should also be used for <20>Discharge diagnosis<69>
* Final diagnosis: 4230359 (should also be used for discharge diagnosis)
* Preliminary diagnosis: 4033240

View File

@ -13,10 +13,10 @@ Field|Required|Type|Description
|unique_device_id |No|varchar(50)|A UDI or equivalent identifying the instance of the Device used in the Person.|
|quantity|No|integer|The number of individual Devices used for the exposure.|
|provider_id|No|integer|A foreign key to the provider in the PROVIDER table who initiated of administered the Device.|
|visit_occurrence_id|No|integer|A foreign key to the visit in the VISIT table during which the device was used.|
|visit_occurrence_id|No|integer|A foreign key to the visit in the VISIT_OCCURRENCE table during which the device was used.|
|visit_detail_id|No|integer|A foreign key to the visit detail in the VISIT_DETAIL table during which the Drug Exposure was initiated.|
|device_source_value|No|varchar(50)|The source code for the Device as it appears in the source data. This code is mapped to a standard Device Concept in the Standardized Vocabularies and the original code is stored here for reference.|
|device_source_ concept_id|No|integer|A foreign key to a Device Concept that refers to the code used in the source.|
|visit_detail_id|No|integer|A foreign key to the visit in the visit-detail table during which the Drug Exposure was initiated.|
### Conventions
@ -25,4 +25,5 @@ Field|Required|Type|Description
* Valid Device Concepts belong to the "Device" domain. The Concepts of this domain are derived from the DI portion of a UDI or based on other source vocabularies, like HCPCS.
* A Device Type is assigned to each Device Exposure to track from what source the information was drawn or inferred. The valid domain_id for these Concepts is "Device Type".
* The Visit during which the Device was first used is recorded through a reference to the VISIT_OCCURRENCE table. This information is not always available.
* The Visit Detail during which the Device was first used is recorded through a reference to the VISIT_DETAIL table. This information is not always available.
* The Provider exposing the patient to the Device is recorded through a reference to the PROVIDER table. This information is not always available.

View File

@ -22,16 +22,16 @@ Field|Required|Type|Description
|refills|No|integer|The number of refills after the initial prescription. The initial prescription is not counted, values start with 0.|
|quantity |No|float|The quantity of drug as recorded in the original prescription or dispensing record.|
|days_supply|No|integer|The number of days of supply of the medication as recorded in the original prescription or dispensing record.|
|sig|No|clob|The directions ("signetur") on the Drug prescription as recorded in the original prescription (and printed on the container) or dispensing record.|
|sig|No|varchar(MAX)|The directions ("signetur") on the Drug prescription as recorded in the original prescription (and printed on the container) or dispensing record.|
|route_concept_id|No|integer|A foreign key to a predefined concept in the Standardized Vocabularies reflecting the route of administration.|
|lot_number|No|varchar(50)|An identifier assigned to a particular quantity or lot of Drug product from the manufacturer.|
|provider_id|No|integer|A foreign key to the provider in the provider table who initiated (prescribed or administered) the Drug Exposure.|
|visit_occurrence_id|No|integer|A foreign key to the visit in the visit table during which the Drug Exposure was initiated.|
|provider_id|No|integer|A foreign key to the provider in the PROVIDER table who initiated (prescribed or administered) the Drug Exposure.|
|visit_occurrence_id|No|integer|A foreign key to the Visit in the VISIT_OCCURRENCE table during which the Drug Exposure was initiated.|
|visit_detail_id|No|integer|A foreign key to the Visit Detail in the VISIT_DETAIL table during which the Drug Exposure was initiated.|
|drug_source_value|No|varchar(50)|The source code for the Drug as it appears in the source data. This code is mapped to a Standard Drug concept in the Standardized Vocabularies and the original code is, stored here for reference.|
|drug_source_concept_id|No|integer|A foreign key to a Drug Concept that refers to the code used in the source.|
|route_source_value|No|varchar(50)|The information about the route of administration as detailed in the source.|
|dose_unit_source_value|No|varchar(50)|The information about the dose unit as detailed in the source.|
|visit_detail_id|No|integer|A foreign key to the visit in the VISIT_DETAIL table during which the Drug Exposure was initiated.|
### Conventions

View File

@ -16,7 +16,7 @@ Field|Required|Type|Description
|range_high|No|float|The upper limit of the normal range of the Measurement. The upper range is assumed to be of the same unit of measure as the Measurement value.|
|provider_id|No|integer|A foreign key to the provider in the PROVIDER table who was responsible for initiating or obtaining the measurement.|
|visit_occurrence_id|No|integer|A foreign key to the Visit in the VISIT_OCCURRENCE table during which the Measurement was recorded.|
|visit_detail_id|No|integer|A foreign key to the Visit in the VISIT_DETAIL table during which the Measurement was recorded. |
|visit_detail_id|No|integer|A foreign key to the Visit Detail in the VISIT_DETAIL table during which the Measurement was recorded. |
|measurement_source_value|No|varchar(50)|The Measurement name as it appears in the source data. This code is mapped to a Standard Concept in the Standardized Vocabularies and the original code is stored here for reference.|
|measurement_source_concept_id|No|integer|A foreign key to a Concept in the Standard Vocabularies that refers to the code used in the source.|
|unit_source_value|No|varchar(50)|The source code for the unit as it appears in the source data. This code is mapped to a standard unit concept in the Standardized Vocabularies and the original code is stored here for reference.|

View File

@ -2,19 +2,20 @@ The NOTE table captures unstructured information that was recorded by a provider
Field|Required|Type|Description
:--------------------|:--------|:------------|:--------------------------------------------------------
|note_id|Yes|integer|A unique identifier for each note.|
|person_id|Yes|integer|A foreign key identifier to the Person about whom the Note was recorded. The demographic details of that Person are stored in the PERSON table.|
|note_date |Yes|date|The date the note was recorded.|
|note_datetime|No|datetime|The date and time the note was recorded.|
|note_type_concept_id|Yes|integer|A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the type, origin or provenance of the Note.|
|note_class_concept_id| Yes| integer| A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the HL7 LOINC Document Type Vocabulary classification of the note.|
|note_title |No| varchar(250)| The title of the Note as it appears in the source.|
|note_text|Yes|RBDMS dependent text|The content of the Note.|
|note_id |Yes|integer|A unique identifier for each note.|
|person_id |Yes|integer|A foreign key identifier to the Person about whom the Note was recorded. The demographic details of that Person are stored in the PERSON table.|
|note_date |Yes|date|The date the note was recorded.|
|note_datetime |No|datetime|The date and time the note was recorded.|
|note_type_concept_id |Yes|integer|A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the type, origin or provenance of the Note.|
|note_class_concept_id |Yes| integer| A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the HL7 LOINC Document Type Vocabulary classification of the note.|
|note_title |No| varchar(250)| The title of the Note as it appears in the source.|
|note_text |Yes|varchar(MAX)|The content of the Note.|
|encoding_concept_id |Yes |integer| A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the note character encoding type|
|language_concept_id |Yes |integer |A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the language of the note|
|provider_id|No|integer|A foreign key to the Provider in the PROVIDER table who took the Note.|
|note_source_value|No|varchar(50)|The source value associated with the origin of the note|
|visit_occurrence_id|No|integer|Foreign key to the Visit in the VISIT_OCCURRENCE table when the Note was taken.|
|provider_id |No|integer|A foreign key to the Provider in the PROVIDER table who took the Note.|
|visit_occurrence_id |No|integer|A foreign key to the Visit in the VISIT_OCCURRENCE table when the Note was taken.|
|visit_detail_id |No|integer|A foreign key to the Visit in the VISIT_DETAIL table when the Note was taken.|
|note_source_value |No|varchar(50)|The source value associated with the origin of the Note|
### Conventions
* The NOTE table contains free text (in ASCII, or preferably in UTF8 format) taken by a healthcare Provider.

View File

@ -2,20 +2,20 @@ The NOTE_NLP table will encode all output of NLP on clinical notes. Each row rep
Field | Required | Type | Description
:------------------------------- | :-------- | :------------ | :---------------------------------------------------
note_nlp_id | Yes | Big Integer | A unique identifier for each term extracted from a note.
note_id | Yes | integer | A foreign key to the Note table note the term was extracted from.
section_concept_id | No | integer | A foreign key to the predefined Concept in the Standardized Vocabularies representing the section of the extracted term.
snippet | No | varchar(250) | A small window of text surrounding the term.
offset | No | varchar(50) | Character offset of the extracted term in the input note.
lexical_variant | Yes | varchar(250) | Raw text extracted from the NLP tool.
note_nlp_concept_id | No | integer | A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the normalized concept for the extracted term. Domain of the term is represented as part of the Concept table.
note_nlp_source_concept_id | no | integer | A foreign key to a Concept that refers to the code in the source vocabulary used by the NLP system
nlp_system | No | varchar(250) | Name and version of the NLP system that extracted the term.Useful for data provenance.
nlp_date | Yes | date | The date of the note processing.Useful for data provenance.
nlp_date_time | No | datetime | The date and time of the note processing. Useful for data provenance.
term_exists | No | varchar(1) | A summary modifier that signifies presence or absence of the term for a given patient. Useful for quick querying. *
term_temporal | No | varchar(50) | An optional time modifier associated with the extracted term. (for now “past” or “present” only). Standardize it later.
term_modifiers | No | varchar(2000) | A compact description of all the modifiers of the specific term extracted by the NLP system. (e.g. “son has rash” ? “negated=no,subject=family, certainty=undef,conditional=false,general=false”).
note_nlp_id | Yes | integer | A unique identifier for each term extracted from a note.
note_id | Yes | integer | A foreign key to the Note table note the term was extracted from.
section_concept_id | No | integer | A foreign key to the predefined Concept in the Standardized Vocabularies representing the section of the extracted term.
snippet | No | varchar(250) | A small window of text surrounding the term.
offset | No | varchar(50) | Character offset of the extracted term in the input note.
lexical_variant | Yes | varchar(250) | Raw text extracted from the NLP tool.
note_nlp_concept_id | No | integer | A foreign key to the predefined Concept in the Standardized Vocabularies reflecting the normalized concept for the extracted term. Domain of the term is represented as part of the Concept table.
note_nlp_source_concept_id | No | integer | A foreign key to a Concept that refers to the code in the source vocabulary used by the NLP system
nlp_system | No | varchar(250) | Name and version of the NLP system that extracted the term.Useful for data provenance.
nlp_date | Yes | date | The date of the note processing.Useful for data provenance.
nlp_date_time | No | datetime | The date and time of the note processing. Useful for data provenance.
term_exists | No | varchar(1) | A summary modifier that signifies presence or absence of the term for a given patient. Useful for quick querying. *
term_temporal | No | varchar(50) | An optional time modifier associated with the extracted term. (for now “past” or “present” only). Standardize it later.
term_modifiers | No | varchar(2000) | A compact description of all the modifiers of the specific term extracted by the NLP system. (e.g. “son has rash” ? “negated=no,subject=family, certainty=undef,conditional=false,general=false”).
### Conventions

View File

@ -2,9 +2,9 @@ The OBSERVATION table captures clinical facts about a Person obtained in the con
Field|Required|Type|Description
:----------------------------------|:--------|:------------|:------------------------------------
|observation_id|Yes|integer|A unique identifier for each observation.|
|person_id|Yes|integer|A foreign key identifier to the Person about whom the observation was recorded. The demographic details of that Person are stored in the PERSON table.|
|observation_concept_id|Yes|integer|A foreign key to the standard observation concept identifier in the Standardized Vocabularies.|
|observation_id |Yes|integer|A unique identifier for each observation.|
|person_id |Yes|integer|A foreign key identifier to the Person about whom the observation was recorded. The demographic details of that Person are stored in the PERSON table.|
|observation_concept_id |Yes|integer|A foreign key to the standard observation concept identifier in the Standardized Vocabularies.|
|observation_date|Yes|date|The date of the observation.|
|observation_datetime|No|datetime|The date and time of the observation.|
|observation_type_concept_id|Yes|integer|A foreign key to the predefined concept identifier in the Standardized Vocabularies reflecting the type of the observation.|

View File

@ -13,12 +13,12 @@ Field|Required|Type|Description
|procedure_type_concept_id|Yes|integer|A foreign key to the predefined Concept identifier in the Standardized Vocabularies reflecting the type of source data from which the procedure record is derived.|
|modifier_concept_id|No|integer|A foreign key to a Standard Concept identifier for a modifier to the Procedure (e.g. bilateral)|
|quantity|No|integer|The quantity of procedures ordered or administered.|
|provider_id|No|integer|A foreign key to the provider in the provider table who was responsible for carrying out the procedure.|
|visit_occurrence_id|No|integer|A foreign key to the visit in the visit table during which the Procedure was carried out.|
|provider_id|No|integer|A foreign key to the provider in the PROVIDER table who was responsible for carrying out the procedure.|
|visit_occurrence_id|No|integer|A foreign key to the Visit in the VISIT_OCCURRENCE table during which the Procedure was carried out.|
|visit_detail_id|No|integer|A foreign key to the Visit Detail in the VISIT_DETAIL table during which the Procedure was carried out.|
|procedure_source_value|No|varchar(50)|The source code for the Procedure as it appears in the source data. This code is mapped to a standard procedure Concept in the Standardized Vocabularies and the original code is, stored here for reference. Procedure source codes are typically ICD-9-Proc, CPT-4, HCPCS or OPCS-4 codes.|
|procedure_source_concept_id|No|integer|A foreign key to a Procedure Concept that refers to the code used in the source.|
|qualifier_source_value|No|varchar(50)|The source code for the qualifier as it appears in the source data.|
|visit_detail_id|No|integer|A foreign key to the visit in the visit table during which the Procedure was carried out.|
|modifier_source_value|No|varchar(50)|The source code for the qualifier as it appears in the source data.|
### Conventions
@ -28,4 +28,5 @@ Field|Required|Type|Description
* If the quantity value is omitted, a single procedure is assumed.
* The Procedure Type defines from where the Procedure Occurrence is drawn or inferred. For administrative claims records the type indicates whether a Procedure was primary or secondary and their relative positioning within a claim.
* The Visit during which the procedure was performed is recorded through a reference to the VISIT_OCCURRENCE table. This information is not always available.
* The Visit Detail during with the procedure was performed is recorded through a reference to the VISIT_DETAIL table. This information is not always available.
* The Provider carrying out the procedure is recorded through a reference to the PROVIDER table. This information is not always available.

View File

@ -3,44 +3,46 @@ The VISIT_DETAIL table is an optional table used to represents details of each r
Field|Required|Type|Description
:------------------------|:--------|:-----|:-------------------------------------------------
|visit_detail_id|Yes|integer|A unique identifier for each Person's visit or encounter at a healthcare provider.|
|person_id|Yes|integer|A foreign key identifier to the Person for whom the visit is recorded. The demographic details of that Person are stored in the PERSON table.|
|visit_concept_id|Yes|integer|A foreign key that refers to a visit Concept identifier in the Standardized Vocabularies.|
|visit_start_date|Yes|date|The start date of the visit.|
|visit_start_datetime|No|datetime|The date and time of the visit started.|
|visit_end_date|Yes|date|The end date of the visit. If this is a one-day visit the end date should match the start date.|
|visit_end_datetime|No|datetime|The date and time of the visit end.|
|visit_type_concept_id|Yes|Integer|A foreign key to the predefined Concept identifier in the Standardized Vocabularies reflecting the type of source data from which the visit record is derived.|
|provider_id|No|integer|A foreign key to the provider in the provider table who was associated with the visit.|
|care_site_id|No|integer|A foreign key to the care site in the care site table that was visited.|
|visit_source_value|No|string(50)|The source code for the visit as it appears in the source data.|
|visit_source_concept_id|No|Integer|A foreign key to a Concept that refers to the code used in the source.|
|admitting_source_value |Varchar(50)| No| The source code for the admitting source as it appears in the source data.|
|admitting_source_concept_id| |Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the admitting source for a visit.|
|discharge_to_source_value| Varchar(50)| No| The source code for the discharge disposition as it appears in the source data.|
|discharge_to_concept_id| Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the discharge disposition for a visit.|
|visit_detail_id |Yes|integer|A unique identifier for each Person's visit or encounter at a healthcare provider.|
|person_id |Yes|integer|A foreign key identifier to the Person for whom the visit is recorded. The demographic details of that Person are stored in the PERSON table.|
|visit_concept_id |Yes|integer|A foreign key that refers to a visit Concept identifier in the Standardized Vocabularies.|
|visit_start_date |Yes|date|The start date of the visit.|
|visit_start_datetime |No|datetime|The date and time of the visit started.|
|visit_end_date |Yes|date|The end date of the visit. If this is a one-day visit the end date should match the start date.|
|visit_end_datetime |No|datetime|The date and time of the visit end.|
|visit_type_concept_id |Yes|Integer|A foreign key to the predefined Concept identifier in the Standardized Vocabularies reflecting the type of source data from which the visit record is derived.|
|provider_id |No|integer|A foreign key to the provider in the provider table who was associated with the visit.|
|care_site_id |No|integer|A foreign key to the care site in the care site table that was visited.|
|visit_source_value |No|string(50)|The source code for the visit as it appears in the source data.|
|visit_source_concept_id |No|Integer|A foreign key to a Concept that refers to the code used in the source.|
|admitting_source_value |Varchar(50)| No| The source code for the admitting source as it appears in the source data.|
|admitting_source_concept_id |Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the admitting source for a visit.|
|discharge_to_source_value | Varchar(50)| No| The source code for the discharge disposition as it appears in the source data.|
|discharge_to_concept_id | Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the discharge disposition for a visit.|
|preceding_visit_detail_id |Integer| No |A foreign key to the VISIT_DETAIL table of the visit immediately preceding this visit|
|visit_detail_parent_id |Integer| No |A foreign key to the VISIT_DETAIL table record to represent the immediate parent visit-detail record.|
|visit_occurrence_id |Integer| Yes |A foreign key that refers to the record in the VISIT_OCCURRENCE table. This is a required field, because for every visit_detail is a child of visit_occurrence and cannot exist without a corresponding parent record in visit_occurrence.|
|visit_detail_parent_id |Integer| No |A foreign key to the VISIT_DETAIL table record to represent the immediate parent visit-detail record.|
|visit_occurrence_id |Integer| Yes |A foreign key that refers to the record in the VISIT_OCCURRENCE table. This is a required field, because for every visit_detail is a child of visit_occurrence and cannot exist without a corresponding parent record in visit_occurrence.|
### Conventions
* All conventions used in Visit occurrence apply to visit detail, some notable exceptions:
* A Visit Detail is an optional detail record for each visit-occurrence to a healthcare facility. For every record in visit_detail there has to be a parent visit_occurrence record.
* One record in visit_detail can only have one visit_occurrence parent.
* A single visit_occurrence record may have many child visit_detail records.
* Valid Visit Concepts belong to the "Visit" domain. Standard Visit Concepts are yet to be defined, but will represent a detail of the standard visit concept in visit-occurrence.
* Handling of death: Is same as visit_occurrence
* Source Concepts from place of service vocabularies are mapped into these standard visit Concepts in the Standardized Vocabularies.
* At any one day, there could be more than one visit. Visit_occurrence allows for more than one visit within single day. Visit_detail is to be used to only capture details within the visit_occurrence.
* One visit may involve multiple providers, in which case, in visit_occurrence, the ETL must specify how a single provider id is selected or leave the provider_id field null. Visit_detail allows for ETL to speicify multiple child records per visit_occurrence - and each of these child may represent different provider_ids.
* One visit may involve multiple Care Sites, in which case, in visit_occurrence, the ETL must specify how a single care_site id is selected or leave the care_site_id field null. Visit_detail allows for ETL to speicify multiple child records per visit_occurrence - and each of these child may represent different care_sites.
* Just like in visit_occurrence, records in visit_detail may be sequentially related to each. These sequential relations are represented using preceding_visit_detail_id
* Unlike visit_occurrence, visit_detail may have nested visits with hierarchial relationships to each other.
* Representation of US claim data: US claims data generally has two-levels. Header/summary data that summarizes the entire claim; Line/detail that details a claim. Detail is thus a child of the summary, and for every record in summary there is one or more records in detail. i.e. there will be atleast one FK link from visit_detail to visit_occurrence.
* All conventions used in VISIT_OCCURRENCE apply to VISIT_DETAIL, some notable exceptions:
* A Visit Detail is an optional detail record for each Visit Occurrence to a healthcare facility. For every record in VISIT_DETAIL there has to be a parent VISIT_OCCURRENCE record.
* One record in VISIT_DETAIL can only have one VISIT_OCCURRENCE parent.
* A single VISIT_OCCURRENCE record may have many child VISIT_DETAIL records.
* Valid Visit Concepts belong to the "Visit" domain. Standard Visit Concepts are yet to be defined, but will represent a detail of the Standard Visit Concept in VISIT_OCCURRENCE.
* Handling of death: In the case when a patient died during admission (VISIT_OCCURRENCE.DISCHARGE_DISPOSITION_CONCEPT_ID = 4216643 'Patient died'), a record in the Death table should be created with DEATH_TYPE_CONCEPT_ID = 44818516 (EHR discharge status "Expired").
* Source Concepts from place of service vocabularies are mapped into these Standard Visit Concepts in the Standardized Vocabularies.
* At any one day, there could be more than one visit. VISIT_OCCURRENCE allows for more than one visit within a single day. VISIT_DETAIL is to be used to only capture details within the visit.
* One visit may involve multiple providers, in which case, in VISIT_OCCURRENCE, the ETL must specify how a single provider id is selected or leave the provider_id field null. VISIT_DETAIL allows for ETL to speicify multiple child records per visit occurrence - and each of these child records may represent different provider_ids.
* One visit may involve multiple Care Sites, in which case, in VISIT_OCCURRENCE, the ETL must specify how a single care_site id is selected or leave the care_site_id field null. VISIT_DETAIL allows for ETL to speicify multiple child records per visit occurrence - and each of these child records may represent different care_sites.
* Just like in VISIT_OCCURRENCE, records in VISIT_DETAIL may be sequentially related to each. These sequential relations are represented using preceding_visit_detail_id
* Unlike VISIT_OCCURRENCE, VISIT_DETAIL may have nested visits with hierarchial relationships to each other.
* Representation of US claim data: US claims data generally has two-levels. Header/summary data that summarizes the entire claim; Line/detail that details a claim. Detail is thus a child of the summary, and for every record in summary there is one or more records in detail. i.e. there will be atleast one FK link from VISIT_DETAIL to VISIT_OCCURRENCE.
Example: an entire inpatient stay maybe one record in visit_occurrence table. This may have one or more detail information such as ER, ICU, medical floor, rehabilitation floor etc. Each of these visit_details may have different start/end date-times, different concept_id's and fact_id's - that would be separate record in visit_detail with a FK link to visit_occurrence. Each record within visit_detail maybe related to each other, sequentially > ER leading to ICU leading to medical floor, leading to rehabilitation, or in hierarchical parent-child visit > a visit for dialysis while in ICU.
Example: an entire inpatient stay maybe one record in the VISIT_OCCURRENCE table. This may have one or more detail records such as ER, ICU, medical floor, rehabilitation floor etc. Each of these visit details may have different start/end date-times, different concept_ids and fact_ids. These would become separate records in VISIT_DETAIL with a FK link to VISIT_OCCURRENCE.
Each record within VISIT_DETAIL may be related to each other, sequentially > ER leading to ICU leading to medical floor, leading to rehabilitation, or in hierarchical parent-child visit > a visit for dialysis while in ICU.
Note the concept-id for visits is 9, and is shared between visit_occurrence and visit_detail in OMOP CDM. The key deviation from visit_occurrence is
Note the CONCEPT_ID for visits is 8, and is shared between VISIT_OCCURRENCE and VISIT_DETAIL in OMOP CDM. The key deviation from VISIT_OCCURRENCE is
- self-referencing key: a new foreign key visit_detail_parent_id allows self referencing for nested visits.
- visit_detail points to its parent record in visit_occurrence table (visit_occurrence_id)
- VISIT_DETAIL points to its parent record in the VISIT_OCCURRENCE table (visit_occurrence_id)

View File

@ -12,20 +12,20 @@ Field|Required|Type|Description
|visit_type_concept_id|Yes|Integer|A foreign key to the predefined Concept identifier in the Standardized Vocabularies reflecting the type of source data from which the visit record is derived.|
|provider_id|No|integer|A foreign key to the provider in the provider table who was associated with the visit.|
|care_site_id|No|integer|A foreign key to the care site in the care site table that was visited.|
|visit_source_value|No|string(50)|The source code for the visit as it appears in the source data.|
|visit_source_concept_id|No|Integer|A foreign key to a Concept that refers to the code used in the source.|
|admitting_source_concept_id| |Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the admitting source for a visit.|
|admitting_source_value |Varchar(50)| No| The source code for the admitting source as it appears in the source data.|
|discharge_to_concept_id| Integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the discharge disposition for a visit.|
|discharge_to_source_value| Varchar(50)| No| The source code for the discharge disposition as it appears in the source data.|
|preceding_visit_occurrence_id |Integer| No |A foreign key to the VISIT_OCCURRENCE table of the visit immediately preceding this visit|
|visit_source_value|No|varchar(50)|The source code for the visit as it appears in the source data.|
|visit_source_concept_id|No|integer|A foreign key to a Concept that refers to the code used in the source.|
|admitting_source_concept_id |integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the admitting source for a visit.|
|admitting_source_value |varchar(50)| No| The source code for the admitting source as it appears in the source data.|
|discharge_to_concept_id | integer |No |A foreign key to the predefined concept in the Place of Service Vocabulary reflecting the discharge disposition for a visit.|
|discharge_to_source_value | varchar(50)| No| The source code for the discharge disposition as it appears in the source data.|
|preceding_visit_occurrence_id |integer| No |A foreign key to the VISIT_OCCURRENCE table of the visit immediately preceding this visit|
### Conventions
* A Visit Occurrence is recorded for each visit to a healthcare facility.
* Valid Visit Concepts belong to the "Visit" domain.
* Standard Visit Concepts are defined as Inpatient Visit, Outpatient Visit, Emergency Room Visit, Long Term Care Visit and combined ER and Inpatient Visit. The latter is necessary because it is close to impossible to separate the two in many EHR system, treating them interchangeably. To annotate this correctly, the visit concept "Emergency Room and Inpatient Visit" (concept_id=262) should be used.
* Handling of death: In case when patient died during admission (Visit_Occurrence. discharge_disposition_concept_id = 4216643 'Patient died'), a record in the Death table should be created with death_type_concept_id = 44818516 (EHR discharge status "Expired").
* Handling of death: In the case when a patient died during admission (Visit_Occurrence. discharge_disposition_concept_id = 4216643 'Patient died'), a record in the Death table should be created with death_type_concept_id = 44818516 (EHR discharge status "Expired").
* Source Concepts from place of service vocabularies are mapped into these standard visit Concepts in the Standardized Vocabularies.
* At any one day, there could be more than one visit.
* One visit may involve multiple providers, in which case the ETL must specify how a single provider id is selected or leave the provider_id field null.
@ -39,4 +39,4 @@ Field|Required|Type|Description
* Patient self-discharge against medical advice: 4021968
* In the case where a patient died during admission (Visit_Occurrence.discharge_disposition_concept_id = 4216643 <20>Patient died<65>), a record in the Death table should be created with death_type_concept_id = 44818516 (<28>EHR discharge status "Expired").
* PRECEDING_VISIT_ID can be used to link a visit immediately preceding the current visit
* Some EMR systems combine emergency room followed by inpatient admission into one visit, and it is close to impossible to separate the two. To annotate this visit type, a new visit concept <EFBFBD>Emergency Room and Inpatient Visit<69> was added (CONCEPT_ID 262).
* Some EMR systems combine emergency room followed by inpatient admission into one visit, and it is close to impossible to separate the two. To annotate this visit type, a new visit concept "Emergency Room and Inpatient Visit" was added (CONCEPT_ID 262).

View File

@ -4,28 +4,28 @@ The information about the cost is defined by the amount of money paid by the Per
Field|Required|Type|Description
:-----------------------------|:--------|:------------|:----------------------------------------------------
|cost_id|Yes|integer|A unique identifier for each COST record.|
|cost_event_id|Yes|integer|A foreign key identifier to the event (e.g. Measurement, Procedure, Visit, Drug Exposure, etc) record for which cost data are recorded.|
|cost_domain_id|Yes|string(20)|The concept representing the domain of the cost event, from which the corresponding table can be inferred that contains the entity for which cost information is recorded.|
|cost_type_concept_id|Yes|integer|A foreign key identifier to a concept in the CONCEPT table for the provenance or the source of the COST data: Calculated from insurance claim information, provider revenue, calculated from cost-to-charge ratio, reported from accounting database, etc.|
|currency_concept_id|No|integer|A foreign key identifier to the concept representing the 3-letter code used to delineate international currencies, such as USD for US Dollar.|
|total_charge|No|float|The total amount charged by some provider of goods or services (e.g. hospital, physician pharmacy, dme provider) to payers (insurance companies, the patient).|
|total_cost|No|float|The cost incurred by the provider of goods or services.|
|total_paid|No|float|The total amount actually paid from all payers for goods or services of the provider.|
|paid_by_payer|No|float|The amount paid by the Payer for the goods or services.|
|paid_by_patient|No|float|The total amount paid by the Person as a share of the expenses.|
|paid_patient_copay|No|float|The amount paid by the Person as a fixed contribution to the expenses.|
|paid_patient_coinsurance|No|float|The amount paid by the Person as a joint assumption of risk. Typically, this is a percentage of the expenses defined by the Payer Plan after the Person's deductible is exceeded.|
|paid_patient_deductible|No|float|The amount paid by the Person that is counted toward the deductible defined by the Payer Plan. paid_patient_deductible does contribute to the paid_by_patient variable.|
|paid_by_primary|No|float|The amount paid by a primary Payer through the coordination of benefits.|
|paid_ingredient_cost|No|float|The amount paid by the Payer to a pharmacy for the drug, excluding the amount paid for dispensing the drug. paid_ingredient_cost contributes to the paid_by_payer field if this field is populated with a nonzero value.|
|paid_dispensing_fee|No|float|The amount paid by the Payer to a pharmacy for dispensing a drug, excluding the amount paid for the drug ingredient. paid_dispensing_fee contributes to the paid_by_payer field if this field is populated with a nonzero value.|
|payer_plan_period_id|No|integer|A foreign key to the PAYER_PLAN_PERIOD table, where the details of the Payer, Plan and Family are stored. Record the payer_plan_id that relates to the payer who contributed to the paid_by_payer field.|
|amount_allowed|No|float|The contracted amount agreed between the payer and provider.|
|revenue_code_concept_id|No|integer|A foreign key referring to a Standard Concept ID in the Standardized Vocabularies for Revenue codes.|
|revenue_code_source_value|No|string(50)|The source code for the Revenue code as it appears in the source data, stored here for reference.|
|drg_concept_id| integer| No |A foreign key to the predefined concept in the DRG Vocabulary reflecting the DRG for a visit.|
|drg_source_value| varchar(3)| No| The 3-digit DRG source code as it appears in the source data.|
|cost_id |Yes|integer|A unique identifier for each COST record.|
|cost_event_id |Yes|integer|A foreign key identifier to the event (e.g. Measurement, Procedure, Visit, Drug Exposure, etc) record for which cost data are recorded.|
|cost_domain_id |Yes|varchar(20)|The concept representing the domain of the cost event, from which the corresponding table can be inferred that contains the entity for which cost information is recorded.|
|cost_type_concept_id |Yes|integer|A foreign key identifier to a concept in the CONCEPT table for the provenance or the source of the COST data: Calculated from insurance claim information, provider revenue, calculated from cost-to-charge ratio, reported from accounting database, etc.|
|currency_concept_id |No|integer|A foreign key identifier to the concept representing the 3-letter code used to delineate international currencies, such as USD for US Dollar.|
|total_charge |No|float|The total amount charged by some provider of goods or services (e.g. hospital, physician pharmacy, dme provider) to payers (insurance companies, the patient).|
|total_cost |No|float|The cost incurred by the provider of goods or services.|
|total_paid |No|float|The total amount actually paid from all payers for goods or services of the provider.|
|paid_by_payer |No|float|The amount paid by the Payer for the goods or services.|
|paid_by_patient |No|float|The total amount paid by the Person as a share of the expenses.|
|paid_patient_copay |No|float|The amount paid by the Person as a fixed contribution to the expenses.|
|paid_patient_coinsurance |No|float|The amount paid by the Person as a joint assumption of risk. Typically, this is a percentage of the expenses defined by the Payer Plan after the Person's deductible is exceeded.|
|paid_patient_deductible |No|float|The amount paid by the Person that is counted toward the deductible defined by the Payer Plan. paid_patient_deductible does contribute to the paid_by_patient variable.|
|paid_by_primary |No|float|The amount paid by a primary Payer through the coordination of benefits.|
|paid_ingredient_cost |No|float|The amount paid by the Payer to a pharmacy for the drug, excluding the amount paid for dispensing the drug. paid_ingredient_cost contributes to the paid_by_payer field if this field is populated with a nonzero value.|
|paid_dispensing_fee |No|float|The amount paid by the Payer to a pharmacy for dispensing a drug, excluding the amount paid for the drug ingredient. paid_dispensing_fee contributes to the paid_by_payer field if this field is populated with a nonzero value.|
|payer_plan_period_id |No|integer|A foreign key to the PAYER_PLAN_PERIOD table, where the details of the Payer, Plan and Family are stored. Record the payer_plan_id that relates to the payer who contributed to the paid_by_payer field.|
|amount_allowed |No|float|The contracted amount agreed between the payer and provider.|
|revenue_code_concept_id |No|integer|A foreign key referring to a Standard Concept ID in the Standardized Vocabularies for Revenue codes.|
|revenue_code_source_value |No|varchar(50)|The source code for the Revenue code as it appears in the source data, stored here for reference.|
|drg_concept_id |No|integer|A foreign key to the predefined concept in the DRG Vocabulary reflecting the DRG for a visit.|
|drg_source_value |No|varchar(3)| The 3-digit DRG source code as it appears in the source data.|
### Conventions
The COST table will store information reporting money or currency amounts. There are three types of cost data, defined in the cost_type_concept_id: 1) paid or reimbursed amounts, 2) charges or list prices (such as Average Wholesale Prices), and 3) costs or expenses incurred by the provider. The defined fields are variables found in almost all U.S.-based claims data sources, which is the most common data source for researchers. Non-U.S.-based data holders are encouraged to engage with OHDSI to adjust these tables to their needs.

View File

@ -2,15 +2,24 @@ The PAYER_PLAN_PERIOD table captures details of the period of time that a Person
Field|Required|Type|Description
:------------------------------|:--------|:------------|:----------------------------------------------
|payer_plan_period_id|Yes|integer|A identifier for each unique combination of payer, plan, family code and time span.|
|person_id|Yes|integer|A foreign key identifier to the Person covered by the payer. The demographic details of that Person are stored in the PERSON table.|
|payer_plan_period_start_date|Yes|date|The start date of the payer plan period.|
|payer_plan_period_end_date|Yes|date|The end date of the payer plan period.|
|payer_source_value|No|varchar(50)|The source code for the payer as it appears in the source data.|
|plan_source_value|No|varchar(50)|The source code for the Person's health benefit plan as it appears in the source data.|
|family_source_value|No|varchar(50)|The source code for the Person's family as it appears in the source data.|
|payer_plan_period_id |Yes|integer|A identifier for each unique combination of payer, plan, family code and time span.|
|person_id |Yes|integer|A foreign key identifier to the Person covered by the payer. The demographic details of that Person are stored in the PERSON table.|
|payer_plan_period_start_date |Yes|date|The start date of the payer plan period.|
|payer_plan_period_end_date |Yes|date|The end date of the payer plan period.|
|payer_concept_id |No|integer|A foreign key that refers to a standard Payer concept identifier in the Standarized Vocabularies|
|payer_source_value |No|varchar(50)|The source code for the payer as it appears in the source data.|
|payer_source_concept_id |No|integer|A foreign key to a payer concept that refers to the code used in the source.|
|plan_concept_id |No|integer|A foreign key that refers to a standard plan concept identifier that represents the health benefit plan in the Standardized Vocabularies|
|plan_source_value |No|varchar(50)|The source code for the Person's health benefit plan as it appears in the source data.|
|plan_source_concept_id |No|integer|A foreign key to a plan concept that refers to the plan code used in the source data.|
|sponsor_concept_id |No|integer|A foreign key that refers to a concept identifier that represents the sponsor in the Standardized Vocabularies.|
|sponsor_source_value |No|varchar(50)|The source code for the Person's sponsor of the health plan as it appears in the source data.|
|sponsor_source_concept_id |No|integer|A foreign key to a sponsor concept that refers to the sponsor code used in the source data.|
|family_source_value |No|varchar(50)|The source code for the Person's family as it appears in the source data.|
|stop_reason_concept_id |No|integer|A foreign key that refers to a standard termination reason that represents the reason for the termination in the Standardized Vocabularies.|
|stop_reason_source_value |No|varchar(50)|The reason for stop-coverage as it appears in the source data.|
|stop_reason_source_concept_id |No|integer|A foreign key to a stop-coverage concept that refers to the code used in the source.|
### Conventions
* Different Payers have different designs for their health benefit Plans. The PAYER_PLAN_PERIOD table does not capture all details of the plan design or the relationship between Plans or the cost of healthcare triggering a change from one Plan to another. However, it allows identifying the unique combination of Payer (insurer), Plan (determining healthcare benefits and limits) and Person. Typically, depending on healthcare utilization, a Person may have one or many subsequent Plans during coverage by a single Payer.
* Payer or Plan information is not normalized or recorded as part of the Standard Vocabularies. Instead, they are referred to only by their source_value.
* Typically, family members are covered under the same Plan as the Person. In those cases, the payer_source_value, plan_source_value and family_source_value are identical.
* Typically, family members are covered under the same Plan as the Person. In those cases, the payer_source_value, plan_source_value and family_source_value are identical.

View File

@ -3,7 +3,7 @@ The PROVIDER table contains a list of uniquely identified healthcare providers.
Field|Required|Type|Description
:-------------------------|:--------|:------------|:-------------------------------------
|provider_id|Yes|integer|A unique identifier for each Provider.|
|provider_name|No|varchar(50)|A description of the Provider.|
|provider_name|No|varchar(255)|A description of the Provider.|
|npi|No|varchar(20)|The National Provider Identifier (NPI) of the provider.|
|dea|No|varchar(20)|The Drug Enforcement Administration (DEA) number of the provider.|
|specialty_concept_id|No|integer|A foreign key to a Standard Specialty Concept ID in the Standardized Vocabularies.|

View File

@ -0,0 +1,15 @@
The METADATA table contains metadata information about a dataset that has been transformed to the OMOP Common Data Model.
Field |Required |Type |Description
:------------------------------|:--------|:------------|:-----------------------------------------
|metadata_concept_id |Yes |integer |A foreign key that refers to a Standard Metadata Concept identifier in the Standardized Vocabularies.|
|metadata_type_concept_id |Yes |integer |A foreign key that refers to a Standard Type Concept identifier in the Standardized Vocabularies.|
|name |Yes |varchar(250) |The name of the Concept stored in metadata_concept_id or a description of the data being stored.|
|value_as_string |No |nvarchar |The metadata value stored as a string.|
|value_as_concept_id |No |integer |A foreign key to a metadata value stored as a Concept ID.|
|metadata date |No |date |The date associated with the metadata|
|metadata_datetime |No |datetime |The date and time associated with the metadata|
### Conventions
*

View File

@ -4,9 +4,9 @@ Field|Required|Type|Description
:-------------------------|:--------|:-----|:--------------------------------------
|attribute_definition_id|Yes|integer|A unique identifier for each Attribute.|
|attribute_name|Yes|varchar(255)|A short description of the Attribute.|
|attribute_description|No|CLOB|A complete description of the Attribute definition|
|attribute_description|No|varchar(MAX)|A complete description of the Attribute definition|
|attribute_type_concept_id|Yes|integer|Type defining what kind of Attribute Definition the record represents and how the syntax may be executed|
|attribute_syntax|No|CLOB|Syntax or code to operationalize the Attribute definition|
|attribute_syntax|No|varchar(MAX)|Syntax or code to operationalize the Attribute definition|
### Conventions

View File

@ -4,9 +4,9 @@ Field|Required|Type|Description
:------------------------------|:--------|:-----|:-----------------------------------------------
|cohort_definition_id|Yes|integer|A unique identifier for each Cohort.|
|cohort_definition_name|Yes|varchar(255)|A short description of the Cohort.|
|cohort_definition_description|No|CLOB|A complete description of the Cohort definition|
|cohort_definition_description|No|varchar(MAX)|A complete description of the Cohort definition|
|definition_type_concept_id|Yes|integer|Type defining what kind of Cohort Definition the record represents and how the syntax may be executed|
|cohort_definition_syntax|No|CLOB|Syntax or code to operationalize the Cohort definition|
|cohort_definition_syntax|No|varchar(MAX)|Syntax or code to operationalize the Cohort definition|
|subject_concept_id|Yes|integer|A foreign key to the Concept to which defines the domain of subjects that are members of the cohort (e.g., Person, Provider, Visit).|
|cohort_instantiation_date|No|Date|A date to indicate when the Cohort was instantiated in the COHORT table|

View File

@ -4,8 +4,8 @@ Field|Required|Type|Description
:-------------------------|:--------|:------------|:----------------------------
|source_code|Yes|varchar(50)|The source code being translated into a Standard Concept.|
|source_concept_id|Yes|integer|A foreign key to the Source Concept that is being translated into a Standard Concept.|
|source_vocabulary_id|No|varchar(20)|A foreign key to the VOCABULARY table defining the vocabulary of the source code that is being translated to a Standard Concept.|
|source_code_description|Yes|varchar(255)|An optional description for the source code. This is included as a convenience to compare the description of the source code to the name of the concept.|
|source_vocabulary_id|Yes|varchar(20)|A foreign key to the VOCABULARY table defining the vocabulary of the source code that is being translated to a Standard Concept.|
|source_code_description|No|varchar(255)|An optional description for the source code. This is included as a convenience to compare the description of the source code to the name of the concept.|
|target_concept_id|Yes|integer|A foreign key to the target Concept to which the source code is being mapped.|
|target_vocabulary_id|Yes|varchar(20)|A foreign key to the VOCABULARY table defining the vocabulary of the target Concept.|
|valid_start_date|Yes|date|The date when the mapping instance was first recorded.|

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View File

@ -1,512 +0,0 @@
names(inds) <-conceptSetIds[[1]]
conceptSetIds
inds <- lapply(conceptSetIds[[2]], getConcepts)
dir <- "\\wprdusmj12rcz\Epi\Mood_Haliperidol\project390\"
dir <- "S:Epi\Mood_Haliperidol\project390\"
dir <- "S:Epi/Mood_Haliperidol/project390/"
inds <- lapply(conceptSetIds[[2]], getConcepts)
inds
names(inds) <-conceptSetIds[[1]]
getConcepts <- function(conceptSetIdentifiers) {
results <- list()
length(results) <- length(conceptSetIdentifiers)
ind <- 0
for (conceptSetIdentifier in conceptSetIdentifiers){
ind <- ind+1
# get the concept set expression from the webapi
conceptSetExpressionUrl = paste("http://hix.jnj.com:8080/WebAPI/conceptset/", conceptSetIdentifier, "/expression", sep = "")
## http://hix.jnj.com:8080/WebAPI/VOCAB/vocabulary/lookup/mapped
expression <- httr::content(httr::GET(conceptSetExpressionUrl),"text")
result <- RJSONIO::fromJSON(expression)
concepts <- t(as.data.frame(lapply(result[[1]], function(x) c(x$concept$CONCEPT_ID,
x$concept$CONCEPT_CODE,
x$concept$CONCEPT_NAME,
x$concept$VOCABULARY_ID,
x$isExcluded, x$includeDescendants,
x$includeMapped)) ))
concepts <- as.data.frame(concepts)
rownames(concepts) <- NULL
colnames(concepts) <- c('concept_id','concept_code','concept_name','vocabulary_id',
'exclude','descendants','mapped')
concepts[,'exclude'] <- ifelse(concepts[,'exclude']=='TRUE', 1, 0)
concepts[,'descendants'] <- ifelse(concepts[,'descendants']=='TRUE', 1, 0)
concepts[,'mapped'] <- ifelse(concepts[,'mapped']=='TRUE', 1, 0)
# save to temp table
connectionDetails <- createConnectionDetails(dbms="pdw",
server="JRDUSAPSCTL01",
port=17001,
user=NULL,
password=NULL)
conn <- connect(connectionDetails)
DatabaseConnector::insertTable(conn, 'scratch.dbo.390_concepts', concepts)#, tempTable = T)
# run cocnept_extract sql using temp table
sql <- SqlRender::readSql(file.path(dir,'concept_extract.sql'))
sql <- SqlRender::renderSql(sql, cdm='Vocabulary')$sql
sql <- SqlRender::translateSql(sql, sourceDialect = 'sql server', targetDialect = 'pdw')$sql
results[[ind]] <- DatabaseConnector::querySql(conn,sql)
}
return(results)
}
conceptSetIds <- list(name=c(#'Agitation, aggression or psychotic Symptoms in dementia together',
'Agitation, aggression or psychotic Symptoms in dementia sep',
'Tic disorder',
'Schizophrenia',
'Aggression in children with autism or developmental disorders'),
code=list(#2349,
c(2478,2479), 2348, 2347,c(2361, 2362)
))
# put concept sets into inds
inds <- lapply(conceptSetIds[[2]], getConcepts)
getConcepts <- function(conceptSetIdentifiers) {
results <- list()
length(results) <- length(conceptSetIdentifiers)
ind <- 0
for (conceptSetIdentifier in conceptSetIdentifiers){
ind <- ind+1
# get the concept set expression from the webapi
conceptSetExpressionUrl = paste("http://hix.jnj.com:8080/WebAPI/conceptset/", conceptSetIdentifier, "/expression", sep = "")
## http://hix.jnj.com:8080/WebAPI/VOCAB/vocabulary/lookup/mapped
expression <- httr::content(httr::GET(conceptSetExpressionUrl),"text")
result <- RJSONIO::fromJSON(expression)
concepts <- t(as.data.frame(lapply(result[[1]], function(x) c(x$concept$CONCEPT_ID,
x$concept$CONCEPT_CODE,
x$concept$CONCEPT_NAME,
x$concept$VOCABULARY_ID,
x$isExcluded, x$includeDescendants,
x$includeMapped)) ))
concepts <- as.data.frame(concepts)
rownames(concepts) <- NULL
colnames(concepts) <- c('concept_id','concept_code','concept_name','vocabulary_id',
'exclude','descendants','mapped')
concepts[,'exclude'] <- ifelse(concepts[,'exclude']=='TRUE', 1, 0)
concepts[,'descendants'] <- ifelse(concepts[,'descendants']=='TRUE', 1, 0)
concepts[,'mapped'] <- ifelse(concepts[,'mapped']=='TRUE', 1, 0)
# save to temp table
connectionDetails <- createConnectionDetails(dbms="pdw",
server="JRDUSAPSCTL01",
port=17001,
user=NULL,
password=NULL)
conn <- connect(connectionDetails)
DatabaseConnector::insertTable(conn, 'scratch.dbo.concepts_390', concepts)#, tempTable = T)
# run cocnept_extract sql using temp table
sql <- SqlRender::readSql(file.path(dir,'concept_extract.sql'))
sql <- SqlRender::renderSql(sql, cdm='Vocabulary')$sql
sql <- SqlRender::translateSql(sql, sourceDialect = 'sql server', targetDialect = 'pdw')$sql
results[[ind]] <- DatabaseConnector::querySql(conn,sql)
}
return(results)
}
conceptSetIds <- list(name=c(#'Agitation, aggression or psychotic Symptoms in dementia together',
'Agitation, aggression or psychotic Symptoms in dementia sep',
'Tic disorder',
'Schizophrenia',
'Aggression in children with autism or developmental disorders'),
code=list(#2349,
c(2478,2479), 2348, 2347,c(2361, 2362)
))
# put concept sets into inds
inds <- lapply(conceptSetIds[[2]], getConcepts)
names(inds) <-conceptSetIds[[1]]
getConcepts <- function(conceptSetIdentifiers) {
results <- list()
length(results) <- length(conceptSetIdentifiers)
ind <- 0
for (conceptSetIdentifier in conceptSetIdentifiers){
ind <- ind+1
# get the concept set expression from the webapi
conceptSetExpressionUrl = paste("http://hix.jnj.com:8080/WebAPI/conceptset/", conceptSetIdentifier, "/expression", sep = "")
## http://hix.jnj.com:8080/WebAPI/VOCAB/vocabulary/lookup/mapped
expression <- httr::content(httr::GET(conceptSetExpressionUrl),"text")
result <- RJSONIO::fromJSON(expression)
concepts <- t(as.data.frame(lapply(result[[1]], function(x) c(x$concept$CONCEPT_ID,
x$concept$CONCEPT_CODE,
x$concept$CONCEPT_NAME,
x$concept$VOCABULARY_ID,
x$isExcluded, x$includeDescendants,
x$includeMapped)) ))
concepts <- as.data.frame(concepts)
rownames(concepts) <- NULL
colnames(concepts) <- c('concept_id','concept_code','concept_name','vocabulary_id',
'exclude','descendants','mapped')
concepts[,'exclude'] <- ifelse(concepts[,'exclude']=='TRUE', 1, 0)
concepts[,'descendants'] <- ifelse(concepts[,'descendants']=='TRUE', 1, 0)
concepts[,'mapped'] <- ifelse(concepts[,'mapped']=='TRUE', 1, 0)
# save to temp table
connectionDetails <- createConnectionDetails(dbms="pdw",
server="JRDUSAPSCTL01",
port=17001,
user=NULL,
password=NULL)
conn <- connect(connectionDetails)
DatabaseConnector::insertTable(conn, 'scratch.dbo.concepts_390', concepts)#, tempTable = T)
# run cocnept_extract sql using temp table
sql <- SqlRender::readSql(file.path(dir,'concept_extract.sql'))
sql <- SqlRender::renderSql(sql, cdm='Vocabulary')$sql
sql <- SqlRender::translateSql(sql, sourceDialect = 'sql server', targetDialect = 'pdw')$sql
results[[ind]] <- DatabaseConnector::querySql(conn,sql)
}
return(results)
}
conceptSetIds <- list(name=c(#'Agitation, aggression or psychotic Symptoms in dementia together',
'Agitation, aggression or psychotic Symptoms in dementia sep',
'Tic disorder',
'Schizophrenia',
'Aggression in children with autism or developmental disorders'),
code=list(#2349,
c(2478,2479), 2348, 2347,c(2361, 2362)
))
# put concept sets into inds
inds <- lapply(conceptSetIds[[2]], getConcepts)
names(inds) <-conceptSetIds[[1]]
getConcepts <- function(conceptSetIdentifiers) {
results <- list()
length(results) <- length(conceptSetIdentifiers)
ind <- 0
for (conceptSetIdentifier in conceptSetIdentifiers){
ind <- ind+1
# get the concept set expression from the webapi
conceptSetExpressionUrl = paste("http://hix.jnj.com:8080/WebAPI/conceptset/", conceptSetIdentifier, "/expression", sep = "")
## http://hix.jnj.com:8080/WebAPI/VOCAB/vocabulary/lookup/mapped
expression <- httr::content(httr::GET(conceptSetExpressionUrl),"text")
result <- RJSONIO::fromJSON(expression)
concepts <- t(as.data.frame(lapply(result[[1]], function(x) c(x$concept$CONCEPT_ID,
x$concept$CONCEPT_CODE,
x$concept$CONCEPT_NAME,
x$concept$VOCABULARY_ID,
x$isExcluded, x$includeDescendants,
x$includeMapped)) ))
concepts <- as.data.frame(concepts)
rownames(concepts) <- NULL
colnames(concepts) <- c('concept_id','concept_code','concept_name','vocabulary_id',
'exclude','descendants','mapped')
concepts[,'exclude'] <- ifelse(concepts[,'exclude']=='TRUE', 1, 0)
concepts[,'descendants'] <- ifelse(concepts[,'descendants']=='TRUE', 1, 0)
concepts[,'mapped'] <- ifelse(concepts[,'mapped']=='TRUE', 1, 0)
# save to temp table
connectionDetails <- createConnectionDetails(dbms="pdw",
server="JRDUSAPSCTL01",
port=17001,
user=NULL,
password=NULL)
conn <- connect(connectionDetails)
DatabaseConnector::insertTable(conn, 'concepts', concepts, tempTable = T)
# run cocnept_extract sql using temp table
sql <- SqlRender::readSql(file.path(dir,'concept_extract.sql'))
sql <- SqlRender::renderSql(sql, cdm='Vocabulary')$sql
sql <- SqlRender::translateSql(sql, sourceDialect = 'sql server', targetDialect = 'pdw')$sql
results[[ind]] <- DatabaseConnector::querySql(conn,sql)
}
return(results)
}
conceptSetIds <- list(name=c(#'Agitation, aggression or psychotic Symptoms in dementia together',
'Agitation, aggression or psychotic Symptoms in dementia sep',
'Tic disorder',
'Schizophrenia',
'Aggression in children with autism or developmental disorders'),
code=list(#2349,
c(2478,2479), 2348, 2347,c(2361, 2362)
))
# put concept sets into inds
inds <- lapply(conceptSetIds[[2]], getConcepts)
getConcepts <- function(conceptSetIdentifiers) {
results <- list()
length(results) <- length(conceptSetIdentifiers)
ind <- 0
for (conceptSetIdentifier in conceptSetIdentifiers){
ind <- ind+1
# get the concept set expression from the webapi
conceptSetExpressionUrl = paste("http://hix.jnj.com:8080/WebAPI/conceptset/", conceptSetIdentifier, "/expression", sep = "")
## http://hix.jnj.com:8080/WebAPI/VOCAB/vocabulary/lookup/mapped
expression <- httr::content(httr::GET(conceptSetExpressionUrl),"text")
result <- RJSONIO::fromJSON(expression)
concepts <- t(as.data.frame(lapply(result[[1]], function(x) c(x$concept$CONCEPT_ID,
x$concept$CONCEPT_CODE,
x$concept$CONCEPT_NAME,
x$concept$VOCABULARY_ID,
x$isExcluded, x$includeDescendants,
x$includeMapped)) ))
concepts <- as.data.frame(concepts)
rownames(concepts) <- NULL
colnames(concepts) <- c('concept_id','concept_code','concept_name','vocabulary_id',
'exclude','descendants','mapped')
concepts[,'exclude'] <- ifelse(concepts[,'exclude']=='TRUE', 1, 0)
concepts[,'descendants'] <- ifelse(concepts[,'descendants']=='TRUE', 1, 0)
concepts[,'mapped'] <- ifelse(concepts[,'mapped']=='TRUE', 1, 0)
# save to temp table
connectionDetails <- createConnectionDetails(dbms="pdw",
server="JRDUSAPSCTL01",
port=17001,
user=NULL,
password=NULL)
conn <- connect(connectionDetails)
DatabaseConnector::insertTable(conn, 'scratch.dbo.concepts_390', concepts)#, tempTable = T)
# run cocnept_extract sql using temp table
sql <- SqlRender::readSql(file.path(dir,'concept_extract.sql'))
sql <- SqlRender::renderSql(sql, cdm='Vocabulary')$sql
sql <- SqlRender::translateSql(sql, sourceDialect = 'sql server', targetDialect = 'pdw')$sql
results[[ind]] <- DatabaseConnector::querySql(conn,sql)
}
return(results)
}
conceptSetIds <- list(name=c(#'Agitation, aggression or psychotic Symptoms in dementia together',
'Agitation, aggression or psychotic Symptoms in dementia sep',
'Tic disorder',
'Schizophrenia',
'Aggression in children with autism or developmental disorders'),
code=list(#2349,
c(2478,2479), 2348, 2347,c(2361, 2362)
))
# put concept sets into inds
inds <- lapply(conceptSetIds[[2]], getConcepts)
library(SqlRender)
library(DatabaseConnector)
library(stringr)
library(openxlsx)
cohortIds <- c(2520, 2521)
buildDatabase <- function(id, name, schema)
{
dataSource <- {};
dataSource$id = id;
dataSource$name = name;
dataSource$schema = schema;
return(dataSource);
}
dbList <- list(
buildDatabase("CPRD_V423", "CDM_CPRD_V423", "dbo"),
buildDatabase("JMDC_V429", "CDM_JMDC_V429", "dbo"),
buildDatabase("OPTUMEXTSES_V427", "CDM_OPTUM_EXTENDED_SES_V427", "dbo"),
buildDatabase("PREMIER_V428", "CDM_PREMIER_V428", "dbo"),
buildDatabase("TRUVENCCAE_V418", "CDM_TRUVEN_CCAE_V418", "dbo"),
buildDatabase("TRUVENMDCD_V432", "CDM_TRUVEN_MDCD_V432", "dbo"),
buildDatabase("TRUVENMDCR_V415", "CDM_TRUVEN_MDCR_V415", "dbo")
);
connectionDetails <- createConnectionDetails(dbms = "pdw", server = "JRDUSAPSCTL01",
port = 17001, user = "hix_reader", password = "reader1!")
outputExcel <- "Output/ExcelFiles/PP_Atlas"
for (cohortId in cohortIds)
{
filePath <- paste(paste(outputExcel, cohortId, sep="/", collapse=""), ".xlsx", sep="", collapse="")
if (file.exists(filePath))
{
file.remove(filePath)
}
wb <- createWorkbook()
for (db in dbList)
{
addWorksheet(wb, db$id)
pp_sql <- readSql("sql/PP_Atlas.sql");
pp_sql <- renderSql(pp_sql, cdmDatabaseSchema = paste(db$name, db$schema, sep=".", collapse=""), cohort_definition_id = cohortId,
urlPrefix = paste("'http://hix.jnj.com/atlas/#/profiles",
db$id, cohortId, "'", sep="/", collapse=""))$sql;
conn <- connect(connectionDetails)
pp_data <- querySql(conn, pp_sql)
hs <- createStyle(textDecoration = "Bold")
writeData(wb, sheet=db$id, pp_data,
startCol = 1, startRow = 1, colNames = TRUE, rowNames = FALSE, headerStyle = hs)
setColWidths(wb, sheet = db$id, cols = 1:5, widths = "auto")
}
saveWorkbook(wb, filePath, overwrite = TRUE)
}
install_github("ohdsi/Aphrodite")
install_github("ohdsi/Aphrodite")
library(OhdsiRTools)
install_github("ohdsi/Aphrodite")
install.packages("ohdsi/Aphrodite")
install.packages("devtools")
library("devtools")
install_github("ohdsi/Aphrodite")
install.packages(chron)
install.packages("chron")
install_github("ohdsi/Aphrodite")
install_github("OHDSI/CdmAtlasCutover")
library(devtools)
install_github("OHDSI/CdmAtlasCutover")
repoConnectionDetails <- createConnectionDetails(dbms = "sql server",
server = "rndusrdhit01",
port = 1433, schema = "ohdsi_repository.dbo")
oldCdmSources <- list(
buildCdmSource(sourceKey = "DEATHSUBSET_CCAE")
)
newCdmSources <- list(
buildCdmSource(sourceKey = "DEATHSUBSET_CCAE", sourceName = "Death Subset - Truven CCAE",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae", resultsDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae",
vocabDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae"),
buildCdmSource(sourceKey = "DEATHSUBSET_MDCR", sourceName = "Death Subset - Truven MDCR",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.truven_mdcr",
resultsDatabaseSchema = "CDM_DEATH_SUBSET.truven_mdcr",
vocabDatabaseSchema = "VOCABULARY_20161218.dbo"),
buildCdmSource(sourceKey = "DEATHSUBSET_OPTUM", sourceName = "Death Subset - Optum Extended DOD",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.optum_extended_dod",
resultsDatabaseSchema = "CDM_DEATH_SUBSET.optum_extended_dod",
vocabDatabaseSchema = "VOCABULARY_20161218.dbo")
)
library(CdmAtlasCutover)
oldCdmSources <- list(
buildCdmSource(sourceKey = "DEATHSUBSET_CCAE")
)
newCdmSources <- list(
buildCdmSource(sourceKey = "DEATHSUBSET_CCAE", sourceName = "Death Subset - Truven CCAE",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae", resultsDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae",
vocabDatabaseSchema = "CDM_DEATH_SUBSET.truven_ccae"),
buildCdmSource(sourceKey = "DEATHSUBSET_MDCR", sourceName = "Death Subset - Truven MDCR",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.truven_mdcr",
resultsDatabaseSchema = "CDM_DEATH_SUBSET.truven_mdcr",
vocabDatabaseSchema = "VOCABULARY_20161218.dbo"),
buildCdmSource(sourceKey = "DEATHSUBSET_OPTUM", sourceName = "Death Subset - Optum Extended DOD",
dbms = "pdw",
connectionString = "jdbc:sqlserver://JRDUSAPSCTL01:17001;databaseName=CDM_DEATH_SUBSET;user=hix_writer;password=writer1!",
cdmDatabaseSchema = "CDM_DEATH_SUBSET.optum_extended_dod",
resultsDatabaseSchema = "CDM_DEATH_SUBSET.optum_extended_dod",
vocabDatabaseSchema = "VOCABULARY_20161218.dbo")
)
removeCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = oldCdmSources, sqlOnly = TRUE)
createOhdsiResultsTables(cdmSources = newCdmSources, sqlOnly = TRUE)
insertCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = newCdmSources, sourceIdx = TRUE,
daimonIdx = TRUE, sqlOnly = TRUE)
repoConnectionDetails <- createConnectionDetails(dbms = "sql server",
server = "rndusrdhit01",
port = 1433, schema = "ohdsi_repository.dbo")
removeCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = oldCdmSources, sqlOnly = TRUE)
removeCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = oldCdmSources, sqlOnly = TRUE)
insertCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = newCdmSources, sourceIdx = TRUE,
daimonIdx = TRUE, sqlOnly = TRUE)
install_github("OHDSI/CdmAtlasCutover", force=TRUE)
library(CdmAtlasCutover)
# Initialize CDM database list, with all the CDMs to be cut over
repoConnectionDetails <- createConnectionDetails(dbms = "sql server",
server = "rndusrdhit01",
port = 1433, schema = "ohdsi_repository.dbo")
oldCdmSources <- list(
buildCdmSource(sourceKey = "DEATHSUBSET_CCAE")
)
removeCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = oldCdmSources, sqlOnly = TRUE)
createOhdsiResultsTables(cdmSources = newCdmSources, sqlOnly = TRUE)
insertCdmSources(repoConnectionDetails = repoConnectionDetails, cdmSources = newCdmSources, sourceIdx = TRUE,
daimonIdx = TRUE, sqlOnly = TRUE)
setwd("C:/Git/CommonDataModel/Documentation")
render("GlossaryofTerms.md","pdf_document")
library(rmarkdown)
render("GlossaryofTerms.md","pdf_document")
render("GlossaryofTerms.md",pdf_document(fig_width = 6.5))
render("GlossaryofTerms.md",pdf_document(fig_width = 6.5))
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd', pdf_document(includes = includes(after_body = "footer.txt")))
rmarkdown::render('report.Rmd', pdf_document(includes = includes(after_body = "footer.txt")))
rmarkdown::render('report.Rmd', pdf_document(includes = includes(after_body = "footer.txt")))
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
---
title: "OMOP Common Data Model v5.1 Specifications"
author: "Christian Reich, Patrick Ryan, Rimma Belenkaya, Karthik Natarajan and Clair Blacketer"
date: "`r Sys.Date()`"
output:
pdf_document:
number_sections: yes
toc: yes
linkcolor: blue
---
```{r child = 'C:/Git/CommonDataModel.wiki/License.md'}
```
```{r child = 'C:/Git/CommonDataModel.wiki/Background/TheRoleoftheCommonDataModel.md'}
```
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')
rmarkdown::render('report.Rmd')

View File

@ -1,5 +0,0 @@
C%3A%2FGit%2FGitHub%2FCDM_v5.2%2FCommonDataModel%2FDocumentation%2FCommonDataModel_pdf_create%2FMD_to_PDF_conversion.R="BBDD195"
C%3A%2FGit%2FGitHub%2FCDM_v5.2%2FCommonDataModel%2FDocumentation%2FCommonDataModel_pdf_create%2FOMOP_CDM_PDF.Rmd="4851A9DE"
C%3A%2FGit%2FGitHub%2FCommonDataModel%2FDocumentation%2FCommonDataModel_pdf_create%2F.Rhistory="49A263C2"
C%3A%2FGit%2FGitHub%2FCommonDataModel%2FDocumentation%2FCommonDataModel_pdf_create%2FMD_to_PDF_conversion.R="BC873E69"
C%3A%2FGit%2FGitHub%2FCommonDataModel%2FDocumentation%2FCommonDataModel_pdf_create%2FOMOP_CDM_PDF.Rmd="9FB0FECF"

File diff suppressed because one or more lines are too long

View File

@ -1,20 +0,0 @@
{
"collab_server" : "",
"contents" : "## Run this code and point it to the .Rmd file so it can convert the markdown files on the wiki to a pdf\ninstall.packages(\"rmarkdown\")\n\nrmarkdown::render(input = \"OMOP_CDM_PDF.Rmd\", output_format = \"pdf_document\", output_file = \"OMOP_CDM_v5_2.pdf\")\n",
"created" : 1500488094416.000,
"dirty" : false,
"encoding" : "UTF-8",
"folds" : "",
"hash" : "4214385325",
"id" : "C0F9B15",
"lastKnownWriteTime" : 1500494244,
"last_content_update" : 1500494244700,
"path" : "C:/Git/GitHub/CDM_v5.2/CommonDataModel/Documentation/CommonDataModel_pdf_create/MD_to_PDF_conversion.R",
"project_path" : "MD_to_PDF_conversion.R",
"properties" : {
},
"relative_order" : 2,
"source_on_save" : false,
"source_window" : "",
"type" : "r_source"
}

View File

@ -1 +0,0 @@
virtual-session-id="FBCE731C"

View File

@ -1 +0,0 @@
C:/Git/CommonDataModel/Documentation/CommonDataModel_pdf_create/OMOP_CDM_PDF.Rmd="71819BA2"

View File

@ -1,13 +0,0 @@
Version: 1.0
RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default
EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 8
Encoding: UTF-8
RnwWeave: Sweave
LaTeX: pdfLaTeX

View File

@ -1,4 +0,0 @@
## Run this code and point it to the .Rmd file so it can convert the markdown files on the wiki to a pdf
install.packages("rmarkdown")
rmarkdown::render(input = "OMOP_CDM_PDF.Rmd", output_format = "pdf_document", output_file = "../../OMOP_CDM_v5_2.pdf")

View File

@ -1,207 +0,0 @@
---
title: "OMOP Common Data Model v5.2 Specifications"
author: "Christian Reich, Patrick Ryan, Rimma Belenkaya, Karthik Natarajan and Clair Blacketer"
date: "`r Sys.Date()`"
output:
pdf_document:
number_sections: yes
toc: yes
linkcolor: blue
---
# License
```{r child = '../CommonDataModel_Wiki_Files/License.md'}
```
# Background
```{r child = '../CommonDataModel_Wiki_Files/Background/Background.md'}
```
## The Role of the Common Data Model
```{r child = '../CommonDataModel_Wiki_Files/Background/The-Role-of-the-Common-Data-Model.md'}
```
## Design Principles
```{r child = '../CommonDataModel_Wiki_Files/Background/Design-Principles.md'}
```
## Data Model Conventions
```{r child = '../CommonDataModel_Wiki_Files/Background/Data-Model-Conventions.md'}
```
# Glossary of Terms
```{r child = '../CommonDataModel_Wiki_Files/Glossary-of-Terms.md'}
```
# Standardized Vocabularies
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/Standardized-Vocabularies.md'}
```
## CONCEPT
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/CONCEPT.md'}
```
## VOCABULARY
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/VOCABULARY.md'}
```
## DOMAIN
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/DOMAIN.md'}
```
## CONCEPT_CLASS
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/CONCEPT_CLASS.md'}
```
## CONCEPT_RELATIONSHIP
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/CONCEPT_RELATIONSHIP.md'}
```
## RELATIONSHIP
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/RELATIONSHIP.md'}
```
## CONCEPT_SYNONYM
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/CONCEPT_SYNONYM.md'}
```
## CONCEPT_ANCESTOR
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/CONCEPT_ANCESTOR.md'}
```
## SOURCE_TO_CONCEPT_MAP
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/SOURCE_TO_CONCEPT_MAP.md'}
```
## DRUG_STRENGTH
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/DRUG_STRENGTH.md'}
```
## COHORT_DEFINITION
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/COHORT_DEFINITION.md'}
```
## ATTRIBUTE_DEFINITION
```{r child = '../CommonDataModel_Wiki_Files/StandardizedVocabularies/ATTRIBUTE_DEFINITION.md'}
```
# Standardized Metadata
```{r child = '../CommonDataModel_Wiki_Files/StandardizedMetadata/Standardized-Metadata.md'}
```
## CDM_SOURCE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedMetadata/CDM_SOURCE.md'}
```
# Standardized Clinical Data Tables
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/Standardized-clinical-Data-Tables.md'}
```
## PERSON
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/PERSON.md'}
```
## OBSERVATION_PERIOD
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/OBSERVATION_PERIOD.md'}
```
## SPECIMEN
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/SPECIMEN.md'}
```
## DEATH
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/DEATH.md'}
```
## VISIT_OCCURRENCE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/VISIT_OCCURRENCE.md'}
```
## PROCEDURE_OCCURRENCE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/PROCEDURE_OCCURRENCE.md'}
```
## DRUG_EXPOSURE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/DRUG_EXPOSURE.md'}
```
## DEVICE_EXPOSURE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/DEVICE_EXPOSURE.md'}
```
## CONDITION_OCCURRENCE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/CONDITION_OCCURRENCE.md'}
```
## MEASUREMENT
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/MEASUREMENT.md'}
```
## NOTE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/NOTE.md'}
```
## NOTE_NLP
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/NOTE_NLP.md'}
```
## OBSERVATION
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/OBSERVATION.md'}
```
## FACT_RELATIONSHIP
```{r child = '../CommonDataModel_Wiki_Files/StandardizedclinicalDataTables/FACT_RELATIONSHIP.md'}
```
# Standardized Health System Data Tables
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthSystemDataTables/Standardized-Health-System-Data-Tables.md'}
```
## LOCATION
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthSystemDataTables/LOCATION.md'}
```
## CARE_SITE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthSystemDataTables/CARE_SITE.md'}
```
## PROVIDER
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthSystemDataTables/PROVIDER.md'}
```
# Standardized Health Economics Data Tables
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthEconomicsDataTables/Standardized-Health-Economics-Data-Tables.md'}
```
## PAYER_PLAN_PERIOD
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthEconomicsDataTables/PAYER_PLAN_PERIOD.md'}
```
## COST
```{r child = '../CommonDataModel_Wiki_Files/StandardizedHealthEconomicsDataTables/COST.md'}
```
# Standardized Derived Elements
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/Standardized-Derived-Elements.md'}
```
## COHORT
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/COHORT.md'}
```
## COHORT_ATTRIBUTE
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/COHORT_ATTRIBUTE.md'}
```
## DRUG_ERA
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/DRUG_ERA.md'}
```
## DOSE_ERA
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/DOSE_ERA.md'}
```
## CONDITION_ERA
```{r child = '../CommonDataModel_Wiki_Files/StandardizedDerivedElements/CONDITION_ERA.md'}
```

File diff suppressed because it is too large Load Diff

View File

@ -1,716 +0,0 @@
/*********************************************************************************
# Copyright 2014-6 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### #
####### # # ####### # ##### ###### # # ## ##### ### #######
script to create OMOP common data model, version 5.2 for Hadoop (Hive/Impala) database
Based on the PostgreSQL version, with the following changes:
* NULL/NOT NULL is not used.
* Dates are stored as VARCHAR(8). See http://stackoverflow.com/questions/33024309/convert-yyyymmdd-string-to-date-in-impala for how to treat date columns as dates.
* PostgreSQL NUMERIC is stored as DOUBLE for amounts, and DECIMAL(19,4) for prices.
* PostgreSQL TEXT is stored as STRING.
*************************/
/************************
Standardized vocabulary
************************/
CREATE TABLE concept (
concept_id INTEGER,
concept_name VARCHAR(255),
domain_id VARCHAR(20),
vocabulary_id VARCHAR(20),
concept_class_id VARCHAR(20),
standard_concept CHAR(1),
concept_code VARCHAR(50),
valid_start_date VARCHAR(8), -- DATE
valid_end_date VARCHAR(8), -- DATE
invalid_reason CHAR(1)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20),
vocabulary_name VARCHAR(255),
vocabulary_reference VARCHAR(255),
vocabulary_version VARCHAR(255),
vocabulary_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE domain (
domain_id VARCHAR(20),
domain_name VARCHAR(255),
domain_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE concept_class (
concept_class_id VARCHAR(20),
concept_class_name VARCHAR(255),
concept_class_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE concept_relationship (
concept_id_1 INTEGER,
concept_id_2 INTEGER,
relationship_id VARCHAR(20),
valid_start_date VARCHAR(8), -- DATE
valid_end_date VARCHAR(8), -- DATE
invalid_reason CHAR(1)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE relationship (
relationship_id VARCHAR(20),
relationship_name VARCHAR(255),
is_hierarchical CHAR(1),
defines_ancestry CHAR(1),
reverse_relationship_id VARCHAR(20),
relationship_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE concept_synonym (
concept_id INTEGER,
concept_synonym_name VARCHAR(1000),
language_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE concept_ancestor (
ancestor_concept_id INTEGER,
descendant_concept_id INTEGER,
min_levels_of_separation INTEGER,
max_levels_of_separation INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE source_to_concept_map (
source_code VARCHAR(50),
source_concept_id INTEGER,
source_vocabulary_id VARCHAR(20),
source_code_description VARCHAR(255),
target_concept_id INTEGER,
target_vocabulary_id VARCHAR(20),
valid_start_date VARCHAR(8), -- DATE
valid_end_date VARCHAR(8), -- DATE
invalid_reason CHAR(1)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE drug_strength (
drug_concept_id INTEGER,
ingredient_concept_id INTEGER,
amount_value DOUBLE, -- NUMERIC
amount_unit_concept_id INTEGER,
numerator_value DOUBLE, -- NUMERIC
numerator_unit_concept_id INTEGER,
denominator_value DOUBLE, -- NUMERIC
denominator_unit_concept_id INTEGER,
box_size INTEGER,
valid_start_date VARCHAR(8), -- DATE
valid_end_date VARCHAR(8), -- DATE
invalid_reason CHAR(1)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER,
cohort_definition_name VARCHAR(255),
cohort_definition_description STRING, -- TEXT
definition_type_concept_id INTEGER,
cohort_definition_syntax STRING, -- TEXT
subject_concept_id INTEGER,
cohort_initiation_date VARCHAR(8) -- DATE
)
;
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER,
attribute_name VARCHAR(255),
attribute_description STRING, -- TEXT
attribute_type_concept_id INTEGER,
attribute_syntax STRING -- TEXT
)
;
/**************************
Standardized meta-data
***************************/
CREATE TABLE cdm_source
(
cdm_source_name VARCHAR(255),
cdm_source_abbreviation VARCHAR(25),
cdm_holder VARCHAR(255),
source_description STRING, -- TEXT
source_documentation_reference VARCHAR(255),
cdm_etl_reference VARCHAR(255),
source_release_date VARCHAR(8), -- DATE
cdm_release_date VARCHAR(8), -- DATE
cdm_version VARCHAR(10),
vocabulary_version VARCHAR(20)
)
;
/************************
Standardized clinical data
************************/
CREATE TABLE person (
person_id INTEGER,
gender_concept_id INTEGER,
year_of_birth INTEGER,
month_of_birth INTEGER,
day_of_birth INTEGER,
birth_datetime VARCHAR(10),
race_concept_id INTEGER,
ethnicity_concept_id INTEGER,
location_id INTEGER,
provider_id INTEGER,
care_site_id INTEGER,
person_source_value VARCHAR(50),
gender_source_value VARCHAR(50),
gender_source_concept_id INTEGER,
race_source_value VARCHAR(50),
race_source_concept_id INTEGER,
ethnicity_source_value VARCHAR(50),
ethnicity_source_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE observation_period (
observation_period_id INTEGER,
person_id INTEGER,
observation_period_start_date VARCHAR(8), -- DATE
observation_period_end_date VARCHAR(8), -- DATE
period_type_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE specimen (
specimen_id INTEGER,
person_id INTEGER,
specimen_concept_id INTEGER,
specimen_type_concept_id INTEGER,
specimen_date VARCHAR(8), -- DATE
specimen_datetime VARCHAR(10),
quantity DOUBLE, -- NUMERIC
unit_concept_id INTEGER,
anatomic_site_concept_id INTEGER,
disease_status_concept_id INTEGER,
specimen_source_id VARCHAR(50),
specimen_source_value VARCHAR(50),
unit_source_value VARCHAR(50),
anatomic_site_source_value VARCHAR(50),
disease_status_source_value VARCHAR(50)
)
;
CREATE TABLE death (
person_id INTEGER,
death_date VARCHAR(8), -- DATE
death_type_concept_id INTEGER,
cause_concept_id INTEGER,
cause_source_value VARCHAR(50),
cause_source_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE visit_occurrence (
visit_occurrence_id INTEGER,
person_id INTEGER,
visit_concept_id INTEGER,
visit_start_date VARCHAR(8), -- DATE
visit_start_datetime VARCHAR(10),
visit_end_date VARCHAR(8), -- DATE
visit_end_datetime VARCHAR(10),
visit_type_concept_id INTEGER,
provider_id INTEGER,
care_site_id INTEGER,
visit_source_value VARCHAR(50),
visit_source_concept_id INTEGER,
admitting_source_concept_id INTEGER,
admitting_source_value VARCHAR(50),
discharge_to_concept_id INTEGER,
discharge_to_source_value VARCHAR(50),
preceding_visit_occurrence_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE procedure_occurrence (
procedure_occurrence_id INTEGER,
person_id INTEGER,
procedure_concept_id INTEGER,
procedure_date VARCHAR(8), -- DATE
procedure_type_concept_id INTEGER,
modifier_concept_id INTEGER,
quantity INTEGER,
provider_id INTEGER,
visit_occurrence_id INTEGER,
procedure_source_value VARCHAR(50),
procedure_source_concept_id INTEGER,
qualifier_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE drug_exposure (
drug_exposure_id INTEGER,
person_id INTEGER,
drug_concept_id INTEGER,
drug_exposure_start_date VARCHAR(8), -- DATE
drug_exposure_end_date VARCHAR(8), -- DATE
verbatim_end_date VARCHAR(8), --DATE
drug_type_concept_id INTEGER,
stop_reason VARCHAR(20),
refills INTEGER,
quantity DOUBLE, -- NUMERIC
days_supply INTEGER,
sig STRING, -- TEXT
route_concept_id INTEGER,
lot_number VARCHAR(50),
provider_id INTEGER,
visit_occurrence_id INTEGER,
drug_source_value VARCHAR(50),
drug_source_concept_id INTEGER,
route_source_value VARCHAR(50),
dose_unit_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE device_exposure (
device_exposure_id INTEGER,
person_id INTEGER,
device_concept_id INTEGER,
device_exposure_start_date VARCHAR(8), -- DATE
device_exposure_end_date VARCHAR(8), -- DATE
device_type_concept_id INTEGER,
unique_device_id VARCHAR(50),
quantity INTEGER,
provider_id INTEGER,
visit_occurrence_id INTEGER,
device_source_value VARCHAR(100),
device_source_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE condition_occurrence (
condition_occurrence_id INTEGER,
person_id INTEGER,
condition_concept_id INTEGER,
condition_start_date VARCHAR(8), -- DATE
condition_end_date VARCHAR(8), -- DATE
condition_type_concept_id INTEGER,
stop_reason VARCHAR(20),
provider_id INTEGER,
visit_occurrence_id INTEGER,
condition_source_value VARCHAR(50),
condition_source_concept_id INTEGER,
condition_status_source_value VARCHAR(50),
condition_status_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE measurement (
measurement_id INTEGER,
person_id INTEGER,
measurement_concept_id INTEGER,
measurement_date VARCHAR(8), -- DATE
measurement_datetime VARCHAR(10),
measurement_type_concept_id INTEGER,
operator_concept_id INTEGER,
value_as_number DOUBLE, -- NUMERIC
value_as_concept_id INTEGER,
unit_concept_id INTEGER,
range_low DOUBLE, -- NUMERIC
range_high DOUBLE, -- NUMERIC
provider_id INTEGER,
visit_occurrence_id INTEGER,
measurement_source_value VARCHAR(50),
measurement_source_concept_id INTEGER,
unit_source_value VARCHAR(50),
value_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE note (
note_id INTEGER,
person_id INTEGER,
note_date VARCHAR(8), -- DATE
note_datetime VARCHAR(10),
note_type_concept_id INTEGER,
note_class_concept_id INTEGER,
note_title VARCHAR(250),
note_text STRING, -- TEXT
encoding_concept_id INTEGER,
language_concept_id INTEGER,
provider_id INTEGER,
visit_occurrence_id INTEGER,
note_source_value VARCHAR(50)
)
;
CREATE TABLE note_nlp (
note_nlp_id BIGINT,
note_id INTEGER,
section_concept_id INTEGER,
snippet VARCHAR(250),
offset VARCHAR(250),
lexical_variant VARCHAR(250),
note_nlp_concept_id INTEGER,
note_nlp_source_concept_id INTEGER,
nlp_system VARCHAR(250),
nlp_date VARCHAR(8),
nlp_datetime VARCHAR(10),
term_exists CHAR(1),
term_temporal VARCHAR(50),
term_modifiers VARCHAR(2000)
)
;
CREATE TABLE observation (
observation_id INTEGER,
person_id INTEGER,
observation_concept_id INTEGER,
observation_date VARCHAR(8), -- DATE
observation_datetime VARCHAR(10),
observation_type_concept_id INTEGER,
value_as_number DOUBLE, -- NUMERIC
value_as_string VARCHAR(60),
value_as_concept_id INTEGER,
qualifier_concept_id INTEGER,
unit_concept_id INTEGER,
provider_id INTEGER,
visit_occurrence_id INTEGER,
observation_source_value VARCHAR(50),
observation_source_concept_id INTEGER,
unit_source_value VARCHAR(50),
qualifier_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE fact_relationship (
domain_concept_id_1 INTEGER,
fact_id_1 INTEGER,
domain_concept_id_2 INTEGER,
fact_id_2 INTEGER,
relationship_concept_id INTEGER
)
;
/************************
Standardized health system data
************************/
CREATE TABLE `location` (
location_id INTEGER,
address_1 VARCHAR(50),
address_2 VARCHAR(50),
city VARCHAR(50),
state CHAR(2),
zip VARCHAR(9),
county VARCHAR(20),
location_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE care_site (
care_site_id INTEGER,
care_site_name VARCHAR(255),
place_of_service_concept_id INTEGER,
location_id INTEGER,
care_site_source_value VARCHAR(50),
place_of_service_source_value VARCHAR(50)
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE provider (
provider_id INTEGER,
provider_name VARCHAR(255),
NPI VARCHAR(20),
DEA VARCHAR(20),
specialty_concept_id INTEGER,
care_site_id INTEGER,
year_of_birth INTEGER,
gender_concept_id INTEGER,
provider_source_value VARCHAR(50),
specialty_source_value VARCHAR(50),
specialty_source_concept_id INTEGER,
gender_source_value VARCHAR(50),
gender_source_concept_id INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
/************************
Standardized health economics
************************/
CREATE TABLE payer_plan_period (
payer_plan_period_id INTEGER,
person_id INTEGER,
payer_plan_period_start_date VARCHAR(8), -- DATE
payer_plan_period_end_date VARCHAR(8), -- DATE
payer_source_value VARCHAR (50),
plan_source_value VARCHAR (50),
family_source_value VARCHAR (50)
)
;
CREATE TABLE cost (
cost_id INTEGER,
cost_event_id INTEGER,
cost_domain_id VARCHAR(20),
cost_type_concept_id INTEGER,
currency_concept_id INTEGER,
total_charge DECIMAL(19,4), -- NUMERIC
total_cost DECIMAL(19,4), -- NUMERIC
total_paid DECIMAL(19,4), -- NUMERIC
paid_by_payer DECIMAL(19,4), -- NUMERIC
paid_by_patient DECIMAL(19,4), -- NUMERIC
paid_patient_copay DECIMAL(19,4), -- NUMERIC
paid_patient_coinsurance DECIMAL(19,4), -- NUMERIC
paid_patient_deductible DECIMAL(19,4), -- NUMERIC
paid_by_primary DECIMAL(19,4), -- NUMERIC
paid_ingredient_cost DECIMAL(19,4), -- NUMERIC
paid_dispensing_fee DECIMAL(19,4), -- NUMERIC
payer_plan_period_id INTEGER,
amount_allowed DECIMAL(19,4), -- NUMERIC
revenue_code_concept_id INTEGER,
reveue_code_source_value VARCHAR(50),
drg_concept_id INTEGER,
drg_source_value CHAR(3)
)
;
/************************
Standardized derived elements
************************/
CREATE TABLE cohort (
cohort_definition_id INTEGER,
subject_id INTEGER,
cohort_start_date VARCHAR(8), -- DATE
cohort_end_date VARCHAR(8) -- DATE
)
;
CREATE TABLE cohort_attribute (
cohort_definition_id INTEGER,
cohort_start_date VARCHAR(8), -- DATE
cohort_end_date VARCHAR(8), -- DATE
subject_id INTEGER,
attribute_definition_id INTEGER,
value_as_number DOUBLE, -- NUMERIC
value_as_concept_id INTEGER
)
;
CREATE TABLE drug_era (
drug_era_id INTEGER,
person_id INTEGER,
drug_concept_id INTEGER,
drug_era_start_date VARCHAR(8), -- DATE
drug_era_end_date VARCHAR(8), -- DATE
drug_exposure_count INTEGER,
gap_days INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;
CREATE TABLE dose_era (
dose_era_id INTEGER,
person_id INTEGER,
drug_concept_id INTEGER,
unit_concept_id INTEGER,
dose_value DOUBLE, -- NUMERIC
dose_era_start_date VARCHAR(8), -- DATE
dose_era_end_date VARCHAR(8) -- DATE
)
;
CREATE TABLE condition_era (
condition_era_id INTEGER,
person_id INTEGER,
condition_concept_id INTEGER,
condition_era_start_date VARCHAR(8), -- DATE
condition_era_end_date VARCHAR(8), -- DATE
condition_occurrence_count INTEGER
)
ROW FORMAT DELIMITED FIELDS TERMINATED BY ','
TBLPROPERTIES ("skip.header.line.count"="1")
;

View File

@ -1,461 +0,0 @@
-- Use the search/replace regex in an editor to fix DATE columns:
-- ([^ ]+) VARCHAR\(8\), \-\- DATE
-- TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST($1 AS STRING), 1, 4), SUBSTR(CAST($1 AS STRING), 5, 2), SUBSTR(CAST($1 AS STRING), 7, 2)), 'UTC') AS $1,
CREATE TABLE omop_cdm_parquet.concept
STORED AS PARQUET
AS
SELECT
concept_id,
concept_name,
domain_id,
vocabulary_id,
concept_class_id,
standard_concept,
concept_code,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept;
CREATE TABLE omop_cdm_parquet.vocabulary
STORED AS PARQUET
AS
SELECT * from omop_cdm.vocabulary;
CREATE TABLE omop_cdm_parquet.domain
STORED AS PARQUET
AS
SELECT * from omop_cdm.domain;
CREATE TABLE omop_cdm_parquet.concept_class
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_class;
CREATE TABLE omop_cdm_parquet.concept_relationship
STORED AS PARQUET
AS
SELECT
concept_id_1,
concept_id_2,
relationship_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept_relationship;
CREATE TABLE omop_cdm_parquet.relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.relationship;
CREATE TABLE omop_cdm_parquet.concept_synonym
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_synonym;
CREATE TABLE omop_cdm_parquet.concept_ancestor
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_ancestor;
CREATE TABLE omop_cdm_parquet.source_to_concept_map
STORED AS PARQUET
AS
SELECT
source_code,
source_concept_id,
source_vocabulary_id,
source_code_description,
target_concept_id,
target_vocabulary_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.source_to_concept_map;
CREATE TABLE omop_cdm_parquet.drug_strength
STORED AS PARQUET
AS
SELECT
drug_concept_id,
ingredient_concept_id,
amount_value, -- NUMERIC
amount_unit_concept_id,
numerator_value, -- NUMERIC
numerator_unit_concept_id,
denominator_value, -- NUMERIC
denominator_unit_concept_id,
box_size,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.drug_strength;
CREATE TABLE omop_cdm_parquet.cohort_definition
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
cohort_definition_name,
cohort_definition_description, -- TEXT
definition_type_concept_id,
cohort_definition_syntax, -- TEXT
subject_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_initiation_date AS STRING), 1, 4), SUBSTR(CAST(cohort_initiation_date AS STRING), 5, 2), SUBSTR(CAST(cohort_initiation_date AS STRING), 7, 2)), 'UTC') AS cohort_initiation_date
FROM omop_cdm.cohort_definition;
CREATE TABLE omop_cdm_parquet.attribute_definition
STORED AS PARQUET
AS
SELECT * from omop_cdm.attribute_definition;
CREATE TABLE omop_cdm_parquet.cdm_source
STORED AS PARQUET
AS
SELECT
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description, -- TEXT
source_documentation_reference,
cdm_etl_reference,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(source_release_date AS STRING), 1, 4), SUBSTR(CAST(source_release_date AS STRING), 5, 2), SUBSTR(CAST(source_release_date AS STRING), 7, 2)), 'UTC') AS source_release_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cdm_release_date AS STRING), 1, 4), SUBSTR(CAST(cdm_release_date AS STRING), 5, 2), SUBSTR(CAST(cdm_release_date AS STRING), 7, 2)), 'UTC') AS cdm_release_date,
cdm_version,
vocabulary_version
FROM omop_cdm.cdm_source;
CREATE TABLE omop_cdm_parquet.person
STORED AS PARQUET
AS
SELECT * from omop_cdm.person;
CREATE TABLE omop_cdm_parquet.observation_period
STORED AS PARQUET
AS
SELECT
observation_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_date,
period_type_concept_id
FROM omop_cdm.observation_period;
CREATE TABLE omop_cdm_parquet.specimen
STORED AS PARQUET
AS
SELECT
specimen_id,
person_id,
specimen_concept_id,
specimen_type_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_date,
specimen_time,
quantity, -- NUMERIC
unit_concept_id,
anatomic_site_concept_id,
disease_status_concept_id,
specimen_source_id,
specimen_source_value,
unit_source_value,
anatomic_site_source_value,
disease_status_source_value
FROM omop_cdm.specimen;
CREATE TABLE omop_cdm_parquet.death
STORED AS PARQUET
AS
SELECT
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_date,
death_type_concept_id,
cause_concept_id,
cause_source_value,
cause_source_concept_id
FROM omop_cdm.death;
CREATE TABLE omop_cdm_parquet.visit_occurrence
STORED AS PARQUET
AS
SELECT
visit_occurrence_id,
person_id,
visit_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_date,
visit_start_time,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_date,
visit_end_time,
visit_type_concept_id,
provider_id,
care_site_id,
visit_source_value,
visit_source_concept_id
FROM omop_cdm.visit_occurrence;
CREATE TABLE omop_cdm_parquet.procedure_occurrence
STORED AS PARQUET
AS
SELECT
procedure_occurrence_id,
person_id,
procedure_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_date,
procedure_type_concept_id,
modifier_concept_id,
quantity,
provider_id,
visit_occurrence_id,
procedure_source_value,
procedure_source_concept_id,
qualifier_source_value
FROM omop_cdm.procedure_occurrence;
CREATE TABLE omop_cdm_parquet.drug_exposure
STORED AS PARQUET
AS
SELECT
drug_exposure_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date, TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(verbatim_end_date AS STRING), 1, 4), SUBSTR(CAST(verbatim_end_date AS STRING), 5, 2), SUBSTR(CAST(verbatim_end_date AS STRING), 7, 2)), 'UTC') AS verbatim_end_date,
drug_type_concept_id,
stop_reason,
refills,
quantity, -- NUMERIC
days_supply,
sig, -- TEXT
route_concept_id,
effective_drug_dose, -- NUMERIC
dose_unit_concept_id,
lot_number,
provider_id,
visit_occurrence_id,
drug_source_value,
drug_source_concept_id,
route_source_value,
dose_unit_source_value
FROM omop_cdm.drug_exposure;
CREATE TABLE omop_cdm_parquet.device_exposure
STORED AS PARQUET
AS
SELECT
device_exposure_id,
person_id,
device_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_date,
device_type_concept_id,
unique_device_id,
quantity,
provider_id,
visit_occurrence_id,
device_source_value,
device_source_concept_id
FROM omop_cdm.device_exposure;
CREATE TABLE omop_cdm_parquet.condition_occurrence
STORED AS PARQUET
AS
SELECT
condition_occurrence_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_date,
condition_type_concept_id,
stop_reason,
provider_id,
visit_occurrence_id,
condition_source_value,
condition_source_concept_id
FROM omop_cdm.condition_occurrence;
CREATE TABLE omop_cdm_parquet.measurement
STORED AS PARQUET
AS
SELECT
measurement_id,
person_id,
measurement_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_date,
measurement_time,
measurement_type_concept_id,
operator_concept_id,
value_as_number, -- NUMERIC
value_as_concept_id,
unit_concept_id,
range_low, -- NUMERIC
range_high, -- NUMERIC
provider_id,
visit_occurrence_id,
measurement_source_value,
measurement_source_concept_id,
unit_source_value,
value_source_value
FROM omop_cdm.measurement;
CREATE TABLE omop_cdm_parquet.note
STORED AS PARQUET
AS
SELECT
note_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_date,
note_time,
note_type_concept_id,
note_text, -- TEXT
provider_id,
visit_occurrence_id,
note_source_value
FROM omop_cdm.note;
CREATE TABLE omop_cdm_parquet.observation
STORED AS PARQUET
AS
SELECT
observation_id,
person_id,
observation_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_date,
observation_time,
observation_type_concept_id,
value_as_number, -- NUMERIC
value_as_string,
value_as_concept_id,
qualifier_concept_id,
unit_concept_id,
provider_id,
visit_occurrence_id,
observation_source_value,
observation_source_concept_id ,
unit_source_value,
qualifier_source_value
FROM omop_cdm.observation;
CREATE TABLE omop_cdm_parquet.fact_relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.fact_relationship;
CREATE TABLE omop_cdm_parquet.`location`
STORED AS PARQUET
AS
SELECT * from omop_cdm.`location`;
CREATE TABLE omop_cdm_parquet.care_site
STORED AS PARQUET
AS
SELECT * from omop_cdm.care_site;
CREATE TABLE omop_cdm_parquet.provider
STORED AS PARQUET
AS
SELECT * from omop_cdm.provider;
CREATE TABLE omop_cdm_parquet.payer_plan_period
STORED AS PARQUET
AS
SELECT
payer_plan_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_start_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_end_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_end_date,
payer_source_value,
plan_source_value,
family_source_value
FROM omop_cdm.payer_plan_period;
/* The individual cost tables are being phased out and will disappear soon
CREATE TABLE omop_cdm_parquet.visit_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.visit_cost;
CREATE TABLE omop_cdm_parquet.procedure_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.procedure_cost;
CREATE TABLE omop_cdm_parquet.drug_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.drug_cost;
CREATE TABLE omop_cdm_parquet.device_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.device_cost;
*/
CREATE TABLE omop_cdm_parquet.cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.cost;
CREATE TABLE omop_cdm_parquet.cohort
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
subject_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date
FROM omop_cdm.cohort;
CREATE TABLE omop_cdm_parquet.cohort_attribute
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date,
subject_id,
attribute_definition_id,
value_as_number, -- NUMERIC
value_as_concept_id
FROM omop_cdm.cohort_attribute;
CREATE TABLE omop_cdm_parquet.drug_era
STORED AS PARQUET
AS
SELECT
drug_era_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_start_date AS STRING), 7, 2)), 'UTC') AS drug_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_end_date AS STRING), 7, 2)), 'UTC') AS drug_era_end_date,
drug_exposure_count,
gap_days
FROM omop_cdm.drug_era;
CREATE TABLE omop_cdm_parquet.dose_era
STORED AS PARQUET
AS
SELECT
dose_era_id,
person_id,
drug_concept_id,
unit_concept_id,
dose_value, -- NUMERIC
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_start_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_start_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_start_date AS STRING), 7, 2)), 'UTC') AS dose_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_end_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_end_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_end_date AS STRING), 7, 2)), 'UTC') AS dose_era_end_date
FROM omop_cdm.dose_era;
CREATE TABLE omop_cdm_parquet.condition_era
STORED AS PARQUET
AS
SELECT
condition_era_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_start_date AS STRING), 7, 2)), 'UTC') AS condition_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_end_date AS STRING), 7, 2)), 'UTC') AS condition_era_end_date,
condition_occurrence_count
FROM omop_cdm.condition_era;

View File

@ -1,490 +0,0 @@
-- Use the search/replace regex in an editor to fix DATE columns:
-- ([^ ]+) VARCHAR\(8\), \-\- DATE
-- TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST($1 AS STRING), 1, 4), SUBSTR(CAST($1 AS STRING), 5, 2), SUBSTR(CAST($1 AS STRING), 7, 2)), 'UTC') AS $1,
CREATE TABLE omop_cdm_parquet.concept
STORED AS PARQUET
AS
SELECT
concept_id,
concept_name,
domain_id,
vocabulary_id,
concept_class_id,
standard_concept,
concept_code,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept;
CREATE TABLE omop_cdm_parquet.vocabulary
STORED AS PARQUET
AS
SELECT * from omop_cdm.vocabulary;
CREATE TABLE omop_cdm_parquet.domain
STORED AS PARQUET
AS
SELECT * from omop_cdm.domain;
CREATE TABLE omop_cdm_parquet.concept_class
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_class;
CREATE TABLE omop_cdm_parquet.concept_relationship
STORED AS PARQUET
AS
SELECT
concept_id_1,
concept_id_2,
relationship_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept_relationship;
CREATE TABLE omop_cdm_parquet.relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.relationship;
CREATE TABLE omop_cdm_parquet.concept_synonym
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_synonym;
CREATE TABLE omop_cdm_parquet.concept_ancestor
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_ancestor;
CREATE TABLE omop_cdm_parquet.source_to_concept_map
STORED AS PARQUET
AS
SELECT
source_code,
source_concept_id,
source_vocabulary_id,
source_code_description,
target_concept_id,
target_vocabulary_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.source_to_concept_map;
CREATE TABLE omop_cdm_parquet.drug_strength
STORED AS PARQUET
AS
SELECT
drug_concept_id,
ingredient_concept_id,
amount_value, -- NUMERIC
amount_unit_concept_id,
numerator_value, -- NUMERIC
numerator_unit_concept_id,
denominator_value, -- NUMERIC
denominator_unit_concept_id,
box_size,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.drug_strength;
CREATE TABLE omop_cdm_parquet.cohort_definition
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
cohort_definition_name,
cohort_definition_description, -- TEXT
definition_type_concept_id,
cohort_definition_syntax, -- TEXT
subject_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_initiation_date AS STRING), 1, 4), SUBSTR(CAST(cohort_initiation_date AS STRING), 5, 2), SUBSTR(CAST(cohort_initiation_date AS STRING), 7, 2)), 'UTC') AS cohort_initiation_date
FROM omop_cdm.cohort_definition;
CREATE TABLE omop_cdm_parquet.attribute_definition
STORED AS PARQUET
AS
SELECT * from omop_cdm.attribute_definition;
CREATE TABLE omop_cdm_parquet.cdm_source
STORED AS PARQUET
AS
SELECT
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description, -- TEXT
source_documentation_reference,
cdm_etl_reference,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(source_release_date AS STRING), 1, 4), SUBSTR(CAST(source_release_date AS STRING), 5, 2), SUBSTR(CAST(source_release_date AS STRING), 7, 2)), 'UTC') AS source_release_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cdm_release_date AS STRING), 1, 4), SUBSTR(CAST(cdm_release_date AS STRING), 5, 2), SUBSTR(CAST(cdm_release_date AS STRING), 7, 2)), 'UTC') AS cdm_release_date,
cdm_version,
vocabulary_version
FROM omop_cdm.cdm_source;
CREATE TABLE omop_cdm_parquet.person
STORED AS PARQUET
AS
SELECT
person_id,
gender_concept_id,
year_of_birth,
month_of_birth,
day_of_birth,
TO_UTC_TIMESTAMP(CONCAT_WS('-', CAST(year_of_birth AS STRING), SUBSTR(CONCAT('0', CAST(month_of_birth AS STRING)), -2), SUBSTR(CONCAT('0', CAST(day_of_birth AS STRING)), -2)), 'UTC') AS birth_datetime,
race_concept_id,
ethnicity_concept_id,
location_id,
provider_id,
care_site_id,
person_source_value,
gender_source_value,
gender_source_concept_id,
race_source_value,
race_source_concept_id,
ethnicity_source_value,
ethnicity_source_concept_id
FROM omop_cdm.person;
CREATE TABLE omop_cdm_parquet.observation_period
STORED AS PARQUET
AS
SELECT
observation_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_datetime,
period_type_concept_id
FROM omop_cdm.observation_period;
CREATE TABLE omop_cdm_parquet.specimen
STORED AS PARQUET
AS
SELECT
specimen_id,
person_id,
specimen_concept_id,
specimen_type_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_datetime,
quantity, -- NUMERIC
unit_concept_id,
anatomic_site_concept_id,
disease_status_concept_id,
specimen_source_id,
specimen_source_value,
unit_source_value,
anatomic_site_source_value,
disease_status_source_value
FROM omop_cdm.specimen;
CREATE TABLE omop_cdm_parquet.death
STORED AS PARQUET
AS
SELECT
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_datetime,
death_type_concept_id,
cause_concept_id,
cause_source_value,
cause_source_concept_id
FROM omop_cdm.death;
CREATE TABLE omop_cdm_parquet.visit_occurrence
STORED AS PARQUET
AS
SELECT
visit_occurrence_id,
person_id,
visit_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_datetime,
visit_type_concept_id,
provider_id,
care_site_id,
visit_source_value,
visit_source_concept_id
FROM omop_cdm.visit_occurrence;
CREATE TABLE omop_cdm_parquet.procedure_occurrence
STORED AS PARQUET
AS
SELECT
procedure_occurrence_id,
person_id,
procedure_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_datetime,
procedure_type_concept_id,
modifier_concept_id,
quantity,
provider_id,
visit_occurrence_id,
procedure_source_value,
procedure_source_concept_id,
qualifier_source_value
FROM omop_cdm.procedure_occurrence;
CREATE TABLE omop_cdm_parquet.drug_exposure
STORED AS PARQUET
AS
SELECT
drug_exposure_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_datetime,
drug_type_concept_id,
stop_reason,
refills,
quantity, -- NUMERIC
days_supply,
sig, -- TEXT
route_concept_id,
effective_drug_dose, -- NUMERIC
dose_unit_concept_id,
lot_number,
provider_id,
visit_occurrence_id,
drug_source_value,
drug_source_concept_id,
route_source_value,
dose_unit_source_value
FROM omop_cdm.drug_exposure;
CREATE TABLE omop_cdm_parquet.device_exposure
STORED AS PARQUET
AS
SELECT
device_exposure_id,
person_id,
device_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_datetime,
device_type_concept_id,
unique_device_id,
quantity,
provider_id,
visit_occurrence_id,
device_source_value,
device_source_concept_id
FROM omop_cdm.device_exposure;
CREATE TABLE omop_cdm_parquet.condition_occurrence
STORED AS PARQUET
AS
SELECT
condition_occurrence_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_datetime,
condition_type_concept_id,
stop_reason,
provider_id,
visit_occurrence_id,
condition_source_value,
condition_source_concept_id
FROM omop_cdm.condition_occurrence;
CREATE TABLE omop_cdm_parquet.measurement
STORED AS PARQUET
AS
SELECT
measurement_id,
person_id,
measurement_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_datetime,
measurement_type_concept_id,
operator_concept_id,
value_as_number, -- NUMERIC
value_as_concept_id,
unit_concept_id,
range_low, -- NUMERIC
range_high, -- NUMERIC
provider_id,
visit_occurrence_id,
measurement_source_value,
measurement_source_concept_id,
unit_source_value,
value_source_value
FROM omop_cdm.measurement;
CREATE TABLE omop_cdm_parquet.note
STORED AS PARQUET
AS
SELECT
note_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_datetime,
note_type_concept_id,
note_text, -- TEXT
provider_id,
visit_occurrence_id,
note_source_value
FROM omop_cdm.note;
CREATE TABLE omop_cdm_parquet.observation
STORED AS PARQUET
AS
SELECT
observation_id,
person_id,
observation_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_datetime,
observation_type_concept_id,
value_as_number, -- NUMERIC
value_as_string,
value_as_concept_id,
qualifier_concept_id,
unit_concept_id,
provider_id,
visit_occurrence_id,
observation_source_value,
observation_source_concept_id ,
unit_source_value,
qualifier_source_value
FROM omop_cdm.observation;
CREATE TABLE omop_cdm_parquet.fact_relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.fact_relationship;
CREATE TABLE omop_cdm_parquet.`location`
STORED AS PARQUET
AS
SELECT * from omop_cdm.`location`;
CREATE TABLE omop_cdm_parquet.care_site
STORED AS PARQUET
AS
SELECT * from omop_cdm.care_site;
CREATE TABLE omop_cdm_parquet.provider
STORED AS PARQUET
AS
SELECT * from omop_cdm.provider;
CREATE TABLE omop_cdm_parquet.payer_plan_period
STORED AS PARQUET
AS
SELECT
payer_plan_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_start_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_end_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_end_date,
payer_source_value,
plan_source_value,
family_source_value
FROM omop_cdm.payer_plan_period;
/* The individual cost tables are being phased out and will disappear soon
CREATE TABLE omop_cdm_parquet.visit_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.visit_cost;
CREATE TABLE omop_cdm_parquet.procedure_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.procedure_cost;
CREATE TABLE omop_cdm_parquet.drug_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.drug_cost;
CREATE TABLE omop_cdm_parquet.device_cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.device_cost;
*/
CREATE TABLE omop_cdm_parquet.cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.cost;
CREATE TABLE omop_cdm_parquet.cohort
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
subject_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date
FROM omop_cdm.cohort;
CREATE TABLE omop_cdm_parquet.cohort_attribute
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date,
subject_id,
attribute_definition_id,
value_as_number, -- NUMERIC
value_as_concept_id
FROM omop_cdm.cohort_attribute;
CREATE TABLE omop_cdm_parquet.drug_era
STORED AS PARQUET
AS
SELECT
drug_era_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_start_date AS STRING), 7, 2)), 'UTC') AS drug_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_end_date AS STRING), 7, 2)), 'UTC') AS drug_era_end_date,
drug_exposure_count,
gap_days
FROM omop_cdm.drug_era;
CREATE TABLE omop_cdm_parquet.dose_era
STORED AS PARQUET
AS
SELECT
dose_era_id,
person_id,
drug_concept_id,
unit_concept_id,
dose_value, -- NUMERIC
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_start_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_start_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_start_date AS STRING), 7, 2)), 'UTC') AS dose_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_end_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_end_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_end_date AS STRING), 7, 2)), 'UTC') AS dose_era_end_date
FROM omop_cdm.dose_era;
CREATE TABLE omop_cdm_parquet.condition_era
STORED AS PARQUET
AS
SELECT
condition_era_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_start_date AS STRING), 7, 2)), 'UTC') AS condition_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_end_date AS STRING), 7, 2)), 'UTC') AS condition_era_end_date,
condition_occurrence_count
FROM omop_cdm.condition_era;

View File

@ -1,501 +0,0 @@
-- Use the search/replace regex in an editor to fix DATE columns:
-- ([^ ]+) VARCHAR\(8\), \-\- DATE
-- TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST($1 AS STRING), 1, 4), SUBSTR(CAST($1 AS STRING), 5, 2), SUBSTR(CAST($1 AS STRING), 7, 2)), 'UTC') AS $1,
CREATE TABLE omop_cdm_parquet.concept
STORED AS PARQUET
AS
SELECT
concept_id,
concept_name,
domain_id,
vocabulary_id,
concept_class_id,
standard_concept,
concept_code,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept;
CREATE TABLE omop_cdm_parquet.vocabulary
STORED AS PARQUET
AS
SELECT * from omop_cdm.vocabulary;
CREATE TABLE omop_cdm_parquet.domain
STORED AS PARQUET
AS
SELECT * from omop_cdm.domain;
CREATE TABLE omop_cdm_parquet.concept_class
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_class;
CREATE TABLE omop_cdm_parquet.concept_relationship
STORED AS PARQUET
AS
SELECT
concept_id_1,
concept_id_2,
relationship_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.concept_relationship;
CREATE TABLE omop_cdm_parquet.relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.relationship;
CREATE TABLE omop_cdm_parquet.concept_synonym
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_synonym;
CREATE TABLE omop_cdm_parquet.concept_ancestor
STORED AS PARQUET
AS
SELECT * from omop_cdm.concept_ancestor;
CREATE TABLE omop_cdm_parquet.source_to_concept_map
STORED AS PARQUET
AS
SELECT
source_code,
source_concept_id,
source_vocabulary_id,
source_code_description,
target_concept_id,
target_vocabulary_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.source_to_concept_map;
CREATE TABLE omop_cdm_parquet.drug_strength
STORED AS PARQUET
AS
SELECT
drug_concept_id,
ingredient_concept_id,
amount_value, -- NUMERIC
amount_unit_concept_id,
numerator_value, -- NUMERIC
numerator_unit_concept_id,
denominator_value, -- NUMERIC
denominator_unit_concept_id,
box_size,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_start_date AS STRING), 1, 4), SUBSTR(CAST(valid_start_date AS STRING), 5, 2), SUBSTR(CAST(valid_start_date AS STRING), 7, 2)), 'UTC') AS valid_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(valid_end_date AS STRING), 1, 4), SUBSTR(CAST(valid_end_date AS STRING), 5, 2), SUBSTR(CAST(valid_end_date AS STRING), 7, 2)), 'UTC') AS valid_end_date,
nullif(invalid_reason, '') AS invalid_reason
FROM omop_cdm.drug_strength;
CREATE TABLE omop_cdm_parquet.cohort_definition
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
cohort_definition_name,
cohort_definition_description, -- TEXT
definition_type_concept_id,
cohort_definition_syntax, -- TEXT
subject_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_initiation_date AS STRING), 1, 4), SUBSTR(CAST(cohort_initiation_date AS STRING), 5, 2), SUBSTR(CAST(cohort_initiation_date AS STRING), 7, 2)), 'UTC') AS cohort_initiation_date
FROM omop_cdm.cohort_definition;
CREATE TABLE omop_cdm_parquet.attribute_definition
STORED AS PARQUET
AS
SELECT * from omop_cdm.attribute_definition;
CREATE TABLE omop_cdm_parquet.cdm_source
STORED AS PARQUET
AS
SELECT
cdm_source_name,
cdm_source_abbreviation,
cdm_holder,
source_description, -- TEXT
source_documentation_reference,
cdm_etl_reference,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(source_release_date AS STRING), 1, 4), SUBSTR(CAST(source_release_date AS STRING), 5, 2), SUBSTR(CAST(source_release_date AS STRING), 7, 2)), 'UTC') AS source_release_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cdm_release_date AS STRING), 1, 4), SUBSTR(CAST(cdm_release_date AS STRING), 5, 2), SUBSTR(CAST(cdm_release_date AS STRING), 7, 2)), 'UTC') AS cdm_release_date,
cdm_version,
vocabulary_version
FROM omop_cdm.cdm_source;
CREATE TABLE omop_cdm_parquet.person
STORED AS PARQUET
AS
SELECT
person_id,
gender_concept_id,
year_of_birth,
month_of_birth,
day_of_birth,
TO_UTC_TIMESTAMP(CONCAT_WS('-', CAST(year_of_birth AS STRING), SUBSTR(CONCAT('0', CAST(month_of_birth AS STRING)), -2), SUBSTR(CONCAT('0', CAST(day_of_birth AS STRING)), -2)), 'UTC') AS birth_datetime,
race_concept_id,
ethnicity_concept_id,
location_id,
provider_id,
care_site_id,
person_source_value,
gender_source_value,
gender_source_concept_id,
race_source_value,
race_source_concept_id,
ethnicity_source_value,
ethnicity_source_concept_id
FROM omop_cdm.person;
CREATE TABLE omop_cdm_parquet.observation_period
STORED AS PARQUET
AS
SELECT
observation_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_start_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_start_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_start_date AS STRING), 7, 2)), 'UTC') AS observation_period_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_period_end_date AS STRING), 1, 4), SUBSTR(CAST(observation_period_end_date AS STRING), 5, 2), SUBSTR(CAST(observation_period_end_date AS STRING), 7, 2)), 'UTC') AS observation_period_end_datetime,
period_type_concept_id
FROM omop_cdm.observation_period;
CREATE TABLE omop_cdm_parquet.specimen
STORED AS PARQUET
AS
SELECT
specimen_id,
person_id,
specimen_concept_id,
specimen_type_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(specimen_date AS STRING), 1, 4), SUBSTR(CAST(specimen_date AS STRING), 5, 2), SUBSTR(CAST(specimen_date AS STRING), 7, 2)), 'UTC') AS specimen_datetime,
quantity, -- NUMERIC
unit_concept_id,
anatomic_site_concept_id,
disease_status_concept_id,
specimen_source_id,
specimen_source_value,
unit_source_value,
anatomic_site_source_value,
disease_status_source_value
FROM omop_cdm.specimen;
CREATE TABLE omop_cdm_parquet.death
STORED AS PARQUET
AS
SELECT
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(death_date AS STRING), 1, 4), SUBSTR(CAST(death_date AS STRING), 5, 2), SUBSTR(CAST(death_date AS STRING), 7, 2)), 'UTC') AS death_datetime,
death_type_concept_id,
cause_concept_id,
cause_source_value,
cause_source_concept_id
FROM omop_cdm.death;
CREATE TABLE omop_cdm_parquet.visit_occurrence
STORED AS PARQUET
AS
SELECT
visit_occurrence_id,
person_id,
visit_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_start_date AS STRING), 1, 4), SUBSTR(CAST(visit_start_date AS STRING), 5, 2), SUBSTR(CAST(visit_start_date AS STRING), 7, 2)), 'UTC') AS visit_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(visit_end_date AS STRING), 1, 4), SUBSTR(CAST(visit_end_date AS STRING), 5, 2), SUBSTR(CAST(visit_end_date AS STRING), 7, 2)), 'UTC') AS visit_end_datetime,
visit_type_concept_id,
provider_id,
care_site_id,
visit_source_value,
visit_source_concept_id,
admitting_source_concept_id,
admitting_source_value,
discharge_to_concept_id,
discharge_to_source_value,
preceding_visit_occurrence_id
FROM omop_cdm.visit_occurrence;
CREATE TABLE omop_cdm_parquet.procedure_occurrence
STORED AS PARQUET
AS
SELECT
procedure_occurrence_id,
person_id,
procedure_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(procedure_date AS STRING), 1, 4), SUBSTR(CAST(procedure_date AS STRING), 5, 2), SUBSTR(CAST(procedure_date AS STRING), 7, 2)), 'UTC') AS procedure_datetime,
procedure_type_concept_id,
modifier_concept_id,
quantity,
provider_id,
visit_occurrence_id,
procedure_source_value,
procedure_source_concept_id,
qualifier_source_value
FROM omop_cdm.procedure_occurrence;
CREATE TABLE omop_cdm_parquet.drug_exposure
STORED AS PARQUET
AS
SELECT
drug_exposure_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_start_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_exposure_end_date AS STRING), 7, 2)), 'UTC') AS drug_exposure_end_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(verbatim_end_date AS STRING), 1, 4), SUBSTR(CAST(verbatim_end_date AS STRING), 5, 2), SUBSTR(CAST(verbatim_end_date AS STRING), 7, 2)), 'UTC') AS verbatim_end_date,
drug_type_concept_id,
stop_reason,
refills,
quantity, -- NUMERIC
days_supply,
sig, -- TEXT
route_concept_id,
lot_number,
provider_id,
visit_occurrence_id,
drug_source_value,
drug_source_concept_id,
route_source_value,
dose_unit_source_value
FROM omop_cdm.drug_exposure;
CREATE TABLE omop_cdm_parquet.device_exposure
STORED AS PARQUET
AS
SELECT
device_exposure_id,
person_id,
device_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_start_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_start_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_start_date AS STRING), 7, 2)), 'UTC') AS device_exposure_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(device_exposure_end_date AS STRING), 1, 4), SUBSTR(CAST(device_exposure_end_date AS STRING), 5, 2), SUBSTR(CAST(device_exposure_end_date AS STRING), 7, 2)), 'UTC') AS device_exposure_end_datetime,
device_type_concept_id,
unique_device_id,
quantity,
provider_id,
visit_occurrence_id,
device_source_value,
device_source_concept_id
FROM omop_cdm.device_exposure;
CREATE TABLE omop_cdm_parquet.condition_occurrence
STORED AS PARQUET
AS
SELECT
condition_occurrence_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_start_date AS STRING), 7, 2)), 'UTC') AS condition_start_datetime,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_end_date AS STRING), 7, 2)), 'UTC') AS condition_end_datetime,
condition_type_concept_id,
stop_reason,
provider_id,
visit_occurrence_id,
condition_source_value,
condition_source_concept_id,
condition_status_source_value,
condition_status_concept_id
FROM omop_cdm.condition_occurrence;
CREATE TABLE omop_cdm_parquet.measurement
STORED AS PARQUET
AS
SELECT
measurement_id,
person_id,
measurement_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(measurement_date AS STRING), 1, 4), SUBSTR(CAST(measurement_date AS STRING), 5, 2), SUBSTR(CAST(measurement_date AS STRING), 7, 2)), 'UTC') AS measurement_datetime,
measurement_type_concept_id,
operator_concept_id,
value_as_number, -- NUMERIC
value_as_concept_id,
unit_concept_id,
range_low, -- NUMERIC
range_high, -- NUMERIC
provider_id,
visit_occurrence_id,
measurement_source_value,
measurement_source_concept_id,
unit_source_value,
value_source_value
FROM omop_cdm.measurement;
CREATE TABLE omop_cdm_parquet.note
STORED AS PARQUET
AS
SELECT
note_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(note_date AS STRING), 1, 4), SUBSTR(CAST(note_date AS STRING), 5, 2), SUBSTR(CAST(note_date AS STRING), 7, 2)), 'UTC') AS note_datetime,
note_type_concept_id,
note_class_concept_id,
note_title,
note_text, -- TEXT
encoding_concept_id,
language_concept_id,
provider_id,
visit_occurrence_id,
note_source_value
FROM omop_cdm.note;
CREATE TABLE omop_cdm_parquet.note_nlp
STORED AS PARQUET
AS
SELECT
note_nlp_id,
note_id,
section_concept_id,
snippet,
offset,
lexical_variant,
note_nlp_concept_id,
note_nlp_source_concept_id,
nlp_system,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(nlp_date AS STRING), 1, 4), SUBSTR(CAST(nlp_date AS STRING), 5, 2), SUBSTR(CAST(nlp_date AS STRING), 7, 2)), 'UTC') AS nlp_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(nlp_date AS STRING), 1, 4), SUBSTR(CAST(nlp_date AS STRING), 5, 2), SUBSTR(CAST(nlp_date AS STRING), 7, 2)), 'UTC') AS nlp_datetime,
term_exists,
term_temporal,
term_modifiers
FROM omop_cdm.note_nlp;
CREATE TABLE omop_cdm_parquet.observation
STORED AS PARQUET
AS
SELECT
observation_id,
person_id,
observation_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(observation_date AS STRING), 1, 4), SUBSTR(CAST(observation_date AS STRING), 5, 2), SUBSTR(CAST(observation_date AS STRING), 7, 2)), 'UTC') AS observation_datetime,
observation_type_concept_id,
value_as_number, -- NUMERIC
value_as_string,
value_as_concept_id,
qualifier_concept_id,
unit_concept_id,
provider_id,
visit_occurrence_id,
observation_source_value,
observation_source_concept_id ,
unit_source_value,
qualifier_source_value
FROM omop_cdm.observation;
CREATE TABLE omop_cdm_parquet.fact_relationship
STORED AS PARQUET
AS
SELECT * from omop_cdm.fact_relationship;
CREATE TABLE omop_cdm_parquet.`location`
STORED AS PARQUET
AS
SELECT * from omop_cdm.`location`;
CREATE TABLE omop_cdm_parquet.care_site
STORED AS PARQUET
AS
SELECT * from omop_cdm.care_site;
CREATE TABLE omop_cdm_parquet.provider
STORED AS PARQUET
AS
SELECT * from omop_cdm.provider;
CREATE TABLE omop_cdm_parquet.payer_plan_period
STORED AS PARQUET
AS
SELECT
payer_plan_period_id,
person_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_start_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_start_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(payer_plan_period_end_date AS STRING), 1, 4), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 5, 2), SUBSTR(CAST(payer_plan_period_end_date AS STRING), 7, 2)), 'UTC') AS payer_plan_period_end_date,
payer_source_value,
plan_source_value,
family_source_value
FROM omop_cdm.payer_plan_period;
CREATE TABLE omop_cdm_parquet.cost
STORED AS PARQUET
AS
SELECT * from omop_cdm.cost;
CREATE TABLE omop_cdm_parquet.cohort
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
subject_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date
FROM omop_cdm.cohort;
CREATE TABLE omop_cdm_parquet.cohort_attribute
STORED AS PARQUET
AS
SELECT
cohort_definition_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_start_date AS STRING), 1, 4), SUBSTR(CAST(cohort_start_date AS STRING), 5, 2), SUBSTR(CAST(cohort_start_date AS STRING), 7, 2)), 'UTC') AS cohort_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(cohort_end_date AS STRING), 1, 4), SUBSTR(CAST(cohort_end_date AS STRING), 5, 2), SUBSTR(CAST(cohort_end_date AS STRING), 7, 2)), 'UTC') AS cohort_end_date,
subject_id,
attribute_definition_id,
value_as_number, -- NUMERIC
value_as_concept_id
FROM omop_cdm.cohort_attribute;
CREATE TABLE omop_cdm_parquet.drug_era
STORED AS PARQUET
AS
SELECT
drug_era_id,
person_id,
drug_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_start_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_start_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_start_date AS STRING), 7, 2)), 'UTC') AS drug_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(drug_era_end_date AS STRING), 1, 4), SUBSTR(CAST(drug_era_end_date AS STRING), 5, 2), SUBSTR(CAST(drug_era_end_date AS STRING), 7, 2)), 'UTC') AS drug_era_end_date,
drug_exposure_count,
gap_days
FROM omop_cdm.drug_era;
CREATE TABLE omop_cdm_parquet.dose_era
STORED AS PARQUET
AS
SELECT
dose_era_id,
person_id,
drug_concept_id,
unit_concept_id,
dose_value, -- NUMERIC
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_start_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_start_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_start_date AS STRING), 7, 2)), 'UTC') AS dose_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(dose_era_end_date AS STRING), 1, 4), SUBSTR(CAST(dose_era_end_date AS STRING), 5, 2), SUBSTR(CAST(dose_era_end_date AS STRING), 7, 2)), 'UTC') AS dose_era_end_date
FROM omop_cdm.dose_era;
CREATE TABLE omop_cdm_parquet.condition_era
STORED AS PARQUET
AS
SELECT
condition_era_id,
person_id,
condition_concept_id,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_start_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_start_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_start_date AS STRING), 7, 2)), 'UTC') AS condition_era_start_date,
TO_UTC_TIMESTAMP(CONCAT_WS('-', SUBSTR(CAST(condition_era_end_date AS STRING), 1, 4), SUBSTR(CAST(condition_era_end_date AS STRING), 5, 2), SUBSTR(CAST(condition_era_end_date AS STRING), 7, 2)), 'UTC') AS condition_era_end_date,
condition_occurrence_count
FROM omop_cdm.condition_era;

View File

@ -11,10 +11,10 @@ In order to create your instantiation of the Common Data Model, we recommend fol
impala-shell -q 'CREATE DATABASE omop_cdm'
```
2. Execute the script `OMOP_CDM_ddl_Impala.sql` to create the tables and fields.
2. Execute the script `OMOP CDM impala ddl.txt` (you will need to convert it to a sql file first) to create the tables and fields.
```bash
impala-shell -d omop_cdm -f OMOP_CDM_ddl_Impala.sql
impala-shell -d omop_cdm -f OMOP_CDM_impala_ddl.sql
```
3. Load your data into the schema.

View File

@ -0,0 +1,780 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
netezza script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
--HINT DISTRIBUTE ON RANDOM
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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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
)
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE drug_strength (
drug_concept_id INTEGER NOT NULL,
ingredient_concept_id INTEGER NOT NULL,
amount_value REAL NULL,
amount_unit_concept_id INTEGER NULL,
numerator_value REAL NULL,
numerator_unit_concept_id INTEGER NULL,
denominator_value REAL NULL,
denominator_unit_concept_id INTEGER NULL,
box_size INTEGER NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason VARCHAR(1) NULL
)
DISTRIBUTE ON RANDOM
;
-HINT DISTRIBUTE ON RANDOM
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description VARCHAR(1000) NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax VARCHAR(1000) NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description VARCHAR(1000) NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax VARCHAR(1000) NULL
)
DISTRIBUTE ON RANDOM
;
/**************************
Standardized meta-data
***************************/
--HINT DISTRIBUTE ON RANDOM
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(1000) 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
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
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(1000) NULL ,
value_as_concept_id INTEGER NULL ,
metadata_date DATE NULL ,
metadata_datetime DATETIME NULL
)
DISTRIBUTE ON RANDOM
;
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime DATETIME NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime DATETIME NULL ,
quantity REAL NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id 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
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime DATETIME NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_detail
(
visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime DATETIME NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime DATETIME NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime DATETIME NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity REAL NULL ,
days_supply INTEGER NULL ,
sig VARCHAR(1000) 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
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime DATETIME NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime DATETIME NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime DATETIME NULL ,
condition_end_date DATE NULL ,
condition_end_datetime DATETIME NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_datetime DATETIME NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number REAL NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low REAL NULL ,
range_high REAL NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime DATETIME NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text VARCHAR(1000) 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
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE note_nlp
(
note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime DATETIME NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime DATETIME NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number REAL NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
DISTRIBUTE ON RANDOM
;
/************************
Standardized health system data
************************/
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
DISTRIBUTE ON RANDOM
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
DISTRIBUTE ON RANDOM
;
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE ON RANDOM
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge REAL NULL ,
total_cost REAL NULL ,
total_paid REAL NULL ,
paid_by_payer REAL NULL ,
paid_by_patient REAL NULL ,
paid_patient_copay REAL NULL ,
paid_patient_coinsurance REAL NULL ,
paid_patient_deductible REAL NULL ,
paid_by_primary REAL NULL ,
paid_ingredient_cost REAL NULL ,
paid_dispensing_fee REAL NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed REAL NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
DISTRIBUTE ON RANDOM
;
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
DISTRIBUTE ON (subject_id)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number REAL NULL ,
value_as_concept_id INTEGER NULL
)
DISTRIBUTE ON (subject_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value REAL NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
DISTRIBUTE ON (person_id)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
DISTRIBUTE ON (person_id)
;

4
Netezza/README.md Normal file
View File

@ -0,0 +1,4 @@
Common-Data-Model / Netezza
=================
This folder contains the script for Netezza.

View File

@ -1,701 +0,0 @@
/*********************************************************************************
# Copyright 2014-6 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### #
####### # # ####### # ##### ###### # # ## ##### ### #######
script to create OMOP common data model, version 5.2 for Oracle database
last revised: 14 July 2017
Authors: Patrick Ryan, Christian Reich
*************************/
/************************
Standardized vocabulary
************************/
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 CHAR(1) NULL,
concept_code VARCHAR(50) NOT NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason CHAR(1) NULL
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NULL,
vocabulary_version VARCHAR(255) NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL)
;
CREATE TABLE relationship (
relationship_id VARCHAR(20) NOT NULL,
relationship_name VARCHAR(255) NOT NULL,
is_hierarchical CHAR(1) NOT NULL,
defines_ancestry CHAR(1) NOT NULL,
reverse_relationship_id VARCHAR(20) NOT NULL,
relationship_concept_id INTEGER NOT NULL
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL
)
;
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 CHAR(1) NULL
)
;
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description CLOB NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax CLOB NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
;
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description CLOB NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax CLOB NULL
)
;
/**************************
Standardized meta-data
***************************/
CREATE TABLE cdm_source
(
cdm_source_name VARCHAR(255) NOT NULL,
cdm_source_abbreviation VARCHAR(25) NULL,
cdm_holder VARCHAR(255) NULL,
source_description CLOB 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
)
;
/************************
Standardized clinical data
************************/
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime TIMESTAMP WITH TIME ZONE 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
)
;
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
observation_period_end_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime TIMESTAMP WITH TIME ZONE NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime TIMESTAMP WITH TIME ZONE NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP WITH TIME ZONE NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP WITH TIME ZONE NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime TIMESTAMP WITH TIME ZONE NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig CLOB NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
drug_source_value VARCHAR(50) NULL ,
drug_source_concept_id INTEGER NULL ,
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
;
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP WITH TIME ZONE 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 ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime TIMESTAMP WITH TIME ZONE NOT NULL ,
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP WITH TIME ZONE NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_datetime TIMESTAMP WITH TIME ZONE NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime TIMESTAMP WITH TIME ZONE NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text CLOB NOT NULL ,
encoding_concept_id INTEGER NOT NULL ,
language_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
note_source_value VARCHAR(50) NULL
)
;
/*This table is new in CDM v5.2*/
CREATE TABLE note_nlp
(
note_nlp_id NUMBER(19) NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP WITH TIME ZONE NULL ,
term_exists CHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime TIMESTAMP WITH TIME ZONE NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state CHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_source_value VARCHAR (50) NULL ,
plan_source_value VARCHAR (50) NULL ,
family_source_value VARCHAR (50) NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR2(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR2(50) NULL ,
drg_concept_id INTEGER NULL,
drg_source_value CHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
subject_id INTEGER NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
;
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -1,171 +0,0 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### ####
script to create the required indexes within OMOP common data model, version 5.2 for Oracle database
last revised: 17 July 2017
author: Patrick Ryan
description: These indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
Standardized vocabulary
************************/
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC);
CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC);
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC);
CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC);
CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC);
CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_drug_person_id ON drug_exposure (person_id ASC);
CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC);
CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_device_person_id ON device_exposure (person_id ASC);
CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC);
CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_condition_person_id ON condition_occurrence (person_id ASC);
CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC);
CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_measurement_person_id ON measurement (person_id ASC);
CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC);
CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC);
CREATE INDEX idx_note_person_id ON note (person_id ASC);
CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC);
CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC);
CREATE INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC);
CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC);
CREATE INDEX idx_observation_person_id ON observation (person_id ASC);
CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC);
CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC);
CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC);
CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC);
CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC);
/************************
Standardized health system data
************************/
/************************
Standardized health economics
************************/
CREATE INDEX idx_period_person_id ON payer_plan_period (person_id ASC);
/************************
Standardized derived elements
************************/
CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC);
CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC);
CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC);
CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC);
CREATE INDEX idx_drug_era_person_id ON drug_era (person_id ASC);
CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC);
CREATE INDEX idx_dose_era_person_id ON dose_era (person_id ASC);
CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC);
CREATE INDEX idx_condition_era_person_id ON condition_era (person_id ASC);
CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC);

View File

@ -1,13 +1,13 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
@ -17,172 +17,25 @@
/************************
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # ####
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
script to create constraints within OMOP common data model, version 5.2 for PostgreSQL database
last revised: 14 July 2017
oracle script to create foreign key constraints within OMOP common data model, version 5.3.0
author: Patrick Ryan
last revised: 15-November-2017
author: Patrick Ryan, Clair Blacketer
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ;
/************************
*************************
*************************
@ -314,8 +167,6 @@ ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_so
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
@ -328,6 +179,29 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (a
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_parent FOREIGN KEY (visit_detail_parent_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpd_v_detail_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id);
@ -425,7 +299,8 @@ ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_note FOREIGN KEY (note_id) REFE
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept FOREIGN KEY (section_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id);
@ -493,7 +368,6 @@ ALTER TABLE cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_pe
ALTER TABLE cost ADD CONSTRAINT fpk_drg_concept FOREIGN KEY (drg_concept_id) REFERENCES concept (concept_id);
/************************
Standardized derived elements
@ -527,3 +401,17 @@ ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (p
ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id);
/************************
*************************
*************************
*************************
Unique constraints
*************************
*************************
*************************
************************/
ALTER TABLE concept_synonym ADD CONSTRAINT uq_concept_synonym UNIQUE (concept_id, concept_synonym_name, language_concept_id);

View File

@ -0,0 +1,730 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
oracle script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
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
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
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
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
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
)
;
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description CLOB NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax CLOB NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
;
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description CLOB NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax CLOB NULL
)
;
/**************************
Standardized meta-data
***************************/
CREATE TABLE cdm_source
(
cdm_source_name VARCHAR(255) NOT NULL ,
cdm_source_abbreviation VARCHAR(25) NULL ,
cdm_holder VARCHAR(255) NULL ,
source_description CLOB 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
)
;
CREATE TABLE metadata
(
metadata_concept_id INTEGER NOT NULL ,
metadata_type_concept_id INTEGER NOT NULL ,
name VARCHAR(250) NOT NULL ,
value_as_string CLOB NULL ,
value_as_concept_id INTEGER NULL ,
metadata_date DATE NULL ,
metadata_datetime TIMESTAMP NULL
)
;
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime TIMESTAMP NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime TIMESTAMP NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime TIMESTAMP NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_detail
(
visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime TIMESTAMP NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime TIMESTAMP NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime TIMESTAMP NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig CLOB NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
drug_source_value VARCHAR(50) NULL ,
drug_source_concept_id INTEGER NULL ,
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime TIMESTAMP NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime TIMESTAMP NULL ,
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_time VARCHAR(10) NULL ,
measurement_datetime TIMESTAMP NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime TIMESTAMP NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text CLOB 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
)
;
CREATE TABLE note_nlp
(
note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime TIMESTAMP NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -1,13 +1,13 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
@ -17,50 +17,234 @@
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### ####
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
script to create the required indexes within OMOP common data model, version 5.2 for Oracle database
last revised: 14 July 2017
oracle script to create the required indexes within OMOP common data model, version 5.3
author: Patrick Ryan
last revised: 14-November-2017
description: These indices are considered a minimal requirement to ensure adequate performance of analyses.
author: Patrick Ryan, Clair Blacketer
description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC);
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ;
ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY ( visit_detail_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ;
/************************
*************************
*************************
*************************
Indices
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC);
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
@ -96,7 +280,14 @@ Standardized clinical data
************************/
CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC);
BEGIN
EXECUTE IMMEDIATE 'CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC)';
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE != -1408 THEN
RAISE;
END IF;
END;
CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC);
@ -108,6 +299,9 @@ CREATE INDEX idx_death_person_id ON death (person_id ASC);
CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC);
CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC);
CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);

View File

@ -7,14 +7,13 @@ In order to create your instantiation of the Common Data Model, we recommend fol
1. Create an empty schema.
2. Execute the script `OMOP CDM ddl - Oracle.sql` to create the tables and fields.
2. Execute the script `OMOP CDM oracle ddl.txt` to create the tables and fields.
3. Load your data into the schema.
4. Execute the script `OMOP CDM constraints - Oracle.sql` to add the constraints (primary and foreign keys).
4. Execute the script `OMOP CDM oracle constraints.txt` to add the constraints (primary keys).
5. Execute the script `OMOP CDM indexes required - Oracle - With constraints.sql` to add the minimum set of indexes we recommend.
5. Execute the script `OMOP CDM oracle indexes.txt` to add the minimum set of indexes and foreign keys we recommend.
Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably.
Also note: you can apply the indexes without first applying the constraints, but then we recommend you use the script `OMOP CDM indexes required - Oracle - Without constraints.sql`. (This script will also create the indexes that would normally be automatically created by the primary key constraints.)

View File

@ -1,13 +1,13 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
@ -17,173 +17,25 @@
/************************
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # ####
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
script to create constraints within OMOP common data model, version 5.2 for Oracle database
last revised: 14 July 2017
pdw script to create foreign key constraints within OMOP common data model, version 5.3.0
last revised: 15-November-2017
author: Patrick Ryan, Clair Blacketer
author: Patrick Ryan
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ;
/************************
*************************
*************************
@ -315,8 +167,6 @@ ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_so
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
@ -329,6 +179,29 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (a
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_parent FOREIGN KEY (visit_detail_parent_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpd_v_detail_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id);
@ -426,7 +299,8 @@ ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_note FOREIGN KEY (note_id) REFE
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept FOREIGN KEY (section_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id);
@ -477,7 +351,7 @@ ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specia
ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cost ADD CONSTRAINT fpk_drg_concept FOREIGN KEY (drg_concept_id) REFERENCES concept (concept_id);
/************************
@ -492,8 +366,7 @@ ALTER TABLE cost ADD CONSTRAINT fpk_visit_cost_currency FOREIGN KEY (currency_co
ALTER TABLE cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id);
ALTER TABLE cost ADD CONSTRAINT fpk_drg_concept FOREIGN KEY (drg_concept_id) REFERENCES concept (concept_id);
/************************
@ -528,3 +401,17 @@ ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (p
ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id);
/************************
*************************
*************************
*************************
Unique constraints
*************************
*************************
*************************
************************/
ALTER TABLE concept_synonym ADD CONSTRAINT uq_concept_synonym UNIQUE (concept_id, concept_synonym_name, language_concept_id);

View File

@ -0,0 +1,691 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
pdw script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE vocabulary (vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE domain (domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE concept_synonym (concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort_definition (cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description VARCHAR(1000) NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax VARCHAR(1000) NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE attribute_definition (attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description VARCHAR(1000) NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax VARCHAR(1000) NULL
)
WITH (DISTRIBUTION = REPLICATE);
/**************************
Standardized meta-data
***************************/
IF XACT_STATE() = 1 COMMIT; 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(1000) 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
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; 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(1000) NULL ,
value_as_concept_id INTEGER NULL ,
metadata_date DATE NULL ,
metadata_datetime DATETIME NULL
)
WITH (DISTRIBUTION = REPLICATE);
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE person
(person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime DATETIME NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation_period
(observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE specimen
(specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime DATETIME NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE death
(person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime DATETIME NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_occurrence
(visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE visit_detail
(visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE procedure_occurrence
(procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime DATETIME NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_exposure
(drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime DATETIME NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime DATETIME NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig VARCHAR(1000) 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
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE device_exposure
(device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime DATETIME NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime DATETIME NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE condition_occurrence
(condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime DATETIME NULL ,
condition_end_date DATE NULL ,
condition_end_datetime DATETIME NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE measurement
(measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_time VARCHAR(10) NULL ,
measurement_datetime DATETIME NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE note
(note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime DATETIME NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text VARCHAR(1000) 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
)
WITH (DISTRIBUTION = HASH(person_id));
IF XACT_STATE() = 1 COMMIT; CREATE TABLE note_nlp
(note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime DATETIME NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
WITH (DISTRIBUTION = REPLICATE);
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE observation
(observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime DATETIME NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = HASH(person_id));
IF XACT_STATE() = 1 COMMIT; CREATE TABLE fact_relationship
(domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
WITH (DISTRIBUTION = REPLICATE);
/************************
Standardized health system data
************************/
IF XACT_STATE() = 1 COMMIT; CREATE TABLE location
(location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE care_site
(care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
WITH (DISTRIBUTION = REPLICATE);
IF XACT_STATE() = 1 COMMIT; CREATE TABLE provider
(provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = REPLICATE);
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE payer_plan_period
(payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cost
(cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
WITH (DISTRIBUTION = REPLICATE);
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort
(cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
WITH (DISTRIBUTION = HASH(subject_id));
--HINT DISTRIBUTE_ON_KEY(subject_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE cohort_attribute
(cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
WITH (DISTRIBUTION = HASH(subject_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE drug_era
(drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE dose_era
(dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
WITH (DISTRIBUTION = HASH(person_id));
--HINT DISTRIBUTE_ON_KEY(person_id)
IF XACT_STATE() = 1 COMMIT; CREATE TABLE condition_era
(condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
WITH (DISTRIBUTION = HASH(person_id));

View File

@ -1,13 +1,13 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
@ -17,26 +17,175 @@
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### ####
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
script to create the required indexes within OMOP common data model, version 5.2 for SQL Server database
last revised: 14-July-2017
pdw script to create the required indexes within OMOP common data model, version 5.3
author: Patrick Ryan
last revised: 14-November-2017
description: These indices are considered a minimal requirement to ensure adequate performance of analyses.
author: Patrick Ryan, Clair Blacketer
description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY NONCLUSTERED (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY NONCLUSTERED (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY NONCLUSTERED (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY NONCLUSTERED (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY NONCLUSTERED (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY NONCLUSTERED (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY NONCLUSTERED (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY NONCLUSTERED (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY NONCLUSTERED (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY NONCLUSTERED ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY NONCLUSTERED ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY NONCLUSTERED ( visit_occurrence_id ) ;
ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY NONCLUSTERED ( visit_detail_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY NONCLUSTERED ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY NONCLUSTERED ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY NONCLUSTERED ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY NONCLUSTERED ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY NONCLUSTERED ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY NONCLUSTERED ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY NONCLUSTERED ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY NONCLUSTERED ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY NONCLUSTERED ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY NONCLUSTERED ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY NONCLUSTERED ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY NONCLUSTERED ( condition_era_id ) ;
/************************
*************************
*************************
*************************
Indices
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
@ -55,9 +204,9 @@ CREATE UNIQUE CLUSTERED INDEX idx_domain_domain_id ON domain (domain_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
@ -107,6 +256,9 @@ CREATE CLUSTERED INDEX idx_death_person_id ON death (person_id ASC);
CREATE CLUSTERED INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE CLUSTERED INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC);
CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC);
CREATE CLUSTERED INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);

View File

@ -0,0 +1,16 @@
Common-Data-Model / Parallel Data Warehouse
=================
This folder contains the script for Parallel Data Warehouse.
n order to create your instantiation of the Common Data Model, we recommend following these steps:
1. Create an empty schema.
2. Execute the script `OMOP CDM pdw ddl.txt` to create the tables and fields.
3. Load your data into the schema.
4. Execute the script `OMOP CDM pdw constraints.txt` to add the constraints (primary keys).
5. Execute the script `OMOP CDM pdw indexes.txt` to add the minimum set of indexes and foreign keys we recommend.

View File

@ -1,704 +0,0 @@
/*********************************************************************************
# Copyright 2014-6 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### #
####### # # ####### # ##### ###### # # ## ##### ### #######
script to create OMOP common data model, version 5.2 for PostgreSQL database
last revised: 14 July 2017
Authors: Patrick Ryan, Christian Reich
*************************/
/************************
Standardized vocabulary
************************/
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 CHAR(1) NULL,
concept_code VARCHAR(50) NOT NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason CHAR(1) NULL
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NULL,
vocabulary_version VARCHAR(255) NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL)
;
CREATE TABLE relationship (
relationship_id VARCHAR(20) NOT NULL,
relationship_name VARCHAR(255) NOT NULL,
is_hierarchical CHAR(1) NOT NULL,
defines_ancestry CHAR(1) NOT NULL,
reverse_relationship_id VARCHAR(20) NOT NULL,
relationship_concept_id INTEGER NOT NULL
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL
)
;
CREATE TABLE drug_strength (
drug_concept_id INTEGER NOT NULL,
ingredient_concept_id INTEGER NOT NULL,
amount_value NUMERIC NULL,
amount_unit_concept_id INTEGER NULL,
numerator_value NUMERIC NULL,
numerator_unit_concept_id INTEGER NULL,
denominator_value NUMERIC NULL,
denominator_unit_concept_id INTEGER NULL,
box_size INTEGER NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason CHAR(1) NULL
)
;
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description TEXT NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax TEXT NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
;
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description TEXT NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax TEXT NULL
)
;
/**************************
Standardized meta-data
***************************/
CREATE TABLE cdm_source
(
cdm_source_name VARCHAR(255) NOT NULL,
cdm_source_abbreviation VARCHAR(25) NULL,
cdm_holder VARCHAR(255) NULL,
source_description TEXT NULL,
source_documentation_reference VARCHAR(255) NULL,
cdm_etl_reference VARCHAR(255) NULL,
source_release_date DATE NULL,
cdm_release_date DATE NULL,
cdm_version VARCHAR(10) NULL,
vocabulary_version VARCHAR(20) NULL
)
;
/************************
Standardized clinical data
************************/
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
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
)
;
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_start_datetime TIMESTAMP NOT NULL ,
observation_period_end_date DATE NOT NULL ,
observation_period_end_datetime TIMESTAMP NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime TIMESTAMP NULL ,
quantity NUMERIC NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime TIMESTAMP NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime TIMESTAMP NOT NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime TIMESTAMP NOT NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime TIMESTAMP NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity NUMERIC NULL ,
days_supply INTEGER NULL ,
sig TEXT NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
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
)
;
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime TIMESTAMP NOT NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime TIMESTAMP NOT NULL ,
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_datetime TIMESTAMP NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number NUMERIC NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low NUMERIC NULL ,
range_high NUMERIC NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime TIMESTAMP NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text TEXT NOT NULL ,
encoding_concept_id INTEGER NOT NULL ,
language_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
note_source_value VARCHAR(50) NULL
)
;
/*This table is new in CDM v5.2*/
CREATE TABLE note_nlp
(
note_nlp_id BIGINT NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP NULL ,
term_exists CHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime TIMESTAMP NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number NUMERIC NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state CHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_source_value VARCHAR (50) NULL ,
plan_source_value VARCHAR (50) NULL ,
family_source_value VARCHAR (50) NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge NUMERIC NULL ,
total_cost NUMERIC NULL ,
total_paid NUMERIC NULL ,
paid_by_payer NUMERIC NULL ,
paid_by_patient NUMERIC NULL ,
paid_patient_copay NUMERIC NULL ,
paid_patient_coinsurance NUMERIC NULL ,
paid_patient_deductible NUMERIC NULL ,
paid_by_primary NUMERIC NULL ,
paid_ingredient_cost NUMERIC NULL ,
paid_dispensing_fee NUMERIC NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed NUMERIC NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL ,
drg_concept_id INTEGER NULL,
drg_source_value CHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
subject_id INTEGER NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number NUMERIC NULL ,
value_as_concept_id INTEGER NULL
)
;
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value NUMERIC NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -1,218 +0,0 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ### # # ##### ###### # # ###### ####
script to create the required indexes within OMOP common data model, version 5.2 for PostgreSQL database
last revised: 14 July 2017
author: Patrick Ryan
description: These indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
Standardized vocabulary
************************/
CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC);
CLUSTER concept USING idx_concept_concept_id ;
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
CLUSTER vocabulary USING idx_vocabulary_vocabulary_id ;
CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC);
CLUSTER domain USING idx_domain_domain_id ;
CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
CLUSTER concept_class USING idx_concept_class_class_id ;
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
CLUSTER relationship USING idx_relationship_rel_id ;
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
CLUSTER concept_synonym USING idx_concept_synonym_id ;
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
CLUSTER concept_ancestor USING idx_concept_ancestor_id_1 ;
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC);
CLUSTER source_to_concept_map USING idx_source_to_concept_map_id_3 ;
CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC);
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
CLUSTER drug_strength USING idx_drug_strength_id_1 ;
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC);
CLUSTER cohort_definition USING idx_cohort_definition_id ;
CREATE INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC);
CLUSTER attribute_definition USING idx_attribute_definition_id ;
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC);
CLUSTER person USING idx_person_id ;
CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC);
CLUSTER observation_period USING idx_observation_period_id ;
CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC);
CLUSTER specimen USING idx_specimen_person_id ;
CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC);
CREATE INDEX idx_death_person_id ON death (person_id ASC);
CLUSTER death USING idx_death_person_id ;
CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CLUSTER visit_occurrence USING idx_visit_person_id ;
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CLUSTER procedure_occurrence USING idx_procedure_person_id ;
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_drug_person_id ON drug_exposure (person_id ASC);
CLUSTER drug_exposure USING idx_drug_person_id ;
CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC);
CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_device_person_id ON device_exposure (person_id ASC);
CLUSTER device_exposure USING idx_device_person_id ;
CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC);
CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_condition_person_id ON condition_occurrence (person_id ASC);
CLUSTER condition_occurrence USING idx_condition_person_id ;
CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC);
CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_measurement_person_id ON measurement (person_id ASC);
CLUSTER measurement USING idx_measurement_person_id ;
CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC);
CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC);
CREATE INDEX idx_note_person_id ON note (person_id ASC);
CLUSTER note USING idx_note_person_id ;
CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC);
CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC);
CREATE INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC);
CLUSTER note_nlp USING idx_note_nlp_note_id ;
CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC);
CREATE INDEX idx_observation_person_id ON observation (person_id ASC);
CLUSTER observation USING idx_observation_person_id ;
CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC);
CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC);
CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC);
CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC);
CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC);
/************************
Standardized health system data
************************/
/************************
Standardized health economics
************************/
CREATE INDEX idx_period_person_id ON payer_plan_period (person_id ASC);
CLUSTER payer_plan_period USING idx_period_person_id ;
/************************
Standardized derived elements
************************/
CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC);
CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC);
CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC);
CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC);
CREATE INDEX idx_drug_era_person_id ON drug_era (person_id ASC);
CLUSTER drug_era USING idx_drug_era_person_id ;
CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC);
CREATE INDEX idx_dose_era_person_id ON dose_era (person_id ASC);
CLUSTER dose_era USING idx_dose_era_person_id ;
CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC);
CREATE INDEX idx_condition_era_person_id ON condition_era (person_id ASC);
CLUSTER condition_era USING idx_condition_era_person_id ;
CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC);

View File

@ -1,13 +1,13 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
@ -17,172 +17,25 @@
/************************
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ####### ##### #### # # #### # # # # # # # # # ####
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
script to create constraints within OMOP common data model, version 5.1.0 for SQL Server database
last revised: 12 Oct 2014
postgresql script to create foreign key constraints within OMOP common data model, version 5.3.0
author: Patrick Ryan
last revised: 15-November-2017
author: Patrick Ryan, Clair Blacketer
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY NONCLUSTERED (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY NONCLUSTERED (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY NONCLUSTERED (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY NONCLUSTERED (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY NONCLUSTERED (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY NONCLUSTERED (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY NONCLUSTERED (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY NONCLUSTERED (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY NONCLUSTERED (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY NONCLUSTERED ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY NONCLUSTERED ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY NONCLUSTERED ( visit_occurrence_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY NONCLUSTERED ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY NONCLUSTERED ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY NONCLUSTERED ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY NONCLUSTERED ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY NONCLUSTERED ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY NONCLUSTERED ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY NONCLUSTERED ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY NONCLUSTERED ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY NONCLUSTERED ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY NONCLUSTERED ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY NONCLUSTERED ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY NONCLUSTERED ( condition_era_id ) ;
/************************
*************************
*************************
@ -314,8 +167,6 @@ ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_so
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept FOREIGN KEY (visit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
@ -328,6 +179,29 @@ ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (a
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_parent FOREIGN KEY (visit_detail_parent_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpd_v_detail_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id);
@ -425,7 +299,7 @@ ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_note FOREIGN KEY (note_id) REFE
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept FOREIGN KEY (section_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
@ -527,3 +401,17 @@ ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (p
ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id);
/************************
*************************
*************************
*************************
Unique constraints
*************************
*************************
*************************
************************/
ALTER TABLE concept_synonym ADD CONSTRAINT uq_concept_synonym UNIQUE (concept_id, concept_synonym_name, language_concept_id);

View File

@ -0,0 +1,730 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
postgresql script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
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
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
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
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
CREATE TABLE drug_strength (
drug_concept_id INTEGER NOT NULL,
ingredient_concept_id INTEGER NOT NULL,
amount_value NUMERIC NULL,
amount_unit_concept_id INTEGER NULL,
numerator_value NUMERIC NULL,
numerator_unit_concept_id INTEGER NULL,
denominator_value NUMERIC NULL,
denominator_unit_concept_id INTEGER NULL,
box_size INTEGER NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason VARCHAR(1) NULL
)
;
CREATE TABLE cohort_definition (
cohort_definition_id INTEGER NOT NULL,
cohort_definition_name VARCHAR(255) NOT NULL,
cohort_definition_description TEXT NULL,
definition_type_concept_id INTEGER NOT NULL,
cohort_definition_syntax TEXT NULL,
subject_concept_id INTEGER NOT NULL,
cohort_initiation_date DATE NULL
)
;
CREATE TABLE attribute_definition (
attribute_definition_id INTEGER NOT NULL,
attribute_name VARCHAR(255) NOT NULL,
attribute_description TEXT NULL,
attribute_type_concept_id INTEGER NOT NULL,
attribute_syntax TEXT NULL
)
;
/**************************
Standardized meta-data
***************************/
CREATE TABLE cdm_source
(
cdm_source_name VARCHAR(255) NOT NULL ,
cdm_source_abbreviation VARCHAR(25) NULL ,
cdm_holder VARCHAR(255) NULL ,
source_description TEXT NULL ,
source_documentation_reference VARCHAR(255) NULL ,
cdm_etl_reference VARCHAR(255) NULL ,
source_release_date DATE NULL ,
cdm_release_date DATE NULL ,
cdm_version VARCHAR(10) NULL ,
vocabulary_version VARCHAR(20) NULL
)
;
CREATE TABLE metadata
(
metadata_concept_id INTEGER NOT NULL ,
metadata_type_concept_id INTEGER NOT NULL ,
name VARCHAR(250) NOT NULL ,
value_as_string TEXT NULL ,
value_as_concept_id INTEGER NULL ,
metadata_date DATE NULL ,
metadata_datetime TIMESTAMP NULL
)
;
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime TIMESTAMP NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime TIMESTAMP NULL ,
quantity NUMERIC NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime TIMESTAMP NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_detail
(
visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime TIMESTAMP NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime TIMESTAMP NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime TIMESTAMP NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity NUMERIC NULL ,
days_supply INTEGER NULL ,
sig TEXT NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
drug_source_value VARCHAR(50) NULL ,
drug_source_concept_id INTEGER NULL ,
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime TIMESTAMP NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime TIMESTAMP NULL ,
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_time VARCHAR(10) NULL ,
measurement_datetime TIMESTAMP NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number NUMERIC NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low NUMERIC NULL ,
range_high NUMERIC NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime TIMESTAMP NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text TEXT 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
)
;
CREATE TABLE note_nlp
(
note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime TIMESTAMP NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number NUMERIC NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge NUMERIC NULL ,
total_cost NUMERIC NULL ,
total_paid NUMERIC NULL ,
paid_by_payer NUMERIC NULL ,
paid_by_patient NUMERIC NULL ,
paid_patient_copay NUMERIC NULL ,
paid_patient_coinsurance NUMERIC NULL ,
paid_patient_deductible NUMERIC NULL ,
paid_by_primary NUMERIC NULL ,
paid_ingredient_cost NUMERIC NULL ,
paid_dispensing_fee NUMERIC NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed NUMERIC NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number NUMERIC NULL ,
value_as_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value NUMERIC NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -0,0 +1,371 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
postgresql script to create the required indexes within OMOP common data model, version 5.3
last revised: 14-November-2017
author: Patrick Ryan, Clair Blacketer
description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY ( visit_occurrence_id ) ;
ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY ( visit_detail_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY ( condition_era_id ) ;
/************************
*************************
*************************
*************************
Indices
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
CREATE UNIQUE INDEX idx_concept_concept_id ON concept (concept_id ASC);
CLUSTER concept USING idx_concept_concept_id ;
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
CREATE UNIQUE INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
CLUSTER vocabulary USING idx_vocabulary_vocabulary_id ;
CREATE UNIQUE INDEX idx_domain_domain_id ON domain (domain_id ASC);
CLUSTER domain USING idx_domain_domain_id ;
CREATE UNIQUE INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
CLUSTER concept_class USING idx_concept_class_class_id ;
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE UNIQUE INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
CLUSTER relationship USING idx_relationship_rel_id ;
CREATE INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
CLUSTER concept_synonym USING idx_concept_synonym_id ;
CREATE INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
CLUSTER concept_ancestor USING idx_concept_ancestor_id_1 ;
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
CREATE INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC);
CLUSTER source_to_concept_map USING idx_source_to_concept_map_id_3 ;
CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC);
CREATE INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
CLUSTER drug_strength USING idx_drug_strength_id_1 ;
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC);
CLUSTER cohort_definition USING idx_cohort_definition_id ;
CREATE INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC);
CLUSTER attribute_definition USING idx_attribute_definition_id ;
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
CREATE UNIQUE INDEX idx_person_id ON person (person_id ASC);
CLUSTER person USING idx_person_id ;
CREATE INDEX idx_observation_period_id ON observation_period (person_id ASC);
CLUSTER observation_period USING idx_observation_period_id ;
CREATE INDEX idx_specimen_person_id ON specimen (person_id ASC);
CLUSTER specimen USING idx_specimen_person_id ;
CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC);
CREATE INDEX idx_death_person_id ON death (person_id ASC);
CLUSTER death USING idx_death_person_id ;
CREATE INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CLUSTER visit_occurrence USING idx_visit_person_id ;
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC);
CLUSTER visit_detail USING idx_visit_detail_person_id ;
CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC);
CREATE INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CLUSTER procedure_occurrence USING idx_procedure_person_id ;
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_drug_person_id ON drug_exposure (person_id ASC);
CLUSTER drug_exposure USING idx_drug_person_id ;
CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC);
CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_device_person_id ON device_exposure (person_id ASC);
CLUSTER device_exposure USING idx_device_person_id ;
CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC);
CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC);
CREATE INDEX idx_condition_person_id ON condition_occurrence (person_id ASC);
CLUSTER condition_occurrence USING idx_condition_person_id ;
CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC);
CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC);
CREATE INDEX idx_measurement_person_id ON measurement (person_id ASC);
CLUSTER measurement USING idx_measurement_person_id ;
CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC);
CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC);
CREATE INDEX idx_note_person_id ON note (person_id ASC);
CLUSTER note USING idx_note_person_id ;
CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC);
CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC);
CREATE INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC);
CLUSTER note_nlp USING idx_note_nlp_note_id ;
CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC);
CREATE INDEX idx_observation_person_id ON observation (person_id ASC);
CLUSTER observation USING idx_observation_person_id ;
CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC);
CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC);
CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC);
CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC);
CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC);
/************************
Standardized health system data
************************/
/************************
Standardized health economics
************************/
CREATE INDEX idx_period_person_id ON payer_plan_period (person_id ASC);
CLUSTER payer_plan_period USING idx_period_person_id ;
/************************
Standardized derived elements
************************/
CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC);
CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC);
CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC);
CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC);
CREATE INDEX idx_drug_era_person_id ON drug_era (person_id ASC);
CLUSTER drug_era USING idx_drug_era_person_id ;
CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC);
CREATE INDEX idx_dose_era_person_id ON dose_era (person_id ASC);
CLUSTER dose_era USING idx_dose_era_person_id ;
CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC);
CREATE INDEX idx_condition_era_person_id ON condition_era (person_id ASC);
CLUSTER condition_era USING idx_condition_era_person_id ;
CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC);

View File

@ -7,12 +7,12 @@ In order to create your instantiation of the Common Data Model, we recommend fol
1. Create an empty schema.
2. Execute the script `OMOP CDM ddl - PostgreSQL.sql` to create the tables and fields.
2. Execute the script `OMOP CDM postgresql ddl.txt` to create the tables and fields.
3. Load your data into the schema.
4. Execute the script `OMOP CDM constraints - PostgreSQL.sql` to add the constraints (primary and foreign keys).
4. Execute the script `OMOP CDM postgresql constraints.txt` to add the constraints (primary keys).
5. Execute the script `OMOP CDM indexes required - PostgreSQL.sql` to add the minimum set of indexes we recommend.
5. Execute the script `OMOP CDM postgresql indexes required.txt` to add the minimum set of indexes and foreign keys we recommend.
Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably.

View File

@ -1,46 +1,38 @@
Common Data Model v5.2
Common Data Model v5.3
=================
See full CDM specification file on our github [wiki](https://github.com/OHDSI/CommonDataModel/wiki) or in the [CDM V5.2 PDF](https://github.com/OHDSI/CommonDataModel/blob/master/OMOP_CDM_v5_2.pdf)
See full CDM specification file on our github [wiki](https://github.com/OHDSI/CommonDataModel/wiki) or in the [CDM V5.3 PDF](https://github.com/OHDSI/CommonDataModel/blob/master/OMOP_CDM_v5_3.pdf)
Release Notes for v5.2.0
Release Notes for v5.3
=============
This version is based on the CDM working group proposals:
* [#71](https://github.com/OHDSI/CommonDataModel/issues/71) Adds the field VERBATIM_END_DATE to DRUG_EXPOSURE and makes DRUG_EXPOSURE_END_DATE a required field
* [#73](https://github.com/OHDSI/CommonDataModel/issues/73) Removes EFFECTIVE_DRUG_DOSE and DOSE_UNIT_CONCEPT_ID from DRUG_EXPOSURE
* [#75](https://github.com/OHDSI/CommonDataModel/issues/75) Adds the field BOX_SIZE to DRUG_STRENGTH
* [#83](https://github.com/OHDSI/CommonDataModel/issues/83) Adds the following fields to VISIT_OCCURRENCE:
* ADMITTING_SOURCE_CONCEPT_ID
* ADMITTING_SOURCE_VALUE
* DISCHARGE_TO_CONCEPT_ID
* DISCHARGE_TO_SOURCE_VALUE
* PRECEDING_VISIT_OCCURRENCE_ID
* [#84](https://github.com/OHDSI/CommonDataModel/issues/84) Adds the following fields to CONDITION_OCCURRENCE:
* CONDITION_STATUS_CONCEPT_ID
* CONDITION_STATUS_SOURCE_VALUE
* [#69](https://github.com/OHDSI/CommonDataModel/issues/69) Adds the following fields to COST:
* DRG_CONCEPT_ID
* DRG_SOURCE_VALUE
* [#85](https://github.com/OHDSI/CommonDataModel/issues/85) Adds the NOTE_NLP table and the following fields to NOTE:
* NOTE_CLASS_CONCEPT_ID
* NOTE_TITLE
* ENCODING_CONCEPT_ID
* LANGUAGE_CONCEPT_ID
This version is based on the pull requests and CDM proposals:
* [#64](https://github.com/OHDSI/CommonDataModel/pull/64) This removes the datetime fields from OBSERVATION_PERIOD
* [#70](https://github.com/OHDSI/CommonDataModel/issues/70) Adds the VISIT_DETAIL table
* [#79](https://github.com/OHDSI/CommonDataModel/issues/79) Adds the METADATA table
* [#92](https://github.com/OHDSI/CommonDataModel/issues/92) Fixes qualifier typo in PROCEDURE_OCCURRENCE
* [#120](https://github.com/OHDSI/CommonDataModel/issues/120) Adds the following fields to PAYER_PLAN_PERIOD:
* PAYER_CONCEPT_ID
* PAYER_SOURCE_CONCEPT_ID
* PLAN_CONCEPT_ID
* PLAN_SOURCE_CONCEPT_ID
* SPONSOR_CONCEPT_ID
* SPONSOR_SOURCE_CONCEPT_ID
* STOP_REASON_CONCEPT_ID
* STOP_REASON_SOURCE_VALUE
* STOP_REASON_SOURCE_CONCEPT_ID
Additional Updates
==================
* Files to generate the '_ERA' tables are now available in the [CodeExcerpts](https://github.com/OHDSI/CommonDataModel/tree/master/CodeExcerpts) folder
* Redshift DDLs are now available
This version is **backwards compatibile with v5.0.1**.
* There is a [development branch](https://github.com/OHDSI/CommonDataModel/tree/Dev) now available with the DDLs and documentation for tables and/or changes that have been accepted into a future version of the CDM. Please use these with caution as they are subject to change upon formal release
* BigQuery, Netezza, and Parallel Data Warehouse DDLs are now available
---------
This repo contains the definition of the OMOP Common Data Model. It supports the 5 SQL technologies: Impala, Oracle, Postgres, Redshift, and SQL Server. For each, the DDL, constraints and indexes (if appropriate) are defined.
This repo contains the definition of the OMOP Common Data Model. It supports the SQL technologies: BigQuery, Impala, Netezza, Oracle, Parallel Data Warehouse, Postgres, Redshift, and SQL Server. For each, the DDL, constraints and indexes (if appropriate) are defined.
Versions are defined using tagging and versioning. Full versions (V6, 7 etc.) are released each year (1-Jan) and are not backwards compatible. Minor versions (V5.1, 5.2 etc.) are released each quarter (1-Apr, 1-Jul and 1-Sep) and are not guaranteed to be backwards compatible though an effort is made to make sure that current queries will not break. Micro versions (V5.1.1, V5.1.2 etc.) are released irregularly and often, and contain small hot fixes or backward compatible changes to the last minor version.
Versions are defined using tagging and versioning. Full versions (V6, 7 etc.) are usually released each year (1-Jan) and are not backwards compatible. Minor versions (V5.1, 5.2 etc.) are not guaranteed to be backwards compatible though an effort is made to make sure that current queries will not break. Micro versions (V5.1.1, V5.1.2 etc.) are released irregularly and often, and contain small hot fixes or backward compatible changes to the last minor version.

View File

@ -1,798 +0,0 @@
/*********************************************************************************
# Copyright 2017 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### #
####### # # ####### # ##### ###### # # ## ##### ### #######
script to create OMOP common data model, version 5.2.0 for Amazon Redshift database
last revised: 20-July-2017
Authors: Patrick Ryan, Christian Reich
Editors: Komathi Sunilkumar, Ajit Londhe
*************************/
/************************
Standardized vocabulary
************************/
create table concept
(
concept_id integer not null,
concept_name varchar(255) null,
domain_id varchar(20) not null,
vocabulary_id varchar(20) not null,
concept_class_id varchar(20) not null,
standard_concept char(1) null,
concept_code varchar(50) null,
valid_start_date date not null,
valid_end_date date not null,
invalid_reason char(1) null
)
diststyle all;
create table vocabulary
(
vocabulary_id varchar(20) not null,
vocabulary_name varchar(255) not null,
vocabulary_reference varchar(255) null,
vocabulary_version varchar(255) null,
vocabulary_concept_id integer not null
)
diststyle all;
create table domain
(
domain_id varchar(20) not null,
domain_name varchar(255) not null,
domain_concept_id integer not null
)
diststyle all;
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;
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 char(1) null
)
diststyle all;
create table relationship
(
relationship_id varchar(20) not null,
relationship_name varchar(255) not null,
is_hierarchical char(1) not null,
defines_ancestry char(1) not null,
reverse_relationship_id varchar(20) not null,
relationship_concept_id integer not null
)
diststyle all;
create table concept_synonym
(
concept_id integer not null,
concept_synonym_name varchar(1000) not null,
language_concept_id integer not null
)
diststyle all;
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;
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 char(1) null
)
diststyle all;
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 char(1) null
)
diststyle all;
create table cohort_definition
(
cohort_definition_id integer not null,
cohort_definition_name varchar(255) not null,
cohort_definition_description varchar(8000) null,
definition_type_concept_id integer not null,
cohort_definition_syntax varchar(8000) null,
subject_concept_id integer not null,
cohort_initiation_date date null
)
diststyle all;
create table attribute_definition
(
attribute_definition_id integer not null,
attribute_name varchar(255) not null,
attribute_description varchar(8000) null,
attribute_type_concept_id integer not null,
attribute_syntax varchar(8000) null
)
diststyle all;
/**************************
standardized meta-data
***************************/
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(8000) null,
source_documentation_reference varchar(255) null,
cdm_etl_reference varchar(255) null,
source_release_date date null,
cdm_release_date date null,
cdm_version varchar(10) null,
vocabulary_version varchar(20) null
)
diststyle all;
/************************
standardized clinical data
************************/
create table person
(
person_id integer not null ,
gender_concept_id integer not null ,
year_of_birth integer not null ,
month_of_birth integer null,
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)
sortkey(person_id);
create table observation_period
(
observation_period_id integer not null ,
person_id integer not null ,
observation_period_start_date date not null ,
observation_period_start_datetime timestamp not null ,
observation_period_end_date date not null ,
observation_period_end_datetime timestamp not null ,
period_type_concept_id integer not null
)
distkey(person_id)
interleaved sortkey(person_id, observation_period_start_date, observation_period_end_date);
create table specimen
(
specimen_id integer not null ,
person_id integer not null ,
specimen_concept_id integer not null ,
specimen_type_concept_id integer not null ,
specimen_date date not null ,
specimen_datetime timestamp null ,
quantity float null ,
unit_concept_id integer null ,
anatomic_site_concept_id integer null ,
disease_status_concept_id integer null ,
specimen_source_id varchar(50) null ,
specimen_source_value varchar(50) null ,
unit_source_value varchar(50) null ,
anatomic_site_source_value varchar(50) null ,
disease_status_source_value varchar(50) null
)
distkey(person_id)
sortkey(person_id);
create table death
(
person_id integer not null ,
death_date date not null ,
death_datetime timestamp null ,
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)
sortkey(person_id);
create table visit_occurrence
(
visit_occurrence_id integer not null ,
person_id integer not null ,
visit_concept_id integer not null ,
visit_start_date date not null ,
visit_start_datetime timestamp null ,
visit_end_date date not null ,
visit_end_datetime timestamp null ,
visit_type_concept_id integer not null ,
provider_id integer null,
care_site_id integer null,
visit_source_value varchar(50) null,
visit_source_concept_id integer null,
admitting_source_concept_id integer null,
admitting_source_value varchar(50) null,
discharge_to_concept_id integer null,
discharge_to_source_value varchar(50) null,
preceding_visit_occurrence_id integer null
)
distkey(payer_plan_period_id)
sortkey(payer_plan_period_id);
create table procedure_occurrence
(
procedure_occurrence_id integer not null ,
person_id integer not null ,
procedure_concept_id integer not null ,
procedure_date date not null ,
procedure_datetime timestamp not null ,
procedure_type_concept_id integer not null ,
modifier_concept_id integer null ,
quantity integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
procedure_source_value varchar(50) null ,
procedure_source_concept_id integer null ,
qualifier_source_value varchar(50) null
)
distkey(person_id)
interleaved sortkey(person_id, procedure_date);
create table drug_exposure
(
drug_exposure_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
drug_exposure_start_date date not null ,
drug_exposure_start_datetime timestamp not null ,
drug_exposure_end_date date null ,
drug_exposure_end_datetime timestamp null ,
verbatim_end_date date null,
drug_type_concept_id integer not null ,
stop_reason varchar(20) null ,
refills integer null ,
quantity float null ,
days_supply integer null ,
sig varchar(8000) null ,
route_concept_id integer null ,
lot_number varchar(50) null ,
provider_id integer null ,
visit_occurrence_id integer null ,
drug_source_value varchar(50) null ,
drug_source_concept_id integer null ,
route_source_value varchar(50) null ,
dose_unit_source_value varchar(50) null
)
distkey(person_id)
INTERLEAVED SORTKEY(person_id, drug_concept_id, drug_exposure_start_date, drug_exposure_end_date);
create table device_exposure
(
device_exposure_id integer not null ,
person_id integer not null ,
device_concept_id integer not null ,
device_exposure_start_date date not null ,
device_exposure_start_datetime timestamp not null ,
device_exposure_end_date date null ,
device_exposure_end_datetime timestamp null ,
device_type_concept_id integer not null ,
unique_device_id varchar(50) null ,
quantity integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
device_source_value varchar(100) null ,
device_source_concept_id integer null
)
distkey(person_id)
interleaved sortkey(person_id, device_concept_id, device_exposure_start_date, device_exposure_end_date);
create table condition_occurrence
(
condition_occurrence_id integer not null ,
person_id integer not null ,
condition_concept_id integer not null ,
condition_start_date date not null ,
condition_start_datetime timestamp not null ,
condition_end_date date null ,
condition_end_datetime timestamp null ,
condition_type_concept_id integer not null ,
stop_reason varchar(20) null ,
provider_id integer null ,
visit_occurrence_id integer null ,
condition_source_value varchar(50) null ,
condition_source_concept_id integer null ,
condition_status_source_value varchar(50) null ,
condition_status_concept_id integer null
)
distkey(person_id)
interleaved sortkey(person_id, condition_concept_id, condition_start_date, condition_end_date);
create table measurement
(
measurement_id integer not null ,
person_id integer not null ,
measurement_concept_id integer not null ,
measurement_date date not null ,
measurement_datetime timestamp null ,
measurement_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 ,
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)
interleaved sortkey(person_id, measurement_concept_id, measurement_date);
create table note
(
note_id integer not null ,
person_id integer not null ,
note_date date not null ,
note_datetime timestamp null ,
note_type_concept_id integer not null ,
note_text varchar(max) not null ,
provider_id integer null ,
visit_occurrence_id integer null ,
note_source_value varchar(50) null
)
distkey(person_id)
sortkey(person_id);
/*This table is new in CDM v5.2*/
CREATE TABLE note_nlp
(
note_nlp_id bigint not null ,
note_id integer not null ,
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 ,
note_nlp_source_concept_id integer null ,
nlp_system varchar(250) null ,
nlp_date date not null ,
nlp_datetime timestamp null ,
term_exists char(1) null ,
term_temporal varchar(50) null ,
term_modifiers varchar(2000) null
)
distkey(note_id)
sortkey(note_id);
create table observation
(
observation_id integer not null ,
person_id integer not null ,
observation_concept_id integer not null ,
observation_date date not null ,
observation_datetime timestamp null ,
observation_type_concept_id integer not null ,
value_as_number float null ,
value_as_string varchar(60) null ,
value_as_concept_id integer null ,
qualifier_concept_id integer null ,
unit_concept_id integer null ,
provider_id integer null ,
visit_occurrence_id integer null ,
observation_source_value varchar(50) null ,
observation_source_concept_id integer null ,
unit_source_value varchar(50) null ,
qualifier_source_value varchar(50) null
)
distkey(person_id)
interleaved sortkey(person_id, observation_concept_id, observation_date);
create table fact_relationship
(
domain_concept_id_1 integer not null ,
fact_id_1 integer not null ,
domain_concept_id_2 integer not null ,
fact_id_2 integer not null ,
relationship_concept_id integer not null
)
diststyle all;
/************************
standardized health system data
************************/
create table location
(
location_id integer not null ,
address_1 varchar(50) null ,
address_2 varchar(50) null ,
city varchar(50) null ,
state char(2) null ,
zip varchar(9) null ,
county varchar(20) null ,
location_source_value varchar(50) null
)
diststyle all;
create table care_site
(
care_site_id integer not null ,
care_site_name varchar(255) null ,
place_of_service_concept_id integer null ,
location_id integer null ,
care_site_source_value varchar(50) null ,
place_of_service_source_value varchar(50) null
)
diststyle all;
create table provider
(
provider_id integer not null ,
provider_name varchar(255) null ,
npi varchar(20) null ,
dea varchar(20) null ,
specialty_concept_id integer null ,
care_site_id integer null ,
year_of_birth integer null ,
gender_concept_id integer null ,
provider_source_value varchar(50) null ,
specialty_source_value varchar(50) null ,
specialty_source_concept_id integer null ,
gender_source_value varchar(50) null ,
gender_source_concept_id integer null
)
distkey(provider_id);
/************************
standardized health economics
************************/
create table payer_plan_period
(
payer_plan_period_id integer not null ,
person_id integer not null ,
payer_plan_period_start_date date not null ,
payer_plan_period_end_date date not null ,
payer_source_value varchar (50) null ,
plan_source_value varchar (50) null ,
family_source_value varchar (50) null
)
distkey(person_id)
interleaved sortkey(person_id, payer_plan_period_start_date, payer_plan_period_end_date);
/* the individual cost tables are being phased out and will disappear
create table visit_cost
(
visit_cost_id integer not null ,
visit_occurrence_id integer not null ,
currency_concept_id integer null ,
paid_copay float null ,
paid_coinsurance float null ,
paid_toward_deductible float null ,
paid_by_payer float null ,
paid_by_coordination_benefits float null ,
total_out_of_pocket float null ,
total_paid float null ,
payer_plan_period_id integer null
)
distkey(payer_plan_period_id)
sortkey(payer_plan_period_id);
create table procedure_cost
(
procedure_cost_id integer not null ,
procedure_occurrence_id integer not null ,
currency_concept_id integer null ,
paid_copay float null ,
paid_coinsurance float null ,
paid_toward_deductible float null ,
paid_by_payer float null ,
paid_by_coordination_benefits float null ,
total_out_of_pocket float null ,
total_paid float null ,
revenue_code_concept_id integer null ,
payer_plan_period_id integer null ,
revenue_code_source_value varchar(50) null
)
distkey(procedure_occurrence_id)
sortkey(procedure_occurrence_id);
create table drug_cost
(
drug_cost_id integer not null ,
drug_exposure_id integer not null ,
currency_concept_id integer null ,
paid_copay float null ,
paid_coinsurance float null ,
paid_toward_deductible float null ,
paid_by_payer float null ,
paid_by_coordination_benefits float null ,
total_out_of_pocket float null ,
total_paid float null ,
ingredient_cost float null ,
dispensing_fee float null ,
average_wholesale_price float null ,
payer_plan_period_id integer null
)
distkey(payer_plan_period_id)
sortkey(payer_plan_period_id);
create table device_cost
(
device_cost_id integer not null ,
device_exposure_id integer not null ,
currency_concept_id integer null ,
paid_copay float null ,
paid_coinsurance float null ,
paid_toward_deductible float null ,
paid_by_payer float null ,
paid_by_coordination_benefits float null ,
total_out_of_pocket float null ,
total_paid float null ,
payer_plan_period_id integer null
)
distkey(payer_plan_period_id)
sortkey(payer_plan_period_id);
*/
create table cost
(
cost_id integer not null ,
cost_event_id integer not null ,
cost_domain_id varchar(20) not null ,
cost_type_concept_id integer not null ,
currency_concept_id integer null ,
total_charge float null ,
total_cost float null ,
total_paid float null ,
paid_by_payer float null ,
paid_by_patient float null ,
paid_patient_copay float null ,
paid_patient_coinsurance float null ,
paid_patient_deductible float null ,
paid_by_primary float null ,
paid_ingredient_cost float null ,
paid_dispensing_fee float null ,
payer_plan_period_id integer null ,
amount_allowed float null ,
revenue_code_concept_id integer null ,
reveue_code_source_value varchar(50) null ,
drg_concept_id integer null,
drg_source_value char(3) null
)
distkey(payer_plan_period_id)
sortkey(payer_plan_period_id);
/************************
standardized derived elements
************************/
create table cohort
(
cohort_definition_id integer not null ,
subject_id integer not null ,
cohort_start_date date not null ,
cohort_end_date date not null
)
distkey(subject_id)
sortkey(subject_id);
create table cohort_attribute
(
cohort_definition_id integer not null ,
cohort_start_date date not null ,
cohort_end_date date not null ,
subject_id integer not null ,
attribute_definition_id integer not null ,
value_as_number float null ,
value_as_concept_id integer null
)
distkey(subject_id)
sortkey(subject_id);
create table drug_era
(
drug_era_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
drug_era_start_date date not null ,
drug_era_end_date date not null ,
drug_exposure_count integer null ,
gap_days integer null
)
distkey(person_id)
interleaved sortkey(person_id, drug_concept_id, drug_era_start_date, drug_era_end_date);
create table dose_era
(
dose_era_id integer not null ,
person_id integer not null ,
drug_concept_id integer not null ,
unit_concept_id integer not null ,
dose_value float not null ,
dose_era_start_date date not null ,
dose_era_end_date date not null
)
distkey(person_id)
sortkey(person_id);
create table condition_era
(
condition_era_id integer not null ,
person_id integer not null ,
condition_concept_id integer not null ,
condition_era_start_date date not null ,
condition_era_end_date date not null ,
condition_occurrence_count integer null
)
distkey(person_id)
interleaved sortkey(person_id, condition_concept_id, condition_era_start_date, condition_era_end_date);

View File

@ -0,0 +1,691 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
redshift script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
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;
CREATE TABLE vocabulary (vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
CREATE TABLE domain (domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
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;
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;
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;
CREATE TABLE concept_synonym (concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
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;
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;
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;
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;
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
***************************/
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;
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;
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
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);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation_period
(observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE specimen
(specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime TIMESTAMP NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE death
(person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime TIMESTAMP NULL ,
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);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_detail
(visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime TIMESTAMP NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime TIMESTAMP NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE procedure_occurrence
(procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime TIMESTAMP NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_exposure
(drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime TIMESTAMP NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime TIMESTAMP NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig 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);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE device_exposure
(device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime TIMESTAMP NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime TIMESTAMP NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_occurrence
(condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime TIMESTAMP NULL ,
condition_end_date DATE NULL ,
condition_end_datetime TIMESTAMP NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE measurement
(measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_time VARCHAR(10) NULL ,
measurement_datetime TIMESTAMP NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE note
(note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime TIMESTAMP NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text 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);
CREATE TABLE note_nlp
(note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime TIMESTAMP NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
DISTSTYLE ALL;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime TIMESTAMP NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
DISTKEY(person_id);
CREATE TABLE fact_relationship
(domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
DISTSTYLE ALL;
/************************
Standardized health system data
************************/
CREATE TABLE location
(location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
DISTSTYLE ALL;
CREATE TABLE care_site
(care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
DISTSTYLE ALL;
CREATE TABLE provider
(provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
DISTSTYLE ALL;
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
DISTKEY(person_id);
CREATE TABLE cost
(cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
DISTSTYLE ALL;
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
DISTKEY(subject_id);
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
DISTKEY(subject_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
DISTKEY(person_id);
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
DISTKEY(person_id);

View File

@ -9,6 +9,6 @@ In order to create your instantiation of the Common Data Model, we recommend fol
2. Set the search_path to that schema.
3. Execute the script `OMOP CDM ddl - Redshift.sql` to create the tables and fields.
3. Execute the script `OMOP CDM redshift ddl.txt` to create the tables and fields.
4. Load your data into the schema using COPY commands from Amazon S3.

View File

@ -1,701 +0,0 @@
/*********************************************************************************
# Copyright 2014-6 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### #
####### # # ####### # ##### ###### # # ## ##### ### #######
script to create OMOP common data model, version 5.2 for SQL Server database
last revised: 14-July-2017
Authors: Patrick Ryan, Christian Reich
*************************/
/************************
Standardized vocabulary
************************/
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 CHAR(1) NULL,
concept_code VARCHAR(50) NOT NULL,
valid_start_date DATE NOT NULL,
valid_end_date DATE NOT NULL,
invalid_reason CHAR(1) NULL
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NULL,
vocabulary_version VARCHAR(255) NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL)
;
CREATE TABLE relationship (
relationship_id VARCHAR(20) NOT NULL,
relationship_name VARCHAR(255) NOT NULL,
is_hierarchical CHAR(1) NOT NULL,
defines_ancestry CHAR(1) NOT NULL,
reverse_relationship_id VARCHAR(20) NOT NULL,
relationship_concept_id INTEGER NOT NULL
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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 CHAR(1) NULL
)
;
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 CHAR(1) NULL
)
;
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
)
;
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
)
;
/**************************
Standardized meta-data
***************************/
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
)
;
/************************
Standardized clinical data
************************/
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime DATETIME2 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
)
;
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_start_datetime DATETIME2 NOT NULL ,
observation_period_end_date DATE NOT NULL ,
observation_period_end_datetime DATETIME2 NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime DATETIME2 NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime DATETIME2 NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME2 NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME2 NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime DATETIME2 NOT NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime DATETIME2 NOT NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime DATETIME2 NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
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 ,
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
)
;
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime DATETIME2 NOT NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime DATETIME2 NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime DATETIME2 NOT NULL ,
condition_end_date DATE NULL ,
condition_end_datetime DATETIME2 NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_datetime DATETIME2 NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime DATETIME2 NULL ,
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 ,
note_source_value VARCHAR(50) NULL
)
;
/*This table is new in CDM v5.2*/
CREATE TABLE note_nlp
(
note_nlp_id BIGINT NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime DATETIME2 NULL ,
term_exists CHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime DATETIME2 NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state CHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_source_value VARCHAR (50) NULL ,
plan_source_value VARCHAR (50) NULL ,
family_source_value VARCHAR (50) NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
revenue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value CHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
subject_id INTEGER NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
;
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -0,0 +1,417 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### #####
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
sql server script to create foreign key constraints within OMOP common data model, version 5.3.0
last revised: 15-November-2017
author: Patrick Ryan, Clair Blacketer
*************************/
/************************
*************************
*************************
*************************
Foreign key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT fpk_concept_domain FOREIGN KEY (domain_id) REFERENCES domain (domain_id);
ALTER TABLE concept ADD CONSTRAINT fpk_concept_class FOREIGN KEY (concept_class_id) REFERENCES concept_class (concept_class_id);
ALTER TABLE concept ADD CONSTRAINT fpk_concept_vocabulary FOREIGN KEY (vocabulary_id) REFERENCES vocabulary (vocabulary_id);
ALTER TABLE vocabulary ADD CONSTRAINT fpk_vocabulary_concept FOREIGN KEY (vocabulary_concept_id) REFERENCES concept (concept_id);
ALTER TABLE domain ADD CONSTRAINT fpk_domain_concept FOREIGN KEY (domain_concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_class ADD CONSTRAINT fpk_concept_class_concept FOREIGN KEY (concept_class_concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_1 FOREIGN KEY (concept_id_1) REFERENCES concept (concept_id);
ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_c_2 FOREIGN KEY (concept_id_2) REFERENCES concept (concept_id);
ALTER TABLE concept_relationship ADD CONSTRAINT fpk_concept_relationship_id FOREIGN KEY (relationship_id) REFERENCES relationship (relationship_id);
ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_concept FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id);
ALTER TABLE relationship ADD CONSTRAINT fpk_relationship_reverse FOREIGN KEY (reverse_relationship_id) REFERENCES relationship (relationship_id);
ALTER TABLE concept_synonym ADD CONSTRAINT fpk_concept_synonym_concept FOREIGN KEY (concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_1 FOREIGN KEY (ancestor_concept_id) REFERENCES concept (concept_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT fpk_concept_ancestor_concept_2 FOREIGN KEY (descendant_concept_id) REFERENCES concept (concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_1 FOREIGN KEY (source_vocabulary_id) REFERENCES vocabulary (vocabulary_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_v_2 FOREIGN KEY (target_vocabulary_id) REFERENCES vocabulary (vocabulary_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT fpk_source_to_concept_map_c_1 FOREIGN KEY (target_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_1 FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_concept_2 FOREIGN KEY (ingredient_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_1 FOREIGN KEY (amount_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_2 FOREIGN KEY (numerator_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_strength ADD CONSTRAINT fpk_drug_strength_unit_3 FOREIGN KEY (denominator_unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT fpk_cohort_definition_concept FOREIGN KEY (definition_type_concept_id) REFERENCES concept (concept_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept FOREIGN KEY (race_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept FOREIGN KEY (ethnicity_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_gender_concept_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_race_concept_s FOREIGN KEY (race_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_ethnicity_concept_s FOREIGN KEY (ethnicity_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_location FOREIGN KEY (location_id) REFERENCES location (location_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE person ADD CONSTRAINT fpk_person_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE observation_period ADD CONSTRAINT fpk_observation_period_concept FOREIGN KEY (period_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_concept FOREIGN KEY (specimen_concept_id) REFERENCES concept (concept_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_type_concept FOREIGN KEY (specimen_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_site_concept FOREIGN KEY (anatomic_site_concept_id) REFERENCES concept (concept_id);
ALTER TABLE specimen ADD CONSTRAINT fpk_specimen_status_concept FOREIGN KEY (disease_status_concept_id) REFERENCES concept (concept_id);
ALTER TABLE death ADD CONSTRAINT fpk_death_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE death ADD CONSTRAINT fpk_death_type_concept FOREIGN KEY (death_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept FOREIGN KEY (cause_concept_id) REFERENCES concept (concept_id);
ALTER TABLE death ADD CONSTRAINT fpk_death_cause_concept_s FOREIGN KEY (cause_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_occurrence ADD CONSTRAINT fpk_visit_preceding FOREIGN KEY (preceding_visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_type_concept FOREIGN KEY (visit_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_concept_s FOREIGN KEY (visit_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_admitting_s FOREIGN KEY (admitting_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_discharge FOREIGN KEY (discharge_to_concept_id) REFERENCES concept (concept_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_preceding FOREIGN KEY (preceding_visit_detail_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpk_v_detail_parent FOREIGN KEY (visit_detail_parent_id) REFERENCES visit_detail (visit_detail_id);
ALTER TABLE visit_detail ADD CONSTRAINT fpd_v_detail_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept FOREIGN KEY (procedure_concept_id) REFERENCES concept (concept_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_type_concept FOREIGN KEY (procedure_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_modifier FOREIGN KEY (modifier_concept_id) REFERENCES concept (concept_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE procedure_occurrence ADD CONSTRAINT fpk_procedure_concept_s FOREIGN KEY (procedure_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_type_concept FOREIGN KEY (drug_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_route_concept FOREIGN KEY (route_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE drug_exposure ADD CONSTRAINT fpk_drug_concept_s FOREIGN KEY (drug_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept FOREIGN KEY (device_concept_id) REFERENCES concept (concept_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_type_concept FOREIGN KEY (device_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE device_exposure ADD CONSTRAINT fpk_device_concept_s FOREIGN KEY (device_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_type_concept FOREIGN KEY (condition_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_concept_s FOREIGN KEY (condition_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE condition_occurrence ADD CONSTRAINT fpk_condition_status_concept FOREIGN KEY (condition_status_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept FOREIGN KEY (measurement_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_type_concept FOREIGN KEY (measurement_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_operator FOREIGN KEY (operator_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE measurement ADD CONSTRAINT fpk_measurement_concept_s FOREIGN KEY (measurement_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_type_concept FOREIGN KEY (note_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_class_concept FOREIGN KEY (note_class_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_encoding_concept FOREIGN KEY (encoding_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note ADD CONSTRAINT fpk_language_concept FOREIGN KEY (language_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE note ADD CONSTRAINT fpk_note_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_note FOREIGN KEY (note_id) REFERENCES note (note_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_section_concept FOREIGN KEY (section_concept_id) REFERENCES concept (concept_id);
ALTER TABLE note_nlp ADD CONSTRAINT fpk_note_nlp_concept FOREIGN KEY (note_nlp_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept FOREIGN KEY (observation_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_type_concept FOREIGN KEY (observation_type_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_qualifier FOREIGN KEY (qualifier_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_unit FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_provider FOREIGN KEY (provider_id) REFERENCES provider (provider_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_visit FOREIGN KEY (visit_occurrence_id) REFERENCES visit_occurrence (visit_occurrence_id);
ALTER TABLE observation ADD CONSTRAINT fpk_observation_concept_s FOREIGN KEY (observation_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_1 FOREIGN KEY (domain_concept_id_1) REFERENCES concept (concept_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_domain_2 FOREIGN KEY (domain_concept_id_2) REFERENCES concept (concept_id);
ALTER TABLE fact_relationship ADD CONSTRAINT fpk_fact_relationship FOREIGN KEY (relationship_concept_id) REFERENCES concept (concept_id);
/************************
Standardized health system data
************************/
ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_location FOREIGN KEY (location_id) REFERENCES location (location_id);
ALTER TABLE care_site ADD CONSTRAINT fpk_care_site_place FOREIGN KEY (place_of_service_concept_id) REFERENCES concept (concept_id);
ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty FOREIGN KEY (specialty_concept_id) REFERENCES concept (concept_id);
ALTER TABLE provider ADD CONSTRAINT fpk_provider_care_site FOREIGN KEY (care_site_id) REFERENCES care_site (care_site_id);
ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender FOREIGN KEY (gender_concept_id) REFERENCES concept (concept_id);
ALTER TABLE provider ADD CONSTRAINT fpk_provider_specialty_s FOREIGN KEY (specialty_source_concept_id) REFERENCES concept (concept_id);
ALTER TABLE provider ADD CONSTRAINT fpk_provider_gender_s FOREIGN KEY (gender_source_concept_id) REFERENCES concept (concept_id);
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT fpk_payer_plan_period FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE cost ADD CONSTRAINT fpk_visit_cost_currency FOREIGN KEY (currency_concept_id) REFERENCES concept (concept_id);
ALTER TABLE cost ADD CONSTRAINT fpk_visit_cost_period FOREIGN KEY (payer_plan_period_id) REFERENCES payer_plan_period (payer_plan_period_id);
ALTER TABLE cost ADD CONSTRAINT fpk_drg_concept FOREIGN KEY (drg_concept_id) REFERENCES concept (concept_id);
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT fpk_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_cohort_definition FOREIGN KEY (cohort_definition_id) REFERENCES cohort_definition (cohort_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_attribute_definition FOREIGN KEY (attribute_definition_id) REFERENCES attribute_definition (attribute_definition_id);
ALTER TABLE cohort_attribute ADD CONSTRAINT fpk_ca_value FOREIGN KEY (value_as_concept_id) REFERENCES concept (concept_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE drug_era ADD CONSTRAINT fpk_drug_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);
ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_concept FOREIGN KEY (drug_concept_id) REFERENCES concept (concept_id);
ALTER TABLE dose_era ADD CONSTRAINT fpk_dose_era_unit_concept FOREIGN KEY (unit_concept_id) REFERENCES concept (concept_id);
ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_person FOREIGN KEY (person_id) REFERENCES person (person_id);
ALTER TABLE condition_era ADD CONSTRAINT fpk_condition_era_concept FOREIGN KEY (condition_concept_id) REFERENCES concept (concept_id);
/************************
*************************
*************************
*************************
Unique constraints
*************************
*************************
*************************
************************/
ALTER TABLE concept_synonym ADD CONSTRAINT uq_concept_synonym UNIQUE (concept_id, concept_synonym_name, language_concept_id);

View File

@ -0,0 +1,730 @@
/*********************************************************************************
# Copyright 2017-11 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### #####
# # ## ## # # # # # # # # ## ## # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### #####
# # # # # # # # # # # # # # # ### #
# # # # # # # # # # # # # # # # # ### # #
####### # # ####### # ##### ###### # # ## ##### ### #####
sql server script to create OMOP common data model version 5.3
last revised: 6-Nov-2017
Authors: Patrick Ryan, Christian Reich, Clair Blacketer
*************************/
/************************
Standardized vocabulary
************************/
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
)
;
CREATE TABLE vocabulary (
vocabulary_id VARCHAR(20) NOT NULL,
vocabulary_name VARCHAR(255) NOT NULL,
vocabulary_reference VARCHAR(255) NOT NULL,
vocabulary_version VARCHAR(255) NOT NULL,
vocabulary_concept_id INTEGER NOT NULL
)
;
CREATE TABLE domain (
domain_id VARCHAR(20) NOT NULL,
domain_name VARCHAR(255) NOT NULL,
domain_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
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
)
;
CREATE TABLE concept_synonym (
concept_id INTEGER NOT NULL,
concept_synonym_name VARCHAR(1000) NOT NULL,
language_concept_id INTEGER NOT NULL
)
;
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
)
;
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
)
;
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
)
;
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
)
;
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
)
;
/**************************
Standardized meta-data
***************************/
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
)
;
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 DATETIME NULL
)
;
/************************
Standardized clinical data
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE person
(
person_id INTEGER NOT NULL ,
gender_concept_id INTEGER NOT NULL ,
year_of_birth INTEGER NOT NULL ,
month_of_birth INTEGER NULL,
day_of_birth INTEGER NULL,
birth_datetime DATETIME NULL,
race_concept_id INTEGER NOT NULL,
ethnicity_concept_id INTEGER NOT NULL,
location_id INTEGER NULL,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
person_source_value VARCHAR(50) NULL,
gender_source_value VARCHAR(50) NULL,
gender_source_concept_id INTEGER NULL,
race_source_value VARCHAR(50) NULL,
race_source_concept_id INTEGER NULL,
ethnicity_source_value VARCHAR(50) NULL,
ethnicity_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation_period
(
observation_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_period_start_date DATE NOT NULL ,
observation_period_end_date DATE NOT NULL ,
period_type_concept_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE specimen
(
specimen_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
specimen_concept_id INTEGER NOT NULL ,
specimen_type_concept_id INTEGER NOT NULL ,
specimen_date DATE NOT NULL ,
specimen_datetime DATETIME NULL ,
quantity FLOAT NULL ,
unit_concept_id INTEGER NULL ,
anatomic_site_concept_id INTEGER NULL ,
disease_status_concept_id INTEGER NULL ,
specimen_source_id VARCHAR(50) NULL ,
specimen_source_value VARCHAR(50) NULL ,
unit_source_value VARCHAR(50) NULL ,
anatomic_site_source_value VARCHAR(50) NULL ,
disease_status_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE death
(
person_id INTEGER NOT NULL ,
death_date DATE NOT NULL ,
death_datetime DATETIME NULL ,
death_type_concept_id INTEGER NOT NULL ,
cause_concept_id INTEGER NULL ,
cause_source_value VARCHAR(50) NULL,
cause_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_occurrence
(
visit_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL,
care_site_id INTEGER NULL,
visit_source_value VARCHAR(50) NULL,
visit_source_concept_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_concept_id INTEGER NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
preceding_visit_occurrence_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE visit_detail
(
visit_detail_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
visit_detail_concept_id INTEGER NOT NULL ,
visit_start_date DATE NOT NULL ,
visit_start_datetime DATETIME NULL ,
visit_end_date DATE NOT NULL ,
visit_end_datetime DATETIME NULL ,
visit_type_concept_id INTEGER NOT NULL ,
provider_id INTEGER NULL ,
care_site_id INTEGER NULL ,
admitting_source_concept_id INTEGER NULL ,
discharge_to_concept_id INTEGER NULL ,
preceding_visit_detail_id INTEGER NULL ,
visit_source_value VARCHAR(50) NULL ,
visit_source_concept_id INTEGER NULL ,
admitting_source_value VARCHAR(50) NULL ,
discharge_to_source_value VARCHAR(50) NULL ,
visit_detail_parent_id INTEGER NULL ,
visit_occurrence_id INTEGER NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE procedure_occurrence
(
procedure_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
procedure_concept_id INTEGER NOT NULL ,
procedure_date DATE NOT NULL ,
procedure_datetime DATETIME NULL ,
procedure_type_concept_id INTEGER NOT NULL ,
modifier_concept_id INTEGER NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
procedure_source_value VARCHAR(50) NULL ,
procedure_source_concept_id INTEGER NULL ,
modifier_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_exposure
(
drug_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_exposure_start_date DATE NOT NULL ,
drug_exposure_start_datetime DATETIME NULL ,
drug_exposure_end_date DATE NOT NULL ,
drug_exposure_end_datetime DATETIME NULL ,
verbatim_end_date DATE NULL ,
drug_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
refills INTEGER NULL ,
quantity FLOAT NULL ,
days_supply INTEGER NULL ,
sig VARCHAR(MAX) NULL ,
route_concept_id INTEGER NULL ,
lot_number VARCHAR(50) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
drug_source_value VARCHAR(50) NULL ,
drug_source_concept_id INTEGER NULL ,
route_source_value VARCHAR(50) NULL ,
dose_unit_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE device_exposure
(
device_exposure_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
device_concept_id INTEGER NOT NULL ,
device_exposure_start_date DATE NOT NULL ,
device_exposure_start_datetime DATETIME NULL ,
device_exposure_end_date DATE NULL ,
device_exposure_end_datetime DATETIME NULL ,
device_type_concept_id INTEGER NOT NULL ,
unique_device_id VARCHAR(50) NULL ,
quantity INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
device_source_value VARCHAR(100) NULL ,
device_source_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_occurrence
(
condition_occurrence_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_start_date DATE NOT NULL ,
condition_start_datetime DATETIME NULL ,
condition_end_date DATE NULL ,
condition_end_datetime DATETIME NULL ,
condition_type_concept_id INTEGER NOT NULL ,
stop_reason VARCHAR(20) NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
condition_source_value VARCHAR(50) NULL ,
condition_source_concept_id INTEGER NULL ,
condition_status_source_value VARCHAR(50) NULL ,
condition_status_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE measurement
(
measurement_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
measurement_concept_id INTEGER NOT NULL ,
measurement_date DATE NOT NULL ,
measurement_time VARCHAR(10) NULL ,
measurement_datetime DATETIME NULL ,
measurement_type_concept_id INTEGER NOT NULL ,
operator_concept_id INTEGER NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
range_low FLOAT NULL ,
range_high FLOAT NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
measurement_source_value VARCHAR(50) NULL ,
measurement_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
value_source_value VARCHAR(50) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE note
(
note_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
note_date DATE NOT NULL ,
note_datetime DATETIME NULL ,
note_type_concept_id INTEGER NOT NULL ,
note_class_concept_id INTEGER NOT NULL ,
note_title VARCHAR(250) NULL ,
note_text VARCHAR(MAX) 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
)
;
CREATE TABLE note_nlp
(
note_nlp_id INTEGER NOT NULL ,
note_id INTEGER NOT NULL ,
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 ,
note_nlp_source_concept_id INTEGER NULL ,
nlp_system VARCHAR(250) NULL ,
nlp_date DATE NOT NULL ,
nlp_datetime DATETIME NULL ,
term_exists VARCHAR(1) NULL ,
term_temporal VARCHAR(50) NULL ,
term_modifiers VARCHAR(2000) NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE observation
(
observation_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
observation_concept_id INTEGER NOT NULL ,
observation_date DATE NOT NULL ,
observation_datetime DATETIME NULL ,
observation_type_concept_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_string VARCHAR(60) NULL ,
value_as_concept_id INTEGER NULL ,
qualifier_concept_id INTEGER NULL ,
unit_concept_id INTEGER NULL ,
provider_id INTEGER NULL ,
visit_occurrence_id INTEGER NULL ,
visit_detail_id INTEGER NULL ,
observation_source_value VARCHAR(50) NULL ,
observation_source_concept_id INTEGER NULL ,
unit_source_value VARCHAR(50) NULL ,
qualifier_source_value VARCHAR(50) NULL
)
;
CREATE TABLE fact_relationship
(
domain_concept_id_1 INTEGER NOT NULL ,
fact_id_1 INTEGER NOT NULL ,
domain_concept_id_2 INTEGER NOT NULL ,
fact_id_2 INTEGER NOT NULL ,
relationship_concept_id INTEGER NOT NULL
)
;
/************************
Standardized health system data
************************/
CREATE TABLE location
(
location_id INTEGER NOT NULL ,
address_1 VARCHAR(50) NULL ,
address_2 VARCHAR(50) NULL ,
city VARCHAR(50) NULL ,
state VARCHAR(2) NULL ,
zip VARCHAR(9) NULL ,
county VARCHAR(20) NULL ,
location_source_value VARCHAR(50) NULL
)
;
CREATE TABLE care_site
(
care_site_id INTEGER NOT NULL ,
care_site_name VARCHAR(255) NULL ,
place_of_service_concept_id INTEGER NULL ,
location_id INTEGER NULL ,
care_site_source_value VARCHAR(50) NULL ,
place_of_service_source_value VARCHAR(50) NULL
)
;
CREATE TABLE provider
(
provider_id INTEGER NOT NULL ,
provider_name VARCHAR(255) NULL ,
NPI VARCHAR(20) NULL ,
DEA VARCHAR(20) NULL ,
specialty_concept_id INTEGER NULL ,
care_site_id INTEGER NULL ,
year_of_birth INTEGER NULL ,
gender_concept_id INTEGER NULL ,
provider_source_value VARCHAR(50) NULL ,
specialty_source_value VARCHAR(50) NULL ,
specialty_source_concept_id INTEGER NULL ,
gender_source_value VARCHAR(50) NULL ,
gender_source_concept_id INTEGER NULL
)
;
/************************
Standardized health economics
************************/
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE payer_plan_period
(
payer_plan_period_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
payer_plan_period_start_date DATE NOT NULL ,
payer_plan_period_end_date DATE NOT NULL ,
payer_concept_id INTEGER NULL ,
payer_source_value VARCHAR(50) NULL ,
payer_source_concept_id INTEGER NULL ,
plan_concept_id INTEGER NULL ,
plan_source_value VARCHAR(50) NULL ,
plan_source_concept_id INTEGER NULL ,
sponsor_concept_id INTEGER NULL ,
sponsor_source_value VARCHAR(50) NULL ,
sponsor_source_concept_id INTEGER NULL ,
family_source_value VARCHAR(50) NULL ,
stop_reason_concept_id INTEGER NULL ,
stop_reason_source_value INTEGER NULL ,
stop_reason_source_concept_id INTEGER NULL
)
;
CREATE TABLE cost
(
cost_id INTEGER NOT NULL ,
cost_event_id INTEGER NOT NULL ,
cost_domain_id VARCHAR(20) NOT NULL ,
cost_type_concept_id INTEGER NOT NULL ,
currency_concept_id INTEGER NULL ,
total_charge FLOAT NULL ,
total_cost FLOAT NULL ,
total_paid FLOAT NULL ,
paid_by_payer FLOAT NULL ,
paid_by_patient FLOAT NULL ,
paid_patient_copay FLOAT NULL ,
paid_patient_coinsurance FLOAT NULL ,
paid_patient_deductible FLOAT NULL ,
paid_by_primary FLOAT NULL ,
paid_ingredient_cost FLOAT NULL ,
paid_dispensing_fee FLOAT NULL ,
payer_plan_period_id INTEGER NULL ,
amount_allowed FLOAT NULL ,
revenue_code_concept_id INTEGER NULL ,
reveue_code_source_value VARCHAR(50) NULL,
drg_concept_id INTEGER NULL,
drg_source_value VARCHAR(3) NULL
)
;
/************************
Standardized derived elements
************************/
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(subject_id)
CREATE TABLE cohort_attribute
(
cohort_definition_id INTEGER NOT NULL ,
subject_id INTEGER NOT NULL ,
cohort_start_date DATE NOT NULL ,
cohort_end_date DATE NOT NULL ,
attribute_definition_id INTEGER NOT NULL ,
value_as_number FLOAT NULL ,
value_as_concept_id INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE drug_era
(
drug_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
drug_era_start_date DATE NOT NULL ,
drug_era_end_date DATE NOT NULL ,
drug_exposure_count INTEGER NULL ,
gap_days INTEGER NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE dose_era
(
dose_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
drug_concept_id INTEGER NOT NULL ,
unit_concept_id INTEGER NOT NULL ,
dose_value FLOAT NOT NULL ,
dose_era_start_date DATE NOT NULL ,
dose_era_end_date DATE NOT NULL
)
;
--HINT DISTRIBUTE_ON_KEY(person_id)
CREATE TABLE condition_era
(
condition_era_id INTEGER NOT NULL ,
person_id INTEGER NOT NULL ,
condition_concept_id INTEGER NOT NULL ,
condition_era_start_date DATE NOT NULL ,
condition_era_end_date DATE NOT NULL ,
condition_occurrence_count INTEGER NULL
)
;

View File

@ -0,0 +1,342 @@
/*********************************************************************************
# Copyright 2014 Observational Health Data Sciences and Informatics
#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# 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.
********************************************************************************/
/************************
####### # # ####### ###### ##### ###### # # ####### ##### ###
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
sql server script to create the required indexes within OMOP common data model, version 5.3
last revised: 14-November-2017
author: Patrick Ryan, Clair Blacketer
description: These primary keys and indices are considered a minimal requirement to ensure adequate performance of analyses.
*************************/
/************************
*************************
*************************
*************************
Primary key constraints
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
ALTER TABLE concept ADD CONSTRAINT xpk_concept PRIMARY KEY NONCLUSTERED (concept_id);
ALTER TABLE vocabulary ADD CONSTRAINT xpk_vocabulary PRIMARY KEY NONCLUSTERED (vocabulary_id);
ALTER TABLE domain ADD CONSTRAINT xpk_domain PRIMARY KEY NONCLUSTERED (domain_id);
ALTER TABLE concept_class ADD CONSTRAINT xpk_concept_class PRIMARY KEY NONCLUSTERED (concept_class_id);
ALTER TABLE concept_relationship ADD CONSTRAINT xpk_concept_relationship PRIMARY KEY NONCLUSTERED (concept_id_1,concept_id_2,relationship_id);
ALTER TABLE relationship ADD CONSTRAINT xpk_relationship PRIMARY KEY NONCLUSTERED (relationship_id);
ALTER TABLE concept_ancestor ADD CONSTRAINT xpk_concept_ancestor PRIMARY KEY NONCLUSTERED (ancestor_concept_id,descendant_concept_id);
ALTER TABLE source_to_concept_map ADD CONSTRAINT xpk_source_to_concept_map PRIMARY KEY NONCLUSTERED (source_vocabulary_id,target_concept_id,source_code,valid_end_date);
ALTER TABLE drug_strength ADD CONSTRAINT xpk_drug_strength PRIMARY KEY NONCLUSTERED (drug_concept_id, ingredient_concept_id);
ALTER TABLE cohort_definition ADD CONSTRAINT xpk_cohort_definition PRIMARY KEY NONCLUSTERED (cohort_definition_id);
ALTER TABLE attribute_definition ADD CONSTRAINT xpk_attribute_definition PRIMARY KEY NONCLUSTERED (attribute_definition_id);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
/**PRIMARY KEY NONCLUSTERED constraints**/
ALTER TABLE person ADD CONSTRAINT xpk_person PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE observation_period ADD CONSTRAINT xpk_observation_period PRIMARY KEY NONCLUSTERED ( observation_period_id ) ;
ALTER TABLE specimen ADD CONSTRAINT xpk_specimen PRIMARY KEY NONCLUSTERED ( specimen_id ) ;
ALTER TABLE death ADD CONSTRAINT xpk_death PRIMARY KEY NONCLUSTERED ( person_id ) ;
ALTER TABLE visit_occurrence ADD CONSTRAINT xpk_visit_occurrence PRIMARY KEY NONCLUSTERED ( visit_occurrence_id ) ;
ALTER TABLE visit_detail ADD CONSTRAINT xpk_visit_detail PRIMARY KEY NONCLUSTERED ( visit_detail_id ) ;
ALTER TABLE procedure_occurrence ADD CONSTRAINT xpk_procedure_occurrence PRIMARY KEY NONCLUSTERED ( procedure_occurrence_id ) ;
ALTER TABLE drug_exposure ADD CONSTRAINT xpk_drug_exposure PRIMARY KEY NONCLUSTERED ( drug_exposure_id ) ;
ALTER TABLE device_exposure ADD CONSTRAINT xpk_device_exposure PRIMARY KEY NONCLUSTERED ( device_exposure_id ) ;
ALTER TABLE condition_occurrence ADD CONSTRAINT xpk_condition_occurrence PRIMARY KEY NONCLUSTERED ( condition_occurrence_id ) ;
ALTER TABLE measurement ADD CONSTRAINT xpk_measurement PRIMARY KEY NONCLUSTERED ( measurement_id ) ;
ALTER TABLE note ADD CONSTRAINT xpk_note PRIMARY KEY NONCLUSTERED ( note_id ) ;
ALTER TABLE note_nlp ADD CONSTRAINT xpk_note_nlp PRIMARY KEY NONCLUSTERED ( note_nlp_id ) ;
ALTER TABLE observation ADD CONSTRAINT xpk_observation PRIMARY KEY NONCLUSTERED ( observation_id ) ;
/************************
Standardized health system data
************************/
ALTER TABLE location ADD CONSTRAINT xpk_location PRIMARY KEY NONCLUSTERED ( location_id ) ;
ALTER TABLE care_site ADD CONSTRAINT xpk_care_site PRIMARY KEY NONCLUSTERED ( care_site_id ) ;
ALTER TABLE provider ADD CONSTRAINT xpk_provider PRIMARY KEY NONCLUSTERED ( provider_id ) ;
/************************
Standardized health economics
************************/
ALTER TABLE payer_plan_period ADD CONSTRAINT xpk_payer_plan_period PRIMARY KEY NONCLUSTERED ( payer_plan_period_id ) ;
ALTER TABLE cost ADD CONSTRAINT xpk_visit_cost PRIMARY KEY NONCLUSTERED ( cost_id ) ;
/************************
Standardized derived elements
************************/
ALTER TABLE cohort ADD CONSTRAINT xpk_cohort PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date ) ;
ALTER TABLE cohort_attribute ADD CONSTRAINT xpk_cohort_attribute PRIMARY KEY NONCLUSTERED ( cohort_definition_id, subject_id, cohort_start_date, cohort_end_date, attribute_definition_id ) ;
ALTER TABLE drug_era ADD CONSTRAINT xpk_drug_era PRIMARY KEY NONCLUSTERED ( drug_era_id ) ;
ALTER TABLE dose_era ADD CONSTRAINT xpk_dose_era PRIMARY KEY NONCLUSTERED ( dose_era_id ) ;
ALTER TABLE condition_era ADD CONSTRAINT xpk_condition_era PRIMARY KEY NONCLUSTERED ( condition_era_id ) ;
/************************
*************************
*************************
*************************
Indices
*************************
*************************
*************************
************************/
/************************
Standardized vocabulary
************************/
CREATE UNIQUE CLUSTERED INDEX idx_concept_concept_id ON concept (concept_id ASC);
CREATE INDEX idx_concept_code ON concept (concept_code ASC);
CREATE INDEX idx_concept_vocabluary_id ON concept (vocabulary_id ASC);
CREATE INDEX idx_concept_domain_id ON concept (domain_id ASC);
CREATE INDEX idx_concept_class_id ON concept (concept_class_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_vocabulary_vocabulary_id ON vocabulary (vocabulary_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_domain_domain_id ON domain (domain_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_concept_class_class_id ON concept_class (concept_class_id ASC);
CREATE INDEX idx_concept_relationship_id_1 ON concept_relationship (concept_id_1 ASC);
CREATE INDEX idx_concept_relationship_id_2 ON concept_relationship (concept_id_2 ASC);
CREATE INDEX idx_concept_relationship_id_3 ON concept_relationship (relationship_id ASC);
CREATE UNIQUE CLUSTERED INDEX idx_relationship_rel_id ON relationship (relationship_id ASC);
CREATE CLUSTERED INDEX idx_concept_synonym_id ON concept_synonym (concept_id ASC);
CREATE CLUSTERED INDEX idx_concept_ancestor_id_1 ON concept_ancestor (ancestor_concept_id ASC);
CREATE INDEX idx_concept_ancestor_id_2 ON concept_ancestor (descendant_concept_id ASC);
CREATE CLUSTERED INDEX idx_source_to_concept_map_id_3 ON source_to_concept_map (target_concept_id ASC);
CREATE INDEX idx_source_to_concept_map_id_1 ON source_to_concept_map (source_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_id_2 ON source_to_concept_map (target_vocabulary_id ASC);
CREATE INDEX idx_source_to_concept_map_code ON source_to_concept_map (source_code ASC);
CREATE CLUSTERED INDEX idx_drug_strength_id_1 ON drug_strength (drug_concept_id ASC);
CREATE INDEX idx_drug_strength_id_2 ON drug_strength (ingredient_concept_id ASC);
CREATE CLUSTERED INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC);
CREATE CLUSTERED INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC);
/**************************
Standardized meta-data
***************************/
/************************
Standardized clinical data
************************/
CREATE UNIQUE CLUSTERED INDEX idx_person_id ON person (person_id ASC);
CREATE CLUSTERED INDEX idx_observation_period_id ON observation_period (person_id ASC);
CREATE CLUSTERED INDEX idx_specimen_person_id ON specimen (person_id ASC);
CREATE INDEX idx_specimen_concept_id ON specimen (specimen_concept_id ASC);
CREATE CLUSTERED INDEX idx_death_person_id ON death (person_id ASC);
CREATE CLUSTERED INDEX idx_visit_person_id ON visit_occurrence (person_id ASC);
CREATE INDEX idx_visit_concept_id ON visit_occurrence (visit_concept_id ASC);
CREATE CLUSTERED INDEX idx_visit_detail_person_id ON visit_detail (person_id ASC);
CREATE INDEX idx_visit_detail_concept_id ON visit_detail (visit_detail_concept_id ASC);
CREATE CLUSTERED INDEX idx_procedure_person_id ON procedure_occurrence (person_id ASC);
CREATE INDEX idx_procedure_concept_id ON procedure_occurrence (procedure_concept_id ASC);
CREATE INDEX idx_procedure_visit_id ON procedure_occurrence (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_drug_person_id ON drug_exposure (person_id ASC);
CREATE INDEX idx_drug_concept_id ON drug_exposure (drug_concept_id ASC);
CREATE INDEX idx_drug_visit_id ON drug_exposure (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_device_person_id ON device_exposure (person_id ASC);
CREATE INDEX idx_device_concept_id ON device_exposure (device_concept_id ASC);
CREATE INDEX idx_device_visit_id ON device_exposure (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_condition_person_id ON condition_occurrence (person_id ASC);
CREATE INDEX idx_condition_concept_id ON condition_occurrence (condition_concept_id ASC);
CREATE INDEX idx_condition_visit_id ON condition_occurrence (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_measurement_person_id ON measurement (person_id ASC);
CREATE INDEX idx_measurement_concept_id ON measurement (measurement_concept_id ASC);
CREATE INDEX idx_measurement_visit_id ON measurement (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_note_person_id ON note (person_id ASC);
CREATE INDEX idx_note_concept_id ON note (note_type_concept_id ASC);
CREATE INDEX idx_note_visit_id ON note (visit_occurrence_id ASC);
CREATE CLUSTERED INDEX idx_note_nlp_note_id ON note_nlp (note_id ASC);
CREATE INDEX idx_note_nlp_concept_id ON note_nlp (note_nlp_concept_id ASC);
CREATE CLUSTERED INDEX idx_observation_person_id ON observation (person_id ASC);
CREATE INDEX idx_observation_concept_id ON observation (observation_concept_id ASC);
CREATE INDEX idx_observation_visit_id ON observation (visit_occurrence_id ASC);
CREATE INDEX idx_fact_relationship_id_1 ON fact_relationship (domain_concept_id_1 ASC);
CREATE INDEX idx_fact_relationship_id_2 ON fact_relationship (domain_concept_id_2 ASC);
CREATE INDEX idx_fact_relationship_id_3 ON fact_relationship (relationship_concept_id ASC);
/************************
Standardized health system data
************************/
/************************
Standardized health economics
************************/
CREATE CLUSTERED INDEX idx_period_person_id ON payer_plan_period (person_id ASC);
/************************
Standardized derived elements
************************/
CREATE INDEX idx_cohort_subject_id ON cohort (subject_id ASC);
CREATE INDEX idx_cohort_c_definition_id ON cohort (cohort_definition_id ASC);
CREATE INDEX idx_ca_subject_id ON cohort_attribute (subject_id ASC);
CREATE INDEX idx_ca_definition_id ON cohort_attribute (cohort_definition_id ASC);
CREATE CLUSTERED INDEX idx_drug_era_person_id ON drug_era (person_id ASC);
CREATE INDEX idx_drug_era_concept_id ON drug_era (drug_concept_id ASC);
CREATE CLUSTERED INDEX idx_dose_era_person_id ON dose_era (person_id ASC);
CREATE INDEX idx_dose_era_concept_id ON dose_era (drug_concept_id ASC);
CREATE CLUSTERED INDEX idx_condition_era_person_id ON condition_era (person_id ASC);
CREATE INDEX idx_condition_era_concept_id ON condition_era (condition_concept_id ASC);

View File

@ -7,12 +7,12 @@ In order to create your instantiation of the Common Data Model, we recommend fol
1. Create an empty schema.
2. Execute the script `OMOP CDM ddl - SQL Server.sql` to create the tables and fields.
2. Execute the script `OMOP CDM sql server ddl.txt` to create the tables and fields.
3. Load your data into the schema.
4. Execute the script `OMOP CDM constraints - SQL Server.sql` to add the constraints (primary and foreign keys).
4. Execute the script `OMOP CDM sql server constraints.txt` to add the constraints (primary keys).
5. Execute the script `OMOP CDM indexes required - SQL Server.sql` to add the minimum set of indexes we recommend.
5. Execute the script `OMOP CDM sql server indexes.txt` to add the minimum set of indexes and foreign keys we recommend.
Note: you could also apply the constraints and/or the indexes before loading the data, but this will slow down the insertion of the data considerably.