Moving DDLGeneratr to separate location
This commit is contained in:
parent
9a66851f0d
commit
7f3d02cae8
|
@ -1,2 +0,0 @@
|
|||
^.*\.Rproj$
|
||||
^\.Rproj\.user$
|
|
@ -1,21 +0,0 @@
|
|||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
StripTrailingWhitespace: Yes
|
||||
|
||||
BuildType: Package
|
||||
PackageUseDevtools: Yes
|
||||
PackageInstallArgs: --no-multiarch --with-keep.source
|
||||
PackageRoxygenize: rd,collate,namespace
|
|
@ -1,18 +0,0 @@
|
|||
Package: DDLGeneratr
|
||||
Type: Package
|
||||
Title: OMOP CDM DDL Generator
|
||||
Version: 0.1.0
|
||||
Author: Clair Blacketer
|
||||
Maintainer: Clair Blacketer <mblacke@its.jnj.com>
|
||||
Description: This packages uses the SqlRender package to convert a DDL script written in OHDSql to the other supported dialects.
|
||||
License: Apache License 2.0
|
||||
Encoding: UTF-8
|
||||
LazyData: true
|
||||
VignetteBuilder: knitr
|
||||
Imports:
|
||||
SqlRender,
|
||||
rmarkdown,
|
||||
stringr
|
||||
NeedsCompilation: no
|
||||
RoxygenNote: 6.0.1
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
# Generated by roxygen2: do not edit by hand
|
||||
|
||||
export(parseWiki)
|
||||
export(writeConstraints)
|
||||
export(writeDDL)
|
||||
export(writeIndex)
|
||||
export(writePrimaryKeys)
|
|
@ -1,69 +0,0 @@
|
|||
# Copyright 2017 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of DDLGeneratr
|
||||
#
|
||||
# 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.
|
||||
|
||||
|
||||
#' Parse Wiki files
|
||||
#'
|
||||
#' @description
|
||||
#' Parses all .md files in the specified location (or any subfolders), extracting definitions
|
||||
#' of the Common Data Model.
|
||||
#'
|
||||
#' @param mdFilesLocation Path to the root folder of the Wiki repository.
|
||||
#'
|
||||
#' @return
|
||||
#' A data frame with the table definitions culled from the Wiki files.
|
||||
#'
|
||||
#' @export
|
||||
parseWiki <- function(mdFilesLocation) {
|
||||
# mdFilesLocation <- "../../CommonDataModel.wiki"
|
||||
files <- list.files(mdFilesLocation, pattern = ".*\\.md", recursive = TRUE, full.names = TRUE)
|
||||
file <- files[10]
|
||||
parseTableRow <- function(row) {
|
||||
cells <- stringr::str_trim(stringr::str_split(row, "\\|")[[1]])
|
||||
cells <- cells[2:5]
|
||||
return(data.frame(field = tolower(cells[1]),
|
||||
required = cells[2],
|
||||
type = toupper(cells[3]),
|
||||
description = cells[4]))
|
||||
}
|
||||
|
||||
parseMdFile <- function(file) {
|
||||
text <- readChar(file, file.info(file)$size)
|
||||
lines <- stringr::str_split(text, "\n")[[1]]
|
||||
lines <- stringr::str_trim(lines)
|
||||
tableStart <- grep("\\s*field\\s*\\|\\s*required\\s*\\|\\s*type\\s*\\|\\s*description\\s*", tolower(lines))
|
||||
if (length(tableStart) > 1)
|
||||
stop("More than one table definition found in ", file)
|
||||
|
||||
if (length(tableStart) == 1) {
|
||||
tableName <- basename(file)
|
||||
tableName <- tolower(stringr::str_sub(tableName, 1, -4))
|
||||
writeLines(paste("Parsing table", tableName))
|
||||
tableStart <- tableStart + 2
|
||||
tableEnd <- which(lines == "")
|
||||
tableEnd <- min(tableEnd[tableEnd > tableStart]) - 1
|
||||
tableDefinition <- lapply(lines[tableStart:tableEnd], parseTableRow)
|
||||
tableDefinition <- do.call(rbind, tableDefinition)
|
||||
tableDefinition$table <- tableName
|
||||
return(tableDefinition)
|
||||
} else {
|
||||
return(NULL)
|
||||
}
|
||||
}
|
||||
tableDefinitions <- lapply(files, parseMdFile)
|
||||
tableDefinitions <- do.call(rbind, tableDefinitions)
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright 2017 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of DDLGeneratr
|
||||
#
|
||||
# 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.
|
||||
|
||||
#' Write constraint script
|
||||
#'
|
||||
#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"
|
||||
#'
|
||||
#' @export
|
||||
writeConstraints <- function(targetdialect) {
|
||||
if(!dir.exists("output")){
|
||||
dir.create("output")
|
||||
}
|
||||
|
||||
if(!dir.exists(paste0("output/",targetdialect))){
|
||||
dir.create(paste0("output/",targetdialect))
|
||||
}
|
||||
|
||||
sql <- SqlRender::loadRenderTranslateSql(sqlFilename = "OMOP CDM constraints.sql",
|
||||
packageName = "DDLGeneratr",
|
||||
dbms = targetdialect,
|
||||
targetdialect = targetdialect)
|
||||
|
||||
SqlRender::writeSql(sql = sql,
|
||||
targetFile = paste0("output/",targetdialect,"/OMOP CDM ",targetdialect," constraints.txt"))
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright 2017 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of DDLGeneratr
|
||||
#
|
||||
# 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.
|
||||
|
||||
#' Write DDL script
|
||||
#'
|
||||
#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"
|
||||
#'
|
||||
#' @export
|
||||
writeDDL <- function(targetdialect) {
|
||||
if(!dir.exists("output")){
|
||||
dir.create("output")
|
||||
}
|
||||
|
||||
if(!dir.exists(paste0("output/",targetdialect))){
|
||||
dir.create(paste0("output/",targetdialect))
|
||||
}
|
||||
|
||||
sql <- SqlRender::loadRenderTranslateSql(sqlFilename = "OMOP CDM ddl.sql",
|
||||
packageName = "DDLGeneratr",
|
||||
dbms = targetdialect,
|
||||
targetdialect = targetdialect)
|
||||
|
||||
SqlRender::writeSql(sql = sql,
|
||||
targetFile = paste0("output/",targetdialect,"/OMOP CDM ",targetdialect," ddl.txt"))
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
# Copyright 2017 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of DDLGeneratr
|
||||
#
|
||||
# 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.
|
||||
|
||||
#' Write Index script
|
||||
#'
|
||||
#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"
|
||||
#'
|
||||
#' @export
|
||||
writeIndex <- function(targetdialect) {
|
||||
if(!dir.exists("output")){
|
||||
dir.create("output")
|
||||
}
|
||||
|
||||
if(!dir.exists(paste0("output/",targetdialect))){
|
||||
dir.create(paste0("output/",targetdialect))
|
||||
}
|
||||
|
||||
sql <- SqlRender::loadRenderTranslateSql(sqlFilename = "OMOP CDM indexes required.sql",
|
||||
packageName = "DDLGeneratr",
|
||||
dbms = targetdialect,
|
||||
targetdialect = targetdialect)
|
||||
|
||||
SqlRender::writeSql(sql = sql,
|
||||
targetFile = paste0("output/",targetdialect,"/OMOP CDM ",targetdialect," indexes.txt"))
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
# Copyright 2017 Observational Health Data Sciences and Informatics
|
||||
#
|
||||
# This file is part of DDLGeneratr
|
||||
#
|
||||
# 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.
|
||||
|
||||
#' Write primary key script
|
||||
#'
|
||||
#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"
|
||||
#'
|
||||
#' @export
|
||||
|
||||
writePrimaryKeys <- function(targetdialect) {
|
||||
if(!dir.exists("output")){
|
||||
dir.create("output")
|
||||
}
|
||||
|
||||
if(!dir.exists(paste0("output/",targetdialect))){
|
||||
dir.create(paste0("output/",targetdialect))
|
||||
}
|
||||
|
||||
sql <- SqlRender::loadRenderTranslateSql(sqlFilename = "OMOP CDM Primary Keys.sql",
|
||||
packageName = "DDLGeneratr",
|
||||
dbms = targetdialect,
|
||||
targetdialect = targetdialect)
|
||||
|
||||
SqlRender::writeSql(sql = sql,
|
||||
targetFile = paste0("output/",targetdialect,"/OMOP CDM ",targetdialect," primary keys.txt"))
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#This script is meant to create the OMOP Common Data Model DDLs for each dialect as well as the pdf of the documentation.
|
||||
|
||||
|
||||
# Step 1: Update the file inst/sql/sql_server/OMOP CDM ddl.sql with the changes for the new version and set the below variables
|
||||
|
||||
# Step 1.1: The version of the CDM you are writing. This will be used for the name of the pdf so, for example, write v5.3 as v5_3
|
||||
cdmVersion <- "v5_3"
|
||||
|
||||
# Step 1.2: The location of the wiki markdown files. The default is "../../Documentation/CommonDataModel_Wiki_Files"
|
||||
mdFilesLocation <- "../../Documentation/CommonDataModel_Wiki_Files"
|
||||
|
||||
# Step 2: Run the following code to create the DDLs for each dialect:
|
||||
|
||||
writeDDL("bigquery")
|
||||
writeDDL("impala")
|
||||
writeDDL("netezza")
|
||||
writeDDL("oracle")
|
||||
writeDDL("pdw")
|
||||
writeDDL("postgresql")
|
||||
writeDDL("redshift")
|
||||
writeDDL("sql server")
|
||||
|
||||
# Step 3: Run the following code to create the primary key constraints and index files for Oracle, Postgres, PDW and Sql Server
|
||||
|
||||
writeIndex("oracle")
|
||||
writeIndex("postgresql")
|
||||
writeIndex("pdw")
|
||||
writeIndex("sql server")
|
||||
|
||||
# Step 4: Run the following code to create primary key constraints for Netezza
|
||||
|
||||
writePrimaryKeys("netezza")
|
||||
|
||||
# Step 5: Run the following code to create foreign key constraints for Oracle, Postgres, PDW and Sql Server
|
||||
|
||||
writeConstraints("oracle")
|
||||
writeConstraints("postgresql")
|
||||
writeConstraints("pdw")
|
||||
writeConstraints("sql server")
|
||||
|
||||
# step 6: Run the following code to create the pdf documentation. It will be written to the reports folder.
|
||||
|
||||
rmarkdown::render("reports/OMOP_CDM_PDF.Rmd",
|
||||
output_format = "pdf_document",
|
||||
output_file = paste0("OMOP_CDM_",cdmVersion,".pdf"),
|
||||
params = list(mdFilesLocation = mdFilesLocation))
|
|
@ -1,174 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
@targetdialect 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 ) ;
|
|
@ -1,417 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
@targetdialect 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);
|
|
@ -1,729 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### #####
|
||||
# # # # # # # # # # # # # # # ### #
|
||||
# # # # # # # # # # # # # # # # # ### # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### #####
|
||||
|
||||
|
||||
@targetdialect 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_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
|
||||
)
|
||||
;
|
|
@ -1,342 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### ###
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
|
||||
|
||||
|
||||
@targetdialect 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);
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
\name{hello}
|
||||
\alias{hello}
|
||||
\title{Hello, World!}
|
||||
\usage{
|
||||
hello()
|
||||
}
|
||||
\description{
|
||||
Prints 'Hello, world!'.
|
||||
}
|
||||
\examples{
|
||||
hello()
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/WikiParser.R
|
||||
\name{parseWiki}
|
||||
\alias{parseWiki}
|
||||
\title{Parse Wiki files}
|
||||
\usage{
|
||||
parseWiki(mdFilesLocation)
|
||||
}
|
||||
\arguments{
|
||||
\item{mdFilesLocation}{Path to the root folder of the Wiki repository.}
|
||||
}
|
||||
\value{
|
||||
A data frame with the table definitions culled from the Wiki files.
|
||||
}
|
||||
\description{
|
||||
Parses all .md files in the specified location (or any subfolders), extracting definitions
|
||||
of the Common Data Model.
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/writeConstraints.R
|
||||
\name{writeConstraints}
|
||||
\alias{writeConstraints}
|
||||
\title{Write constraint script}
|
||||
\usage{
|
||||
writeConstraints(targetdialect)
|
||||
}
|
||||
\arguments{
|
||||
\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"}
|
||||
}
|
||||
\description{
|
||||
Write constraint script
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/writeDDL.R
|
||||
\name{writeDDL}
|
||||
\alias{writeDDL}
|
||||
\title{Write DDL script}
|
||||
\usage{
|
||||
writeDDL(targetdialect)
|
||||
}
|
||||
\arguments{
|
||||
\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"}
|
||||
}
|
||||
\description{
|
||||
Write DDL script
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/writeIndex.R
|
||||
\name{writeIndex}
|
||||
\alias{writeIndex}
|
||||
\title{Write Index script}
|
||||
\usage{
|
||||
writeIndex(targetdialect)
|
||||
}
|
||||
\arguments{
|
||||
\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"}
|
||||
}
|
||||
\description{
|
||||
Write Index script
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/writePrimaryKeys.R
|
||||
\name{writePrimaryKeys}
|
||||
\alias{writePrimaryKeys}
|
||||
\title{Write primary key script}
|
||||
\usage{
|
||||
writePrimaryKeys(targetdialect)
|
||||
}
|
||||
\arguments{
|
||||
\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"}
|
||||
}
|
||||
\description{
|
||||
Write primary key script
|
||||
}
|
|
@ -1,730 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### #####
|
||||
# # # # # # # # # # # # # # # ### #
|
||||
# # # # # # # # # # # # # # # # # ### # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### #####
|
||||
|
||||
|
||||
bigquery 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
|
||||
)
|
||||
;
|
|
@ -1,651 +0,0 @@
|
|||
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
|
||||
)
|
||||
;
|
|
@ -1,735 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # #
|
||||
# # # # # # # # # # # # # # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### #####
|
||||
# # # # # # # # # # # # # # # ### #
|
||||
# # # # # # # # # # # # # # # # # ### # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### #####
|
||||
|
||||
|
||||
impala 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) ,
|
||||
domain_id VARCHAR(20) ,
|
||||
vocabulary_id VARCHAR(20) ,
|
||||
concept_class_id VARCHAR(20) ,
|
||||
standard_concept VARCHAR(1) NULL ,
|
||||
concept_code VARCHAR(50) ,
|
||||
valid_start_date DATE NOT NULL ,
|
||||
valid_end_date DATE NOT NULL ,
|
||||
invalid_reason VARCHAR(1) NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE vocabulary (
|
||||
vocabulary_id VARCHAR(20),
|
||||
vocabulary_name VARCHAR(255),
|
||||
vocabulary_reference VARCHAR(255),
|
||||
vocabulary_version VARCHAR(255),
|
||||
vocabulary_concept_id INTEGER NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE domain (
|
||||
domain_id VARCHAR(20),
|
||||
domain_name VARCHAR(255),
|
||||
domain_concept_id INTEGER NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE concept_class (
|
||||
concept_class_id VARCHAR(20),
|
||||
concept_class_name VARCHAR(255),
|
||||
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),
|
||||
valid_start_date DATE NOT NULL,
|
||||
valid_end_date DATE NOT NULL,
|
||||
invalid_reason VARCHAR(1) NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE relationship (
|
||||
relationship_id VARCHAR(20),
|
||||
relationship_name VARCHAR(255),
|
||||
is_hierarchical VARCHAR(1),
|
||||
defines_ancestry VARCHAR(1),
|
||||
reverse_relationship_id VARCHAR(20),
|
||||
relationship_concept_id INTEGER NOT NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
CREATE TABLE concept_synonym (
|
||||
concept_id INTEGER NOT NULL,
|
||||
concept_synonym_name VARCHAR(1000),
|
||||
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),
|
||||
source_concept_id INTEGER NOT NULL,
|
||||
source_vocabulary_id VARCHAR(20),
|
||||
source_code_description VARCHAR(255) NULL,
|
||||
target_concept_id INTEGER NOT NULL,
|
||||
target_vocabulary_id VARCHAR(20),
|
||||
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),
|
||||
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),
|
||||
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) ,
|
||||
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) ,
|
||||
value_as_string NVARCHAR NULL ,
|
||||
value_as_concept_id INTEGER NULL ,
|
||||
metadata_date DATE NULL ,
|
||||
metadata_datetime DATETIME2 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_end_date DATE 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(50) NULL ,
|
||||
discharge_to_source_value VARCHAR(50) NULL ,
|
||||
preceding_visit_occurrence_id INTEGER NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
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 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 ,
|
||||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
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 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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
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 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 ,
|
||||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
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 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 ,
|
||||
visit_detail_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 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 ,
|
||||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
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 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 ,
|
||||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
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 ,
|
||||
visit_detail_id INTEGER NULL ,
|
||||
note_source_value VARCHAR(50) NULL
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE note_nlp
|
||||
(
|
||||
note_nlp_id INTEGER ,
|
||||
note_id INTEGER NOT NULL ,
|
||||
section_concept_id INTEGER NULL ,
|
||||
snippet VARCHAR(250) NULL ,
|
||||
offset VARCHAR(250) NULL ,
|
||||
lexical_variant VARCHAR(250) ,
|
||||
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 VARCHAR(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 ,
|
||||
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
|
||||
|
||||
************************/
|
||||
|
||||
|
||||
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) ,
|
||||
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
|
||||
|
||||
************************/
|
||||
|
||||
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 ,
|
||||
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
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,780 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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)
|
||||
;
|
|
@ -1,174 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
netezza 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 ) ;
|
|
@ -1,417 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
oracle 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);
|
|
@ -1,730 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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
|
||||
)
|
||||
;
|
|
@ -1,385 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### ###
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
|
||||
|
||||
|
||||
oracle 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
|
||||
|
||||
************************/
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
CREATE INDEX idx_cohort_definition_id ON cohort_definition (cohort_definition_id ASC);
|
||||
|
||||
CREATE INDEX idx_attribute_definition_id ON attribute_definition (attribute_definition_id ASC);
|
||||
|
||||
|
||||
/**************************
|
||||
|
||||
Standardized meta-data
|
||||
|
||||
***************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/************************
|
||||
|
||||
Standardized clinical data
|
||||
|
||||
************************/
|
||||
|
||||
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);
|
||||
|
||||
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_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);
|
||||
|
||||
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);
|
||||
|
|
@ -1,417 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
*************************/
|
||||
|
||||
|
||||
/************************
|
||||
*************************
|
||||
*************************
|
||||
*************************
|
||||
|
||||
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);
|
|
@ -1,691 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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));
|
|
@ -1,342 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### ###
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
|
||||
|
||||
|
||||
pdw 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);
|
||||
|
|
@ -1,417 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
postgresql 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);
|
|
@ -1,730 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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
|
||||
)
|
||||
;
|
|
@ -1,371 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### ###
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
|
||||
|
||||
|
||||
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);
|
||||
|
|
@ -1,691 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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);
|
|
@ -1,417 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### #####
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # #### # # #### ##### ##### ## # # # ##### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # # ## # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # #### # # # # # # # # # # ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # # ##### ###### # # # # # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # # # # ## # # # # # # # # # ## # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ##### #### # # #### # # # # # # # # # ####
|
||||
|
||||
|
||||
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);
|
|
@ -1,730 +0,0 @@
|
|||
/*********************************************************************************
|
||||
# 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
|
||||
)
|
||||
;
|
|
@ -1,342 +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.
|
||||
********************************************************************************/
|
||||
|
||||
/************************
|
||||
|
||||
####### # # ####### ###### ##### ###### # # ####### ##### ###
|
||||
# # ## ## # # # # # # # # ## ## # # # # # # # # ##### ###### # # ###### ####
|
||||
# # # # # # # # # # # # # # # # # # # # # # ## # # # # # # # #
|
||||
# # # # # # # ###### # # # # # # # # ###### ##### # # # # # # ##### ## ##### ####
|
||||
# # # # # # # # # # # # # # # ### # # # # # # # # ## # #
|
||||
# # # # # # # # # # # # # # # # # ### # # # # ## # # # # # # # #
|
||||
####### # # ####### # ##### ###### # # ## ##### ### ##### ### # # ##### ###### # # ###### ####
|
||||
|
||||
|
||||
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);
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
---
|
||||
title: "OMOP Common Data Model Specifications"
|
||||
author: "Christian Reich, Patrick Ryan, Rimma Belenkaya, Karthik Natarajan and Clair Blacketer"
|
||||
date: "`r Sys.Date()`"
|
||||
params:
|
||||
mdFilesLocation: "../../Documentation/CommonDataModel_Wiki_Files"
|
||||
output:
|
||||
pdf_document:
|
||||
number_sections: yes
|
||||
toc: yes
|
||||
linkcolor: blue
|
||||
---
|
||||
|
||||
```{r, echo=FALSE}
|
||||
mdFilesLocation <- params$mdFilesLocation
|
||||
```
|
||||
|
||||
# License
|
||||
```{r child = paste0(mdFilesLocation,'/License.md')}
|
||||
```
|
||||
|
||||
# Background
|
||||
```{r child = paste0(mdFilesLocation,'/Background/Background.md')}
|
||||
```
|
||||
|
||||
## The Role of the Common Data Model
|
||||
```{r child = paste0(mdFilesLocation,'/Background/The-Role-of-the-Common-Data-Model.md')}
|
||||
```
|
||||
|
||||
## Design Principles
|
||||
```{r child = paste0(mdFilesLocation,'/Background/Design-Principles.md')}
|
||||
```
|
||||
|
||||
## Data Model Conventions
|
||||
```{r child = paste0(mdFilesLocation,'/Background/Data-Model-Conventions.md')}
|
||||
```
|
||||
|
||||
# Glossary of Terms
|
||||
```{r child = paste0(mdFilesLocation,'/Glossary-of-Terms.md')}
|
||||
```
|
||||
|
||||
# Standardized Vocabularies
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/Standardized-Vocabularies.md')}
|
||||
```
|
||||
|
||||
## CONCEPT
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/CONCEPT.md')}
|
||||
```
|
||||
|
||||
## VOCABULARY
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/VOCABULARY.md')}
|
||||
```
|
||||
|
||||
## DOMAIN
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/DOMAIN.md')}
|
||||
```
|
||||
|
||||
## CONCEPT_CLASS
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/CONCEPT_CLASS.md')}
|
||||
```
|
||||
|
||||
## CONCEPT_RELATIONSHIP
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/CONCEPT_RELATIONSHIP.md')}
|
||||
```
|
||||
|
||||
## RELATIONSHIP
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/RELATIONSHIP.md')}
|
||||
```
|
||||
|
||||
## CONCEPT_SYNONYM
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/CONCEPT_SYNONYM.md')}
|
||||
```
|
||||
|
||||
## CONCEPT_ANCESTOR
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/CONCEPT_ANCESTOR.md')}
|
||||
```
|
||||
|
||||
## SOURCE_TO_CONCEPT_MAP
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/SOURCE_TO_CONCEPT_MAP.md')}
|
||||
```
|
||||
|
||||
## DRUG_STRENGTH
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/DRUG_STRENGTH.md')}
|
||||
```
|
||||
|
||||
## COHORT_DEFINITION
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/COHORT_DEFINITION.md')}
|
||||
```
|
||||
|
||||
## ATTRIBUTE_DEFINITION
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedVocabularies/ATTRIBUTE_DEFINITION.md')}
|
||||
```
|
||||
|
||||
# Standardized Metadata
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedMetadata/Standardized-Metadata.md')}
|
||||
```
|
||||
|
||||
## CDM_SOURCE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedMetadata/CDM_SOURCE.md')}
|
||||
```
|
||||
|
||||
# Standardized Clinical Data Tables
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/Standardized-clinical-Data-Tables.md')}
|
||||
```
|
||||
|
||||
## PERSON
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/PERSON.md')}
|
||||
```
|
||||
|
||||
## OBSERVATION_PERIOD
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/OBSERVATION_PERIOD.md')}
|
||||
```
|
||||
|
||||
## SPECIMEN
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/SPECIMEN.md')}
|
||||
```
|
||||
|
||||
## DEATH
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/DEATH.md')}
|
||||
```
|
||||
|
||||
## VISIT_OCCURRENCE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/VISIT_OCCURRENCE.md')}
|
||||
```
|
||||
|
||||
## PROCEDURE_OCCURRENCE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/PROCEDURE_OCCURRENCE.md')}
|
||||
```
|
||||
|
||||
## DRUG_EXPOSURE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/DRUG_EXPOSURE.md')}
|
||||
```
|
||||
|
||||
## DEVICE_EXPOSURE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/DEVICE_EXPOSURE.md')}
|
||||
```
|
||||
|
||||
## CONDITION_OCCURRENCE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/CONDITION_OCCURRENCE.md')}
|
||||
```
|
||||
|
||||
## MEASUREMENT
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/MEASUREMENT.md')}
|
||||
```
|
||||
|
||||
## NOTE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/NOTE.md')}
|
||||
```
|
||||
|
||||
## NOTE_NLP
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/NOTE_NLP.md')}
|
||||
```
|
||||
|
||||
## OBSERVATION
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/OBSERVATION.md')}
|
||||
```
|
||||
|
||||
## FACT_RELATIONSHIP
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedclinicalDataTables/FACT_RELATIONSHIP.md')}
|
||||
```
|
||||
|
||||
# Standardized Health System Data Tables
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthSystemDataTables/Standardized-Health-System-Data-Tables.md')}
|
||||
```
|
||||
|
||||
## LOCATION
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthSystemDataTables/LOCATION.md')}
|
||||
```
|
||||
|
||||
## CARE_SITE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthSystemDataTables/CARE_SITE.md')}
|
||||
```
|
||||
|
||||
## PROVIDER
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthSystemDataTables/PROVIDER.md')}
|
||||
```
|
||||
|
||||
# Standardized Health Economics Data Tables
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthEconomicsDataTables/Standardized-Health-Economics-Data-Tables.md')}
|
||||
```
|
||||
|
||||
## PAYER_PLAN_PERIOD
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthEconomicsDataTables/PAYER_PLAN_PERIOD.md')}
|
||||
```
|
||||
|
||||
## COST
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedHealthEconomicsDataTables/COST.md')}
|
||||
```
|
||||
|
||||
# Standardized Derived Elements
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/Standardized-Derived-Elements.md')}
|
||||
```
|
||||
|
||||
## COHORT
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/COHORT.md')}
|
||||
```
|
||||
|
||||
## COHORT_ATTRIBUTE
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/COHORT_ATTRIBUTE.md')}
|
||||
```
|
||||
|
||||
## DRUG_ERA
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/DRUG_ERA.md')}
|
||||
```
|
||||
|
||||
## DOSE_ERA
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/DOSE_ERA.md')}
|
||||
```
|
||||
|
||||
## CONDITION_ERA
|
||||
```{r child = paste0(mdFilesLocation,'/StandardizedDerivedElements/CONDITION_ERA.md')}
|
||||
```
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue