From 2c3c42fb1c1fbb4a73db9aa497683c7a3fcf5d9b Mon Sep 17 00:00:00 2001 From: Andryc Date: Wed, 18 Aug 2021 12:19:04 -0400 Subject: [PATCH 1/7] update to metadata table - issue 202 --- inst/csv/OMOP_CDMv5.4_Field_Level.csv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inst/csv/OMOP_CDMv5.4_Field_Level.csv b/inst/csv/OMOP_CDMv5.4_Field_Level.csv index 203a04f..8db0962 100644 --- a/inst/csv/OMOP_CDMv5.4_Field_Level.csv +++ b/inst/csv/OMOP_CDMv5.4_Field_Level.csv @@ -359,11 +359,13 @@ Condition.",,No,No,,,,, CONDITION_ERA,condition_occurrence_count,No,integer,"The number of individual Condition Occurrences used to construct the condition era.",,No,No,,,,, +METADATA,metadata_id,Yes,integer,The unique key given to a Metadata record.,Attribute value is auto-generated,Yes,No,,,,, METADATA,metadata_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, METADATA,metadata_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, METADATA,name,Yes,varchar(250),,,No,No,,,,, METADATA,value_as_string,No,varchar(250),,,No,No,,,,, METADATA,value_as_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +METADATA,value_as_number,No,float,"This is the numerical value of the Result of the Metadata, if applicable and available. It is not expected that all Metadata will have numeric results, rather, this field is here to house values should they exist. ",,No,No,,,,, METADATA,metadata_date,No,date,,,No,No,,,,, METADATA,metadata_datetime,No,datetime,,,No,No,,,,, CDM_SOURCE,cdm_source_name,Yes,varchar(255),The name of the CDM instance.,,No,No,,,,, From 19462d322dffa972a2e8cac7cf19a09df99a188a Mon Sep 17 00:00:00 2001 From: Adam Black Date: Thu, 19 Aug 2021 11:49:36 -0400 Subject: [PATCH 2/7] Add tests, github actions, and executeDdl function (#425) * Add github actions workflow to build package and run tests. * update Description file * rename .Rproj file. * Consolidate 'create' functions into one file. * Add tests for create functions. * update description * removed spaces in file and folder names. Regenerated ddl output. Tried to fix Field_Level.csv file. * consolidate write functions into one file. Add execute function. * update docs * add tests for write and execute functions * update documentation * Add windows and linux runners in github actions. * update github actions * download drivers before running tests * fix small error in setup test file. * debug github actions * debug github actions * debug github actions * debug github actions * fix tiny bug * comment out execute ddl test * fix bug in test * Add execute test back in * revert accidental change in description * add print statement for debugging schema error on github actions. * Fix schema environment variable name * Add comment to github actions workflow file. * remove placeholder text in function documentation. * Rename createdDdl.R to createDdl.R Co-authored-by: Adam Black --- .Rbuildignore | 2 + .github/workflows/R_CMD_check.yaml | 117 ++++++++++++++++++ CdmDdlBase.Rproj => CommonDataModel.Rproj | 0 DESCRIPTION | 13 +- NAMESPACE | 3 +- R/createDdl.R | 83 +++++++++++-- R/createForeignKeys.R | 38 ------ R/createPrimaryKeys.R | 38 ------ R/downloadCurrentDdl.R | 3 +- R/executeDdl.R | 86 +++++++++++++ R/writeDDL.R | 108 ++++++++++++++-- R/writeForeignKeys.R | 36 ------ R/writeIndex.R | 38 ------ R/writePrimaryKeys.R | 37 ------ .../OMOPCDM_sql_server_5.3_constraints.sql} | 0 .../OMOPCDM_sql_server_5.3_ddl.sql} | 0 .../OMOPCDM_sql_server_5.3_indices.sql} | 0 .../OMOPCDM_sql_server_5.3_primary_keys.sql} | 0 .../OMOPCDM_sql_server_5.4_constraints.sql} | 0 .../OMOPCDM_sql_server_5.4_ddl.sql} | 0 .../OMOPCDM_sql_server_5.4_indices.sql} | 0 .../OMOPCDM_sql_server_5.4_primary_keys.sql} | 0 errorReport.txt | 26 ---- extras/codeToRun.R | 10 +- inst/csv/OMOP_CDMv5.3_Field_Level.csv | 18 +-- ...ces v5.3.sql => OMOP_CDM_indices_v5.3.sql} | 2 +- ...ces v5.4.sql => OMOP_CDM_indices_v5.4.sql} | 2 +- ...ces v6.0.sql => OMOP_CDM_indices_v6.0.sql} | 2 +- man/createDdl.Rd | 46 ++++--- man/createForeignKeys.Rd | 14 --- man/createPrimaryKeys.Rd | 14 --- man/downloadCurrentDdl.Rd | 3 +- man/executeDdl.Rd | 42 +++++++ man/writeDDL.Rd | 56 +++++++-- man/writeForeignKeys.Rd | 22 ---- man/writeIndex.Rd | 18 --- man/writePrimaryKeys.Rd | 22 ---- tests/setup.R | 21 ++++ tests/testthat.R | 4 + tests/testthat/test-createDdl.R | 38 ++++++ tests/testthat/test-executeDdl.R | 84 +++++++++++++ tests/testthat/test-writeDdl.R | 51 ++++++++ 42 files changed, 719 insertions(+), 378 deletions(-) create mode 100644 .github/workflows/R_CMD_check.yaml rename CdmDdlBase.Rproj => CommonDataModel.Rproj (100%) delete mode 100644 R/createForeignKeys.R delete mode 100644 R/createPrimaryKeys.R create mode 100644 R/executeDdl.R delete mode 100644 R/writeForeignKeys.R delete mode 100644 R/writeIndex.R delete mode 100644 R/writePrimaryKeys.R rename ddl/5.3/{sql server/OMOPCDM_sql server_5.3_constraints.sql => sql_server/OMOPCDM_sql_server_5.3_constraints.sql} (100%) rename ddl/5.3/{sql server/OMOPCDM_sql server_5.3_ddl.sql => sql_server/OMOPCDM_sql_server_5.3_ddl.sql} (100%) rename ddl/5.3/{sql server/OMOPCDM_sql server_5.3_indices.sql => sql_server/OMOPCDM_sql_server_5.3_indices.sql} (100%) rename ddl/5.3/{sql server/OMOPCDM_sql server_5.3_primary_keys.sql => sql_server/OMOPCDM_sql_server_5.3_primary_keys.sql} (100%) rename ddl/5.4/{sql server/OMOPCDM_sql server_5.4_constraints.sql => sql_server/OMOPCDM_sql_server_5.4_constraints.sql} (100%) rename ddl/5.4/{sql server/OMOPCDM_sql server_5.4_ddl.sql => sql_server/OMOPCDM_sql_server_5.4_ddl.sql} (100%) rename ddl/5.4/{sql server/OMOPCDM_sql server_5.4_indices.sql => sql_server/OMOPCDM_sql_server_5.4_indices.sql} (100%) rename ddl/5.4/{sql server/OMOPCDM_sql server_5.4_primary_keys.sql => sql_server/OMOPCDM_sql_server_5.4_primary_keys.sql} (100%) delete mode 100644 errorReport.txt rename inst/sql/sql_server/{OMOP CDM indices v5.3.sql => OMOP_CDM_indices_v5.3.sql} (99%) rename inst/sql/sql_server/{OMOP CDM indices v5.4.sql => OMOP_CDM_indices_v5.4.sql} (99%) rename inst/sql/sql_server/{OMOP CDM indices v6.0.sql => OMOP_CDM_indices_v6.0.sql} (99%) delete mode 100644 man/createForeignKeys.Rd delete mode 100644 man/createPrimaryKeys.Rd create mode 100644 man/executeDdl.Rd delete mode 100644 man/writeForeignKeys.Rd delete mode 100644 man/writeIndex.Rd delete mode 100644 man/writePrimaryKeys.Rd create mode 100644 tests/setup.R create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-createDdl.R create mode 100644 tests/testthat/test-executeDdl.R create mode 100644 tests/testthat/test-writeDdl.R diff --git a/.Rbuildignore b/.Rbuildignore index 91114bf..51cbb5f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,2 +1,4 @@ ^.*\.Rproj$ ^\.Rproj\.user$ +^LICENSE\.md$ +.github/* diff --git a/.github/workflows/R_CMD_check.yaml b/.github/workflows/R_CMD_check.yaml new file mode 100644 index 0000000..c458ae0 --- /dev/null +++ b/.github/workflows/R_CMD_check.yaml @@ -0,0 +1,117 @@ +# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. +# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + # Test create and drop tables in a database so they cannot be executed in parallel + max-parallel: 1 + fail-fast: false + matrix: + config: + - {os: macOS-latest, r: 'release'} + - {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"} + - {os: windows-latest, r: 'release'} # Does not appear to have Java 32-bit, hence the --no-multiarch + + env: + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + RSPM: ${{ matrix.config.rspm }} + CDMDDLBASE_POSTGRESQL_USER: ${{ secrets.CDMDDLBASE_POSTGRESQL_USER }} + CDMDDLBASE_POSTGRESQL_PASSWORD: ${{ secrets.CDMDDLBASE_POSTGRESQL_PASSWORD }} + CDMDDLBASE_POSTGRESQL_SERVER: ${{ secrets.CDMDDLBASE_POSTGRESQL_SERVER }} + CDMDDLBASE_POSTGRESQL_SCHEMA: ${{ secrets.CDMDDLBASE_POSTGRESQL_SCHEMA }} + + steps: + - uses: actions/checkout@v2 + + - uses: r-lib/actions/setup-r@v1 + with: + r-version: ${{ matrix.config.r }} + + - uses: r-lib/actions/setup-tinytex@v1 + + - uses: r-lib/actions/setup-pandoc@v1 + + - name: Query dependencies + run: | + install.packages('remotes') + saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) + writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") + shell: Rscript {0} + + - name: Cache R packages + if: runner.os != 'Windows' + uses: actions/cache@v2 + with: + path: ${{ env.R_LIBS_USER }} + key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + + - name: Install system dependencies + if: runner.os == 'Linux' + run: | + while read -r cmd + do + eval sudo $cmd + done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))') + + - name: Install libssh + if: runner.os == 'Linux' + run: | + sudo apt-get install libssh-dev + + - name: Install dependencies + run: | + remotes::install_deps(dependencies = TRUE, INSTALL_opts=c("--no-multiarch")) + remotes::install_cran("rcmdcheck") + shell: Rscript {0} + + - name: Install covr + if: runner.os == 'macOS' + run: | + remotes::install_cran("covr") + shell: Rscript {0} + + - name: Remove check folder if exists + if: runner.os == 'macOS' + run: unlink("check", recursive = TRUE) + shell: Rscript {0} + + - name: Check + env: + _R_CHECK_CRAN_INCOMING_REMOTE_: false + run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran", "--no-multiarch"), error_on = "warning", check_dir = "check") + shell: Rscript {0} + + - name: Upload check results + if: failure() + uses: actions/upload-artifact@v2 + with: + name: ${{ runner.os }}-r${{ matrix.config.r }}-results + path: check + + - name: Upload source package + if: success() && runner.os == 'macOS' && github.event_name != 'pull_request' && github.ref == 'refs/heads/master' + uses: actions/upload-artifact@v2 + with: + name: package_tarball + path: check/*.tar.gz + + - name: Test coverage + if: runner.os == 'macOS' + run: covr::codecov() + shell: Rscript {0} + diff --git a/CdmDdlBase.Rproj b/CommonDataModel.Rproj similarity index 100% rename from CdmDdlBase.Rproj rename to CommonDataModel.Rproj diff --git a/DESCRIPTION b/DESCRIPTION index 290b438..9e8b93e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,4 +1,4 @@ -Package: CdmDdlBase +Package: CommonDataModel Type: Package Title: OMOP CDM DDL and Documentation Generator Version: 0.1.0 @@ -14,6 +14,15 @@ Imports: rmarkdown, stringr, readxl, - dplyr + DatabaseConnector, + DBI, + dplyr, + readr +Suggests: + knitr, + testthat (>= 3.0.0), + RSQLite, + withr NeedsCompilation: no RoxygenNote: 7.1.1 +Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index e843930..4946218 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,9 +4,10 @@ export(createDdl) export(createForeignKeys) export(createPrimaryKeys) export(downloadCurrentDdl) +export(executeDdl) export(listSupportedVersions) export(parseWiki) -export(writeDDL) +export(writeDdl) export(writeForeignKeys) export(writeIndex) export(writePrimaryKeys) diff --git a/R/createDdl.R b/R/createDdl.R index 3ccf0d6..74464e6 100644 --- a/R/createDdl.R +++ b/R/createDdl.R @@ -1,4 +1,3 @@ - # Copyright 2019 Observational Health Data Sciences and Informatics # # This file is part of CdmDdlBase @@ -15,21 +14,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -#' Create a DDL script from a two csv files that detail the OMOP CDM Specifications. These files also form the basis of the CDM documentation and the Data Quality +#' Create the OHDSI-SQL Common Data Model DDL code +#' +#' The createDdl, createForeignKeys, and createPrimaryKeys functions each return a character string +#' containing their respective DDL SQL code in OHDSQL dialect for a specific CDM version. +#' The SQL they generate needs to be rendered and translated before it can be executed. +#' +#' The DDL SQL code is created from a two csv files that detail the OMOP CDM Specifications. +#' These files also form the basis of the CDM documentation and the Data Quality #' Dashboard. #' -#' @param cdmVersionNum The version of the CDM you are creating, e.g. 5.3.1 -#' -#' @param cdmTableCsvLoc The location of the csv file with the high-level CDM table information. This is defaulted to "inst/csv/OMOP_CDMv5.3.1_Table_Level.csv". -#' If a new version of this file was committed to the CDM repository the package automatically will grab it and place it in "inst/csv/". -#' @param cdmFieldCsvLoc The location of the csv file with the CDM field information. This is defaulted to "inst/csv/OMOP_CDMv5.3.1_Field_Level.csv". -#' If a new version of this file was committed to the CDM repository the package automatically will grab it and place it in "inst/csv/". -#' @param outputFile The name of the output ddl sql file. This is defaulted to a location in the inst/sql/sql server folder and named with today's date and the CDM version. +#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4 +#' @return A character string containing the OHDSQL DDL #' @export +#' @examples +#' ddl <- createDdl("5.4") +#' pk <- createPrimaryKeys("5.4") +#' fk <- createForeignKeys("5.4") +createDdl <- function(cdmVersion){ -createDdl <- function(cdmVersion = cdmVersion){ - cdmTableCsvLoc = paste0("inst/csv/OMOP_CDMv", cdmVersion, "_Table_Level.csv") - cdmFieldCsvLoc = paste0("inst/csv/OMOP_CDMv", cdmVersion, "_Field_Level.csv") + # argument checks + stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions()) + + cdmTableCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Table_Level.csv")), package = "CommonDataModel", mustWork = TRUE) + cdmFieldCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Field_Level.csv")), package = "CommonDataModel", mustWork = TRUE) tableSpecs <- read.csv(cdmTableCsvLoc, stringsAsFactors = FALSE) cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE) @@ -37,7 +45,7 @@ createDdl <- function(cdmVersion = cdmVersion){ tableList <- tableSpecs$cdmTableName sql_result <- c() - sql_result <- c(paste0("--@targetdialect CDM DDL Specification for OMOP Common Data Model ", cdmVersion)) + sql_result <- c(paste0("--@targetDialect CDM DDL Specification for OMOP Common Data Model ", cdmVersion)) for (tableName in tableList){ fields <- subset(cdmSpecs, cdmTableName == tableName) fieldNames <- fields$cdmFieldName @@ -81,3 +89,52 @@ createDdl <- function(cdmVersion = cdmVersion){ } return(paste0(sql_result, collapse = "")) } + + +#' @describeIn createDdl createPrimaryKeys Returns a string containing the OHDSQL for creation of primary keys in the OMOP CDM. +#' @export +createPrimaryKeys <- function(cdmVersion){ + + # argument checks + stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions()) + + cdmFieldCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Field_Level.csv")), package = "CommonDataModel", mustWork = TRUE) + cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE) + + primaryKeys <- subset(cdmSpecs, isPrimaryKey == "Yes") + pkFields <- primaryKeys$cdmFieldName + + sql_result <- c(paste0("--@targetDialect CDM Primary Key Constraints for OMOP Common Data Model ", cdmVersion, "\n")) + for (pkField in pkFields){ + + subquery <- subset(primaryKeys, cdmFieldName==pkField) + + sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT xpk_", subquery$cdmTableName, " PRIMARY KEY NONCLUSTERED (", subquery$cdmFieldName , ");\n")) + + } + return(paste0(sql_result, collapse = "")) +} + +#' @describeIn createDdl createForeignKeys Returns a string containing the OHDSQL for creation of foreign keys in the OMOP CDM. +#' @export +createForeignKeys <- function(cdmVersion){ + + # argument checks + stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions()) + + cdmFieldCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Field_Level.csv")), package = "CommonDataModel", mustWork = TRUE) + cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE) + + foreignKeys <- subset(cdmSpecs, isForeignKey == "Yes") + foreignKeys$key <- paste0(foreignKeys$cdmTableName, "_", foreignKeys$cdmFieldName) + + sql_result <- c(paste0("--@targetDialect CDM Foreign Key Constraints for OMOP Common Data Model ", cdmVersion, "\n")) + for (foreignKey in foreignKeys$key){ + + subquery <- subset(foreignKeys, foreignKeys$key==foreignKey) + + sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT fpk_", subquery$cdmTableName, "_", subquery$cdmFieldName, " FOREIGN KEY (", subquery$cdmFieldName , ") REFERENCES @cdmDatabaseSchema.", subquery$fkTableName, " (", subquery$fkFieldName, ");\n")) + + } + return(paste0(sql_result, collapse = "")) +} diff --git a/R/createForeignKeys.R b/R/createForeignKeys.R deleted file mode 100644 index 0317ed4..0000000 --- a/R/createForeignKeys.R +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2019 Observational Health Data Sciences and Informatics -# -# This file is part of CdmDdlBase -# -# 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. - -#' Create a foreign key sql script from two csv files that detail the OMOP CDM Specifications. - -#' @param cdmVersionNum The version of the CDM you are creating, e.g. 5.3.1 -#' @export - -createForeignKeys <- function(cdmVersion = cdmVersion){ - cdmFieldCsvLoc <- paste0("inst/csv/OMOP_CDMv", cdmVersion, "_Field_Level.csv") - cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE) - - foreignKeys <- subset(cdmSpecs, isForeignKey == "Yes") - foreignKeys$key <- paste0(foreignKeys$cdmTableName, "_", foreignKeys$cdmFieldName) - - sql_result <- c(paste0("--@targetdialect CDM Foreign Key Constraints for OMOP Common Data Model ", cdmVersion, "\n")) - for (foreignKey in foreignKeys$key){ - - subquery <- subset(foreignKeys, foreignKeys$key==foreignKey) - - sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT fpk_", subquery$cdmTableName, "_", subquery$cdmFieldName, " FOREIGN KEY (", subquery$cdmFieldName , ") REFERENCES @cdmDatabaseSchema.", subquery$fkTableName, " (", subquery$fkFieldName, ");\n")) - - } - return(paste0(sql_result, collapse = "")) -} diff --git a/R/createPrimaryKeys.R b/R/createPrimaryKeys.R deleted file mode 100644 index 6897ecf..0000000 --- a/R/createPrimaryKeys.R +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2019 Observational Health Data Sciences and Informatics -# -# This file is part of CdmDdlBase -# -# 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. - -#' Create a primary key sql script from two csv files that detail the OMOP CDM Specifications. - -#' @param cdmVersionNum The version of the CDM you are creating, e.g. 5.3 -#' @export - -createPrimaryKeys <- function(cdmVersion = cdmVersion){ - cdmFieldCsvLoc <- paste0("inst/csv/OMOP_CDMv", cdmVersion, "_Field_Level.csv") - cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE) - - primaryKeys <- subset(cdmSpecs, isPrimaryKey == "Yes") - pkFields <- primaryKeys$cdmFieldName - - sql_result <- c(paste0("--@targetdialect CDM Primary Key Constraints for OMOP Common Data Model ", cdmVersion, "\n")) - for (pkField in pkFields){ - - subquery <- subset(primaryKeys, cdmFieldName==pkField) - - sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT xpk_", subquery$cdmTableName, " PRIMARY KEY NONCLUSTERED (", subquery$cdmFieldName , ");\n")) - - } - return(paste0(sql_result, collapse = "")) -} diff --git a/R/downloadCurrentDdl.R b/R/downloadCurrentDdl.R index 2831e7b..8bd9de3 100644 --- a/R/downloadCurrentDdl.R +++ b/R/downloadCurrentDdl.R @@ -11,7 +11,8 @@ #' #' @examples #' \dontrun{ -#' downloadCurrentDdl("OHDSI/CommonDataModel", pathToCsv="Sql%20Server/OMOP%20CDM%20sql%20server%20ddl.txt") +#' downloadCurrentDdl("OHDSI/CommonDataModel", +#' pathToCsv="Sql%20Server/OMOP%20CDM%20sql%20server%20ddl.txt") #' } #' #' @export diff --git a/R/executeDdl.R b/R/executeDdl.R new file mode 100644 index 0000000..ed5e010 --- /dev/null +++ b/R/executeDdl.R @@ -0,0 +1,86 @@ +# Copyright 2019 Observational Health Data Sciences and Informatics +# +# This file is part of CdmDdlBase +# +# 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. + +#' Generate and execute the DDL on a database +#' +#' This function will generate the DDL for a specific dbms and CDM version and +#' then execute the DDL on a database. +#' +#' @param connectionDetails An object of class connectionDetails as created by the DatabaseConnector::createConnectionDetails function. +#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4 +#' @param cdmDatabaseSchema The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server. +#' @param executeDdl Should the DDL be executed? TRUE or FALSE +#' @param executePrimaryKey Should the primary keys be added? TRUE or FALSE +#' @param executeForeignKey Should the foreign keys be added? TRUE or FALSE +#' @param ... Other arguments passed on to DatabaseConnector::executeSql. (This allows the user to set the path to errorReportFile.) +#' @export +#' +#' @examples +#' \dontrun{ +#' executeDdl(connectionDetails = connectionDetails, +#' cdmVersion = "5.4", +#' cdmDatabaseSchema = "myCdm") +#'} +executeDdl <- function(connectionDetails, + cdmVersion, + cdmDatabaseSchema, + executeDdl = TRUE, + executePrimaryKey = TRUE, + executeForeignKey = TRUE, + ...) { + + outputpath <- tempdir(check = TRUE) + + + if(executeDdl) { + filename <- writeDdl(targetDialect = connectionDetails$dbms, + cdmVersion = cdmVersion, + cdmDatabaseSchema = cdmDatabaseSchema, + outputpath = outputpath) + + sql <- readr::read_file(file.path(outputpath, filename)) + } else { + sql <- "" + } + + if(executePrimaryKey) { + filename <- writePrimaryKeys(targetDialect = connectionDetails$dbms, + cdmVersion = cdmVersion, + cdmDatabaseSchema = cdmDatabaseSchema, + outputpath = outputpath) + + sql <- paste(sql, readr::read_file(file.path(outputpath, filename)), sep = "\n") + } + + if(executeForeignKey) { + filename <- writeForeignKeys(targetDialect = connectionDetails$dbms, + cdmVersion = cdmVersion, + cdmDatabaseSchema = cdmDatabaseSchema, + outputpath = outputpath) + + sql <- paste(sql, readr::read_file(file.path(outputpath, filename)), sep = "\n") + } + + con <- DatabaseConnector::connect(connectionDetails = connectionDetails) + + DatabaseConnector::executeSql(con, sql = sql, ...) + + DatabaseConnector::disconnect(con) +} + + + + diff --git a/R/writeDDL.R b/R/writeDDL.R index 153096d..6b89082 100644 --- a/R/writeDDL.R +++ b/R/writeDDL.R @@ -16,22 +16,108 @@ #' Write DDL script #' -#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server" -#' @param cdmVersion The version of the CDM for which you are creating the DDL. e.g. 5.3.1 +#' Write the DDL to a SQL file. The SQL will be rendered (parameters replaced) and translated to the target SQL +#' dialect. By default the @cdmDatabaseSchema parameter is kept in the SQL file and needs to be replaced before +#' execution. +#' +#' @param targetDialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server" +#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4 +#' @param outputpath The directory or folder where the SQL file should be saved. #' @param cdmDatabaseSchema The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server. #' Defaults to "@cdmDatabaseSchema" #' #' @export -writeDDL <- function(targetdialect, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") { - outputpath <- file.path("ddl", cdmVersion, targetdialect) - dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) +writeDdl <- function(targetDialect, cdmVersion, outputpath, cdmDatabaseSchema = "@cdmDatabaseSchema") { + + # argument checks + stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) + stopifnot(cdmVersion %in% listSupportedVersions()) + stopifnot(is.character(cdmDatabaseSchema)) + + if(missing(outputpath)) { + outputpath <- file.path("ddl", cdmVersion, gsub(" ", "_", targetDialect)) + } + + if(!dir.exists(outputpath)) dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) sql <- createDdl(cdmVersion) - sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetdialect = targetdialect) - sql <- SqlRender::translate(sql, targetDialect = targetdialect) + sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect) + sql <- SqlRender::translate(sql, targetDialect = targetDialect) - filename <- paste("OMOPCDM", targetdialect, cdmVersion, "ddl.sql", sep = "_") - SqlRender::writeSql(sql = sql, - targetFile = file.path(outputpath, filename) - ) + filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "ddl.sql", sep = "_") + SqlRender::writeSql(sql = sql, targetFile = file.path(outputpath, filename)) + invisible(filename) +} + +#' @describeIn writeDdl writePrimaryKeys Write the SQL code that creates the primary keys to a file. +#' @export +writePrimaryKeys <- function(targetDialect, cdmVersion, outputpath, cdmDatabaseSchema = "@cdmDatabaseSchema") { + + # argument checks + stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) + stopifnot(cdmVersion %in% listSupportedVersions()) + stopifnot(is.character(cdmDatabaseSchema)) + + if(missing(outputpath)) { + outputpath <- file.path("ddl", cdmVersion, gsub(" ", "_", targetDialect)) + } + + if(!dir.exists(outputpath)) dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) + + sql <- createPrimaryKeys(cdmVersion) + sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect) + sql <- SqlRender::translate(sql, targetDialect = targetDialect) + + filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "primary", "keys.sql", sep = "_") + SqlRender::writeSql(sql = sql, targetFile = file.path(outputpath, filename)) + invisible(filename) +} + +#' @describeIn writeDdl writeForeignKeys Write the SQL code that creates the foreign keys to a file. +#' @export +writeForeignKeys <- function(targetDialect, cdmVersion, outputpath, cdmDatabaseSchema = "@cdmDatabaseSchema") { + + # argument checks + stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) + stopifnot(cdmVersion %in% listSupportedVersions()) + stopifnot(is.character(cdmDatabaseSchema)) + + if(missing(outputpath)) { + outputpath <- file.path("ddl", cdmVersion, gsub(" ", "_", targetDialect)) + } + + if(!dir.exists(outputpath)) dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) + + sql <- createForeignKeys(cdmVersion) + sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect) + sql <- SqlRender::translate(sql, targetDialect = targetDialect) + + filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "constraints.sql", sep = "_") + SqlRender::writeSql(sql = sql, targetFile = file.path(outputpath, filename)) + invisible(filename) +} + +#' @describeIn writeDdl writeIndex Write the rendered and translated sql that creates recommended indexes to a file. +#' @export +writeIndex <- function(targetDialect, cdmVersion, outputpath, cdmDatabaseSchema = "@cdmDatabaseSchema") { + + # argument checks + stopifnot(targetDialect %in% c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) + stopifnot(cdmVersion %in% listSupportedVersions()) + stopifnot(is.character(cdmDatabaseSchema)) + + if(missing(outputpath)) { + outputpath <- file.path("ddl", cdmVersion, gsub(" ", "_", targetDialect)) + } + + if(!dir.exists(outputpath)) dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) + + sqlFilename <- paste0("OMOP_CDM_indices_v", cdmVersion, ".sql") + sql <- readr::read_file(system.file(file.path("sql", "sql_server", sqlFilename), package = "CommonDataModel")) + sql <- SqlRender::render(sql, targetDialect = targetDialect, cdmDatabaseSchema = cdmDatabaseSchema) + sql <- SqlRender::translate(sql, targetDialect = targetDialect) + + filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "indices.sql", sep = "_") + SqlRender::writeSql(sql = sql, targetFile = file.path(outputpath, filename)) + invisible(filename) } diff --git a/R/writeForeignKeys.R b/R/writeForeignKeys.R deleted file mode 100644 index 92e6bc0..0000000 --- a/R/writeForeignKeys.R +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright 2017 Observational Health Data Sciences and Informatics -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -#' Write constraint script -#' -#' @param targetdialect The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server" -#' @param cdmVersion The version of the CDM that you are creating the primary keys for -#' @param cdmDatabaseSchema The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema" -#' -#' @export - -writeForeignKeys <- function(targetdialect, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") { - outputpath <- file.path("ddl", cdmVersion, targetdialect) - dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) - - sql <- createForeignKeys(cdmVersion) - sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetdialect = targetdialect) - sql <- SqlRender::translate(sql, targetDialect = targetdialect) - - filename <- paste("OMOPCDM", targetdialect, cdmVersion, "constraints.sql", sep = "_") - SqlRender::writeSql(sql = sql, - targetFile = file.path(outputpath, filename) - ) -} diff --git a/R/writeIndex.R b/R/writeIndex.R deleted file mode 100644 index 5f53200..0000000 --- a/R/writeIndex.R +++ /dev/null @@ -1,38 +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" -#' @param cdmVersion The version of the CDM that you are creating the indices for. e.g. 5.3.1 -#' @param cdmDatabaseSchema The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema" -#' -#' @export -writeIndex <- function(targetdialect, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") { - outputpath <- file.path("ddl", cdmVersion, targetdialect) - dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) - - sqlFilename <- paste0("OMOP CDM indices v", cdmVersion, ".sql") - sql <- SqlRender::loadRenderTranslateSql(sqlFilename = sqlFilename, - packageName = "CdmDdlBase", - dbms = targetdialect, - targetdialect = targetdialect, - cdmDatabaseSchema = cdmDatabaseSchema) - - filename <- paste("OMOPCDM", targetdialect, cdmVersion, "indices.sql", sep = "_") - SqlRender::writeSql(sql = sql, - targetFile = file.path(outputpath, filename)) -} diff --git a/R/writePrimaryKeys.R b/R/writePrimaryKeys.R deleted file mode 100644 index d867d33..0000000 --- a/R/writePrimaryKeys.R +++ /dev/null @@ -1,37 +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" -#' @param cdmVersion The version of the CDM that you are creating the primary keys for -#' @param cdmDatabaseSchema The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema" -#' -#' @export - -writePrimaryKeys <- function(targetdialect, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") { - outputpath <- file.path("ddl", cdmVersion, targetdialect) - dir.create(outputpath, showWarnings = FALSE, recursive = TRUE) - - sql <- createPrimaryKeys(cdmVersion) - sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetdialect = targetdialect) - sql <- SqlRender::translate(sql, targetDialect = targetdialect) - - filename <- paste("OMOPCDM", targetdialect, cdmVersion, "primary", "keys.sql", sep = "_") - SqlRender::writeSql(sql = sql, - targetFile = file.path(outputpath, filename) - ) -} diff --git a/ddl/5.3/sql server/OMOPCDM_sql server_5.3_constraints.sql b/ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_constraints.sql similarity index 100% rename from ddl/5.3/sql server/OMOPCDM_sql server_5.3_constraints.sql rename to ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_constraints.sql diff --git a/ddl/5.3/sql server/OMOPCDM_sql server_5.3_ddl.sql b/ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_ddl.sql similarity index 100% rename from ddl/5.3/sql server/OMOPCDM_sql server_5.3_ddl.sql rename to ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_ddl.sql diff --git a/ddl/5.3/sql server/OMOPCDM_sql server_5.3_indices.sql b/ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_indices.sql similarity index 100% rename from ddl/5.3/sql server/OMOPCDM_sql server_5.3_indices.sql rename to ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_indices.sql diff --git a/ddl/5.3/sql server/OMOPCDM_sql server_5.3_primary_keys.sql b/ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_primary_keys.sql similarity index 100% rename from ddl/5.3/sql server/OMOPCDM_sql server_5.3_primary_keys.sql rename to ddl/5.3/sql_server/OMOPCDM_sql_server_5.3_primary_keys.sql diff --git a/ddl/5.4/sql server/OMOPCDM_sql server_5.4_constraints.sql b/ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_constraints.sql similarity index 100% rename from ddl/5.4/sql server/OMOPCDM_sql server_5.4_constraints.sql rename to ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_constraints.sql diff --git a/ddl/5.4/sql server/OMOPCDM_sql server_5.4_ddl.sql b/ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_ddl.sql similarity index 100% rename from ddl/5.4/sql server/OMOPCDM_sql server_5.4_ddl.sql rename to ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_ddl.sql diff --git a/ddl/5.4/sql server/OMOPCDM_sql server_5.4_indices.sql b/ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_indices.sql similarity index 100% rename from ddl/5.4/sql server/OMOPCDM_sql server_5.4_indices.sql rename to ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_indices.sql diff --git a/ddl/5.4/sql server/OMOPCDM_sql server_5.4_primary_keys.sql b/ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_primary_keys.sql similarity index 100% rename from ddl/5.4/sql server/OMOPCDM_sql server_5.4_primary_keys.sql rename to ddl/5.4/sql_server/OMOPCDM_sql_server_5.4_primary_keys.sql diff --git a/errorReport.txt b/errorReport.txt deleted file mode 100644 index 85222f6..0000000 --- a/errorReport.txt +++ /dev/null @@ -1,26 +0,0 @@ -DBMS: -sql server - -Error: -com.microsoft.sqlserver.jdbc.SQLServerException: 'fpk_NOTE_person_id' is not a constraint. - -SQL: -ALTER TABLE ohdsi.dbo.NOTE DROP CONSTRAINT fpk_NOTE_person_id - -R version: -R version 3.4.2 (2017-09-28) - -Platform: -x86_64-w64-mingw32 - -Attached base packages: -- stats -- graphics -- grDevices -- utils -- datasets -- methods -- base - -Other attached packages: -- CdmDdlBase (0.1.0) \ No newline at end of file diff --git a/extras/codeToRun.R b/extras/codeToRun.R index fcc10a0..f93dcc3 100644 --- a/extras/codeToRun.R +++ b/extras/codeToRun.R @@ -7,17 +7,17 @@ cdmVersion <- "5.3" supportedVersions <- listSupportedVersions() for (cdmVersion in supportedVersions) { - for (targetdialect in c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) { - writeDDL(targetdialect = targetdialect, + for (targetDialect in c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server")) { + writeDdl(targetDialect = targetDialect, cdmVersion = cdmVersion) - writePrimaryKeys(targetdialect = targetdialect, + writePrimaryKeys(targetDialect = targetDialect, cdmVersion = cdmVersion) - writeForeignKeys(targetdialect = targetdialect, + writeForeignKeys(targetDialect = targetDialect, cdmVersion = cdmVersion) - writeIndex(targetdialect = targetdialect, + writeIndex(targetDialect = targetDialect, cdmVersion = cdmVersion) } } diff --git a/inst/csv/OMOP_CDMv5.3_Field_Level.csv b/inst/csv/OMOP_CDMv5.3_Field_Level.csv index 6b7418c..80e0e9f 100644 --- a/inst/csv/OMOP_CDMv5.3_Field_Level.csv +++ b/inst/csv/OMOP_CDMv5.3_Field_Level.csv @@ -514,20 +514,4 @@ ATTRIBUTE_DEFINITION,attribute_name,Yes,varchar(255),,,No,No,,,,, ATTRIBUTE_DEFINITION,attribute_description,No,varchar(MAX),,,No,No,,,,, ATTRIBUTE_DEFINITION,attribute_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, ATTRIBUTE_DEFINITION,attribute_syntax,No,varchar(MAX),,,No,No,,,,, -======= -1-Jan-1970.",,No,No,,,,, -DRUG_STRENGTH,valid_end_date,Yes,date,The date when then Concept became invalid.,,No,No,,,,, -DRUG_STRENGTH,invalid_reason,No,varchar(1),"Reason the concept was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, -COHORT_DEFINITION,cohort_definition_id,Yes,integer,"This is the identifier given to the cohort, usually by the ATLAS application",,No,No,,,,, -COHORT_DEFINITION,cohort_definition_name,Yes,varchar(255),A short description of the cohort,,No,No,,,,, -COHORT_DEFINITION,cohort_definition_description,No,varchar(MAX),A complete description of the cohort.,,No,No,,,,, -COHORT_DEFINITION,definition_type_concept_id,Yes,integer,Type defining what kind of Cohort Definition the record represents and how the syntax may be executed.,,No,Yes,CONCEPT,CONCEPT_ID,,, -COHORT_DEFINITION,cohort_definition_syntax,No,varchar(MAX),Syntax or code to operationalize the Cohort Definition.,,No,No,,,,, -COHORT_DEFINITION,subject_concept_id,Yes,integer,"This field contains a Concept that represents the domain of the subjects that are members of the cohort (e.g., Person, Provider, Visit).",,No,Yes,CONCEPT,CONCEPT_ID,,, -COHORT_DEFINITION,cohort_initiation_date,No,date,A date to indicate when the Cohort was initiated in the COHORT table.,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_definition_id,Yes,integer,,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_name,Yes,varchar(255),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_description,No,varchar(MAX),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -ATTRIBUTE_DEFINITION,attribute_syntax,No,varchar(MAX),,,No,No,,,,, ->>>>>>> v5.4:inst/csv/OMOP_CDMv5.3.1_Field_Level.csv + diff --git a/inst/sql/sql_server/OMOP CDM indices v5.3.sql b/inst/sql/sql_server/OMOP_CDM_indices_v5.3.sql similarity index 99% rename from inst/sql/sql_server/OMOP CDM indices v5.3.sql rename to inst/sql/sql_server/OMOP_CDM_indices_v5.3.sql index 9e96c2b..c4a50b5 100644 --- a/inst/sql/sql_server/OMOP CDM indices v5.3.sql +++ b/inst/sql/sql_server/OMOP_CDM_indices_v5.3.sql @@ -1,4 +1,4 @@ -/*@targetdialect OMOP CDM Indices +/*@targetDialect OMOP CDM Indices There are no unique indices created because it is assumed that the primary key constraints have been run prior to implementing indices. diff --git a/inst/sql/sql_server/OMOP CDM indices v5.4.sql b/inst/sql/sql_server/OMOP_CDM_indices_v5.4.sql similarity index 99% rename from inst/sql/sql_server/OMOP CDM indices v5.4.sql rename to inst/sql/sql_server/OMOP_CDM_indices_v5.4.sql index 9e96c2b..c4a50b5 100644 --- a/inst/sql/sql_server/OMOP CDM indices v5.4.sql +++ b/inst/sql/sql_server/OMOP_CDM_indices_v5.4.sql @@ -1,4 +1,4 @@ -/*@targetdialect OMOP CDM Indices +/*@targetDialect OMOP CDM Indices There are no unique indices created because it is assumed that the primary key constraints have been run prior to implementing indices. diff --git a/inst/sql/sql_server/OMOP CDM indices v6.0.sql b/inst/sql/sql_server/OMOP_CDM_indices_v6.0.sql similarity index 99% rename from inst/sql/sql_server/OMOP CDM indices v6.0.sql rename to inst/sql/sql_server/OMOP_CDM_indices_v6.0.sql index ac1aabb..520320c 100644 --- a/inst/sql/sql_server/OMOP CDM indices v6.0.sql +++ b/inst/sql/sql_server/OMOP_CDM_indices_v6.0.sql @@ -1,4 +1,4 @@ -/*@targetdialect OMOP CDM Indices*/ +/*@targetDialect OMOP CDM Indices*/ /************************ diff --git a/man/createDdl.Rd b/man/createDdl.Rd index 748b83e..c30bec1 100644 --- a/man/createDdl.Rd +++ b/man/createDdl.Rd @@ -1,24 +1,42 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/createDdl.R +% Please edit documentation in R/createdDdl.R \name{createDdl} \alias{createDdl} -\title{Create a DDL script from a two csv files that detail the OMOP CDM Specifications. These files also form the basis of the CDM documentation and the Data Quality -Dashboard.} +\alias{createPrimaryKeys} +\alias{createForeignKeys} +\title{Create the OHDSI-SQL Common Data Model DDL code} \usage{ -createDdl(cdmVersion = cdmVersion) +createDdl(cdmVersion) + +createPrimaryKeys(cdmVersion) + +createForeignKeys(cdmVersion) } \arguments{ -\item{cdmVersionNum}{The version of the CDM you are creating, e.g. 5.3.1} - -\item{cdmTableCsvLoc}{The location of the csv file with the high-level CDM table information. This is defaulted to "inst/csv/OMOP_CDMv5.3.1_Table_Level.csv". -If a new version of this file was committed to the CDM repository the package automatically will grab it and place it in "inst/csv/".} - -\item{cdmFieldCsvLoc}{The location of the csv file with the CDM field information. This is defaulted to "inst/csv/OMOP_CDMv5.3.1_Field_Level.csv". -If a new version of this file was committed to the CDM repository the package automatically will grab it and place it in "inst/csv/".} - -\item{outputFile}{The name of the output ddl sql file. This is defaulted to a location in the inst/sql/sql server folder and named with today's date and the CDM version.} +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4} +} +\value{ +A character string containing the OHDSQL DDL } \description{ -Create a DDL script from a two csv files that detail the OMOP CDM Specifications. These files also form the basis of the CDM documentation and the Data Quality +The createDdl, createForeignKeys, and createPrimaryKeys functions each return a character string +containing their respective DDL SQL code in OHDSQL dialect for a specific CDM version. +The SQL they generate needs to be rendered and translated before it can be executed. +} +\details{ +The DDL SQL code is created from a two csv files that detail the OMOP CDM Specifications. +These files also form the basis of the CDM documentation and the Data Quality Dashboard. } +\section{Functions}{ +\itemize{ +\item \code{createPrimaryKeys}: createPrimaryKeys asdfladsfj + +\item \code{createForeignKeys}: createForeignKeys asdfladsf +}} + +\examples{ +ddl <- createDdl("5.4") +pk <- createPrimaryKeys("5.4") +fk <- createForeignKeys("5.4") +} diff --git a/man/createForeignKeys.Rd b/man/createForeignKeys.Rd deleted file mode 100644 index e5d54c3..0000000 --- a/man/createForeignKeys.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/createForeignKeys.R -\name{createForeignKeys} -\alias{createForeignKeys} -\title{Create a foreign key sql script from two csv files that detail the OMOP CDM Specifications.} -\usage{ -createForeignKeys(cdmVersion = cdmVersion) -} -\arguments{ -\item{cdmVersionNum}{The version of the CDM you are creating, e.g. 5.3.1} -} -\description{ -Create a foreign key sql script from two csv files that detail the OMOP CDM Specifications. -} diff --git a/man/createPrimaryKeys.Rd b/man/createPrimaryKeys.Rd deleted file mode 100644 index 53e5236..0000000 --- a/man/createPrimaryKeys.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/createPrimaryKeys.R -\name{createPrimaryKeys} -\alias{createPrimaryKeys} -\title{Create a primary key sql script from two csv files that detail the OMOP CDM Specifications.} -\usage{ -createPrimaryKeys(cdmVersion = cdmVersion) -} -\arguments{ -\item{cdmVersionNum}{The version of the CDM you are creating, e.g. 5.3} -} -\description{ -Create a primary key sql script from two csv files that detail the OMOP CDM Specifications. -} diff --git a/man/downloadCurrentDdl.Rd b/man/downloadCurrentDdl.Rd index 8b806b3..867c863 100644 --- a/man/downloadCurrentDdl.Rd +++ b/man/downloadCurrentDdl.Rd @@ -27,7 +27,8 @@ The default location is } \examples{ \dontrun{ -downloadCurrentDdl("OHDSI/CommonDataModel", pathToCsv="Sql\%20Server/OMOP\%20CDM\%20sql\%20server\%20ddl.txt") +downloadCurrentDdl("OHDSI/CommonDataModel", + pathToCsv="Sql\%20Server/OMOP\%20CDM\%20sql\%20server\%20ddl.txt") } } diff --git a/man/executeDdl.Rd b/man/executeDdl.Rd new file mode 100644 index 0000000..6a49797 --- /dev/null +++ b/man/executeDdl.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/executeDdl.R +\name{executeDdl} +\alias{executeDdl} +\title{Generate and execute the DDL on a database} +\usage{ +executeDdl( + connectionDetails, + cdmVersion, + cdmDatabaseSchema, + executeDdl = TRUE, + executePrimaryKey = TRUE, + executeForeignKey = TRUE, + ... +) +} +\arguments{ +\item{connectionDetails}{An object of class connectionDetails as created by the DatabaseConnector::createConnectionDetails function.} + +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4} + +\item{cdmDatabaseSchema}{The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server.} + +\item{executeDdl}{Should the DDL be executed? TRUE or FALSE} + +\item{executePrimaryKey}{Should the primary keys be added? TRUE or FALSE} + +\item{executeForeignKey}{Should the foreign keys be added? TRUE or FALSE} + +\item{...}{Other arguments passed on to DatabaseConnector::executeSql. (This allows the user to set the path to errorReportFile.)} +} +\description{ +This function will generate the DDL for a specific dbms and CDM version and +then execute the DDL on a database. +} +\examples{ +\dontrun{ +executeDdl(connectionDetails = connectionDetails, + cdmVersion = "5.4", + cdmDatabaseSchema = "myCdm") +} +} diff --git a/man/writeDDL.Rd b/man/writeDDL.Rd index d541d50..c245499 100644 --- a/man/writeDDL.Rd +++ b/man/writeDDL.Rd @@ -1,19 +1,61 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/writeDDL.R -\name{writeDDL} -\alias{writeDDL} +% Please edit documentation in R/writeDdl.R +\name{writeDdl} +\alias{writeDdl} +\alias{writePrimaryKeys} +\alias{writeForeignKeys} +\alias{writeIndex} \title{Write DDL script} \usage{ -writeDDL(targetdialect, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") +writeDdl( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writePrimaryKeys( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writeForeignKeys( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) + +writeIndex( + targetDialect, + cdmVersion, + outputpath, + cdmDatabaseSchema = "@cdmDatabaseSchema" +) } \arguments{ -\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} +\item{targetDialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} -\item{cdmVersion}{The version of the CDM for which you are creating the DDL. e.g. 5.3.1} +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4} + +\item{outputpath}{The directory or folder where the SQL file should be saved.} \item{cdmDatabaseSchema}{The schema of the CDM instance where the DDL will be run. For example, this would be "ohdsi.dbo" when testing on sql server. Defaults to "@cdmDatabaseSchema"} } \description{ -Write DDL script +Write the DDL to a SQL file. The SQL will be rendered (parameters replaced) and translated to the target SQL +dialect. By default the @cdmDatabaseSchema parameter is kept in the SQL file and needs to be replaced before +execution. } +\section{Functions}{ +\itemize{ +\item \code{writePrimaryKeys}: writePrimaryKeys Write the SQL code that creates the primary keys to a file. + +\item \code{writeForeignKeys}: writeForeignKeys Write the SQL code that creates the foreign keys to a file. + +\item \code{writeIndex}: writeIndex Write the rendered and translated sql that creates recommended indexes to a file. +}} + diff --git a/man/writeForeignKeys.Rd b/man/writeForeignKeys.Rd deleted file mode 100644 index fe4d855..0000000 --- a/man/writeForeignKeys.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/writeForeignKeys.R -\name{writeForeignKeys} -\alias{writeForeignKeys} -\title{Write constraint script} -\usage{ -writeForeignKeys( - targetdialect, - cdmVersion, - cdmDatabaseSchema = "@cdmDatabaseSchema" -) -} -\arguments{ -\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} - -\item{cdmVersion}{The version of the CDM that you are creating the primary keys for} - -\item{cdmDatabaseSchema}{The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema"} -} -\description{ -Write constraint script -} diff --git a/man/writeIndex.Rd b/man/writeIndex.Rd deleted file mode 100644 index 5042f3c..0000000 --- a/man/writeIndex.Rd +++ /dev/null @@ -1,18 +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, cdmVersion, cdmDatabaseSchema = "@cdmDatabaseSchema") -} -\arguments{ -\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} - -\item{cdmVersion}{The version of the CDM that you are creating the indices for. e.g. 5.3.1} - -\item{cdmDatabaseSchema}{The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema"} -} -\description{ -Write Index script -} diff --git a/man/writePrimaryKeys.Rd b/man/writePrimaryKeys.Rd deleted file mode 100644 index ad1e2ff..0000000 --- a/man/writePrimaryKeys.Rd +++ /dev/null @@ -1,22 +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, - cdmVersion, - cdmDatabaseSchema = "@cdmDatabaseSchema" -) -} -\arguments{ -\item{targetdialect}{The dialect of the target database. Choices are "oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server"} - -\item{cdmVersion}{The version of the CDM that you are creating the primary keys for} - -\item{cdmDatabaseSchema}{The name of the schema where the cdm sits. Defaults to "@cdmDatabaseSchema"} -} -\description{ -Write primary key script -} diff --git a/tests/setup.R b/tests/setup.R new file mode 100644 index 0000000..d4a2841 --- /dev/null +++ b/tests/setup.R @@ -0,0 +1,21 @@ +# Download the JDBC drivers used in the tests + +# oldJarFolder <- Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") + +driverPath <- file.path(Sys.getenv("HOME"), "drivers") +if(!dir.exists(driverPath)) dir.create(driverPath) +Sys.setenv("DATABASECONNECTOR_JAR_FOLDER" = driverPath) +DatabaseConnector::downloadJdbcDrivers("postgresql", pathToDriver = driverPath) + +print(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER")) +print(list.files(driverPath)) +# if(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER") == "") { + # driverPath <- file.path(Sys.getenv("HOME"), "drivers") +# } +# downloadJdbcDrivers("sql server") +# downloadJdbcDrivers("oracle") + +# withr::defer({ +# unlink(Sys.getenv("DATABASECONNECTOR_JAR_FOLDER"), recursive = TRUE, force = TRUE) +# Sys.setenv("DATABASECONNECTOR_JAR_FOLDER" = oldJarFolder) +# }, testthat::teardown_env()) diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..eaa35d8 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,4 @@ +library(testthat) +library(CommonDataModel) + +test_check("CommonDataModel") diff --git a/tests/testthat/test-createDdl.R b/tests/testthat/test-createDdl.R new file mode 100644 index 0000000..19dd82f --- /dev/null +++ b/tests/testthat/test-createDdl.R @@ -0,0 +1,38 @@ +test_that("createDdl works", { + # for(cdmVersion in listSupportedVersions()) { # 5.3 ddl csv control file is currently messed up. + cdmVersion <- "5.4" + sql <- createDdl(cdmVersion) + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + # } + + expect_error(createDdl(5.4)) + expect_error(createDdl("blah")) + +}) + +test_that("createPrimaryKeys works", { + # for(cdmVersion in listSupportedVersions()) { + cdmVersion <- "5.4" + sql <- createPrimaryKeys(cdmVersion) + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + # } + + expect_error(createPrimaryKeys(5.4)) + expect_error(createPrimaryKeys("blah")) +}) + +test_that("createForeignKeys works", { + # for(cdmVersion in listSupportedVersions()) { + cdmVersion <- "5.4" + sql <- createForeignKeys(cdmVersion) + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + # } + + expect_error(createForeignKeys(5.4)) + expect_error(createForeignKeys("blah")) +}) + + diff --git a/tests/testthat/test-executeDdl.R b/tests/testthat/test-executeDdl.R new file mode 100644 index 0000000..4710f7b --- /dev/null +++ b/tests/testthat/test-executeDdl.R @@ -0,0 +1,84 @@ +library(DatabaseConnector) + +connectionDetails <- createConnectionDetails( + dbms = "postgresql", + user = Sys.getenv("CDMDDLBASE_POSTGRESQL_USER"), + password = Sys.getenv("CDMDDLBASE_POSTGRESQL_PASSWORD"), + server = Sys.getenv("CDMDDLBASE_POSTGRESQL_SERVER"), + pathToDriver = file.path(Sys.getenv("HOME"), "drivers") +) + +# Helper functions used in tests +.listTablesInSchema <- function(connectionDetails, schema) { + con <- DatabaseConnector::connect(connectionDetails) + tables <- DBI::dbListObjects(con, prefix = "cdmddlbase") + DatabaseConnector::disconnect(con) + tables <- subset(tables, is_prefix == FALSE) + tables <- subset(tables, grepl("table", table))$table + tables <- vapply(tables, function(.) .@name, FUN.VALUE = character(1)) + return(tables) +} + +.dropAllTablesFromSchema <- function(connectionDetails, schema) { + tables <- .listTablesInSchema(connectionDetails, schema) + + con <- DatabaseConnector::connect(connectionDetails) + for(table in tables) { + DBI::dbRemoveTable(con, name = DBI::SQL(paste(schema, table, sep = "."))) + } + DatabaseConnector::disconnect(con) +} + +.removeConstraintsPostgresql <- function(connectionDetails, schema) { + # the order of removal of constraints matters! + con <- DatabaseConnector::connect(connectionDetails) + constraints <- DBI::dbGetQuery(con, + "SELECT con.conname, rel.relname as relname + FROM pg_catalog.pg_constraint con + INNER JOIN pg_catalog.pg_class rel + ON rel.oid = con.conrelid + INNER JOIN pg_catalog.pg_namespace nsp + ON nsp.oid = connamespace + WHERE nsp.nspname = 'cdmddlbase';") + + + constraints <- dplyr::mutate(constraints, sql = paste0("alter table ", schema, ".", relname, " drop constraint if exists ", conname, ";\n" )) + + sql <- paste(rev(constraints$sql), collapse = "") + executeSql(con, sql) + + disconnect(con) + +} + +test_that("Database can be connected to", { + expect_error(con <- connect(connectionDetails), NA) + disconnect(con) +}) + +test_that("Execute DDL on Postgres", { + # make sure the schema is cleared out + cdmDatabaseSchema <- Sys.getenv("CDMDDLBASE_POSTGRESQL_SCHEMA") + cdmVersion <- "5.4" + # .removeConstraintsPostgresql(connectionDetails, cdmDatabaseSchema) + .dropAllTablesFromSchema(connectionDetails, cdmDatabaseSchema) + cat(paste("Connecting to schema", cdmDatabaseSchema, "\n")) + executeDdl(connectionDetails, + cdmVersion = cdmVersion, + cdmDatabaseSchema = cdmDatabaseSchema, + executeDdl = TRUE, + executePrimaryKey = FALSE, + executeForeignKey = FALSE) + + tables <- .listTablesInSchema(connectionDetails, schema = cdmDatabaseSchema) + + cdmTableCsvLoc <- system.file(file.path("csv", paste0("OMOP_CDMv", cdmVersion, "_Table_Level.csv")), package = "CommonDataModel", mustWork = TRUE) + tableSpecs <- read.csv(cdmTableCsvLoc, stringsAsFactors = FALSE)$cdmTableName + + # check that the tables in the database match the tables in the specification + expect_equal(sort(tables), sort(tableSpecs)) + + # clear schema + # .removeConstraintsPostgresql(connectionDetails, cdmDatabaseSchema) + .dropAllTablesFromSchema(connectionDetails, cdmDatabaseSchema) +}) diff --git a/tests/testthat/test-writeDdl.R b/tests/testthat/test-writeDdl.R new file mode 100644 index 0000000..1c95f2b --- /dev/null +++ b/tests/testthat/test-writeDdl.R @@ -0,0 +1,51 @@ +test_that("writeDdl works", { + + outputpath <- tempdir(TRUE) + filename <- writeDdl(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + + expect_true(file.exists(file.path(outputpath, filename))) + sql <- readr::read_file(file.path(outputpath, filename)) + + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + +}) + +test_that("writePrimaryKeys works", { + + outputpath <- tempdir(TRUE) + filename <- writePrimaryKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + + expect_true(file.exists(file.path(outputpath, filename))) + sql <- readr::read_file(file.path(outputpath, filename)) + + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + +}) + +test_that("writeForeignKeys works", { + + outputpath <- tempdir(TRUE) + filename <- writeForeignKeys(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + + expect_true(file.exists(file.path(outputpath, filename))) + sql <- readr::read_file(file.path(outputpath, filename)) + + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + +}) + +test_that("writeIndex works", { + + outputpath <- tempdir(TRUE) + filename <- writeIndex(targetDialect = "postgresql", cdmVersion = "5.4", outputpath = outputpath) + + expect_true(file.exists(file.path(outputpath, filename))) + sql <- readr::read_file(file.path(outputpath, filename)) + + expect_type(sql, "character") + expect_gt(nchar(sql), 10) + +}) From 4be728e9d8cdcf32ee5bf2738c15425356eb671a Mon Sep 17 00:00:00 2001 From: Andryc Date: Thu, 19 Aug 2021 12:20:49 -0400 Subject: [PATCH 3/7] Updates to yml and cdm531.Rmd --- rmd/cdm53.Rmd | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ rmd/cdm54.Rmd | 107 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 216 insertions(+) create mode 100644 rmd/cdm53.Rmd create mode 100644 rmd/cdm54.Rmd diff --git a/rmd/cdm53.Rmd b/rmd/cdm53.Rmd new file mode 100644 index 0000000..e7d234b --- /dev/null +++ b/rmd/cdm53.Rmd @@ -0,0 +1,109 @@ +--- +output: + # pdf_document: + # toc: yes + # toc_depth: '5' + html_document: + toc: yes + toc_depth: 5 + toc_float: yes +--- + +```{r setup, include=FALSE, eval=TRUE} + +#todo figure out how to get the document dynamically without specifying the name +library(rmarkdown) +library(knitr) +library(kableExtra) +library(magrittr) +library(dplyr) +library(stringr) + +``` + +# **OMOP CDM v5.3** + +Below is the specification document for the OMOP Common Data Model, v5.3 (previously v5.3.1). Each table is represented with a high-level description and ETL conventions that should be followed. This is continued with a discussion of each field in each table, any conventions related to the field, and constraints that should be followed (like primary key, foreign key, etc). Should you have questions please feel free to visit the [forums](https://forums.ohdsi.org/) or the [github issue](https://github.com/ohdsi/CommonDataModel/issues) page. + +*__Special Note__ This documentation previously referenced v5.3.1. During the OHDSI/CommonDataModel Hack-A-Thon that occurred on August 18, 2021 the decision was made to align documentation with the minor releases. Hot fixes and minor.minor release can be found through the searching of tags.* + +--after regeneration of DDLs +link to csv of cdm +link to pdf of cdm documentation +link to forum on doc page + +```{r docLoop53, echo=FALSE, results='asis'} +tableSpecs <- read.csv("../inst/csv/OMOP_CDMv5.3_Table_Level.csv", stringsAsFactors = FALSE) +cdmSpecs <- read.csv("../inst/csv/OMOP_CDMv5.3_Field_Level.csv", stringsAsFactors = FALSE) + +tables <- tableSpecs$cdmTableName + +cdmSpecsClean <- cdmSpecs %>% + dplyr::select(`CDM Table` = cdmTableName, + `CDM Field` = cdmFieldName, + `User Guide` = userGuidance, + `ETL Conventions` = etlConventions, + `Datatype` = cdmDatatype, + `Required` = isRequired, + `Primary Key` = isPrimaryKey, + `Foreign Key` = isForeignKey, + `FK Table` = fkTableName, + `FK Domain` = fkDomain + ) + +cdmSpecsClean[is.na(cdmSpecsClean)] <- "" + +for(tb in tables) { + + if(tb == 'PERSON'){ + cat("## **Clinical Data Tables**\n\n") + } + + if(tb == 'LOCATION'){ + cat("## **Health System Data Tables**\n\n") + } + + if(tb == 'PAYER_PLAN_PERIOD'){ + cat("## **Health Economics Data Tables**\n\n") + } + + if(tb == 'DRUG_ERA'){ + cat("## **Standardized Derived Elements**\n\n") + } + + if(tb == 'METADATA'){ + cat("## **Metadata Tables**\n\n") + } + if(tb == 'CONCEPT'){ + cat("## **Vocabulary Tables**\n\n") + } + + cat("###", tb, "{.tabset .tabset-pills} \n\n") + + tableInfo <- subset(tableSpecs, cdmTableName == tb) + cat("**Table Description**\n\n",tableInfo[,"tableDescription"], "\n\n") + + if(!isTRUE(tableInfo[,"userGuidance"]=="")){ + cat("**User Guide**\n\n",tableInfo[,"userGuidance"],"\n\n") + } + + if(!isTRUE(tableInfo[,"etlConventions"]=="")){ + cat("**ETL Conventions**\n\n",tableInfo[,"etlConventions"],"\n\n") + } + + loopTable <- subset(cdmSpecsClean, `CDM Table` == tb) + loopTable <- subset(loopTable, select = -c(1)) + + print(kable(x = loopTable, align = "l", row.names = FALSE, format = "html", escape = FALSE) %>% + column_spec(1, bold = T) %>% + column_spec(2, width = "3in", include_thead = T) %>% + column_spec(3, width = "4in", include_thead = T) %>% + column_spec(4:9, width = "1in", include_thead = T) %>% + kable_styling(c("condensed","hover"), position = "center", full_width = T, font_size = 13)) + + + } + + + +``` diff --git a/rmd/cdm54.Rmd b/rmd/cdm54.Rmd new file mode 100644 index 0000000..2cbcfda --- /dev/null +++ b/rmd/cdm54.Rmd @@ -0,0 +1,107 @@ +--- +output: + # pdf_document: + # toc: yes + # toc_depth: '5' + html_document: + toc: yes + toc_depth: 5 + toc_float: yes +--- + +```{r setup, include=FALSE, eval=TRUE} + +#todo figure out how to get the document dynamically without specifying the name +library(rmarkdown) +library(knitr) +library(kableExtra) +library(magrittr) +library(dplyr) +library(stringr) + +``` + +# **OMOP CDM v5.4** + +Below is the specification document for the OMOP Common Data Model, v5.4. Each table is represented with a high-level description and ETL conventions that should be followed. This is continued with a discussion of each field in each table, any conventions related to the field, and constraints that should be followed (like primary key, foreign key, etc). Should you have questions please feel free to visit the [forums](https://forums.ohdsi.org/) or the [github issue](https://github.com/ohdsi/CommonDataModel/issues) page. + +--after regeneration of DDLs +link to csv of cdm +link to pdf of cdm documentation +link to forum on doc page + +```{r docLoop53, echo=FALSE, results='asis'} +tableSpecs <- read.csv("../inst/csv/OMOP_CDMv5.4_Table_Level.csv", stringsAsFactors = FALSE) +cdmSpecs <- read.csv("../inst/csv/OMOP_CDMv5.4_Field_Level.csv", stringsAsFactors = FALSE) + +tables <- tableSpecs$cdmTableName + +cdmSpecsClean <- cdmSpecs %>% + dplyr::select(`CDM Table` = cdmTableName, + `CDM Field` = cdmFieldName, + `User Guide` = userGuidance, + `ETL Conventions` = etlConventions, + `Datatype` = cdmDatatype, + `Required` = isRequired, + `Primary Key` = isPrimaryKey, + `Foreign Key` = isForeignKey, + `FK Table` = fkTableName, + `FK Domain` = fkDomain + ) + +cdmSpecsClean[is.na(cdmSpecsClean)] <- "" + +for(tb in tables) { + + if(tb == 'PERSON'){ + cat("## **Clinical Data Tables**\n\n") + } + + if(tb == 'LOCATION'){ + cat("## **Health System Data Tables**\n\n") + } + + if(tb == 'PAYER_PLAN_PERIOD'){ + cat("## **Health Economics Data Tables**\n\n") + } + + if(tb == 'DRUG_ERA'){ + cat("## **Standardized Derived Elements**\n\n") + } + + if(tb == 'METADATA'){ + cat("## **Metadata Tables**\n\n") + } + if(tb == 'CONCEPT'){ + cat("## **Vocabulary Tables**\n\n") + } + + cat("###", tb, "{.tabset .tabset-pills} \n\n") + + tableInfo <- subset(tableSpecs, cdmTableName == tb) + cat("**Table Description**\n\n",tableInfo[,"tableDescription"], "\n\n") + + if(!isTRUE(tableInfo[,"userGuidance"]=="")){ + cat("**User Guide**\n\n",tableInfo[,"userGuidance"],"\n\n") + } + + if(!isTRUE(tableInfo[,"etlConventions"]=="")){ + cat("**ETL Conventions**\n\n",tableInfo[,"etlConventions"],"\n\n") + } + + loopTable <- subset(cdmSpecsClean, `CDM Table` == tb) + loopTable <- subset(loopTable, select = -c(1)) + + print(kable(x = loopTable, align = "l", row.names = FALSE, format = "html", escape = FALSE) %>% + column_spec(1, bold = T) %>% + column_spec(2, width = "3in", include_thead = T) %>% + column_spec(3, width = "4in", include_thead = T) %>% + column_spec(4:9, width = "1in", include_thead = T) %>% + kable_styling(c("condensed","hover"), position = "center", full_width = T, font_size = 13)) + + + } + + + +``` From a2812b85e56e5ef0906f1a3e9fc6a4cb285aaf80 Mon Sep 17 00:00:00 2001 From: Clair Blacketer Date: Thu, 19 Aug 2021 12:45:44 -0400 Subject: [PATCH 4/7] Added EPISODE and EPISODE_EVENT tables to table_level_5.4 Also update the oncology extension documents to align with the table level file for v5.4 --- inst/csv/OMOP_CDM_Oncology_Ex_Field_Level.csv | 40 +- inst/csv/OMOP_CDM_Oncology_Ex_Table_Level.csv | 23 +- inst/csv/OMOP_CDMv5.4_Field_Level.csv | 818 +++++++++--------- 3 files changed, 432 insertions(+), 449 deletions(-) diff --git a/inst/csv/OMOP_CDM_Oncology_Ex_Field_Level.csv b/inst/csv/OMOP_CDM_Oncology_Ex_Field_Level.csv index d34295c..dff9e78 100644 --- a/inst/csv/OMOP_CDM_Oncology_Ex_Field_Level.csv +++ b/inst/csv/OMOP_CDM_Oncology_Ex_Field_Level.csv @@ -1,21 +1,19 @@ -cdmTableName,cdmFieldName,isRequired,cdmDatatype,userGuidance,etlConventions,isPrimaryKey,isForeignKey,fkTableName,fkFieldName,fkDomain,fkClass -EPISODE,episode_id,Yes,bigint,A unique identifier for each Episode event.,,Yes,No,,,, -EPISODE,person_id,Yes,bigint,A foreign key identifier to the Person who is experiencing the episdoe. The demographic details of that Person are stored in the PERSON table.,,No,Yes,PERSON,PERSON_ID,, -EPISODE,episode_concept_id,Yes,integer,A foreign key that refers to a Standard Concept identifier in the Standardized Vocabularies belonging to the 'Episode' domain.,,No,Yes,,,Episode, -EPISODE,episode_start_datetime,Yes,datetime,The date and time when the Episode begins.,,No,No,,,, -EPISODE,episode_end_datetime,No,datetime,The date when the instance of the Episode is considered to have ended.,,No,No,,,, -EPISODE,episode_parent_id,No,bigint,A foreign key that refers to a parent Episode entry representing an entire episode if the episode spans multiple cycles.,,No,No,,,, -EPISODE,episode_number,No,integer,An ordinal count for an Episode that spans multiple times.,,No,No,,,, -EPISODE,episode_object_concept_id,Yes,integer,"A foreign key that refers to a concept identifier in the Standardized Vocabularies describing the disease, treatment, or other abstraction that the episode describes. Episode entries from the 'Disease Episode' concept class should have an episode_object_concept_id that comes from the Condition domain. Episode entries from the 'Treatment Episode' concept class should have an episode_object_concept_id that scome from the 'Procedure' or 'Regimen' domain.",,No,Yes,CONCEPT,CONCEPT_ID,"Procedure, Regimen", -EPISODE,episode_type_concept_id,Yes,integer,"A foreign key to the predefined Concept identifier in the Standardized Vocabularies reflecting the source data from which the Episode was recorded, the level of standardization, and the type of occurrence. These belong to the 'Episode Type' vocabulary",,No,Yes,CONCEPT,CONCEPT_ID,Type Concept, -EPISODE,episode_source_value,No,varchar(50),The source code for the Episdoe as it appears in the source data. This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,,No,No,,,, -EPISODE,episode_source_concept_id,No,integer,A foreign key to a Episdoe Concept that refers to the code used in the source.,,No,Yes,CONCEPT,CONCEPT_ID,, -EPISODE_EVENT,episode_id,Yes,bigint,A foreign key identifier to the Episode that the Episode Event belongs to.,,No,Yes,EPISODE,EPISODE_ID,Episode, -EPISODE_EVENT,event_id,Yes,bigint,"A foreign key identifier to the underlying event (condition, procedure, measurement, etc.) record in a respective table for which an episode is recorded.",,No,No,,,, -EPISODE_EVENT,episode_event_field_concept_id,Yes,integer,"A foreign key identifier to the standardized concept corresponding to the table primary key column (condition_occurrence.condition_occurrence_id, procedure_occurrence.procedure_occurrence_id, measurment.measurment_id etc.) where the underlying event is stored.",,No,Yes,CONCEPT,CONCEPT_ID,Metadata, -MEASUREMENT,modifier_of_event_id,No,bigint,"A foreign key identifier to the event (e.g. condition, procedure, episode) record for which the modifier is recorded.",,No,No,,,, -MEASUREMENT,modifier_of_field_concept_id,No,integer,The concept representing the table field concept that contains the value of the event id for which the modifier is recorded (e.g. CONDITION_OCCURRENCE.condition_occurre nce_id).,,No,Yes,CONCEPT,CONCEPT_ID,Metadata, -CONCEPT_NUMERIC,concept_id,Yes,integer,A foreign key that refers to a respective concept in the Standardized Vocabularies.,,No,Yes,CONCEPT,CONCEPT_ID,, -CONCEPT_NUMERIC,value_as_number,Yes,float,A value of the concept expressed as a numeric value.,,No,No,,,, -CONCEPT_NUMERIC,unit_concept_id,No,integer,A foreign key to a Standard Concept ID of the concept units in the Standardized Vocabularies that belong to the 'Unit' domain.,,No,Yes,CONCEPT,CONCEPT_ID,, -CONCEPT_NUMERIC,operator_concept_id,yes,float,"A foreign key identifier to the predefined Concept in the Standardized Vocabularies reflecting the mathematical operator that is applied to the value_as_number. Operators are <, <=, =, >=, > and these concepts belong to the 'Meas Value Operator' domain.",,No,Yes,CONCEPT,CONCEPT_ID,, +cdmTableName,cdmFieldName,isRequired,cdmDatatype,userGuidance,etlConventions,isPrimaryKey,isForeignKey,fkTableName,fkFieldName,fkDomain,fkClass +EPISODE,episode_id,Yes,bigint,A unique identifier for each Episode.,,Yes,No,,,, +EPISODE,person_id,Yes,bigint,The PERSON_ID of the PERSON for whom the episode is recorded.,,No,Yes,PERSON,PERSON_ID,, +EPISODE,episode_concept_id,Yes,integer,"The EPISODE_CONCEPT_ID represents the kind abstraction related to the disease phase, outcome or treatment.","Choose a concept in the Episode domain that best represents the ongoing disease phase, outcome, or treatment. Please see [article] for cancers and [article] for non-cancers describing how these are defined. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Episode&page=1&pageSize=15&query=)",No,Yes,,,Episode, +EPISODE,episode_start_date,Yes,date,The date when the Episode beings. ,Please see [article] for how to define an Episode start date.,No,No,,,, +EPISODE,episode_start_datetime,No,datetime,The date and time when the Episode begins.,,No,No,,,, +EPISODE,episode_end_date,No,date,The date when the instance of the Episode is considered to have ended.,Please see [article] for how to define an Episode end date.,,,,,, +EPISODE,episode_end_datetime,No,datetime,The date when the instance of the Episode is considered to have ended.,,No,No,,,, +EPISODE,episode_parent_id,No,bigint,Use this field to find the Episode that subsumes the given Episode record. This is used in the case that an Episode are nested into each other.,"If there are multiple nested levels to how Episodes are represented, the EPISODE_PARENT_ID can be used to record this relationship. ",No,No,,,, +EPISODE,episode_number,No,integer,"For sequences of episodes, this is used to indicate the order the episodes occurred. For example, lines of treatment could be indicated here. ",Please see [article] for the details of how to count episodes.,No,No,,,, +EPISODE,episode_object_concept_id,Yes,integer,"A Standard Concept representing the disease phase, outcome, or other abstraction of which the episode consists. For example, if the EPISODE_CONCEPT_ID is [treatment regimen](https://athena.ohdsi.org/search-terms/terms/32531) then the EPISODE_OBJECT_CONCEPT_ID should contain the chemotherapy regimen concept, like [Afatinib monotherapy](https://athena.ohdsi.org/search-terms/terms/35804392). ",Episode entries from the 'Disease Episode' concept class should have an episode_object_concept_id that comes from the Condition domain. Episode entries from the 'Treatment Episode' concept class should have an episode_object_concept_id that scome from the 'Procedure' domain or 'Regimen' concept class.,No,Yes,CONCEPT,CONCEPT_ID,"Procedure, Regimen", +EPISODE,episode_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Episode record, as in whether the episode was from an EHR system, insurance claim, registry, or other sources.",Choose the EPISODE_TYPE_CONCEPT_ID that best represents the provenance of the record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept, +EPISODE,episode_source_value,No,varchar(50),The source code for the Episdoe as it appears in the source data. This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,,No,No,,,, +EPISODE,episode_source_concept_id,No,integer,A foreign key to a Episode Concept that refers to the code used in the source.,Given that the Episodes are user-defined it is unlikely that there will be a Source Concept available. If that is the case then set this field to zero. ,No,Yes,CONCEPT,CONCEPT_ID,, +EPISODE_EVENT,episode_id,Yes,bigint,Use this field to link the EPISODE_EVENT record to its EPISODE.,Put the EPISODE_ID that subsumes the EPISODE_EVENT record here.,No,Yes,EPISODE,EPISODE_ID,, +EPISODE_EVENT,event_id,Yes,bigint,"This field is the primary key of the linked record in the database. For example, if the Episode Event is a Condition Occurrence, then the CONDITION_OCCURRENCE_ID of the linked record goes in this field. ",Put the primary key of the linked record here. ,No,No,,,, +EPISODE_EVENT,episode_event_field_concept_id,Yes,integer,This field is the CONCEPT_ID that identifies which table the primary key of the linked record came from. ,Put the CONCEPT_ID that identifies which table and field the EVENT_ID came from. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?vocabulary=CDM&conceptClass=Field&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Metadata, +MEASUREMENT,modifier_of_event_id,No,bigint,"If the Measurement record is related to another record in the database, this field is the primary key of the linked record. ","Put the primary key of the linked record, if applicable, here. ",No,No,,,, +MEASUREMENT,modifier_of_field_concept_id,No,integer,"If the Measurement record is related to another record in the database, this field is the CONCEPT_ID that identifies which table the primary key of the linked record came from. ",Put the CONCEPT_ID that identifies which table and field the MODIFIER_OF_EVENT_ID came from. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?vocabulary=CDM&conceptClass=Field&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Metadata, \ No newline at end of file diff --git a/inst/csv/OMOP_CDM_Oncology_Ex_Table_Level.csv b/inst/csv/OMOP_CDM_Oncology_Ex_Table_Level.csv index 6a25a1c..4820ea4 100644 --- a/inst/csv/OMOP_CDM_Oncology_Ex_Table_Level.csv +++ b/inst/csv/OMOP_CDM_Oncology_Ex_Table_Level.csv @@ -1,19 +1,4 @@ -cdmTableName,schema,isRequired,conceptPrefix,measurePersonCompleteness,measurePersonCompletenessThreshold,validation,tableDescription,userGuidance,etlConventions -EPISODE,CDM,No,,No,0,,"The EPISODE table aggregates lower-level clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) into a higher-level abstraction representing clinically and analytically relevant disease phases/outcomes and treatments. The EPISODE_EVENT table connects qualifying clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) to the appropriate EPISODE entry.",,"Valid Episode Concepts belong to the 'Episode' domain.

-Standard Episode Concepts are categorized by concept class:
-Disease Episode
-  32528 ""Disease First Occurrence""
-  32529 ""Disease Recurrence""
-  32530 ""Disease Remission""
-  32677 ""Disease Progression""
-Treatment Episode -  32531 ""Treatment Regimen""
-  32532 ""Treatment Cycle""
-Episode of Care -  32533 ""Episode of Care""

-The relationship between a disease episode and treatment episodes can be represented by the self-referencing foreign key column EPISODE.episode_parent_id.

-A treatment EPISODE can be delivered at regular intervals, cycles or fractions. The parent-child relationship between a treatment episode and its constituent treatment cycles can be represented by the self-referencing foreign key column EPISODE.episode_parent_id. -5 Some episodes may not have links to any underlying clinical events. For such episodes, the EPISODE_EVENT table is not populated." -EPISODE_EVENT,CDM,No,,No,0,,"The EPISODE_EVENT table connects qualifying clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) to the appropriate EPISODE entry. The EPISODE_EVENT table supports the linkage of an EPISODE abstraction to the low-level clinical events that implement the EPISODE abstraction.",,"Some episodes may not have links to any underlying clinical events. For such episodes, the EPISODE_EVENT table is not populated." -MEASUREMENT,CDM,No,MEASUREMENT_,Yes,0,,"The MEASUREMENT table contains records of Measurement, i.e. structured values (numerical or categorical) obtained through systematic and standardized examination or testing of a Person or Person's sample. The MEASUREMENT table contains both orders and results of such Measurements as laboratory tests, vital signs, quantitative findings from pathology reports, etc. Measurements are stored as attribute value pairs, with the attribute as the Measurement Concept and the value representing the result. The value can be a Concept (stored in VALUE_AS_CONCEPT), or a numerical value (VALUE_AS_NUMBER) with a Unit (UNIT_CONCEPT_ID).",Measurements differ from Observations in that they require a standardized test or some other activity to generate a quantitative or qualitative result. , -CONCEPT_NUMERIC,VOCAB,No,,No,0,,"In this table, numeric values, units and math operators indicating range limits (less than) corresponding to ""numeric"" concepts will be stored. It is an extension of the OMOP CDM and vocabulary that supports formal representation of concepts containing numeric values or ranges. This proposal has not yet been ratified by a larger CDM Workgroup. However, it plays a critical role in supporting ETL from tumor registries. NAACCR vocabulary includes concepts representing numeric values or numeric ranges. Often, these concepts also contain measurement units. For example, ""Described as less than 1 centimeter (cm)"". In OMOP CDM, these concepts are normally used in Measurement and Observation tables to store value_as_concept_id. Analysis of these data is currently possible only if the user knows exactly which concepts are used to represent range or value, including their respective units. It is not possible to perform analysis on numeric values of these data, nor is it possible to differentiate numeric values by units. ",, +cdmTableName,schema,isRequired,conceptPrefix,measurePersonCompleteness,measurePersonCompletenessThreshold,validation,tableDescription,userGuidance,etlConventions +EPISODE,CDM,No,,No,0,,"The EPISODE table aggregates lower-level clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) into a higher-level abstraction representing clinically and analytically relevant disease phases,outcomes and treatments. The EPISODE_EVENT table connects qualifying clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) to the appropriate EPISODE entry. For example cancers including their development over time, their treatment, and final resolution. ","Valid Episode Concepts belong to the 'Episode' domain. For cancer episodes please see [article], for non-cancer episodes please see [article]. If your source data does not have all episodes that are relevant to the therapeutic area, write only those you can easily derive from the data. It is understood that that table is not currently expected to be comprehensive. ", +EPISODE_EVENT,CDM,No,,No,0,,"The EPISODE_EVENT table connects qualifying clinical events (such as CONDITION_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, MEASUREMENT) to the appropriate EPISODE entry. For example, linking the precise location of the metastasis (cancer modifier in MEASUREMENT) to the disease episode. ",This connecting table is used instead of the FACT_RELATIONSHIP table for linking low-level events to abstracted Episodes.,"Some episodes may not have links to any underlying clinical events. For such episodes, the EPISODE_EVENT table is not populated." +MEASUREMENT,CDM,No,MEASUREMENT_,Yes,0,,"The MEASUREMENT table contains records of Measurement, i.e. structured values (numerical or categorical) obtained through systematic and standardized examination or testing of a Person or Person's sample. The MEASUREMENT table contains both orders and results of such Measurements as laboratory tests, vital signs, quantitative findings from pathology reports, etc. Measurements are stored as attribute value pairs, with the attribute as the Measurement Concept and the value representing the result. The value can be a Concept (stored in VALUE_AS_CONCEPT), or a numerical value (VALUE_AS_NUMBER) with a Unit (UNIT_CONCEPT_ID).",Measurements differ from Observations in that they require a standardized test or some other activity to generate a quantitative or qualitative result. , \ No newline at end of file diff --git a/inst/csv/OMOP_CDMv5.4_Field_Level.csv b/inst/csv/OMOP_CDMv5.4_Field_Level.csv index 07ccc76..0b0ae76 100644 --- a/inst/csv/OMOP_CDMv5.4_Field_Level.csv +++ b/inst/csv/OMOP_CDMv5.4_Field_Level.csv @@ -1,223 +1,223 @@ -cdmTableName,cdmFieldName,isRequired,cdmDatatype,userGuidance,etlConventions,isPrimaryKey,isForeignKey,fkTableName,fkFieldName,fkDomain,fkClass,unique DQ identifiers -PERSON,person_id,Yes,integer,It is assumed that every person with a different unique identifier is in fact a different person and should be treated independently.,"Any person linkage that needs to occur to uniquely identify Persons ought to be done prior to writing this table. This identifier can be the original id from the source data provided if it is an integer, otherwise it can be an autogenerated number.",Yes,No,,,,, -PERSON,gender_concept_id,Yes,integer,This field is meant to capture the biological sex at birth of the Person. This field should not be used to study gender identity issues.,Use the gender or sex value present in the data under the assumption that it is the biological sex at birth. If the source data captures gender identity it should be stored in the [OBSERVATION](https://ohdsi.github.io/CommonDataModel/cdm531.html#observation) table. [Accepted gender concepts](http://athena.ohdsi.org/search-terms/terms?domain=Gender&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Gender,, -PERSON,year_of_birth,Yes,integer,Compute age using year_of_birth.,"For data sources with date of birth, the year should be extracted. For data sources where the year of birth is not available, the approximate year of birth could be derived based on age group categorization, if available.",No,No,,,,, -PERSON,month_of_birth,No,integer,,"For data sources that provide the precise date of birth, the month should be extracted and stored in this field.",No,No,,,,, -PERSON,day_of_birth,No,integer,,"For data sources that provide the precise date of birth, the day should be extracted and stored in this field.",No,No,,,,, -PERSON,birth_datetime,No,datetime,,"This field is not required but highly encouraged. For data sources that provide the precise datetime of birth, that value should be stored in this field. If birth_datetime is not provided in the source, use the following logic to infer the date: If day_of_birth is null and month_of_birth is not null then use the first of the month in that year. If month_of_birth is null or if day_of_birth AND month_of_birth are both null and the person has records during their year of birth then use the date of the earliest record, otherwise use the 15th of June of that year. If time of birth is not given use midnight (00:00:0000).",No,No,,,,, -PERSON,race_concept_id,Yes,integer,This field captures race or ethnic background of the person.,"Only use this field if you have information about race or ethnic background. The Vocabulary contains Concepts about the main races and ethnic backgrounds in a hierarchical system. Due to the imprecise nature of human races and ethnic backgrounds, this is not a perfect system. Mixed races are not supported. If a clear race or ethnic background cannot be established, use Concept_Id 0. [Accepted Race Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Race&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Race,, -PERSON,ethnicity_concept_id,Yes,integer,"This field captures Ethnicity as defined by the Office of Management and Budget (OMB) of the US Government: it distinguishes only between ""Hispanic"" and ""Not Hispanic"". Races and ethnic backgrounds are not stored here.",Only use this field if you have US-based data and a source of this information. Do not attempt to infer Ethnicity from the race or ethnic background of the Person. [Accepted ethnicity concepts](http://athena.ohdsi.org/search-terms/terms?domain=Ethnicity&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Ethnicity,, -PERSON,location_id,No,integer,The location refers to the physical address of the person. This field should capture the last known location of the person. ,"Put the location_id from the [LOCATION](https://ohdsi.github.io/CommonDataModel/cdm531.html#location) table here that represents the most granular location information for the person. This could represent anything from postal code or parts thereof, state, or county for example. Since many databases contain deidentified data, it is common that the precision of the location is reduced to prevent re-identification. This field should capture the last known location. ",No,Yes,LOCATION,LOCATION_ID,,, -PERSON,provider_id,No,integer,The Provider refers to the last known primary care provider (General Practitioner).,"Put the provider_id from the [PROVIDER](https://ohdsi.github.io/CommonDataModel/cdm531.html#provider) table of the last known general practitioner of the person. If there are multiple providers, it is up to the ETL to decide which to put here.",No,Yes,PROVIDER,PROVIDER_ID,,, -PERSON,care_site_id,No,integer,The Care Site refers to where the Provider typically provides the primary care.,,No,Yes,CARE_SITE,CARE_SITE_ID,,, -PERSON,person_source_value,No,varchar(50),Use this field to link back to persons in the source data. This is typically used for error checking of ETL logic.,Some use cases require the ability to link back to persons in the source data. This field allows for the storing of the person value as it appears in the source. This field is not required but strongly recommended.,No,No,,,,, -PERSON,gender_source_value,No,varchar(50),This field is used to store the biological sex of the person from the source data. It is not intended for use in standard analytics but for reference only.,Put the biological sex of the person as it appears in the source data.,No,No,,,,, -PERSON,gender_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.","If the source data codes biological sex in a non-standard vocabulary, store the concept_id here.",No,Yes,CONCEPT,CONCEPT_ID,,, -PERSON,race_source_value,No,varchar(50),This field is used to store the race of the person from the source data. It is not intended for use in standard analytics but for reference only.,Put the race of the person as it appears in the source data.,No,No,,,,, -PERSON,race_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.",If the source data codes race in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PERSON,ethnicity_source_value,No,varchar(50),This field is used to store the ethnicity of the person from the source data. It is not intended for use in standard analytics but for reference only.,"If the person has an ethnicity other than the OMB standard of ""Hispanic"" or ""Not Hispanic"" store that value from the source data here.",No,No,,,,, -PERSON,ethnicity_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.","If the source data codes ethnicity in an OMOP supported vocabulary, store the concept_id here.",No,Yes,CONCEPT,CONCEPT_ID,,, -OBSERVATION_PERIOD,observation_period_id,Yes,integer,A Person can have multiple discrete Observation Periods which are identified by the Observation_Period_Id.,Assign a unique observation_period_id to each discrete Observation Period for a Person.,Yes,No,,,,, -OBSERVATION_PERIOD,person_id,Yes,integer,The Person ID of the PERSON record for which the Observation Period is recorded.,,No,Yes,PERSON,PERSON_ID,,, -OBSERVATION_PERIOD,observation_period_start_date,Yes,date,Use this date to determine the start date of the Observation Period.,"It is often the case that the idea of Observation Periods does not exist in source data. In those cases, the observation_period_start_date can be inferred as the earliest Event date available for the Person. In insurance claim data, the Observation Period can be considered as the time period the Person is enrolled with a payer. If a Person switches plans but stays with the same payer, and therefore capturing of data continues, that change would be captured in [PAYER_PLAN_PERIOD](https://ohdsi.github.io/CommonDataModel/cdm531.html#payer_plan_period).",No,No,,,,, -OBSERVATION_PERIOD,observation_period_end_date,Yes,date,Use this date to determine the end date of the period for which we can assume that all events for a Person are recorded.,"It is often the case that the idea of Observation Periods does not exist in source data. In those cases, the observation_period_end_date can be inferred as the last Event date available for the Person. In insurance claim data, the Observation Period can be considered as the time period the Person is enrolled with a payer.",No,No,,,,, -OBSERVATION_PERIOD,period_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Observation Period as in whether the period was determined from an insurance enrollment file, EHR healthcare encounters, or other sources.",Choose the observation_period_type_concept_id that best represents how the period was determined. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -VISIT_OCCURRENCE,visit_occurrence_id,Yes,integer,Use this to identify unique interactions between a person and the health care system. This identifier links across the other CDM event tables to associate events with a visit.,This should be populated by creating a unique identifier for each unique interaction between a person and the healthcare system where the person receives a medical good or service over a span of time.,Yes,No,,,,, -VISIT_OCCURRENCE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -VISIT_OCCURRENCE,visit_concept_id,Yes,integer,"This field contains a concept id representing the kind of visit, like inpatient or outpatient. All concepts in this field should be standard and belong to the Visit domain.","Populate this field based on the kind of visit that took place for the person. For example this could be ""Inpatient Visit"", ""Outpatient Visit"", ""Ambulatory Visit"", etc. This table will contain standard concepts in the Visit domain. These concepts are arranged in a hierarchical structure to facilitate cohort definitions by rolling up to generally familiar Visits adopted in most healthcare systems worldwide. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_OCCURRENCE,visit_start_date,Yes,date,"For inpatient visits, the start date is typically the admission date. For outpatient visits the start date and end date will be the same.","When populating VISIT_START_DATE, you should think about the patient experience to make decisions on how to define visits. In the case of an inpatient visit this should be the date the patient was admitted to the hospital or institution. In all other cases this should be the date of the patient-provider interaction.",No,No,,,,, -VISIT_OCCURRENCE,visit_start_datetime,No,datetime,,"If no time is given for the start date of a visit, set it to midnight (00:00:0000).",No,No,,,,, +cdmTableName,cdmFieldName,isRequired,cdmDatatype,userGuidance,etlConventions,isPrimaryKey,isForeignKey,fkTableName,fkFieldName,fkDomain,fkClass,unique DQ identifiers +PERSON,person_id,Yes,integer,It is assumed that every person with a different unique identifier is in fact a different person and should be treated independently.,"Any person linkage that needs to occur to uniquely identify Persons ought to be done prior to writing this table. This identifier can be the original id from the source data provided if it is an integer, otherwise it can be an autogenerated number.",Yes,No,,,,, +PERSON,gender_concept_id,Yes,integer,This field is meant to capture the biological sex at birth of the Person. This field should not be used to study gender identity issues.,Use the gender or sex value present in the data under the assumption that it is the biological sex at birth. If the source data captures gender identity it should be stored in the [OBSERVATION](https://ohdsi.github.io/CommonDataModel/cdm531.html#observation) table. [Accepted gender concepts](http://athena.ohdsi.org/search-terms/terms?domain=Gender&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Gender,, +PERSON,year_of_birth,Yes,integer,Compute age using year_of_birth.,"For data sources with date of birth, the year should be extracted. For data sources where the year of birth is not available, the approximate year of birth could be derived based on age group categorization, if available.",No,No,,,,, +PERSON,month_of_birth,No,integer,,"For data sources that provide the precise date of birth, the month should be extracted and stored in this field.",No,No,,,,, +PERSON,day_of_birth,No,integer,,"For data sources that provide the precise date of birth, the day should be extracted and stored in this field.",No,No,,,,, +PERSON,birth_datetime,No,datetime,,"This field is not required but highly encouraged. For data sources that provide the precise datetime of birth, that value should be stored in this field. If birth_datetime is not provided in the source, use the following logic to infer the date: If day_of_birth is null and month_of_birth is not null then use the first of the month in that year. If month_of_birth is null or if day_of_birth AND month_of_birth are both null and the person has records during their year of birth then use the date of the earliest record, otherwise use the 15th of June of that year. If time of birth is not given use midnight (00:00:0000).",No,No,,,,, +PERSON,race_concept_id,Yes,integer,This field captures race or ethnic background of the person.,"Only use this field if you have information about race or ethnic background. The Vocabulary contains Concepts about the main races and ethnic backgrounds in a hierarchical system. Due to the imprecise nature of human races and ethnic backgrounds, this is not a perfect system. Mixed races are not supported. If a clear race or ethnic background cannot be established, use Concept_Id 0. [Accepted Race Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Race&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Race,, +PERSON,ethnicity_concept_id,Yes,integer,"This field captures Ethnicity as defined by the Office of Management and Budget (OMB) of the US Government: it distinguishes only between ""Hispanic"" and ""Not Hispanic"". Races and ethnic backgrounds are not stored here.",Only use this field if you have US-based data and a source of this information. Do not attempt to infer Ethnicity from the race or ethnic background of the Person. [Accepted ethnicity concepts](http://athena.ohdsi.org/search-terms/terms?domain=Ethnicity&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,Ethnicity,, +PERSON,location_id,No,integer,The location refers to the physical address of the person. This field should capture the last known location of the person. ,"Put the location_id from the [LOCATION](https://ohdsi.github.io/CommonDataModel/cdm531.html#location) table here that represents the most granular location information for the person. This could represent anything from postal code or parts thereof, state, or county for example. Since many databases contain deidentified data, it is common that the precision of the location is reduced to prevent re-identification. This field should capture the last known location. ",No,Yes,LOCATION,LOCATION_ID,,, +PERSON,provider_id,No,integer,The Provider refers to the last known primary care provider (General Practitioner).,"Put the provider_id from the [PROVIDER](https://ohdsi.github.io/CommonDataModel/cdm531.html#provider) table of the last known general practitioner of the person. If there are multiple providers, it is up to the ETL to decide which to put here.",No,Yes,PROVIDER,PROVIDER_ID,,, +PERSON,care_site_id,No,integer,The Care Site refers to where the Provider typically provides the primary care.,,No,Yes,CARE_SITE,CARE_SITE_ID,,, +PERSON,person_source_value,No,varchar(50),Use this field to link back to persons in the source data. This is typically used for error checking of ETL logic.,Some use cases require the ability to link back to persons in the source data. This field allows for the storing of the person value as it appears in the source. This field is not required but strongly recommended.,No,No,,,,, +PERSON,gender_source_value,No,varchar(50),This field is used to store the biological sex of the person from the source data. It is not intended for use in standard analytics but for reference only.,Put the biological sex of the person as it appears in the source data.,No,No,,,,, +PERSON,gender_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.","If the source data codes biological sex in a non-standard vocabulary, store the concept_id here.",No,Yes,CONCEPT,CONCEPT_ID,,, +PERSON,race_source_value,No,varchar(50),This field is used to store the race of the person from the source data. It is not intended for use in standard analytics but for reference only.,Put the race of the person as it appears in the source data.,No,No,,,,, +PERSON,race_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.",If the source data codes race in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PERSON,ethnicity_source_value,No,varchar(50),This field is used to store the ethnicity of the person from the source data. It is not intended for use in standard analytics but for reference only.,"If the person has an ethnicity other than the OMB standard of ""Hispanic"" or ""Not Hispanic"" store that value from the source data here.",No,No,,,,, +PERSON,ethnicity_source_concept_id,No,integer,"Due to the small number of options, this tends to be zero.","If the source data codes ethnicity in an OMOP supported vocabulary, store the concept_id here.",No,Yes,CONCEPT,CONCEPT_ID,,, +OBSERVATION_PERIOD,observation_period_id,Yes,integer,A Person can have multiple discrete Observation Periods which are identified by the Observation_Period_Id.,Assign a unique observation_period_id to each discrete Observation Period for a Person.,Yes,No,,,,, +OBSERVATION_PERIOD,person_id,Yes,integer,The Person ID of the PERSON record for which the Observation Period is recorded.,,No,Yes,PERSON,PERSON_ID,,, +OBSERVATION_PERIOD,observation_period_start_date,Yes,date,Use this date to determine the start date of the Observation Period.,"It is often the case that the idea of Observation Periods does not exist in source data. In those cases, the observation_period_start_date can be inferred as the earliest Event date available for the Person. In insurance claim data, the Observation Period can be considered as the time period the Person is enrolled with a payer. If a Person switches plans but stays with the same payer, and therefore capturing of data continues, that change would be captured in [PAYER_PLAN_PERIOD](https://ohdsi.github.io/CommonDataModel/cdm531.html#payer_plan_period).",No,No,,,,, +OBSERVATION_PERIOD,observation_period_end_date,Yes,date,Use this date to determine the end date of the period for which we can assume that all events for a Person are recorded.,"It is often the case that the idea of Observation Periods does not exist in source data. In those cases, the observation_period_end_date can be inferred as the last Event date available for the Person. In insurance claim data, the Observation Period can be considered as the time period the Person is enrolled with a payer.",No,No,,,,, +OBSERVATION_PERIOD,period_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Observation Period as in whether the period was determined from an insurance enrollment file, EHR healthcare encounters, or other sources.",Choose the observation_period_type_concept_id that best represents how the period was determined. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +VISIT_OCCURRENCE,visit_occurrence_id,Yes,integer,Use this to identify unique interactions between a person and the health care system. This identifier links across the other CDM event tables to associate events with a visit.,This should be populated by creating a unique identifier for each unique interaction between a person and the healthcare system where the person receives a medical good or service over a span of time.,Yes,No,,,,, +VISIT_OCCURRENCE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +VISIT_OCCURRENCE,visit_concept_id,Yes,integer,"This field contains a concept id representing the kind of visit, like inpatient or outpatient. All concepts in this field should be standard and belong to the Visit domain.","Populate this field based on the kind of visit that took place for the person. For example this could be ""Inpatient Visit"", ""Outpatient Visit"", ""Ambulatory Visit"", etc. This table will contain standard concepts in the Visit domain. These concepts are arranged in a hierarchical structure to facilitate cohort definitions by rolling up to generally familiar Visits adopted in most healthcare systems worldwide. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_OCCURRENCE,visit_start_date,Yes,date,"For inpatient visits, the start date is typically the admission date. For outpatient visits the start date and end date will be the same.","When populating VISIT_START_DATE, you should think about the patient experience to make decisions on how to define visits. In the case of an inpatient visit this should be the date the patient was admitted to the hospital or institution. In all other cases this should be the date of the patient-provider interaction.",No,No,,,,, +VISIT_OCCURRENCE,visit_start_datetime,No,datetime,,"If no time is given for the start date of a visit, set it to midnight (00:00:0000).",No,No,,,,, VISIT_OCCURRENCE,visit_end_date,Yes,date,For inpatient visits the end date is typically the discharge date.,"Visit end dates are mandatory. If end dates are not provided in the source there are three ways in which to derive them: - Outpatient Visit: visit_end_datetime = visit_start_datetime - Emergency Room Visit: visit_end_datetime = visit_start_datetime - Inpatient Visit: Usually there is information about discharge. If not, you should be able to derive the end date from the sudden decline of activity or from the absence of inpatient procedures/drugs. - Non-hospital institution Visits: Particularly for claims data, if end dates are not provided assume the visit is for the duration of month that it occurs. For Inpatient Visits ongoing at the date of ETL, put date of processing the data into visit_end_datetime and visit_type_concept_id with 32220 ""Still patient"" to identify the visit as incomplete. -- All other Visits: visit_end_datetime = visit_start_datetime. If this is a one-day visit the end date should match the start date.",No,No,,,,, -VISIT_OCCURRENCE,visit_end_datetime,No,datetime,,"If no time is given for the end date of a visit, set it to midnight (00:00:0000).",No,No,,,,, -VISIT_OCCURRENCE,visit_type_concept_id,Yes,Integer,"Use this field to understand the provenance of the visit record, or where the record comes from.","Populate this field based on the provenance of the visit record, as in whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -VISIT_OCCURRENCE,provider_id,No,integer,"There will only be one provider per visit record and the ETL document should clearly state how they were chosen (attending, admitting, etc.). If there are multiple providers associated with a visit in the source, this can be reflected in the event tables (CONDITION_OCCURRENCE, PROCEDURE_OCCURRENCE, etc.) or in the VISIT_DETAIL table.","If there are multiple providers associated with a visit, you will need to choose which one to put here. The additional providers can be stored in the [VISIT_DETAIL](https://ohdsi.github.io/CommonDataModel/cdm531.html#visit_detail) table.",No,Yes,PROVIDER,PROVIDER_ID,,, -VISIT_OCCURRENCE,care_site_id,No,integer,This field provides information about the Care Site where the Visit took place.,There should only be one Care Site associated with a Visit.,No,Yes,CARE_SITE,CARE_SITE_ID,,, -VISIT_OCCURRENCE,visit_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the visit source value, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, -VISIT_OCCURRENCE,visit_source_concept_id,No,integer,,If the visit source value is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -VISIT_OCCURRENCE,admitted_from_concept_id,No,integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example. If patient is admitted from home, set this field to zero.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_OCCURRENCE,admitted_from_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, -VISIT_OCCURRENCE,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example. If patient is discharged to home, set this field to zero.","If available, map the discharge_to_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_OCCURRENCE,discharge_to_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, -VISIT_OCCURRENCE,preceding_visit_occurrence_id,No,integer,Use this field to find the visit that occurred for the person prior to the given visit. There could be a few days or a few years in between.,"This field can be used to link a visit immediately preceding the current visit. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -VISIT_DETAIL,visit_detail_id,Yes,integer,Use this to identify unique interactions between a person and the health care system. This identifier links across the other CDM event tables to associate events with a visit detail.,This should be populated by creating a unique identifier for each unique interaction between a person and the healthcare system where the person receives a medical good or service over a span of time.,Yes,No,,,,, -VISIT_DETAIL,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -VISIT_DETAIL,visit_detail_concept_id,Yes,integer,"This field contains a concept id representing the kind of visit detail, like inpatient or outpatient. All concepts in this field should be standard and belong to the Visit domain.","Populate this field based on the kind of visit that took place for the person. For example this could be ""Inpatient Visit"", ""Outpatient Visit"", ""Ambulatory Visit"", etc. This table will contain standard concepts in the Visit domain. These concepts are arranged in a hierarchical structure to facilitate cohort definitions by rolling up to generally familiar Visits adopted in most healthcare systems worldwide. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_DETAIL,visit_detail_start_date,Yes,date,This is the date of the start of the encounter. This may or may not be equal to the date of the Visit the Visit Detail is associated with.,"When populating VISIT_DETAIL_START_DATE, you should think about the patient experience to make decisions on how to define visits. Most likely this should be the date of the patient-provider interaction.",No,No,,,,, -VISIT_DETAIL,visit_detail_start_datetime,No,datetime,,"If no time is given for the start date of a visit, set it to midnight (00:00:0000).",No,No,,,,, +- All other Visits: visit_end_datetime = visit_start_datetime. If this is a one-day visit the end date should match the start date.",No,No,,,,, +VISIT_OCCURRENCE,visit_end_datetime,No,datetime,,"If no time is given for the end date of a visit, set it to midnight (00:00:0000).",No,No,,,,, +VISIT_OCCURRENCE,visit_type_concept_id,Yes,Integer,"Use this field to understand the provenance of the visit record, or where the record comes from.","Populate this field based on the provenance of the visit record, as in whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +VISIT_OCCURRENCE,provider_id,No,integer,"There will only be one provider per visit record and the ETL document should clearly state how they were chosen (attending, admitting, etc.). If there are multiple providers associated with a visit in the source, this can be reflected in the event tables (CONDITION_OCCURRENCE, PROCEDURE_OCCURRENCE, etc.) or in the VISIT_DETAIL table.","If there are multiple providers associated with a visit, you will need to choose which one to put here. The additional providers can be stored in the [VISIT_DETAIL](https://ohdsi.github.io/CommonDataModel/cdm531.html#visit_detail) table.",No,Yes,PROVIDER,PROVIDER_ID,,, +VISIT_OCCURRENCE,care_site_id,No,integer,This field provides information about the Care Site where the Visit took place.,There should only be one Care Site associated with a Visit.,No,Yes,CARE_SITE,CARE_SITE_ID,,, +VISIT_OCCURRENCE,visit_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the visit source value, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, +VISIT_OCCURRENCE,visit_source_concept_id,No,integer,,If the visit source value is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +VISIT_OCCURRENCE,admitting_source_concept_id,No,integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_OCCURRENCE,admitting_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, +VISIT_OCCURRENCE,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the discharge_to_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_OCCURRENCE,discharge_to_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, +VISIT_OCCURRENCE,preceding_visit_occurrence_id,No,integer,Use this field to find the visit that occurred for the person prior to the given visit. There could be a few days or a few years in between.,"This field can be used to link a visit immediately preceding the current visit. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +VISIT_DETAIL,visit_detail_id,Yes,integer,Use this to identify unique interactions between a person and the health care system. This identifier links across the other CDM event tables to associate events with a visit detail.,This should be populated by creating a unique identifier for each unique interaction between a person and the healthcare system where the person receives a medical good or service over a span of time.,Yes,No,,,,, +VISIT_DETAIL,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +VISIT_DETAIL,visit_detail_concept_id,Yes,integer,"This field contains a concept id representing the kind of visit detail, like inpatient or outpatient. All concepts in this field should be standard and belong to the Visit domain.","Populate this field based on the kind of visit that took place for the person. For example this could be ""Inpatient Visit"", ""Outpatient Visit"", ""Ambulatory Visit"", etc. This table will contain standard concepts in the Visit domain. These concepts are arranged in a hierarchical structure to facilitate cohort definitions by rolling up to generally familiar Visits adopted in most healthcare systems worldwide. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_DETAIL,visit_detail_start_date,Yes,date,This is the date of the start of the encounter. This may or may not be equal to the date of the Visit the Visit Detail is associated with.,"When populating VISIT_DETAIL_START_DATE, you should think about the patient experience to make decisions on how to define visits. Most likely this should be the date of the patient-provider interaction.",No,No,,,,, +VISIT_DETAIL,visit_detail_start_datetime,No,datetime,,"If no time is given for the start date of a visit, set it to midnight (00:00:0000).",No,No,,,,, VISIT_DETAIL,visit_detail_end_date,Yes,date,This the end date of the patient-provider interaction.,"Visit Detail end dates are mandatory. If end dates are not provided in the source there are three ways in which to derive them:
- Outpatient Visit Detail: visit_detail_end_datetime = visit_detail_start_datetime - Emergency Room Visit Detail: visit_detail_end_datetime = visit_detail_start_datetime - Inpatient Visit Detail: Usually there is information about discharge. If not, you should be able to derive the end date from the sudden decline of activity or from the absence of inpatient procedures/drugs. - Non-hospital institution Visit Details: Particularly for claims data, if end dates are not provided assume the visit is for the duration of month that it occurs.
For Inpatient Visit Details ongoing at the date of ETL, put date of processing the data into visit_detai_end_datetime and visit_detail_type_concept_id with 32220 ""Still patient"" to identify the visit as incomplete. -All other Visits Details: visit_detail_end_datetime = visit_detail_start_datetime. ",No,No,,,,, -VISIT_DETAIL,visit_detail_end_datetime,No,datetime,,"If no time is given for the end date of a visit, set it to midnight (00:00:0000).",No,No,,,,, -VISIT_DETAIL,visit_detail_type_concept_id,Yes,integer,"Use this field to understand the provenance of the visit detail record, or where the record comes from.","Populate this field based on the provenance of the visit detail record, as in whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -VISIT_DETAIL,provider_id,No,integer,"There will only be one provider per **visit** record and the ETL document should clearly state how they were chosen (attending, admitting, etc.). This is a typical reason for leveraging the VISIT_DETAIL table as even though each VISIT_DETAIL record can only have one provider, there is no limit to the number of VISIT_DETAIL records that can be associated to a VISIT_OCCURRENCE record.",The additional providers associated to a Visit can be stored in this table where each VISIT_DETAIL record represents a different provider.,No,Yes,PROVIDER,PROVIDER_ID,,, -VISIT_DETAIL,care_site_id,No,integer,This field provides information about the Care Site where the Visit Detail took place.,There should only be one Care Site associated with a Visit Detail.,No,Yes,CARE_SITE,CARE_SITE_ID,,, -VISIT_DETAIL,visit_detail_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit detail that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit detail in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the VISIT_DETAIL_SOURCE_VALUE, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, -VISIT_DETAIL,visit_detail_source_concept_id,No,Integer,,If the VISIT_DETAIL_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -VISIT_DETAIL,admitted_from_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, -VISIT_DETAIL,admitted_from_concept_id,No,Integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example. If patient is admitted from home, set this field to zero.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_DETAIL,discharge_to_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, -VISIT_DETAIL,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit detail record. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example. If patient is discharged to home, set this field to zero.","If available, map the DISCHARGE_TO_SOURCE_VALUE to a Standard Concept in the Visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_DETAIL,preceding_visit_detail_id,No,integer,Use this field to find the visit detail that occurred for the person prior to the given visit detail record. There could be a few days or a few years in between.,"The PRECEDING_VISIT_DETAIL_ID can be used to link a visit immediately preceding the current Visit Detail. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -VISIT_DETAIL,visit_detail_parent_id,No,integer,Use this field to find the visit detail that subsumes the given visit detail record. This is used in the case that a visit detail record needs to be nested beyond the VISIT_OCCURRENCE/VISIT_DETAIL relationship.,"If there are multiple nested levels to how Visits are represented in the source, the VISIT_DETAIL_PARENT_ID can be used to record this relationship. ",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -VISIT_DETAIL,visit_occurrence_id,Yes,integer,Use this field to link the VISIT_DETAIL record to its VISIT_OCCURRENCE.,Put the VISIT_OCCURRENCE_ID that subsumes the VISIT_DETAIL record here.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -CONDITION_OCCURRENCE,condition_occurrence_id,Yes,integer,The unique key given to a condition record for a person. Refer to the ETL for how duplicate conditions during the same visit were handled.,"Each instance of a condition present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same condition within the same visit. It is valid to keep these duplicates and assign them individual, unique, CONDITION_OCCURRENCE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, -CONDITION_OCCURRENCE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the condition is recorded.,,No,Yes,PERSON,PERSON_ID,,, -CONDITION_OCCURRENCE,condition_concept_id,Yes,integer,"The CONDITION_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source value which represents a condition","The CONCEPT_ID that the CONDITION_SOURCE_VALUE maps to. Only records whose source values map to concepts with a domain of ""Condition"" should go in this table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Condition,, -CONDITION_OCCURRENCE,condition_start_date,Yes,date,Use this date to determine the start date of the condition,"Most often data sources do not have the idea of a start date for a condition. Rather, if a source only has one date associated with a condition record it is acceptable to use that date for both the CONDITION_START_DATE and the CONDITION_END_DATE.",No,No,,,,, -CONDITION_OCCURRENCE,condition_start_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, -CONDITION_OCCURRENCE,condition_end_date,No,date,Use this date to determine the end date of the condition,"Most often data sources do not have the idea of a start date for a condition. Rather, if a source only has one date associated with a condition record it is acceptable to use that date for both the CONDITION_START_DATE and the CONDITION_END_DATE.",No,No,,,,, -CONDITION_OCCURRENCE,condition_end_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, -CONDITION_OCCURRENCE,condition_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Condition record, as in whether the condition was from an EHR system, insurance claim, registry, or other sources.",Choose the CONDITION_TYPE_CONCEPT_ID that best represents the provenance of the record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -CONDITION_OCCURRENCE,condition_status_concept_id,No,integer,"This concept represents the point during the visit the diagnosis was given (admitting diagnosis, final diagnosis), whether the diagnosis was determined due to laboratory findings, if the diagnosis was exclusionary, or if it was a preliminary diagnosis, among others. ","Choose the Concept in the Condition Status domain that best represents the point during the visit when the diagnosis was given. These can include admitting diagnosis, principal diagnosis, and secondary diagnosis. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition+Status&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Condition Status,, -CONDITION_OCCURRENCE,stop_reason,No,varchar(20),The Stop Reason indicates why a Condition is no longer valid with respect to the purpose within the source data. Note that a Stop Reason does not necessarily imply that the condition is no longer occurring.,This information is often not populated in source data and it is a valid etl choice to leave it blank if the information does not exist.,No,No,,,,, -CONDITION_OCCURRENCE,provider_id,No,integer,"The provider associated with condition record, e.g. the provider who made the diagnosis or the provider who recorded the symptom.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the admitting vs attending physician on an EHR record.",No,Yes,PROVIDER,PROVIDER_ID,,, -CONDITION_OCCURRENCE,visit_occurrence_id,No,integer,The visit during which the condition occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a CONDITION_START_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the Visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the CONDITION_OCCURRENCE record.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -CONDITION_OCCURRENCE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the condition occurred. For example, if the person was in the ICU at the time of the diagnosis the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -CONDITION_OCCURRENCE,condition_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the condition that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -CONDITION_OCCURRENCE,condition_source_concept_id,No,integer,"This is the concept representing the condition source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Condition necessary for a given analytic use case. Consider using CONDITION_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the CONDITION_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -CONDITION_OCCURRENCE,condition_status_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the condition status.,This information may be called something different in the source data but the field is meant to contain a value indicating when and how a diagnosis was given to a patient. This source value is mapped to a standard concept which is stored in the CONDITION_STATUS_CONCEPT_ID field.,No,No,,,,, -DRUG_EXPOSURE,drug_exposure_id,Yes,integer,The unique key given to records of drug dispensings or administrations for a person. Refer to the ETL for how duplicate drugs during the same visit were handled.,"Each instance of a drug dispensing or administration present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same drug within the same visit. It is valid to keep these duplicates and assign them individual, unique, DRUG_EXPOSURE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, -DRUG_EXPOSURE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the drug dispensing or administration is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, -DRUG_EXPOSURE,drug_concept_id,Yes,integer,"The DRUG_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source concept id which represents a drug product or molecule otherwise introduced to the body. The drug concepts can have a varying degree of information about drug strength and dose. This information is relevant in the context of quantity and administration information in the subsequent fields plus strength information from the DRUG_STRENGTH table, provided as part of the standard vocabulary download.","The CONCEPT_ID that the DRUG_SOURCE_VALUE maps to. The concept id should be derived either from mapping from the source concept id or by picking the drug concept representing the most amount of detail you have. Records whose source values map to standard concepts with a domain of Drug should go in this table. When the Drug Source Value of the code cannot be translated into Standard Drug Concept IDs, a Drug exposure entry is stored with only the corresponding SOURCE_CONCEPT_ID and DRUG_SOURCE_VALUE and a DRUG_CONCEPT_ID of 0. The Drug Concept with the most detailed content of information is preferred during the mapping process. These are indicated in the CONCEPT_CLASS_ID field of the Concept and are recorded in the following order of precedence: 'Branded Pack', 'Clinical Pack', 'Branded Drug', 'Clinical Drug', 'Branded Drug Component', 'Clinical Drug Component', 'Branded Drug Form', 'Clinical Drug Form', and only if no other information is available 'Ingredient'. Note: If only the drug class is known, the DRUG_CONCEPT_ID field should contain 0. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Drug&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Drug,, -DRUG_EXPOSURE,drug_exposure_start_date,Yes,date,Use this date to determine the start date of the drug record.,"Valid entries include a start date of a prescription, the date a prescription was filled, or the date on which a Drug administration was recorded. It is a valid ETL choice to use the date the drug was ordered as the DRUG_EXPOSURE_START_DATE.",No,No,,,,, -DRUG_EXPOSURE,drug_exposure_start_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, -DRUG_EXPOSURE,drug_exposure_end_date,Yes,date,The DRUG_EXPOSURE_END_DATE denotes the day the drug exposure ended for the patient.,"If this information is not explicitly available in the data, infer the end date using the following methods:

1. Start first with duration or days supply using the calculation drug start date + days supply -1 day. 2. Use quantity divided by daily dose that you may obtain from the sig or a source field (or assumed daily dose of 1) for solid, indivisibile, drug products. If quantity represents ingredient amount, quantity divided by daily dose * concentration (from drug_strength) drug concept id tells you the dose form. 3. If it is an administration record, set drug end date equal to drug start date. If the record is a written prescription then set end date to start date + 29. If the record is a mail-order prescription set end date to start date + 89. The end date must be equal to or greater than the start date. Ibuprofen 20mg/mL oral solution concept tells us this is oral solution. Calculate duration as quantity (200 example) * daily dose (5mL) /concentration (20mg/mL) 200*5/20 = 50 days. [Examples by dose form](https://ohdsi.github.io/CommonDataModel/drug_dose.html)",No,No,,,,, -DRUG_EXPOSURE,drug_exposure_end_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, -DRUG_EXPOSURE,verbatim_end_date,No,date,"This is the end date of the drug exposure as it appears in the source data, if it is given",Put the end date or discontinuation date as it appears from the source data or leave blank if unavailable.,No,No,,,,, -DRUG_EXPOSURE,drug_type_concept_id,Yes,integer,"You can use the TYPE_CONCEPT_ID to delineate between prescriptions written vs. prescriptions dispensed vs. medication history vs. patient-reported exposure, etc.","Choose the drug_type_concept_id that best represents the provenance of the record, for example whether it came from a record of a prescription written or physician administered drug. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -DRUG_EXPOSURE,stop_reason,No,varchar(20),"The reason a person stopped a medication as it is represented in the source. Reasons include regimen completed, changed, removed, etc. This field will be retired in v6.0.",This information is often not populated in source data and it is a valid etl choice to leave it blank if the information does not exist.,No,No,,,,, -DRUG_EXPOSURE,refills,No,integer,This is only filled in when the record is coming from a prescription written this field is meant to represent intended refills at time of the prescription.,,No,No,,,,, +All other Visits Details: visit_detail_end_datetime = visit_detail_start_datetime. ",No,No,,,,, +VISIT_DETAIL,visit_detail_end_datetime,No,datetime,,"If no time is given for the end date of a visit, set it to midnight (00:00:0000).",No,No,,,,, +VISIT_DETAIL,visit_detail_type_concept_id,Yes,integer,"Use this field to understand the provenance of the visit detail record, or where the record comes from.","Populate this field based on the provenance of the visit detail record, as in whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +VISIT_DETAIL,provider_id,No,integer,"There will only be one provider per **visit** record and the ETL document should clearly state how they were chosen (attending, admitting, etc.). This is a typical reason for leveraging the VISIT_DETAIL table as even though each VISIT_DETAIL record can only have one provider, there is no limit to the number of VISIT_DETAIL records that can be associated to a VISIT_OCCURRENCE record.",The additional providers associated to a Visit can be stored in this table where each VISIT_DETAIL record represents a different provider.,No,Yes,PROVIDER,PROVIDER_ID,,, +VISIT_DETAIL,care_site_id,No,integer,This field provides information about the Care Site where the Visit Detail took place.,There should only be one Care Site associated with a Visit Detail.,No,Yes,CARE_SITE,CARE_SITE_ID,,, +VISIT_DETAIL,visit_detail_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit detail that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit detail in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the VISIT_DETAIL_SOURCE_VALUE, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, +VISIT_DETAIL,visit_detail_source_concept_id,No,Integer,,If the VISIT_DETAIL_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +VISIT_DETAIL,admitting_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, +VISIT_DETAIL,admitting_source_concept_id,No,Integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_DETAIL,discharge_to_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, +VISIT_DETAIL,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit detail record. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the DISCHARGE_TO_SOURCE_VALUE to a Standard Concept in the Visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_DETAIL,preceding_visit_detail_id,No,integer,Use this field to find the visit detail that occurred for the person prior to the given visit detail record. There could be a few days or a few years in between.,"The PRECEDING_VISIT_DETAIL_ID can be used to link a visit immediately preceding the current Visit Detail. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +VISIT_DETAIL,visit_detail_parent_id,No,integer,Use this field to find the visit detail that subsumes the given visit detail record. This is used in the case that a visit detail record needs to be nested beyond the VISIT_OCCURRENCE/VISIT_DETAIL relationship.,"If there are multiple nested levels to how Visits are represented in the source, the VISIT_DETAIL_PARENT_ID can be used to record this relationship. ",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +VISIT_DETAIL,visit_occurrence_id,Yes,integer,Use this field to link the VISIT_DETAIL record to its VISIT_OCCURRENCE.,Put the VISIT_OCCURRENCE_ID that subsumes the VISIT_DETAIL record here.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +CONDITION_OCCURRENCE,condition_occurrence_id,Yes,integer,The unique key given to a condition record for a person. Refer to the ETL for how duplicate conditions during the same visit were handled.,"Each instance of a condition present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same condition within the same visit. It is valid to keep these duplicates and assign them individual, unique, CONDITION_OCCURRENCE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, +CONDITION_OCCURRENCE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the condition is recorded.,,No,Yes,PERSON,PERSON_ID,,, +CONDITION_OCCURRENCE,condition_concept_id,Yes,integer,"The CONDITION_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source value which represents a condition","The CONCEPT_ID that the CONDITION_SOURCE_VALUE maps to. Only records whose source values map to concepts with a domain of ""Condition"" should go in this table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Condition,, +CONDITION_OCCURRENCE,condition_start_date,Yes,date,Use this date to determine the start date of the condition,"Most often data sources do not have the idea of a start date for a condition. Rather, if a source only has one date associated with a condition record it is acceptable to use that date for both the CONDITION_START_DATE and the CONDITION_END_DATE.",No,No,,,,, +CONDITION_OCCURRENCE,condition_start_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, +CONDITION_OCCURRENCE,condition_end_date,No,date,Use this date to determine the end date of the condition,"Most often data sources do not have the idea of a start date for a condition. Rather, if a source only has one date associated with a condition record it is acceptable to use that date for both the CONDITION_START_DATE and the CONDITION_END_DATE.",No,No,,,,, +CONDITION_OCCURRENCE,condition_end_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, +CONDITION_OCCURRENCE,condition_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Condition record, as in whether the condition was from an EHR system, insurance claim, registry, or other sources.",Choose the CONDITION_TYPE_CONCEPT_ID that best represents the provenance of the record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +CONDITION_OCCURRENCE,condition_status_concept_id,No,integer,"This concept represents the point during the visit the diagnosis was given (admitting diagnosis, final diagnosis), whether the diagnosis was determined due to laboratory findings, if the diagnosis was exclusionary, or if it was a preliminary diagnosis, among others. ","Choose the Concept in the Condition Status domain that best represents the point during the visit when the diagnosis was given. These can include admitting diagnosis, principal diagnosis, and secondary diagnosis. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition+Status&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Condition Status,, +CONDITION_OCCURRENCE,stop_reason,No,varchar(20),The Stop Reason indicates why a Condition is no longer valid with respect to the purpose within the source data. Note that a Stop Reason does not necessarily imply that the condition is no longer occurring.,This information is often not populated in source data and it is a valid etl choice to leave it blank if the information does not exist.,No,No,,,,, +CONDITION_OCCURRENCE,provider_id,No,integer,"The provider associated with condition record, e.g. the provider who made the diagnosis or the provider who recorded the symptom.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the admitting vs attending physician on an EHR record.",No,Yes,PROVIDER,PROVIDER_ID,,, +CONDITION_OCCURRENCE,visit_occurrence_id,No,integer,The visit during which the condition occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a CONDITION_START_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the Visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the CONDITION_OCCURRENCE record.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +CONDITION_OCCURRENCE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the condition occurred. For example, if the person was in the ICU at the time of the diagnosis the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +CONDITION_OCCURRENCE,condition_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the condition that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +CONDITION_OCCURRENCE,condition_source_concept_id,No,integer,"This is the concept representing the condition source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Condition necessary for a given analytic use case. Consider using CONDITION_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the CONDITION_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +CONDITION_OCCURRENCE,condition_status_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the condition status.,This information may be called something different in the source data but the field is meant to contain a value indicating when and how a diagnosis was given to a patient. This source value is mapped to a standard concept which is stored in the CONDITION_STATUS_CONCEPT_ID field.,No,No,,,,, +DRUG_EXPOSURE,drug_exposure_id,Yes,integer,The unique key given to records of drug dispensings or administrations for a person. Refer to the ETL for how duplicate drugs during the same visit were handled.,"Each instance of a drug dispensing or administration present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same drug within the same visit. It is valid to keep these duplicates and assign them individual, unique, DRUG_EXPOSURE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, +DRUG_EXPOSURE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the drug dispensing or administration is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, +DRUG_EXPOSURE,drug_concept_id,Yes,integer,"The DRUG_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source concept id which represents a drug product or molecule otherwise introduced to the body. The drug concepts can have a varying degree of information about drug strength and dose. This information is relevant in the context of quantity and administration information in the subsequent fields plus strength information from the DRUG_STRENGTH table, provided as part of the standard vocabulary download.","The CONCEPT_ID that the DRUG_SOURCE_VALUE maps to. The concept id should be derived either from mapping from the source concept id or by picking the drug concept representing the most amount of detail you have. Records whose source values map to standard concepts with a domain of Drug should go in this table. When the Drug Source Value of the code cannot be translated into Standard Drug Concept IDs, a Drug exposure entry is stored with only the corresponding SOURCE_CONCEPT_ID and DRUG_SOURCE_VALUE and a DRUG_CONCEPT_ID of 0. The Drug Concept with the most detailed content of information is preferred during the mapping process. These are indicated in the CONCEPT_CLASS_ID field of the Concept and are recorded in the following order of precedence: 'Branded Pack', 'Clinical Pack', 'Branded Drug', 'Clinical Drug', 'Branded Drug Component', 'Clinical Drug Component', 'Branded Drug Form', 'Clinical Drug Form', and only if no other information is available 'Ingredient'. Note: If only the drug class is known, the DRUG_CONCEPT_ID field should contain 0. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Drug&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Drug,, +DRUG_EXPOSURE,drug_exposure_start_date,Yes,date,Use this date to determine the start date of the drug record.,"Valid entries include a start date of a prescription, the date a prescription was filled, or the date on which a Drug administration was recorded. It is a valid ETL choice to use the date the drug was ordered as the DRUG_EXPOSURE_START_DATE.",No,No,,,,, +DRUG_EXPOSURE,drug_exposure_start_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, +DRUG_EXPOSURE,drug_exposure_end_date,Yes,date,The DRUG_EXPOSURE_END_DATE denotes the day the drug exposure ended for the patient.,"If this information is not explicitly available in the data, infer the end date using the following methods:

1. Start first with duration or days supply using the calculation drug start date + days supply -1 day. 2. Use quantity divided by daily dose that you may obtain from the sig or a source field (or assumed daily dose of 1) for solid, indivisibile, drug products. If quantity represents ingredient amount, quantity divided by daily dose * concentration (from drug_strength) drug concept id tells you the dose form. 3. If it is an administration record, set drug end date equal to drug start date. If the record is a written prescription then set end date to start date + 29. If the record is a mail-order prescription set end date to start date + 89. The end date must be equal to or greater than the start date. Ibuprofen 20mg/mL oral solution concept tells us this is oral solution. Calculate duration as quantity (200 example) * daily dose (5mL) /concentration (20mg/mL) 200*5/20 = 50 days. [Examples by dose form](https://ohdsi.github.io/CommonDataModel/drug_dose.html)",No,No,,,,, +DRUG_EXPOSURE,drug_exposure_end_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, +DRUG_EXPOSURE,verbatim_end_date,No,date,"This is the end date of the drug exposure as it appears in the source data, if it is given",Put the end date or discontinuation date as it appears from the source data or leave blank if unavailable.,No,No,,,,, +DRUG_EXPOSURE,drug_type_concept_id,Yes,integer,"You can use the TYPE_CONCEPT_ID to delineate between prescriptions written vs. prescriptions dispensed vs. medication history vs. patient-reported exposure, etc.","Choose the drug_type_concept_id that best represents the provenance of the record, for example whether it came from a record of a prescription written or physician administered drug. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +DRUG_EXPOSURE,stop_reason,No,varchar(20),"The reason a person stopped a medication as it is represented in the source. Reasons include regimen completed, changed, removed, etc. This field will be retired in v6.0.",This information is often not populated in source data and it is a valid etl choice to leave it blank if the information does not exist.,No,No,,,,, +DRUG_EXPOSURE,refills,No,integer,This is only filled in when the record is coming from a prescription written this field is meant to represent intended refills at time of the prescription.,,No,No,,,,, DRUG_EXPOSURE,quantity,No,float,,"To find the dose form of a drug the RELATIONSHIP table can be used where the relationship_id is 'Has dose form'. If liquid, quantity stands for the total amount dispensed or ordered of ingredient in the units given by the drug_strength table. If the unit from the source data does not align with the unit in the DRUG_STRENGTH table the quantity should be converted to the correct unit given in DRUG_STRENGTH. For clinical drugs with fixed dose forms (tablets etc.) the quantity is the number of units/tablets/capsules prescribed or dispensed (can be partial, but then only 1/2 or 1/3, not 0.01). Clinical drugs with divisible dose forms (injections) the quantity is the amount of ingredient the patient got. For example, if the injection is 2mg/mL but the patient got 80mL then quantity is reported as 160. Quantified clinical drugs with divisible dose forms (prefilled syringes), the quantity is the amount of ingredient similar to clinical drugs. Please see [how to calculate drug dose](https://ohdsi.github.io/CommonDataModel/drug_dose.html) for more information. -",No,No,,,,, -DRUG_EXPOSURE,days_supply,No,integer,,Days supply of the drug. This should be the verbatim days_supply as given on the prescription. If the drug is physician administered use duration end date if given or set to 1 as default if duration is not available.,No,No,,,,, -DRUG_EXPOSURE,sig,No,varchar(MAX),This is the verbatim instruction for the drug as written by the provider.,"Put the written out instructions for the drug as it is verbatim in the source, if available.",No,No,,,,, -DRUG_EXPOSURE,route_concept_id,No,integer,,The standard CONCEPT_ID that the ROUTE_SOURCE_VALUE maps to in the route domain.,No,Yes,CONCEPT,CONCEPT_ID,Route,, -DRUG_EXPOSURE,lot_number,No,varchar(50),,,No,No,,,,, -DRUG_EXPOSURE,provider_id,No,integer,"The Provider associated with drug record, e.g. the provider who wrote the prescription or the provider who administered the drug.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the ordering vs administering physician on an EHR record.",No,Yes,PROVIDER,PROVIDER_ID,,, -DRUG_EXPOSURE,visit_occurrence_id,No,integer,"The Visit during which the drug was prescribed, administered or dispensed.",To populate this field drug exposures must be explicitly initiated in the visit.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -DRUG_EXPOSURE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the drug exposure occurred. For example, if the person was in the ICU at the time of the drug administration the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -DRUG_EXPOSURE,drug_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the drug exposure that occurred. For example, this could be an NDC or Gemscript code.",This code is mapped to a Standard Drug Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -DRUG_EXPOSURE,drug_source_concept_id,No,integer,"This is the concept representing the drug source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Drug necessary for a given analytic use case. Consider using DRUG_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the DRUG_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_EXPOSURE,route_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the drug route.,This information may be called something different in the source data but the field is meant to contain a value indicating when and how a drug was given to a patient. This source value is mapped to a standard concept which is stored in the ROUTE_CONCEPT_ID field.,No,No,,,,, -DRUG_EXPOSURE,dose_unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the dose unit of the drug given.,This information may be called something different in the source data but the field is meant to contain a value indicating the unit of dosage of drug given to the patient. This is an older column and will be deprecated in an upcoming version.,No,No,,,,, -PROCEDURE_OCCURRENCE,procedure_occurrence_id,Yes,integer,The unique key given to a procedure record for a person. Refer to the ETL for how duplicate procedures during the same visit were handled.,"Each instance of a procedure occurrence in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same procedure within the same visit. It is valid to keep these duplicates and assign them individual, unique, PROCEDURE_OCCURRENCE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, -PROCEDURE_OCCURRENCE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the procedure is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, -PROCEDURE_OCCURRENCE,procedure_concept_id,Yes,integer,"The PROCEDURE_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source value which represents a procedure","The CONCEPT_ID that the PROCEDURE_SOURCE_VALUE maps to. Only records whose source values map to standard concepts with a domain of ""Procedure"" should go in this table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Procedure&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Procedure,, -PROCEDURE_OCCURRENCE,procedure_date,Yes,date,Use this date to determine the date the procedure occurred.,"If a procedure lasts more than a day, then it should be recorded as a separate record for each day the procedure occurred, this logic is in lieu of the procedure_end_date, which will be added in a future version of the CDM.",No,No,,,,, -PROCEDURE_OCCURRENCE,procedure_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, -PROCEDURE_OCCURRENCE,procedure_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Procedure record, as in whether the procedure was from an EHR system, insurance claim, registry, or other sources.","Choose the PROCEDURE_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. If a procedure is recorded as an EHR encounter, the PROCEDURE_TYPE_CONCEPT would be 'EHR encounter record'. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -PROCEDURE_OCCURRENCE,modifier_concept_id,No,integer,The modifiers are intended to give additional information about the procedure but as of now the vocabulary is under review.,"It is up to the ETL to choose how to map modifiers if they exist in source data. These concepts are typically distinguished by 'Modifier' concept classes (e.g., 'CPT4 Modifier' as part of the 'CPT4' vocabulary). If there is more than one modifier on a record, one should be chosen that pertains to the procedure rather than provider. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?conceptClass=CPT4+Modifier&conceptClass=HCPCS+Modifier&vocabulary=CPT4&vocabulary=HCPCS&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, -PROCEDURE_OCCURRENCE,quantity,No,integer,"If the quantity value is omitted, a single procedure is assumed.","If a Procedure has a quantity of '0' in the source, this should default to '1' in the ETL. If there is a record in the source it can be assumed the exposure occurred at least once",No,No,,,,, -PROCEDURE_OCCURRENCE,provider_id,No,integer,"The provider associated with the procedure record, e.g. the provider who performed the Procedure.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the admitting vs attending physician on an EHR record.",No,No,PROVIDER,PROVIDER_ID,,, -PROCEDURE_OCCURRENCE,visit_occurrence_id,No,integer,The visit during which the procedure occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a PROCEDURE_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the Visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the PROCEDURE_OCCURRENCE record.",No,No,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -PROCEDURE_OCCURRENCE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Procedure occurred. For example, if the Person was in the ICU at the time of the Procedure the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,No,VISIT_DETAIL,VISIT_DETAIL_ID,,, -PROCEDURE_OCCURRENCE,procedure_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the procedure that occurred. For example, this could be an CPT4 or OPCS4 code.",Use this value to look up the source concept id and then map the source concept id to a standard concept id.,No,No,,,,, -PROCEDURE_OCCURRENCE,procedure_source_concept_id,No,integer,"This is the concept representing the procedure source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Procedure necessary for a given analytic use case. Consider using PROCEDURE_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the PROCEDURE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,No,CONCEPT,CONCEPT_ID,,, -PROCEDURE_OCCURRENCE,modifier_source_value,No,varchar(50),,The original modifier code from the source is stored here for reference.,No,No,,,,, -PROCEDURE_OCCURRENCE,procedure_status_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the procedure status (primary or secondary).,"This information may be called something different in the source data but the field is meant to contain a value indicating whether the procedure was the primary reason for performing a surgical operation, infusion, etc. This source value is mapped to a standard concept which is stored in the PROCEDURE_STATUS_CONCEPT_ID field.",,,,,,, -PROCEDURE_OCCURRENCE,procedure_status_concept_id,Yes,integer,"This concept represents if the procedure was the primary reason for the surgical operation, infusion, etc . ",Choose the Concept in the Procedure Status domain that best represents the status ( [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition+Status&standardConcept=Standard&page=1&pageSize=15&query=).,,,,,,, -DEVICE_EXPOSURE,device_exposure_id,Yes,integer,The unique key given to records a person's exposure to a foreign physical object or instrument.,Each instance of an exposure to a foreign object or device present in the source data should be assigned this unique key. ,Yes,No,,,,, -DEVICE_EXPOSURE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -DEVICE_EXPOSURE,device_concept_id,Yes,integer,"The DEVICE_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source concept id which represents a foreign object or instrument the person was exposed to. ",The CONCEPT_ID that the DEVICE_SOURCE_VALUE maps to. ,No,Yes,CONCEPT,CONCEPT_ID,Device,, -DEVICE_EXPOSURE,device_exposure_start_date,Yes,date,Use this date to determine the start date of the device record.,"Valid entries include a start date of a procedure to implant a device, the date of a prescription for a device, or the date of device administration. ",No,No,,,,, -DEVICE_EXPOSURE,device_exposure_start_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, -DEVICE_EXPOSURE,device_exposure_end_date,No,date,"The DEVICE_EXPOSURE_END_DATE denotes the day the device exposure ended for the patient, if given.",Put the end date or discontinuation date as it appears from the source data or leave blank if unavailable.,No,No,,,,, -DEVICE_EXPOSURE,device_exposure_end_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, -DEVICE_EXPOSURE,device_type_concept_id,Yes,integer,"You can use the TYPE_CONCEPT_ID to denote the provenance of the record, as in whether the record is from administrative claims or EHR. ","Choose the drug_type_concept_id that best represents the provenance of the record, for example whether it came from a record of a prescription written or physician administered drug. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -DEVICE_EXPOSURE,unique_device_id,No,varchar(255),"This is the Unique Device Identification (UDI-DI) number for devices regulated by the FDA, if given. ","For medical devices that are regulated by the FDA, a Unique Device Identification (UDI) is provided if available in the data source and is recorded in the UNIQUE_DEVICE_ID field.",No,No,,,,, -DEVICE_EXPOSURE,production_id,No,varchar(255),This is the Production Identifier (UDI-PI) portion of the Unique Device Identification.,,,,,,,, -DEVICE_EXPOSURE,quantity,No,integer,,,No,No,,,,, -DEVICE_EXPOSURE,provider_id,No,integer,"The Provider associated with device record, e.g. the provider who wrote the prescription or the provider who implanted the device.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record.,No,Yes,PROVIDER,PROVIDER_ID,,, -DEVICE_EXPOSURE,visit_occurrence_id,No,integer,The Visit during which the device was prescribed or given.,To populate this field device exposures must be explicitly initiated in the visit.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -DEVICE_EXPOSURE,visit_detail_id,No,integer,The Visit Detail during which the device was prescribed or given.,To populate this field device exposures must be explicitly initiated in the visit detail record.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -DEVICE_EXPOSURE,device_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the device exposure that occurred. For example, this could be an NDC or Gemscript code.",This code is mapped to a Standard Device Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -DEVICE_EXPOSURE,device_source_concept_id,No,integer,"This is the concept representing the device source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Device necessary for a given analytic use case. Consider using DEVICE_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the DEVICE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -DEVICE_EXPOSURE,unit_concept_id,No,integer,UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data. ,"There is no standardization requirement for units associated with DEVICE_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit. If there is no unit associated with a Device record, set to NULL.",,,,,,, -DEVICE_EXPOSURE,unit_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the unit of the Device. For example, blood transfusions are considered devices and can be given in mL quantities. ","This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference. Using the blood transfusion example, blood transfusion is represented by the DEVICE_CONCEPT_ID and the unit (mL) would be housed in the UNIT_SOURCE_VALUE and mapped to a standard concept in the unit domain. ",,,,,,, -DEVICE_EXPOSURE,unit_source_concept_id,No,integer,"This is the concept representing the UNIT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Unit necessary for a given analytic use case. Consider using UNIT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the UNIT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here. ,,,,,,, -MEASUREMENT,measurement_id,Yes,integer,The unique key given to a Measurement record for a Person. Refer to the ETL for how duplicate Measurements during the same Visit were handled.,"Each instance of a measurement present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same measurement within the same visit. It is valid to keep these duplicates and assign them individual, unique, MEASUREMENT_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, -MEASUREMENT,person_id,Yes,integer,The PERSON_ID of the Person for whom the Measurement is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, -MEASUREMENT,measurement_concept_id,Yes,integer,"The MEASUREMENT_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies.","The CONCEPT_ID that the MEASUREMENT_SOURCE_CONCEPT_ID maps to. Only records whose SOURCE_CONCEPT_IDs map to Standard Concepts with a domain of ""Measurement"" should go in this table.",No,Yes,CONCEPT,CONCEPT_ID,Measurement,, -MEASUREMENT,measurement_date,Yes,date,Use this date to determine the date of the measurement.,"If there are multiple dates in the source data associated with a record such as order_date, draw_date, and result_date, choose the one that is closest to the date the sample was drawn from the patient.",No,No,,,,, -MEASUREMENT,measurement_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, -MEASUREMENT,measurement_time,No,varchar(10),,This is present for backwards compatibility and will be deprecated in an upcoming version.,No,No,,,,, -MEASUREMENT,measurement_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Measurement record, as in whether the measurement was from an EHR system, insurance claim, registry, or other sources.","Choose the MEASUREMENT_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -MEASUREMENT,operator_concept_id,No,integer,"The meaning of Concept [4172703](https://athena.ohdsi.org/search-terms/terms/4172703) for '=' is identical to omission of a OPERATOR_CONCEPT_ID value. Since the use of this field is rare, it's important when devising analyses to not to forget testing for the content of this field for values different from =.","Operators are <, <=, =, >=, > and these concepts belong to the 'Meas Value Operator' domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Meas+Value+Operator&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, -MEASUREMENT,value_as_number,No,float,"This is the numerical value of the Result of the Measurement, if available. Note that measurements such as blood pressures will be split into their component parts i.e. one record for systolic, one record for diastolic.","If there is a negative value coming from the source, set the VALUE_AS_NUMBER to NULL, with the exception of the following Measurements (listed as LOINC codes):
- [1925-7](https://athena.ohdsi.org/search-terms/terms/3003396) Base excess in Arterial blood by calculation - [1927-3](https://athena.ohdsi.org/search-terms/terms/3002032) Base excess in Venous blood by calculation - [8632-2](https://athena.ohdsi.org/search-terms/terms/3006277) QRS-Axis - [11555-0](https://athena.ohdsi.org/search-terms/terms/3012501) Base excess in Blood by calculation - [1926-5](https://athena.ohdsi.org/search-terms/terms/3003129) Base excess in Capillary blood by calculation - [28638-5](https://athena.ohdsi.org/search-terms/terms/3004959) Base excess in Arterial cord blood by calculation [28639-3](https://athena.ohdsi.org/search-terms/terms/3007435) Base excess in Venous cord blood by calculation",No,No,,,,, -MEASUREMENT,value_as_concept_id,No,integer,If the raw data gives a categorial result for measurements those values are captured and mapped to standard concepts in the 'Meas Value' domain.,"If the raw data provides categorial results as well as continuous results for measurements, it is a valid ETL choice to preserve both values. The continuous value should go in the VALUE_AS_NUMBER field and the categorical value should be mapped to a standard concept in the 'Meas Value' domain and put in the VALUE_AS_CONCEPT_ID field. This is also the destination for the 'Maps to value' relationship.",No,Yes,CONCEPT,CONCEPT_ID,,, -MEASUREMENT,unit_concept_id,No,integer,"There is currently no recommended unit for individual measurements, i.e. it is not mandatory to represent Hemoglobin a1C measurements as a percentage. UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data.","There is no standardization requirement for units associated with MEASUREMENT_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit.",No,Yes,CONCEPT,CONCEPT_ID,Unit,, -MEASUREMENT,range_low,No,float,Ranges have the same unit as the VALUE_AS_NUMBER. These ranges are provided by the source and should remain NULL if not given.,If reference ranges for upper and lower limit of normal as provided (typically by a laboratory) these are stored in the RANGE_HIGH and RANGE_LOW fields. This should be set to NULL if not provided.,No,No,,,,, -MEASUREMENT,range_high,No,float,Ranges have the same unit as the VALUE_AS_NUMBER. These ranges are provided by the source and should remain NULL if not given.,If reference ranges for upper and lower limit of normal as provided (typically by a laboratory) these are stored in the RANGE_HIGH and RANGE_LOW fields. This should be set to NULL if not provided.,No,No,,,,, -MEASUREMENT,provider_id,No,integer,"The provider associated with measurement record, e.g. the provider who ordered the test or the provider who recorded the result.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record. For example the admitting vs attending physician on an EHR record.,No,Yes,PROVIDER,PROVIDER_ID,,, -MEASUREMENT,visit_occurrence_id,No,integer,The visit during which the Measurement occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a MEASUREMENT_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the measurement record. If a measurement is related to a visit explicitly in the source data, it is possible that the result date of the Measurement falls outside of the bounds of the Visit dates.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -MEASUREMENT,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Measurement occurred. For example, if the Person was in the ICU at the time the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -MEASUREMENT,measurement_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the Measurement that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Measurement Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -MEASUREMENT,measurement_source_concept_id,No,integer,"This is the concept representing the MEASUREMENT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Measurement necessary for a given analytic use case. Consider using MEASUREMENT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the MEASUREMENT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -MEASUREMENT,unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the unit of the Measurement that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -MEASUREMENT,value_source_value,No,varchar(50),This field houses the verbatim result value of the Measurement from the source data . ,"If both a continuous and categorical result are given in the source data such that both VALUE_AS_NUMBER and VALUE_AS_CONCEPT_ID are both included, store the verbatim value that was mapped to VALUE_AS_CONCEPT_ID here.",No,No,,,,, -OBSERVATION,observation_id,Yes,integer,The unique key given to an Observation record for a Person. Refer to the ETL for how duplicate Observations during the same Visit were handled.,Each instance of an observation present in the source data should be assigned this unique key. ,Yes,No,,,,, -OBSERVATION,person_id,Yes,integer,The PERSON_ID of the Person for whom the Observation is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, -OBSERVATION,observation_concept_id,Yes,integer,"The OBSERVATION_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies.","The CONCEPT_ID that the OBSERVATION_SOURCE_CONCEPT_ID maps to. There is no specified domain that the Concepts in this table must adhere to. The only rule is that records with Concepts in the Condition, Procedure, Drug, Measurement, or Device domains MUST go to the corresponding table. ",No,Yes,CONCEPT,CONCEPT_ID,,, -OBSERVATION,observation_date,Yes,date,"The date of the Observation. Depending on what the Observation represents this could be the date of a lab test, the date of a survey, or the date a patient's family history was taken. ",For some observations the ETL may need to make a choice as to which date to choose.,No,No,,,,, -OBSERVATION,observation_datetime,No,datetime,,If no time is given set to midnight (00:00:00).,No,No,,,,, -OBSERVATION,observation_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Observation record, as in whether the measurement was from an EHR system, insurance claim, registry, or other sources.","Choose the OBSERVATION_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -OBSERVATION,value_as_number,No,float,"This is the numerical value of the Result of the Observation, if applicable and available. It is not expected that all Observations will have numeric results, rather, this field is here to house values should they exist. ",,No,No,,,,, -OBSERVATION,value_as_string,No,varchar(60),"This is the categorical value of the Result of the Observation, if applicable and available. ",,No,No,,,,, -OBSERVATION,value_as_concept_id,No,Integer,"It is possible that some records destined for the Observation table have two clinical ideas represented in one source code. This is common with ICD10 codes that describe a family history of some Condition, for example. In OMOP the Vocabulary breaks these two clinical ideas into two codes; one becomes the OBSERVATION_CONCEPT_ID and the other becomes the VALUE_AS_CONCEPT_ID. It is important when using the Observation table to keep this possibility in mind and to examine the VALUE_AS_CONCEPT_ID field for relevant information. ","Note that the value of VALUE_AS_CONCEPT_ID may be provided through mapping from a source Concept which contains the content of the Observation. In those situations, the CONCEPT_RELATIONSHIP table in addition to the 'Maps to' record contains a second record with the relationship_id set to 'Maps to value'. For example, ICD10 [Z82.4](https://athena.ohdsi.org/search-terms/terms/45581076) 'Family history of ischaemic heart disease and other diseases of the circulatory system' has a 'Maps to' relationship to [4167217](https://athena.ohdsi.org/search-terms/terms/4167217) 'Family history of clinical finding' as well as a 'Maps to value' record to [134057](https://athena.ohdsi.org/search-terms/terms/134057) 'Disorder of cardiovascular system'.",No,Yes,CONCEPT,CONCEPT_ID,,, -OBSERVATION,qualifier_concept_id,No,integer,"This field contains all attributes specifying the clinical fact further, such as as degrees, severities, drug-drug interaction alerts etc.","Use your best judgement as to what Concepts to use here and if they are necessary to accurately represent the clinical record. There is no restriction on the domain of these Concepts, they just need to be Standard.",No,Yes,CONCEPT,CONCEPT_ID,,, -OBSERVATION,unit_concept_id,No,integer,There is currently no recommended unit for individual observation concepts. UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data.,"There is no standardization requirement for units associated with OBSERVATION_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit.",No,Yes,CONCEPT,CONCEPT_ID,Unit,, -OBSERVATION,provider_id,No,integer,"The provider associated with the observation record, e.g. the provider who ordered the test or the provider who recorded the result.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record. For example the admitting vs attending physician on an EHR record.,No,Yes,PROVIDER,PROVIDER_ID,,, -OBSERVATION,visit_occurrence_id,No,integer,The visit during which the Observation occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If an OBSERVATION_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the observation record. If an observation is related to a visit explicitly in the source data, it is possible that the result date of the Observation falls outside of the bounds of the Visit dates.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -OBSERVATION,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Observation occurred. For example, if the Person was in the ICU at the time the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -OBSERVATION,observation_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the Observation that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -OBSERVATION,observation_source_concept_id,No,integer,"This is the concept representing the OBSERVATION_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using OBSERVATION_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the OBSERVATION_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -OBSERVATION,unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the unit of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -OBSERVATION,qualifier_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the qualifier of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, -OBSERVATION,value_source_value,No,varchar(50),This field houses the verbatim result value of the Observation from the source data. Do not get confused with the Observation_source_value which captures source value of the observation mapped to observation_concept_id. This field is the observation result value from the source.," If the observation_source_value was a question, for example, or an observation that requires a result then this field is the answer/ result from the source data. Store the verbatim value that represents the result of the observation_source_value. ",No,No,,,,, -DEATH,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -DEATH,death_date,Yes,date,The date the person was deceased.,"If the precise date include day or month is not known or not allowed, December is used as the default month, and the last day of the month the default day.",No,No,,,,, -DEATH,death_datetime,No,datetime,,If not available set time to midnight (00:00:00),No,No,,,,, -DEATH,death_type_concept_id,No,integer,"This is the provenance of the death record, i.e., where it came from. It is possible that an administrative claims database would source death information from a government file so do not assume the Death Type is the same as the Visit Type, etc.",Use the type concept that be reflects the source of the death record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -DEATH,cause_concept_id,No,integer,"This is the Standard Concept representing the Person's cause of death, if available.","There is no specified domain for this concept, just choose the Standard Concept Id that best represents the person's cause of death.",No,Yes,CONCEPT,CONCEPT_ID,,, -DEATH,cause_source_value,No,varchar(50),,"If available, put the source code representing the cause of death here. ",No,No,,,,, -DEATH,cause_source_concept_id,No,integer,,If the cause of death was coded using a Vocabulary present in the OMOP Vocabularies put the CONCEPT_ID representing the cause of death here.,No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE,note_id,Yes,integer,A unique identifier for each note.,,Yes,No,,,,, -NOTE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -NOTE,note_date,Yes,date,The date the note was recorded.,,No,No,,,,, -NOTE,note_datetime,No,datetime,,If time is not given set the time to midnight.,No,No,,,,, -NOTE,note_type_concept_id,Yes,integer,The provenance of the note. Most likely this will be EHR. ,"Put the source system of the note, as in EHR record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Type+Concept&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +",No,No,,,,, +DRUG_EXPOSURE,days_supply,No,integer,,Days supply of the drug. This should be the verbatim days_supply as given on the prescription. If the drug is physician administered use duration end date if given or set to 1 as default if duration is not available.,No,No,,,,, +DRUG_EXPOSURE,sig,No,varchar(MAX),This is the verbatim instruction for the drug as written by the provider.,"Put the written out instructions for the drug as it is verbatim in the source, if available.",No,No,,,,, +DRUG_EXPOSURE,route_concept_id,No,integer,,The standard CONCEPT_ID that the ROUTE_SOURCE_VALUE maps to in the route domain.,No,Yes,CONCEPT,CONCEPT_ID,Route,, +DRUG_EXPOSURE,lot_number,No,varchar(50),,,No,No,,,,, +DRUG_EXPOSURE,provider_id,No,integer,"The Provider associated with drug record, e.g. the provider who wrote the prescription or the provider who administered the drug.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the ordering vs administering physician on an EHR record.",No,Yes,PROVIDER,PROVIDER_ID,,, +DRUG_EXPOSURE,visit_occurrence_id,No,integer,"The Visit during which the drug was prescribed, administered or dispensed.",To populate this field drug exposures must be explicitly initiated in the visit.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +DRUG_EXPOSURE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the drug exposure occurred. For example, if the person was in the ICU at the time of the drug administration the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +DRUG_EXPOSURE,drug_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the drug exposure that occurred. For example, this could be an NDC or Gemscript code.",This code is mapped to a Standard Drug Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +DRUG_EXPOSURE,drug_source_concept_id,No,integer,"This is the concept representing the drug source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Drug necessary for a given analytic use case. Consider using DRUG_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the DRUG_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_EXPOSURE,route_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the drug route.,This information may be called something different in the source data but the field is meant to contain a value indicating when and how a drug was given to a patient. This source value is mapped to a standard concept which is stored in the ROUTE_CONCEPT_ID field.,No,No,,,,, +DRUG_EXPOSURE,dose_unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the dose unit of the drug given.,This information may be called something different in the source data but the field is meant to contain a value indicating the unit of dosage of drug given to the patient. This is an older column and will be deprecated in an upcoming version.,No,No,,,,, +PROCEDURE_OCCURRENCE,procedure_occurrence_id,Yes,integer,The unique key given to a procedure record for a person. Refer to the ETL for how duplicate procedures during the same visit were handled.,"Each instance of a procedure occurrence in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same procedure within the same visit. It is valid to keep these duplicates and assign them individual, unique, PROCEDURE_OCCURRENCE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, +PROCEDURE_OCCURRENCE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the procedure is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, +PROCEDURE_OCCURRENCE,procedure_concept_id,Yes,integer,"The PROCEDURE_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source value which represents a procedure","The CONCEPT_ID that the PROCEDURE_SOURCE_VALUE maps to. Only records whose source values map to standard concepts with a domain of ""Procedure"" should go in this table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Procedure&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Procedure,, +PROCEDURE_OCCURRENCE,procedure_date,Yes,date,Use this date to determine the date the procedure occurred.,"If a procedure lasts more than a day, then it should be recorded as a separate record for each day the procedure occurred, this logic is in lieu of the procedure_end_date, which will be added in a future version of the CDM.",No,No,,,,, +PROCEDURE_OCCURRENCE,procedure_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, +PROCEDURE_OCCURRENCE,procedure_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Procedure record, as in whether the procedure was from an EHR system, insurance claim, registry, or other sources.","Choose the PROCEDURE_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. If a procedure is recorded as an EHR encounter, the PROCEDURE_TYPE_CONCEPT would be 'EHR encounter record'. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +PROCEDURE_OCCURRENCE,modifier_concept_id,No,integer,The modifiers are intended to give additional information about the procedure but as of now the vocabulary is under review.,"It is up to the ETL to choose how to map modifiers if they exist in source data. These concepts are typically distinguished by 'Modifier' concept classes (e.g., 'CPT4 Modifier' as part of the 'CPT4' vocabulary). If there is more than one modifier on a record, one should be chosen that pertains to the procedure rather than provider. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?conceptClass=CPT4+Modifier&conceptClass=HCPCS+Modifier&vocabulary=CPT4&vocabulary=HCPCS&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, +PROCEDURE_OCCURRENCE,quantity,No,integer,"If the quantity value is omitted, a single procedure is assumed.","If a Procedure has a quantity of '0' in the source, this should default to '1' in the ETL. If there is a record in the source it can be assumed the exposure occurred at least once",No,No,,,,, +PROCEDURE_OCCURRENCE,provider_id,No,integer,"The provider associated with the procedure record, e.g. the provider who performed the Procedure.","The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record, for example the admitting vs attending physician on an EHR record.",No,No,PROVIDER,PROVIDER_ID,,, +PROCEDURE_OCCURRENCE,visit_occurrence_id,No,integer,The visit during which the procedure occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a PROCEDURE_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the Visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the PROCEDURE_OCCURRENCE record.",No,No,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +PROCEDURE_OCCURRENCE,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Procedure occurred. For example, if the Person was in the ICU at the time of the Procedure the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,No,VISIT_DETAIL,VISIT_DETAIL_ID,,, +PROCEDURE_OCCURRENCE,procedure_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the procedure that occurred. For example, this could be an CPT4 or OPCS4 code.",Use this value to look up the source concept id and then map the source concept id to a standard concept id.,No,No,,,,, +PROCEDURE_OCCURRENCE,procedure_source_concept_id,No,integer,"This is the concept representing the procedure source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Procedure necessary for a given analytic use case. Consider using PROCEDURE_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the PROCEDURE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,No,CONCEPT,CONCEPT_ID,,, +PROCEDURE_OCCURRENCE,modifier_source_value,No,varchar(50),,The original modifier code from the source is stored here for reference.,No,No,,,,, +PROCEDURE_OCCURRENCE,procedure_status_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the procedure status (primary or secondary).,"This information may be called something different in the source data but the field is meant to contain a value indicating whether the procedure was the primary reason for performing a surgical operation, infusion, etc. This source value is mapped to a standard concept which is stored in the PROCEDURE_STATUS_CONCEPT_ID field.",,,,,,, +PROCEDURE_OCCURRENCE,procedure_status_concept_id,Yes,integer,"This concept represents if the procedure was the primary reason for the surgical operation, infusion, etc . ",Choose the Concept in the Procedure Status domain that best represents the status ( [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Condition+Status&standardConcept=Standard&page=1&pageSize=15&query=).,,,,,,, +DEVICE_EXPOSURE,device_exposure_id,Yes,integer,The unique key given to records a person's exposure to a foreign physical object or instrument.,Each instance of an exposure to a foreign object or device present in the source data should be assigned this unique key. ,Yes,No,,,,, +DEVICE_EXPOSURE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +DEVICE_EXPOSURE,device_concept_id,Yes,integer,"The DEVICE_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies. This is the standard concept mapped from the source concept id which represents a foreign object or instrument the person was exposed to. ",The CONCEPT_ID that the DEVICE_SOURCE_VALUE maps to. ,No,Yes,CONCEPT,CONCEPT_ID,Device,, +DEVICE_EXPOSURE,device_exposure_start_date,Yes,date,Use this date to determine the start date of the device record.,"Valid entries include a start date of a procedure to implant a device, the date of a prescription for a device, or the date of device administration. ",No,No,,,,, +DEVICE_EXPOSURE,device_exposure_start_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, +DEVICE_EXPOSURE,device_exposure_end_date,No,date,"The DEVICE_EXPOSURE_END_DATE denotes the day the device exposure ended for the patient, if given.",Put the end date or discontinuation date as it appears from the source data or leave blank if unavailable.,No,No,,,,, +DEVICE_EXPOSURE,device_exposure_end_datetime,No,datetime,,If a source does not specify datetime the convention is to set the time to midnight (00:00:0000),No,No,,,,, +DEVICE_EXPOSURE,device_type_concept_id,Yes,integer,"You can use the TYPE_CONCEPT_ID to denote the provenance of the record, as in whether the record is from administrative claims or EHR. ","Choose the drug_type_concept_id that best represents the provenance of the record, for example whether it came from a record of a prescription written or physician administered drug. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +DEVICE_EXPOSURE,unique_device_id,No,varchar(255),"This is the Unique Device Identification (UDI-DI) number for devices regulated by the FDA, if given. ","For medical devices that are regulated by the FDA, a Unique Device Identification (UDI) is provided if available in the data source and is recorded in the UNIQUE_DEVICE_ID field.",No,No,,,,, +DEVICE_EXPOSURE,production_id,No,varchar(255),This is the Production Identifier (UDI-PI) portion of the Unique Device Identification.,,,,,,,, +DEVICE_EXPOSURE,quantity,No,integer,,,No,No,,,,, +DEVICE_EXPOSURE,provider_id,No,integer,"The Provider associated with device record, e.g. the provider who wrote the prescription or the provider who implanted the device.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record.,No,Yes,PROVIDER,PROVIDER_ID,,, +DEVICE_EXPOSURE,visit_occurrence_id,No,integer,The Visit during which the device was prescribed or given.,To populate this field device exposures must be explicitly initiated in the visit.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +DEVICE_EXPOSURE,visit_detail_id,No,integer,The Visit Detail during which the device was prescribed or given.,To populate this field device exposures must be explicitly initiated in the visit detail record.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +DEVICE_EXPOSURE,device_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the device exposure that occurred. For example, this could be an NDC or Gemscript code.",This code is mapped to a Standard Device Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +DEVICE_EXPOSURE,device_source_concept_id,No,integer,"This is the concept representing the device source value and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Device necessary for a given analytic use case. Consider using DEVICE_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the DEVICE_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +DEVICE_EXPOSURE,unit_concept_id,No,integer,UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data. ,"There is no standardization requirement for units associated with DEVICE_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit. If there is no unit associated with a Device record, set to NULL.",,,,,,, +DEVICE_EXPOSURE,unit_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the unit of the Device. For example, blood transfusions are considered devices and can be given in mL quantities. ","This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference. Using the blood transfusion example, blood transfusion is represented by the DEVICE_CONCEPT_ID and the unit (mL) would be housed in the UNIT_SOURCE_VALUE and mapped to a standard concept in the unit domain. ",,,,,,, +DEVICE_EXPOSURE,unit_source_concept_id,No,integer,"This is the concept representing the UNIT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Unit necessary for a given analytic use case. Consider using UNIT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the UNIT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here. ,,,,,,, +MEASUREMENT,measurement_id,Yes,integer,The unique key given to a Measurement record for a Person. Refer to the ETL for how duplicate Measurements during the same Visit were handled.,"Each instance of a measurement present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same measurement within the same visit. It is valid to keep these duplicates and assign them individual, unique, MEASUREMENT_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, +MEASUREMENT,person_id,Yes,integer,The PERSON_ID of the Person for whom the Measurement is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, +MEASUREMENT,measurement_concept_id,Yes,integer,"The MEASUREMENT_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies.","The CONCEPT_ID that the MEASUREMENT_SOURCE_CONCEPT_ID maps to. Only records whose SOURCE_CONCEPT_IDs map to Standard Concepts with a domain of ""Measurement"" should go in this table.",No,Yes,CONCEPT,CONCEPT_ID,Measurement,, +MEASUREMENT,measurement_date,Yes,date,Use this date to determine the date of the measurement.,"If there are multiple dates in the source data associated with a record such as order_date, draw_date, and result_date, choose the one that is closest to the date the sample was drawn from the patient.",No,No,,,,, +MEASUREMENT,measurement_datetime,No,datetime,,"This is not required, though it is in v6. If a source does not specify datetime the convention is to set the time to midnight (00:00:0000)",No,No,,,,, +MEASUREMENT,measurement_time,No,varchar(10),,This is present for backwards compatibility and will be deprecated in an upcoming version.,No,No,,,,, +MEASUREMENT,measurement_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Measurement record, as in whether the measurement was from an EHR system, insurance claim, registry, or other sources.","Choose the MEASUREMENT_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +MEASUREMENT,operator_concept_id,No,integer,"The meaning of Concept [4172703](https://athena.ohdsi.org/search-terms/terms/4172703) for '=' is identical to omission of a OPERATOR_CONCEPT_ID value. Since the use of this field is rare, it's important when devising analyses to not to forget testing for the content of this field for values different from =.","Operators are <, <=, =, >=, > and these concepts belong to the 'Meas Value Operator' domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Meas+Value+Operator&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, +MEASUREMENT,value_as_number,No,float,"This is the numerical value of the Result of the Measurement, if available. Note that measurements such as blood pressures will be split into their component parts i.e. one record for systolic, one record for diastolic.","If there is a negative value coming from the source, set the VALUE_AS_NUMBER to NULL, with the exception of the following Measurements (listed as LOINC codes):
- [1925-7](https://athena.ohdsi.org/search-terms/terms/3003396) Base excess in Arterial blood by calculation - [1927-3](https://athena.ohdsi.org/search-terms/terms/3002032) Base excess in Venous blood by calculation - [8632-2](https://athena.ohdsi.org/search-terms/terms/3006277) QRS-Axis - [11555-0](https://athena.ohdsi.org/search-terms/terms/3012501) Base excess in Blood by calculation - [1926-5](https://athena.ohdsi.org/search-terms/terms/3003129) Base excess in Capillary blood by calculation - [28638-5](https://athena.ohdsi.org/search-terms/terms/3004959) Base excess in Arterial cord blood by calculation [28639-3](https://athena.ohdsi.org/search-terms/terms/3007435) Base excess in Venous cord blood by calculation",No,No,,,,, +MEASUREMENT,value_as_concept_id,No,integer,If the raw data gives a categorial result for measurements those values are captured and mapped to standard concepts in the 'Meas Value' domain.,"If the raw data provides categorial results as well as continuous results for measurements, it is a valid ETL choice to preserve both values. The continuous value should go in the VALUE_AS_NUMBER field and the categorical value should be mapped to a standard concept in the 'Meas Value' domain and put in the VALUE_AS_CONCEPT_ID field. This is also the destination for the 'Maps to value' relationship.",No,Yes,CONCEPT,CONCEPT_ID,,, +MEASUREMENT,unit_concept_id,No,integer,"There is currently no recommended unit for individual measurements, i.e. it is not mandatory to represent Hemoglobin a1C measurements as a percentage. UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data.","There is no standardization requirement for units associated with MEASUREMENT_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit.",No,Yes,CONCEPT,CONCEPT_ID,Unit,, +MEASUREMENT,range_low,No,float,Ranges have the same unit as the VALUE_AS_NUMBER. These ranges are provided by the source and should remain NULL if not given.,If reference ranges for upper and lower limit of normal as provided (typically by a laboratory) these are stored in the RANGE_HIGH and RANGE_LOW fields. This should be set to NULL if not provided.,No,No,,,,, +MEASUREMENT,range_high,No,float,Ranges have the same unit as the VALUE_AS_NUMBER. These ranges are provided by the source and should remain NULL if not given.,If reference ranges for upper and lower limit of normal as provided (typically by a laboratory) these are stored in the RANGE_HIGH and RANGE_LOW fields. This should be set to NULL if not provided.,No,No,,,,, +MEASUREMENT,provider_id,No,integer,"The provider associated with measurement record, e.g. the provider who ordered the test or the provider who recorded the result.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record. For example the admitting vs attending physician on an EHR record.,No,Yes,PROVIDER,PROVIDER_ID,,, +MEASUREMENT,visit_occurrence_id,No,integer,The visit during which the Measurement occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If a MEASUREMENT_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the measurement record. If a measurement is related to a visit explicitly in the source data, it is possible that the result date of the Measurement falls outside of the bounds of the Visit dates.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +MEASUREMENT,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Measurement occurred. For example, if the Person was in the ICU at the time the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +MEASUREMENT,measurement_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the Measurement that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Measurement Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +MEASUREMENT,measurement_source_concept_id,No,integer,"This is the concept representing the MEASUREMENT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Measurement necessary for a given analytic use case. Consider using MEASUREMENT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the MEASUREMENT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +MEASUREMENT,unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the unit of the Measurement that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +MEASUREMENT,unit_source_concept_id,No,integer,"""This is the concept representing the UNIT_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Measurement necessary for a given analytic use case. Consider using UNIT_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.""",If the UNIT_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +MEASUREMENT,value_source_value,No,varchar(50),This field houses the verbatim result value of the Measurement from the source data . ,"If both a continuous and categorical result are given in the source data such that both VALUE_AS_NUMBER and VALUE_AS_CONCEPT_ID are both included, store the verbatim value that was mapped to VALUE_AS_CONCEPT_ID here.",No,No,,,,, +OBSERVATION,observation_id,Yes,integer,The unique key given to an Observation record for a Person. Refer to the ETL for how duplicate Observations during the same Visit were handled.,Each instance of an observation present in the source data should be assigned this unique key. ,Yes,No,,,,, +OBSERVATION,person_id,Yes,integer,The PERSON_ID of the Person for whom the Observation is recorded. This may be a system generated code.,,No,Yes,PERSON,PERSON_ID,,, +OBSERVATION,observation_concept_id,Yes,integer,"The OBSERVATION_CONCEPT_ID field is recommended for primary use in analyses, and must be used for network studies.","The CONCEPT_ID that the OBSERVATION_SOURCE_CONCEPT_ID maps to. There is no specified domain that the Concepts in this table must adhere to. The only rule is that records with Concepts in the Condition, Procedure, Drug, Measurement, or Device domains MUST go to the corresponding table. ",No,Yes,CONCEPT,CONCEPT_ID,,, +OBSERVATION,observation_date,Yes,date,"The date of the Observation. Depending on what the Observation represents this could be the date of a lab test, the date of a survey, or the date a patient's family history was taken. ",For some observations the ETL may need to make a choice as to which date to choose.,No,No,,,,, +OBSERVATION,observation_datetime,No,datetime,,If no time is given set to midnight (00:00:00).,No,No,,,,, +OBSERVATION,observation_type_concept_id,Yes,integer,"This field can be used to determine the provenance of the Observation record, as in whether the measurement was from an EHR system, insurance claim, registry, or other sources.","Choose the OBSERVATION_TYPE_CONCEPT_ID that best represents the provenance of the record, for example whether it came from an EHR record or billing claim. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +OBSERVATION,value_as_number,No,float,"This is the numerical value of the Result of the Observation, if applicable and available. It is not expected that all Observations will have numeric results, rather, this field is here to house values should they exist. ",,No,No,,,,, +OBSERVATION,value_as_string,No,varchar(60),"This is the categorical value of the Result of the Observation, if applicable and available. ",,No,No,,,,, +OBSERVATION,value_as_concept_id,No,Integer,"It is possible that some records destined for the Observation table have two clinical ideas represented in one source code. This is common with ICD10 codes that describe a family history of some Condition, for example. In OMOP the Vocabulary breaks these two clinical ideas into two codes; one becomes the OBSERVATION_CONCEPT_ID and the other becomes the VALUE_AS_CONCEPT_ID. It is important when using the Observation table to keep this possibility in mind and to examine the VALUE_AS_CONCEPT_ID field for relevant information. ","Note that the value of VALUE_AS_CONCEPT_ID may be provided through mapping from a source Concept which contains the content of the Observation. In those situations, the CONCEPT_RELATIONSHIP table in addition to the 'Maps to' record contains a second record with the relationship_id set to 'Maps to value'. For example, ICD10 [Z82.4](https://athena.ohdsi.org/search-terms/terms/45581076) 'Family history of ischaemic heart disease and other diseases of the circulatory system' has a 'Maps to' relationship to [4167217](https://athena.ohdsi.org/search-terms/terms/4167217) 'Family history of clinical finding' as well as a 'Maps to value' record to [134057](https://athena.ohdsi.org/search-terms/terms/134057) 'Disorder of cardiovascular system'.",No,Yes,CONCEPT,CONCEPT_ID,,, +OBSERVATION,qualifier_concept_id,No,integer,"This field contains all attributes specifying the clinical fact further, such as as degrees, severities, drug-drug interaction alerts etc.","Use your best judgement as to what Concepts to use here and if they are necessary to accurately represent the clinical record. There is no restriction on the domain of these Concepts, they just need to be Standard.",No,Yes,CONCEPT,CONCEPT_ID,,, +OBSERVATION,unit_concept_id,No,integer,There is currently no recommended unit for individual observation concepts. UNIT_SOURCE_VALUES should be mapped to a Standard Concept in the Unit domain that best represents the unit as given in the source data.,"There is no standardization requirement for units associated with OBSERVATION_CONCEPT_IDs, however, it is the responsibility of the ETL to choose the most plausible unit.",No,Yes,CONCEPT,CONCEPT_ID,Unit,, +OBSERVATION,provider_id,No,integer,"The provider associated with the observation record, e.g. the provider who ordered the test or the provider who recorded the result.",The ETL may need to make a choice as to which PROVIDER_ID to put here. Based on what is available this may or may not be different than the provider associated with the overall VISIT_OCCURRENCE record. For example the admitting vs attending physician on an EHR record.,No,Yes,PROVIDER,PROVIDER_ID,,, +OBSERVATION,visit_occurrence_id,No,integer,The visit during which the Observation occurred.,"Depending on the structure of the source data, this may have to be determined based on dates. If an OBSERVATION_DATE occurs within the start and end date of a Visit it is a valid ETL choice to choose the VISIT_OCCURRENCE_ID from the visit that subsumes it, even if not explicitly stated in the data. While not required, an attempt should be made to locate the VISIT_OCCURRENCE_ID of the observation record. If an observation is related to a visit explicitly in the source data, it is possible that the result date of the Observation falls outside of the bounds of the Visit dates.",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +OBSERVATION,visit_detail_id,No,integer,"The VISIT_DETAIL record during which the Observation occurred. For example, if the Person was in the ICU at the time the VISIT_OCCURRENCE record would reflect the overall hospital stay and the VISIT_DETAIL record would reflect the ICU stay during the hospital visit.",Same rules apply as for the VISIT_OCCURRENCE_ID.,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +OBSERVATION,observation_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the Observation that occurred. For example, this could be an ICD10 or Read code.",This code is mapped to a Standard Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +OBSERVATION,observation_source_concept_id,No,integer,"This is the concept representing the OBSERVATION_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using OBSERVATION_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the OBSERVATION_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, +OBSERVATION,unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the unit of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +OBSERVATION,qualifier_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the qualifier of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +DEATH,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +DEATH,death_date,Yes,date,The date the person was deceased.,"If the precise date include day or month is not known or not allowed, December is used as the default month, and the last day of the month the default day.",No,No,,,,, +DEATH,death_datetime,No,datetime,,If not available set time to midnight (00:00:00),No,No,,,,, +DEATH,death_type_concept_id,No,integer,"This is the provenance of the death record, i.e., where it came from. It is possible that an administrative claims database would source death information from a government file so do not assume the Death Type is the same as the Visit Type, etc.",Use the type concept that be reflects the source of the death record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Type+Concept&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +DEATH,cause_concept_id,No,integer,"This is the Standard Concept representing the Person's cause of death, if available.","There is no specified domain for this concept, just choose the Standard Concept Id that best represents the person's cause of death.",No,Yes,CONCEPT,CONCEPT_ID,,, +DEATH,cause_source_value,No,varchar(50),,"If available, put the source code representing the cause of death here. ",No,No,,,,, +DEATH,cause_source_concept_id,No,integer,,If the cause of death was coded using a Vocabulary present in the OMOP Vocabularies put the CONCEPT_ID representing the cause of death here.,No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE,note_id,Yes,integer,A unique identifier for each note.,,Yes,No,,,,, +NOTE,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +NOTE,note_date,Yes,date,The date the note was recorded.,,No,No,,,,, +NOTE,note_datetime,No,datetime,,If time is not given set the time to midnight.,No,No,,,,, +NOTE,note_type_concept_id,Yes,integer,The provenance of the note. Most likely this will be EHR. ,"Put the source system of the note, as in EHR record. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Type+Concept&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, NOTE,note_class_concept_id,Yes,integer,"A Standard Concept Id representing the HL7 LOINC -Document Type Vocabulary classification of the note.",Map the note classification to a Standard Concept. For more information see the ETL Conventions in the description of the NOTE table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&conceptClass=Doc+Kind&conceptClass=Doc+Role&conceptClass=Doc+Setting&conceptClass=Doc+Subject+Matter&conceptClass=Doc+Type+of+Service&domain=Meas+Value&page=1&pageSize=15&query=). This Concept can alternatively be represented by concepts with the relationship 'Kind of (LOINC)' to [706391](https://athena.ohdsi.org/search-terms/terms/706391) (Note).,No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE,note_title,No,varchar(250),The title of the note.,,No,No,,,,, -NOTE,note_text,Yes,varchar(MAX),The content of the note.,,No,No,,,,, -NOTE,encoding_concept_id,Yes,integer,This is the Concept representing the character encoding type. ,"Put the Concept Id that represents the encoding character type here. Currently the only option is UTF-8 ([32678](https://athena.ohdsi.org/search-terms/terms/32678)). It the note is encoded in any other type, like ASCII then put 0. ",No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE,language_concept_id,Yes,integer,The language of the note. ,Use Concepts that are descendants of the concept [4182347](https://athena.ohdsi.org/search-terms/terms/4182347) (World Languages).,No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE,provider_id,No,integer,The Provider who wrote the note.,The ETL may need to make a determination on which provider to put here.,No,Yes,PROVIDER,PROVIDER_ID,,, -NOTE,visit_occurrence_id,No,integer,The Visit during which the note was written. ,,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, -NOTE,visit_detail_id,No,integer,The Visit Detail during which the note was written.,,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -NOTE,note_source_value,No,varchar(50),,The source value mapped to the NOTE_CLASS_CONCEPT_ID.,No,No,,,,, -NOTE_NLP,note_nlp_id,Yes,integer,A unique identifier for the NLP record.,,Yes,No,,,,, -NOTE_NLP,note_id,Yes,integer,This is the NOTE_ID for the NOTE record the NLP record is associated to.,,No,No,,,,, -NOTE_NLP,section_concept_id,No,integer,,"The SECTION_CONCEPT_ID should be used to represent the note section contained in the NOTE_NLP record. These concepts can be found as parts of document panels and are based on the type of note written, i.e. a discharge summary. These panels can be found as concepts with the relationship 'Subsumes' to CONCEPT_ID [45875957](https://athena.ohdsi.org/search-terms/terms/45875957).",No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE_NLP,snippet,No,varchar(250),A small window of text surrounding the term,,No,No,,,,, -NOTE_NLP,offset,No,varchar(50),Character offset of the extracted term in the input note,,No,No,,,,, -NOTE_NLP,lexical_variant,Yes,varchar(250),Raw text extracted from the NLP tool.,,No,No,,,,, -NOTE_NLP,note_nlp_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE_NLP,note_nlp_source_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -NOTE_NLP,nlp_system,No,varchar(250),,Name and version of the NLP system that extracted the term. Useful for data provenance.,No,No,,,,, -NOTE_NLP,nlp_date,Yes,date,The date of the note processing.,,No,No,,,,, -NOTE_NLP,nlp_datetime,No,datetime,The date and time of the note processing.,,No,No,,,,, +Document Type Vocabulary classification of the note.",Map the note classification to a Standard Concept. For more information see the ETL Conventions in the description of the NOTE table. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&conceptClass=Doc+Kind&conceptClass=Doc+Role&conceptClass=Doc+Setting&conceptClass=Doc+Subject+Matter&conceptClass=Doc+Type+of+Service&domain=Meas+Value&page=1&pageSize=15&query=). This Concept can alternatively be represented by concepts with the relationship 'Kind of (LOINC)' to [706391](https://athena.ohdsi.org/search-terms/terms/706391) (Note).,No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE,note_title,No,varchar(250),The title of the note.,,No,No,,,,, +NOTE,note_text,Yes,varchar(MAX),The content of the note.,,No,No,,,,, +NOTE,encoding_concept_id,Yes,integer,This is the Concept representing the character encoding type. ,"Put the Concept Id that represents the encoding character type here. Currently the only option is UTF-8 ([32678](https://athena.ohdsi.org/search-terms/terms/32678)). It the note is encoded in any other type, like ASCII then put 0. ",No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE,language_concept_id,Yes,integer,The language of the note. ,Use Concepts that are descendants of the concept [4182347](https://athena.ohdsi.org/search-terms/terms/4182347) (World Languages).,No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE,provider_id,No,integer,The Provider who wrote the note.,The ETL may need to make a determination on which provider to put here.,No,Yes,PROVIDER,PROVIDER_ID,,, +NOTE,visit_occurrence_id,No,integer,The Visit during which the note was written. ,,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, +NOTE,visit_detail_id,No,integer,The Visit Detail during which the note was written.,,No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +NOTE,note_source_value,No,varchar(50),,The source value mapped to the NOTE_CLASS_CONCEPT_ID.,No,No,,,,, +NOTE_NLP,note_nlp_id,Yes,integer,A unique identifier for the NLP record.,,Yes,No,,,,, +NOTE_NLP,note_id,Yes,integer,This is the NOTE_ID for the NOTE record the NLP record is associated to.,,No,No,,,,, +NOTE_NLP,section_concept_id,No,integer,,"The SECTION_CONCEPT_ID should be used to represent the note section contained in the NOTE_NLP record. These concepts can be found as parts of document panels and are based on the type of note written, i.e. a discharge summary. These panels can be found as concepts with the relationship 'Subsumes' to CONCEPT_ID [45875957](https://athena.ohdsi.org/search-terms/terms/45875957).",No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE_NLP,snippet,No,varchar(250),A small window of text surrounding the term,,No,No,,,,, +NOTE_NLP,offset,No,varchar(50),Character offset of the extracted term in the input note,,No,No,,,,, +NOTE_NLP,lexical_variant,Yes,varchar(250),Raw text extracted from the NLP tool.,,No,No,,,,, +NOTE_NLP,note_nlp_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE_NLP,note_nlp_source_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +NOTE_NLP,nlp_system,No,varchar(250),,Name and version of the NLP system that extracted the term. Useful for data provenance.,No,No,,,,, +NOTE_NLP,nlp_date,Yes,date,The date of the note processing.,,No,No,,,,, +NOTE_NLP,nlp_datetime,No,datetime,The date and time of the note processing.,,No,No,,,,, NOTE_NLP,term_exists,No,varchar(1),,"Term_exists is defined as a flag that indicates if the patient actually has or had the condition. Any of the following modifiers would make Term_exists false: Negation = true Subject = [anything other than the patient] @@ -225,303 +225,303 @@ Conditional = true/li> Rule_out = true Uncertain = very low certainty or any lower certainties A complete lack of modifiers would make Term_exists true. -",No,No,,,,, +",No,No,,,,, NOTE_NLP,term_temporal,No,varchar(50),,"Term_temporal is to indicate if a condition is present or just in the past. The following would be past:

- History = true -- Concept_date = anything before the time of the report",No,No,,,,, +- Concept_date = anything before the time of the report",No,No,,,,, NOTE_NLP,term_modifiers,No,varchar(2000),,"For the modifiers that are there, they would have to have these values:

- Negation = false - Subject = patient - Conditional = false - Rule_out = false -- Uncertain = true or high or moderate or even low (could argue about low). Term_modifiers will concatenate all modifiers for different types of entities (conditions, drugs, labs etc) into one string. Lab values will be saved as one of the modifiers. ",No,No,,,,, -SPECIMEN,specimen_id,Yes,integer,Unique identifier for each specimen.,,Yes,No,,,,, -SPECIMEN,person_id,Yes,integer,The person from whom the specimen is collected.,,No,Yes,PERSON,PERSON_ID,,, -SPECIMEN,specimen_concept_id,Yes,integer,,The standard CONCEPT_ID that the SPECIMEN_SOURCE_VALUE maps to in the specimen domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Specimen&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, -SPECIMEN,specimen_type_concept_id,Yes,integer,,"Put the source of the specimen record, as in an EHR system. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Type+Concept&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, -SPECIMEN,specimen_date,Yes,date,The date the specimen was collected.,,No,No,,,,, -SPECIMEN,specimen_datetime,No,datetime,,,No,No,,,,, -SPECIMEN,quantity,No,float,The amount of specimen collected from the person.,,No,No,,,,, -SPECIMEN,unit_concept_id,No,integer,The unit for the quantity of the specimen.,Map the UNIT_SOURCE_VALUE to a Standard Concept in the Unit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Unit&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, -SPECIMEN,anatomic_site_concept_id,No,integer,This is the site on the body where the specimen is from.,Map the ANATOMIC_SITE_SOURCE_VALUE to a Standard Concept in the Spec Anatomic Site domain. This should be coded at the lowest level of granularity [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Spec+Anatomic+Site&conceptClass=Body+Structure&page=4&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, -SPECIMEN,disease_status_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -SPECIMEN,specimen_source_id,No,varchar(50),This is the identifier for the specimen from the source system. ,,No,No,,,,, -SPECIMEN,specimen_source_value,No,varchar(50),,,No,No,,,,, -SPECIMEN,unit_source_value,No,varchar(50),,"This unit for the quantity of the specimen, as represented in the source.",No,No,,,,, -SPECIMEN,anatomic_site_source_value,No,varchar(50),,"This is the site on the body where the specimen was taken from, as represented in the source.",No,No,,,,, -SPECIMEN,disease_status_source_value,No,varchar(50),,,No,No,,,,, -FACT_RELATIONSHIP,domain_concept_id_1,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -FACT_RELATIONSHIP,fact_id_1,Yes,integer,,,No,No,,,,, -FACT_RELATIONSHIP,domain_concept_id_2,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -FACT_RELATIONSHIP,fact_id_2,Yes,integer,,,No,No,,,,, -FACT_RELATIONSHIP,relationship_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -LOCATION,location_id,Yes,integer,The unique key given to a unique Location.,Each instance of a Location in the source data should be assigned this unique key.,Yes,No,,,,, -LOCATION,address_1,No,varchar(50),This is the first line of the address.,,No,No,,,,, -LOCATION,address_2,No,varchar(50),This is the second line of the address,,No,No,,,,, -LOCATION,city,No,varchar(50),,,No,No,,,,, -LOCATION,state,No,varchar(2),,,No,No,,,,, -LOCATION,zip,No,varchar(9),,"Zip codes are handled as strings of up to 9 characters length. For US addresses, these represent either a 3-digit abbreviated Zip code as provided by many sources for patient protection reasons, the full 5-digit Zip or the 9-digit (ZIP + 4) codes. Unless for specific reasons analytical methods should expect and utilize only the first 3 digits. For international addresses, different rules apply.",No,No,,,,, -LOCATION,county,No,varchar(20),,,No,No,,,,, -LOCATION,location_source_value,No,varchar(50),,"Put the verbatim value for the location here, as it shows up in the source. ",No,No,,,,, -LOCATION,country_concept_id,No,integer,The Concept Id representing the country. Values should conform to the [Geography](https://athena.ohdsi.org/search-terms/terms?domain=Geography&standardConcept=Standard&page=1&pageSize=15&query=&boosts) domain. ,,,,,,,, -LOCATION,country_source_value,No,varchar(80),The name of the country.,,,,,,,, -LOCATION,latitude,No,float,,Must be between -90 and 90.,,,,,,, -LOCATION,longitude,No,float,,Must be between -180 and 180.,,,,,,, -CARE_SITE,care_site_id,Yes,integer,,Assign an id to each unique combination of location_id and place_of_service_source_value,Yes,No,,,,, -CARE_SITE,care_site_name,No,varchar(255),The name of the care_site as it appears in the source data,,No,No,,,,, -CARE_SITE,place_of_service_concept_id,No,integer,"This is a high-level way of characterizing a Care Site. Typically, however, Care Sites can provide care in multiple settings (inpatient, outpatient, etc.) and this granularity should be reflected in the visit.","Choose the concept in the visit domain that best represents the setting in which healthcare is provided in the Care Site. If most visits in a Care Site are Inpatient, then the place_of_service_concept_id should represent Inpatient. If information is present about a unique Care Site (e.g. Pharmacy) then a Care Site record should be created. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=2&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, -CARE_SITE,location_id,No,integer,The location_id from the LOCATION table representing the physical location of the care_site.,,No,Yes,LOCATION,LOCATION_ID,,, -CARE_SITE,care_site_source_value,No,varchar(50),The identifier of the care_site as it appears in the source data. This could be an identifier separate from the name of the care_site.,,No,No,,,,, -CARE_SITE,place_of_service_source_value,No,varchar(50),,Put the place of service of the care_site as it appears in the source data.,No,No,,,,, -PROVIDER,provider_id,Yes,integer,It is assumed that every provider with a different unique identifier is in fact a different person and should be treated independently.,"This identifier can be the original id from the source data provided it is an integer, otherwise it can be an autogenerated number.",Yes,No,,,,, -PROVIDER,provider_name,No,varchar(255),,"This field is not necessary as it is not necessary to have the actual identity of the Provider. Rather, the idea is to uniquely and anonymously identify providers of care across the database.",No,No,,,,, -PROVIDER,npi,No,varchar(20),This is the National Provider Number issued to health care providers in the US by the Centers for Medicare and Medicaid Services (CMS).,,No,No,,,,, -PROVIDER,dea,No,varchar(20),"This is the identifier issued by the DEA, a US federal agency, that allows a provider to write prescriptions for controlled substances.",,No,No,,,,, -PROVIDER,specialty_concept_id,No,integer,"This field either represents the most common specialty that occurs in the data or the most specific concept that represents all specialties listed, should the provider have more than one. This includes physician specialties such as internal medicine, emergency medicine, etc. and allied health professionals such as nurses, midwives, and pharmacists.","If a Provider has more than one Specialty, there are two options: 1. Choose a concept_id which is a common ancestor to the multiple specialties, or, 2. Choose the specialty that occurs most often for the provider. Concepts in this field should be Standard with a domain of Provider. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Provider&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, -PROVIDER,care_site_id,No,integer,This is the CARE_SITE_ID for the location that the provider primarily practices in.,"If a Provider has more than one Care Site, the main or most often exerted CARE_SITE_ID should be recorded.",No,Yes,CARE_SITE,CARE_SITE_ID,,, -PROVIDER,year_of_birth,No,integer,,,No,No,,,,, -PROVIDER,gender_concept_id,No,integer,This field represents the recorded gender of the provider in the source data.,"If given, put a concept from the gender domain representing the recorded gender of the provider. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Gender&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Gender,, -PROVIDER,provider_source_value,No,varchar(50),Use this field to link back to providers in the source data. This is typically used for error checking of ETL logic.,Some use cases require the ability to link back to providers in the source data. This field allows for the storing of the provider identifier as it appears in the source.,No,No,,,,, -PROVIDER,specialty_source_value,No,varchar(50),"This is the kind of provider or specialty as it appears in the source data. This includes physician specialties such as internal medicine, emergency medicine, etc. and allied health professionals such as nurses, midwives, and pharmacists.",Put the kind of provider as it appears in the source data. This field is up to the discretion of the ETL-er as to whether this should be the coded value from the source or the text description of the lookup value.,No,No,,,,, -PROVIDER,specialty_source_concept_id,No,integer,This is often zero as many sites use proprietary codes to store physician speciality.,If the source data codes provider specialty in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PROVIDER,gender_source_value,No,varchar(50),This is provider's gender as it appears in the source data.,Put the provider's gender as it appears in the source data. This field is up to the discretion of the ETL-er as to whether this should be the coded value from the source or the text description of the lookup value.,No,No,,,,, -PROVIDER,gender_source_concept_id,No,integer,This is often zero as many sites use proprietary codes to store provider gender.,If the source data codes provider gender in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,payer_plan_period_id,Yes,integer,"A unique identifier for each unique combination of a Person, Payer, Plan, and Period of time.",,Yes,Yes,PERSON,PERSON_ID,,, -PAYER_PLAN_PERIOD,person_id,Yes,integer,The Person covered by the Plan.,"A single Person can have multiple, overlapping, PAYER_PLAN_PERIOD records",No,Yes,PERSON,PERSON_ID,,, -PAYER_PLAN_PERIOD,payer_plan_period_start_date,Yes,date,Start date of Plan coverage.,,No,No,,,,, -PAYER_PLAN_PERIOD,payer_plan_period_end_date,Yes,date,End date of Plan coverage.,,No,No,,,,, -PAYER_PLAN_PERIOD,payer_concept_id,No,integer,This field represents the organization who reimburses the provider which administers care to the Person.,"Map the Payer directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same payer, though the name of the Payer is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Payer&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,payer_source_value,No,varchar(50),This is the Payer as it appears in the source data.,,No,No,,,,, -PAYER_PLAN_PERIOD,payer_source_concept_id,No,integer,,If the source data codes the Payer in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,plan_concept_id,No,integer,This field represents the specific health benefit Plan the Person is enrolled in.,Map the Plan directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same health benefit Plan though the name of the Plan is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Plan&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,plan_source_value,No,varchar(50),This is the health benefit Plan of the Person as it appears in the source data.,,No,No,,,,, -PAYER_PLAN_PERIOD,plan_source_concept_id,No,integer,,If the source data codes the Plan in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,sponsor_concept_id,No,integer,"This field represents the sponsor of the Plan who finances the Plan. This includes self-insured, small group health plan and large group health plan.",Map the sponsor directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same sponsor though the name of the sponsor is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Sponsor&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,sponsor_source_value,No,varchar(50),The Plan sponsor as it appears in the source data.,,No,No,,,,, -PAYER_PLAN_PERIOD,sponsor_source_concept_id,No,integer,,If the source data codes the sponsor in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,family_source_value,No,varchar(50),The common identifier for all people (often a family) that covered by the same policy.,Often these are the common digits of the enrollment id of the policy members.,No,No,,,,, -PAYER_PLAN_PERIOD,stop_reason_concept_id,No,integer,"This field represents the reason the Person left the Plan, if known.",Map the stop reason directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Plan+Stop+Reason&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, -PAYER_PLAN_PERIOD,stop_reason_source_value,No,varchar(50),The Plan stop reason as it appears in the source data.,,No,No,,,,, -PAYER_PLAN_PERIOD,stop_reason_source_concept_id,No,integer,,If the source data codes the stop reason in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, -COST,cost_id,Yes,integer,,,Yes,No,,,,, -COST,cost_event_id,Yes,integer,,,No,No,,,,, -COST,cost_domain_id,Yes,varchar(20),,,No,Yes,DOMAIN,DOMAIN_ID,,, -COST,cost_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -COST,currency_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -COST,total_charge,No,float,,,No,No,,,,, -COST,total_cost,No,float,,,No,No,,,,, -COST,total_paid,No,float,,,No,No,,,,, -COST,paid_by_payer,No,float,,,No,No,,,,, -COST,paid_by_patient,No,float,,,No,No,,,,, -COST,paid_patient_copay,No,float,,,No,No,,,,, -COST,paid_patient_coinsurance,No,float,,,No,No,,,,, -COST,paid_patient_deductible,No,float,,,No,No,,,,, -COST,paid_by_primary,No,float,,,No,No,,,,, -COST,paid_ingredient_cost,No,float,,,No,No,,,,, -COST,paid_dispensing_fee,No,float,,,No,No,,,,, -COST,payer_plan_period_id,No,integer,,,No,No,,,,, -COST,amount_allowed,No,float,,,No,No,,,,, -COST,revenue_code_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -COST,revenue_code_source_value,No,varchar(50),Revenue codes are a method to charge for a class of procedures and conditions in the U.S. hospital system.,,No,No,,,,, -COST,drg_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -COST,drg_source_value,No,varchar(3),Diagnosis Related Groups are US codes used to classify hospital cases into one of approximately 500 groups. ,,No,No,,,,, -DRUG_ERA,drug_era_id,Yes,integer,,,Yes,No,,,,, -DRUG_ERA,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -DRUG_ERA,drug_concept_id,Yes,integer,The Concept Id representing the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Drug,Ingredient, -DRUG_ERA,drug_era_start_date,Yes,datetime,,"The Drug Era Start Date is the start date of the first Drug Exposure for a given ingredient, with at least 31 days since the previous exposure. ",No,No,,,,, +- Uncertain = true or high or moderate or even low (could argue about low). Term_modifiers will concatenate all modifiers for different types of entities (conditions, drugs, labs etc) into one string. Lab values will be saved as one of the modifiers. ",No,No,,,,, +SPECIMEN,specimen_id,Yes,integer,Unique identifier for each specimen.,,Yes,No,,,,, +SPECIMEN,person_id,Yes,integer,The person from whom the specimen is collected.,,No,Yes,PERSON,PERSON_ID,,, +SPECIMEN,specimen_concept_id,Yes,integer,,The standard CONCEPT_ID that the SPECIMEN_SOURCE_VALUE maps to in the specimen domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Specimen&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, +SPECIMEN,specimen_type_concept_id,Yes,integer,,"Put the source of the specimen record, as in an EHR system. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Type+Concept&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Type Concept,, +SPECIMEN,specimen_date,Yes,date,The date the specimen was collected.,,No,No,,,,, +SPECIMEN,specimen_datetime,No,datetime,,,No,No,,,,, +SPECIMEN,quantity,No,float,The amount of specimen collected from the person.,,No,No,,,,, +SPECIMEN,unit_concept_id,No,integer,The unit for the quantity of the specimen.,Map the UNIT_SOURCE_VALUE to a Standard Concept in the Unit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Unit&standardConcept=Standard&page=1&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, +SPECIMEN,anatomic_site_concept_id,No,integer,This is the site on the body where the specimen is from.,Map the ANATOMIC_SITE_SOURCE_VALUE to a Standard Concept in the Spec Anatomic Site domain. This should be coded at the lowest level of granularity [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?standardConcept=Standard&domain=Spec+Anatomic+Site&conceptClass=Body+Structure&page=4&pageSize=15&query=),No,Yes,CONCEPT,CONCEPT_ID,,, +SPECIMEN,disease_status_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +SPECIMEN,specimen_source_id,No,varchar(50),This is the identifier for the specimen from the source system. ,,No,No,,,,, +SPECIMEN,specimen_source_value,No,varchar(50),,,No,No,,,,, +SPECIMEN,unit_source_value,No,varchar(50),,"This unit for the quantity of the specimen, as represented in the source.",No,No,,,,, +SPECIMEN,anatomic_site_source_value,No,varchar(50),,"This is the site on the body where the specimen was taken from, as represented in the source.",No,No,,,,, +SPECIMEN,disease_status_source_value,No,varchar(50),,,No,No,,,,, +FACT_RELATIONSHIP,domain_concept_id_1,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +FACT_RELATIONSHIP,fact_id_1,Yes,integer,,,No,No,,,,, +FACT_RELATIONSHIP,domain_concept_id_2,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +FACT_RELATIONSHIP,fact_id_2,Yes,integer,,,No,No,,,,, +FACT_RELATIONSHIP,relationship_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +LOCATION,location_id,Yes,integer,The unique key given to a unique Location.,Each instance of a Location in the source data should be assigned this unique key.,Yes,No,,,,, +LOCATION,address_1,No,varchar(50),This is the first line of the address.,,No,No,,,,, +LOCATION,address_2,No,varchar(50),This is the second line of the address,,No,No,,,,, +LOCATION,city,No,varchar(50),,,No,No,,,,, +LOCATION,state,No,varchar(2),,,No,No,,,,, +LOCATION,zip,No,varchar(9),,"Zip codes are handled as strings of up to 9 characters length. For US addresses, these represent either a 3-digit abbreviated Zip code as provided by many sources for patient protection reasons, the full 5-digit Zip or the 9-digit (ZIP + 4) codes. Unless for specific reasons analytical methods should expect and utilize only the first 3 digits. For international addresses, different rules apply.",No,No,,,,, +LOCATION,county,No,varchar(20),,,No,No,,,,, +LOCATION,location_source_value,No,varchar(50),,"Put the verbatim value for the location here, as it shows up in the source. ",No,No,,,,, +LOCATION,country_concept_id,No,integer,The Concept Id representing the country. Values should conform to the [Geography](https://athena.ohdsi.org/search-terms/terms?domain=Geography&standardConcept=Standard&page=1&pageSize=15&query=&boosts) domain. ,,,,,,,, +LOCATION,country_source_value,No,varchar(80),The name of the country.,,,,,,,, +LOCATION,latitude,No,float,,Must be between -90 and 90.,,,,,,, +LOCATION,longitude,No,float,,Must be between -180 and 180.,,,,,,, +CARE_SITE,care_site_id,Yes,integer,,Assign an id to each unique combination of location_id and place_of_service_source_value,Yes,No,,,,, +CARE_SITE,care_site_name,No,varchar(255),The name of the care_site as it appears in the source data,,No,No,,,,, +CARE_SITE,place_of_service_concept_id,No,integer,"This is a high-level way of characterizing a Care Site. Typically, however, Care Sites can provide care in multiple settings (inpatient, outpatient, etc.) and this granularity should be reflected in the visit.","Choose the concept in the visit domain that best represents the setting in which healthcare is provided in the Care Site. If most visits in a Care Site are Inpatient, then the place_of_service_concept_id should represent Inpatient. If information is present about a unique Care Site (e.g. Pharmacy) then a Care Site record should be created. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=2&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, +CARE_SITE,location_id,No,integer,The location_id from the LOCATION table representing the physical location of the care_site.,,No,Yes,LOCATION,LOCATION_ID,,, +CARE_SITE,care_site_source_value,No,varchar(50),The identifier of the care_site as it appears in the source data. This could be an identifier separate from the name of the care_site.,,No,No,,,,, +CARE_SITE,place_of_service_source_value,No,varchar(50),,Put the place of service of the care_site as it appears in the source data.,No,No,,,,, +PROVIDER,provider_id,Yes,integer,It is assumed that every provider with a different unique identifier is in fact a different person and should be treated independently.,"This identifier can be the original id from the source data provided it is an integer, otherwise it can be an autogenerated number.",Yes,No,,,,, +PROVIDER,provider_name,No,varchar(255),,"This field is not necessary as it is not necessary to have the actual identity of the Provider. Rather, the idea is to uniquely and anonymously identify providers of care across the database.",No,No,,,,, +PROVIDER,npi,No,varchar(20),This is the National Provider Number issued to health care providers in the US by the Centers for Medicare and Medicaid Services (CMS).,,No,No,,,,, +PROVIDER,dea,No,varchar(20),"This is the identifier issued by the DEA, a US federal agency, that allows a provider to write prescriptions for controlled substances.",,No,No,,,,, +PROVIDER,specialty_concept_id,No,integer,"This field either represents the most common specialty that occurs in the data or the most specific concept that represents all specialties listed, should the provider have more than one. This includes physician specialties such as internal medicine, emergency medicine, etc. and allied health professionals such as nurses, midwives, and pharmacists.","If a Provider has more than one Specialty, there are two options: 1. Choose a concept_id which is a common ancestor to the multiple specialties, or, 2. Choose the specialty that occurs most often for the provider. Concepts in this field should be Standard with a domain of Provider. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Provider&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, +PROVIDER,care_site_id,No,integer,This is the CARE_SITE_ID for the location that the provider primarily practices in.,"If a Provider has more than one Care Site, the main or most often exerted CARE_SITE_ID should be recorded.",No,Yes,CARE_SITE,CARE_SITE_ID,,, +PROVIDER,year_of_birth,No,integer,,,No,No,,,,, +PROVIDER,gender_concept_id,No,integer,This field represents the recorded gender of the provider in the source data.,"If given, put a concept from the gender domain representing the recorded gender of the provider. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Gender&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Gender,, +PROVIDER,provider_source_value,No,varchar(50),Use this field to link back to providers in the source data. This is typically used for error checking of ETL logic.,Some use cases require the ability to link back to providers in the source data. This field allows for the storing of the provider identifier as it appears in the source.,No,No,,,,, +PROVIDER,specialty_source_value,No,varchar(50),"This is the kind of provider or specialty as it appears in the source data. This includes physician specialties such as internal medicine, emergency medicine, etc. and allied health professionals such as nurses, midwives, and pharmacists.",Put the kind of provider as it appears in the source data. This field is up to the discretion of the ETL-er as to whether this should be the coded value from the source or the text description of the lookup value.,No,No,,,,, +PROVIDER,specialty_source_concept_id,No,integer,This is often zero as many sites use proprietary codes to store physician speciality.,If the source data codes provider specialty in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PROVIDER,gender_source_value,No,varchar(50),This is provider's gender as it appears in the source data.,Put the provider's gender as it appears in the source data. This field is up to the discretion of the ETL-er as to whether this should be the coded value from the source or the text description of the lookup value.,No,No,,,,, +PROVIDER,gender_source_concept_id,No,integer,This is often zero as many sites use proprietary codes to store provider gender.,If the source data codes provider gender in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,payer_plan_period_id,Yes,integer,"A unique identifier for each unique combination of a Person, Payer, Plan, and Period of time.",,Yes,Yes,PERSON,PERSON_ID,,, +PAYER_PLAN_PERIOD,person_id,Yes,integer,The Person covered by the Plan.,"A single Person can have multiple, overlapping, PAYER_PLAN_PERIOD records",No,Yes,PERSON,PERSON_ID,,, +PAYER_PLAN_PERIOD,payer_plan_period_start_date,Yes,date,Start date of Plan coverage.,,No,No,,,,, +PAYER_PLAN_PERIOD,payer_plan_period_end_date,Yes,date,End date of Plan coverage.,,No,No,,,,, +PAYER_PLAN_PERIOD,payer_concept_id,No,integer,This field represents the organization who reimburses the provider which administers care to the Person.,"Map the Payer directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same payer, though the name of the Payer is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Payer&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,payer_source_value,No,varchar(50),This is the Payer as it appears in the source data.,,No,No,,,,, +PAYER_PLAN_PERIOD,payer_source_concept_id,No,integer,,If the source data codes the Payer in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,plan_concept_id,No,integer,This field represents the specific health benefit Plan the Person is enrolled in.,Map the Plan directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same health benefit Plan though the name of the Plan is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Plan&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,plan_source_value,No,varchar(50),This is the health benefit Plan of the Person as it appears in the source data.,,No,No,,,,, +PAYER_PLAN_PERIOD,plan_source_concept_id,No,integer,,If the source data codes the Plan in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,sponsor_concept_id,No,integer,"This field represents the sponsor of the Plan who finances the Plan. This includes self-insured, small group health plan and large group health plan.",Map the sponsor directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. The point is to stratify on this information and identify if Persons have the same sponsor though the name of the sponsor is not necessary. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Sponsor&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,sponsor_source_value,No,varchar(50),The Plan sponsor as it appears in the source data.,,No,No,,,,, +PAYER_PLAN_PERIOD,sponsor_source_concept_id,No,integer,,If the source data codes the sponsor in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,family_source_value,No,varchar(50),The common identifier for all people (often a family) that covered by the same policy.,Often these are the common digits of the enrollment id of the policy members.,No,No,,,,, +PAYER_PLAN_PERIOD,stop_reason_concept_id,No,integer,"This field represents the reason the Person left the Plan, if known.",Map the stop reason directly to a standard CONCEPT_ID. If one does not exists please contact the vocabulary team. There is no global controlled vocabulary available for this information. [Accepted Concepts](http://athena.ohdsi.org/search-terms/terms?domain=Plan+Stop+Reason&standardConcept=Standard&page=1&pageSize=15&query=).,No,Yes,CONCEPT,CONCEPT_ID,,, +PAYER_PLAN_PERIOD,stop_reason_source_value,No,varchar(50),The Plan stop reason as it appears in the source data.,,No,No,,,,, +PAYER_PLAN_PERIOD,stop_reason_source_concept_id,No,integer,,If the source data codes the stop reason in an OMOP supported vocabulary store the concept_id here.,No,Yes,CONCEPT,CONCEPT_ID,,, +COST,cost_id,Yes,integer,,,Yes,No,,,,, +COST,cost_event_id,Yes,integer,,,No,No,,,,, +COST,cost_domain_id,Yes,varchar(20),,,No,Yes,DOMAIN,DOMAIN_ID,,, +COST,cost_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +COST,currency_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +COST,total_charge,No,float,,,No,No,,,,, +COST,total_cost,No,float,,,No,No,,,,, +COST,total_paid,No,float,,,No,No,,,,, +COST,paid_by_payer,No,float,,,No,No,,,,, +COST,paid_by_patient,No,float,,,No,No,,,,, +COST,paid_patient_copay,No,float,,,No,No,,,,, +COST,paid_patient_coinsurance,No,float,,,No,No,,,,, +COST,paid_patient_deductible,No,float,,,No,No,,,,, +COST,paid_by_primary,No,float,,,No,No,,,,, +COST,paid_ingredient_cost,No,float,,,No,No,,,,, +COST,paid_dispensing_fee,No,float,,,No,No,,,,, +COST,payer_plan_period_id,No,integer,,,No,No,,,,, +COST,amount_allowed,No,float,,,No,No,,,,, +COST,revenue_code_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +COST,revenue_code_source_value,No,varchar(50),Revenue codes are a method to charge for a class of procedures and conditions in the U.S. hospital system.,,No,No,,,,, +COST,drg_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +COST,drg_source_value,No,varchar(3),Diagnosis Related Groups are US codes used to classify hospital cases into one of approximately 500 groups. ,,No,No,,,,, +DRUG_ERA,drug_era_id,Yes,integer,,,Yes,No,,,,, +DRUG_ERA,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +DRUG_ERA,drug_concept_id,Yes,integer,The Concept Id representing the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Drug,Ingredient, +DRUG_ERA,drug_era_start_date,Yes,datetime,,"The Drug Era Start Date is the start date of the first Drug Exposure for a given ingredient, with at least 31 days since the previous exposure. ",No,No,,,,, DRUG_ERA,drug_era_end_date,Yes,datetime,,"The Drug Era End Date is the end date of the last Drug Exposure. The End Date of each Drug Exposure is either taken from the field drug_exposure_end_date or, as it is typically not available, inferred using the following rules: For pharmacy prescription data, the date when the drug was dispensed plus the number of days of supply are used to extrapolate the End Date for the Drug Exposure. Depending on the country-specific healthcare system, this supply information is either explicitly provided in the day_supply field or inferred from package size or similar information. For Procedure Drugs, usually the drug is administered on a single date (i.e., the administration date). -A standard Persistence Window of 30 days (gap, slack) is permitted between two subsequent such extrapolated DRUG_EXPOSURE records to be considered to be merged into a single Drug Era.",No,No,,,,, -DRUG_ERA,drug_exposure_count,No,integer,,,No,No,,,,, -DRUG_ERA,gap_days,No,integer,,"The Gap Days determine how many total drug-free days are observed between all Drug Exposure events that contribute to a DRUG_ERA record. It is assumed that the drugs are ""not stockpiled"" by the patient, i.e. that if a new drug prescription or refill is observed (a new DRUG_EXPOSURE record is written), the remaining supply from the previous events is abandoned. The difference between Persistence Window and Gap Days is that the former is the maximum drug-free time allowed between two subsequent DRUG_EXPOSURE records, while the latter is the sum of actual drug-free days for the given Drug Era under the above assumption of non-stockpiling.",No,No,,,,, -DOSE_ERA,dose_era_id,Yes,integer,,,Yes,No,,,,, -DOSE_ERA,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, -DOSE_ERA,drug_concept_id,Yes,integer,The Concept Id representing the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Drug,Ingredient, -DOSE_ERA,unit_concept_id,Yes,integer,The Concept Id representing the unit of the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Unit,, -DOSE_ERA,dose_value,Yes,float,The numeric value of the dosage of the drug_ingredient.,,No,No,,,,, -DOSE_ERA,dose_era_start_date,Yes,datetime,"The date the Person started on the specific dosage, with at least 31 days since any prior exposure.",,No,No,,,,, -DOSE_ERA,dose_era_end_date,Yes,datetime,,The date the Person was no longer exposed to the dosage of the specific drug ingredient. An era is ended if there are 31 days or more between dosage records.,No,No,,,,, -CONDITION_ERA,condition_era_id,Yes,integer,,,Yes,No,,,,, -CONDITION_ERA,person_id,Yes,integer,,,No,No,PERSON,PERSON_ID,,, -CONDITION_ERA,condition_concept_id,Yes,integer,The Concept Id representing the Condition.,,No,Yes,CONCEPT,CONCEPT_ID,Condition,, +A standard Persistence Window of 30 days (gap, slack) is permitted between two subsequent such extrapolated DRUG_EXPOSURE records to be considered to be merged into a single Drug Era.",No,No,,,,, +DRUG_ERA,drug_exposure_count,No,integer,,,No,No,,,,, +DRUG_ERA,gap_days,No,integer,,"The Gap Days determine how many total drug-free days are observed between all Drug Exposure events that contribute to a DRUG_ERA record. It is assumed that the drugs are ""not stockpiled"" by the patient, i.e. that if a new drug prescription or refill is observed (a new DRUG_EXPOSURE record is written), the remaining supply from the previous events is abandoned. The difference between Persistence Window and Gap Days is that the former is the maximum drug-free time allowed between two subsequent DRUG_EXPOSURE records, while the latter is the sum of actual drug-free days for the given Drug Era under the above assumption of non-stockpiling.",No,No,,,,, +DOSE_ERA,dose_era_id,Yes,integer,,,Yes,No,,,,, +DOSE_ERA,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, +DOSE_ERA,drug_concept_id,Yes,integer,The Concept Id representing the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Drug,Ingredient, +DOSE_ERA,unit_concept_id,Yes,integer,The Concept Id representing the unit of the specific drug ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,Unit,, +DOSE_ERA,dose_value,Yes,float,The numeric value of the dosage of the drug_ingredient.,,No,No,,,,, +DOSE_ERA,dose_era_start_date,Yes,datetime,"The date the Person started on the specific dosage, with at least 31 days since any prior exposure.",,No,No,,,,, +DOSE_ERA,dose_era_end_date,Yes,datetime,,The date the Person was no longer exposed to the dosage of the specific drug ingredient. An era is ended if there are 31 days or more between dosage records.,No,No,,,,, +CONDITION_ERA,condition_era_id,Yes,integer,,,Yes,No,,,,, +CONDITION_ERA,person_id,Yes,integer,,,No,No,PERSON,PERSON_ID,,, +CONDITION_ERA,condition_concept_id,Yes,integer,The Concept Id representing the Condition.,,No,Yes,CONCEPT,CONCEPT_ID,Condition,, CONDITION_ERA,condition_era_start_date,Yes,datetime,"The start date for the Condition Era constructed from the individual instances of Condition Occurrences. It is the start date of the very first chronologically recorded instance of -the condition with at least 31 days since any prior record of the same Condition. ",,No,No,,,,, +the condition with at least 31 days since any prior record of the same Condition. ",,No,No,,,,, CONDITION_ERA,condition_era_end_date,Yes,datetime,"The end date for the Condition Era constructed from the individual instances of Condition Occurrences. It is the end date of the final continuously recorded instance of the -Condition.",,No,No,,,,, +Condition.",,No,No,,,,, CONDITION_ERA,condition_occurrence_count,No,integer,"The number of individual Condition Occurrences used to construct the -condition era.",,No,No,,,,, -METADATA,metadata_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -METADATA,metadata_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -METADATA,name,Yes,varchar(250),,,No,No,,,,, -METADATA,value_as_string,No,varchar(250),,,No,No,,,,, -METADATA,value_as_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -METADATA,metadata_date,No,date,,,No,No,,,,, -METADATA,metadata_datetime,No,datetime,,,No,No,,,,, -CDM_SOURCE,cdm_source_name,Yes,varchar(255),The name of the CDM instance.,,No,No,,,,, -CDM_SOURCE,cdm_source_abbreviation,Yes,varchar(25),The abbreviation of the CDM instance.,,No,No,,,,, -CDM_SOURCE,cdm_holder,Yes,varchar(255),The holder of the CDM instance.,,No,No,,,,, -CDM_SOURCE,source_description,No,varchar(MAX),The description of the CDM instance.,,No,No,,,,, -CDM_SOURCE,source_documentation_reference,No,varchar(255),,,No,No,,,,, -CDM_SOURCE,cdm_etl_reference,No,varchar(255),,Put the link to the CDM version used.,No,No,,,,, -CDM_SOURCE,source_release_date,Yes,date,The release date of the source data.,,No,No,,,,, -CDM_SOURCE,cdm_release_date,Yes,date,The release data of the CDM instance.,,No,No,,,,, -CDM_SOURCE,cdm_version,No,varchar(10),,,No,No,,,,, -CDM_SOURCE,cdm_version_concept_id,Yes,integer,The Concept Id representing the version of the CDM.,,,,,,,, -CDM_SOURCE,vocabulary_version,Yes,varchar(20),,,No,No,,,,, -CONCEPT,concept_id,Yes,integer,A unique identifier for each Concept across all domains.,,Yes,No,,,,, -CONCEPT,concept_name,Yes,varchar(255),"An unambiguous, meaningful and descriptive name for the Concept.",,No,No,,,,, -CONCEPT,domain_id,Yes,varchar(20),A foreign key to the [DOMAIN](https://ohdsi.github.io/CommonDataModel/cdm531.html#domain) table the Concept belongs to.,,No,Yes,DOMAIN,DOMAIN_ID,,, +condition era.",,No,No,,,,, +METADATA,metadata_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +METADATA,metadata_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +METADATA,name,Yes,varchar(250),,,No,No,,,,, +METADATA,value_as_string,No,varchar(250),,,No,No,,,,, +METADATA,value_as_concept_id,No,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +METADATA,metadata_date,No,date,,,No,No,,,,, +METADATA,metadata_datetime,No,datetime,,,No,No,,,,, +CDM_SOURCE,cdm_source_name,Yes,varchar(255),The name of the CDM instance.,,No,No,,,,, +CDM_SOURCE,cdm_source_abbreviation,Yes,varchar(25),The abbreviation of the CDM instance.,,No,No,,,,, +CDM_SOURCE,cdm_holder,Yes,varchar(255),The holder of the CDM instance.,,No,No,,,,, +CDM_SOURCE,source_description,No,varchar(MAX),The description of the CDM instance.,,No,No,,,,, +CDM_SOURCE,source_documentation_reference,No,varchar(255),,,No,No,,,,, +CDM_SOURCE,cdm_etl_reference,No,varchar(255),,Put the link to the CDM version used.,No,No,,,,, +CDM_SOURCE,source_release_date,Yes,date,The release date of the source data.,,No,No,,,,, +CDM_SOURCE,cdm_release_date,Yes,date,The release data of the CDM instance.,,No,No,,,,, +CDM_SOURCE,cdm_version,No,varchar(10),,,No,No,,,,, +CDM_SOURCE,cdm_version_concept_id,Yes,integer,The Concept Id representing the version of the CDM.,,,,,,,, +CDM_SOURCE,vocabulary_version,Yes,varchar(20),,,No,No,,,,, +CONCEPT,concept_id,Yes,integer,A unique identifier for each Concept across all domains.,,Yes,No,,,,, +CONCEPT,concept_name,Yes,varchar(255),"An unambiguous, meaningful and descriptive name for the Concept.",,No,No,,,,, +CONCEPT,domain_id,Yes,varchar(20),A foreign key to the [DOMAIN](https://ohdsi.github.io/CommonDataModel/cdm531.html#domain) table the Concept belongs to.,,No,Yes,DOMAIN,DOMAIN_ID,,, CONCEPT,vocabulary_id,Yes,varchar(20),"A foreign key to the [VOCABULARY](https://ohdsi.github.io/CommonDataModel/cdm531.html#vocabulary) table indicating from which source the -Concept has been adapted.",,No,Yes,VOCABULARY,VOCABULARY_ID,,, +Concept has been adapted.",,No,Yes,VOCABULARY,VOCABULARY_ID,,, CONCEPT,concept_class_id,Yes,varchar(20),"The attribute or concept class of the Concept. Examples are 'Clinical Drug', -'Ingredient', 'Clinical Finding' etc.",,No,Yes,CONCEPT_CLASS,CONCEPT_CLASS_ID,,, +'Ingredient', 'Clinical Finding' etc.",,No,Yes,CONCEPT_CLASS,CONCEPT_CLASS_ID,,, CONCEPT,standard_concept,No,varchar(1),"This flag determines where a Concept is a Standard Concept, i.e. is used in the data, a Classification Concept, or a non-standard Source Concept. The allowable values are 'S' (Standard Concept) and 'C' (Classification -Concept), otherwise the content is NULL.",,No,No,,,,, +Concept), otherwise the content is NULL.",,No,No,,,,, CONCEPT,concept_code,Yes,varchar(50),"The concept code represents the identifier of the Concept in the source vocabulary, such as SNOMED-CT concept IDs, RxNorm RXCUIs etc. Note that concept -codes are not unique across vocabularies.",,No,No,,,,, +codes are not unique across vocabularies.",,No,No,,,,, CONCEPT,valid_start_date,Yes,date,"The date when the Concept was first recorded. The default value is 1-Jan-1970, meaning, the Concept has no -(known) date of inception.",,No,No,,,,, +(known) date of inception.",,No,No,,,,, CONCEPT,valid_end_date,Yes,date,"The date when the Concept became invalid because it was deleted or superseded (updated) by a new concept. The default value is 31-Dec-2099, meaning, the Concept is valid until it -becomes deprecated.",,No,No,,,,, +becomes deprecated.",,No,No,,,,, CONCEPT,invalid_reason,No,varchar(1),"Reason the Concept was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when -valid_end_date has the default value.",,No,No,,,,, +valid_end_date has the default value.",,No,No,,,,, VOCABULARY,vocabulary_id,Yes,varchar(20),"A unique identifier for each Vocabulary, such -as ICD9CM, SNOMED, Visit.",,Yes,No,,,,, +as ICD9CM, SNOMED, Visit.",,Yes,No,,,,, VOCABULARY,vocabulary_name,Yes,varchar(255),"The name describing the vocabulary, for example, International Classification of Diseases, Ninth Revision, Clinical -Modification, Volume 1 and 2 (NCHS) etc.",,No,No,,,,, +Modification, Volume 1 and 2 (NCHS) etc.",,No,No,,,,, VOCABULARY,vocabulary_reference,Yes,varchar(255),"External reference to documentation or available download of the about the -vocabulary.",,No,No,,,,, +vocabulary.",,No,No,,,,, VOCABULARY,vocabulary_version,No,varchar(255),"Version of the Vocabulary as indicated in -the source.",,No,No,,,,, -VOCABULARY,vocabulary_concept_id,Yes,integer,A Concept that represents the Vocabulary the VOCABULARY record belongs to.,,No,Yes,CONCEPT,CONCEPT_ID,,, -DOMAIN,domain_id,Yes,varchar(20),A unique key for each domain.,,Yes,No,,,,, +the source.",,No,No,,,,, +VOCABULARY,vocabulary_concept_id,Yes,integer,A Concept that represents the Vocabulary the VOCABULARY record belongs to.,,No,Yes,CONCEPT,CONCEPT_ID,,, +DOMAIN,domain_id,Yes,varchar(20),A unique key for each domain.,,Yes,No,,,,, DOMAIN,domain_name,Yes,varchar(255),"The name describing the Domain, e.g. Condition, Procedure, Measurement -etc.",,No,No,,,,, -DOMAIN,domain_concept_id,Yes,integer,A Concept representing the Domain Concept the DOMAIN record belongs to.,,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_CLASS,concept_class_id,Yes,varchar(20),A unique key for each class.,,Yes,No,,,,, +etc.",,No,No,,,,, +DOMAIN,domain_concept_id,Yes,integer,A Concept representing the Domain Concept the DOMAIN record belongs to.,,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_CLASS,concept_class_id,Yes,varchar(20),A unique key for each class.,,Yes,No,,,,, CONCEPT_CLASS,concept_class_name,Yes,varchar(255),"The name describing the Concept Class, e.g. -Clinical Finding, Ingredient, etc.",,No,No,,,,, -CONCEPT_CLASS,concept_class_concept_id,Yes,integer,A Concept that represents the Concept Class.,,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_RELATIONSHIP,concept_id_1,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_RELATIONSHIP,concept_id_2,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_RELATIONSHIP,relationship_id,Yes,varchar(20),The relationship between CONCEPT_ID_1 and CONCEPT_ID_2. Please see the [Vocabulary Conventions](https://ohdsi.github.io/CommonDataModel/dataModelConventions.html#concept_relationships). for more information. ,,No,Yes,RELATIONSHIP,RELATIONSHIP_ID,,, -CONCEPT_RELATIONSHIP,valid_start_date,Yes,date,The date when the relationship is first recorded.,,No,No,,,,, -CONCEPT_RELATIONSHIP,valid_end_date,Yes,date,The date when the relationship is invalidated.,,No,No,,,,, -CONCEPT_RELATIONSHIP,invalid_reason,No,varchar(1),"Reason the relationship was invalidated. Possible values are 'D' (deleted), 'U' (updated) or NULL. ",,No,No,,,,, +Clinical Finding, Ingredient, etc.",,No,No,,,,, +CONCEPT_CLASS,concept_class_concept_id,Yes,integer,A Concept that represents the Concept Class.,,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_RELATIONSHIP,concept_id_1,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_RELATIONSHIP,concept_id_2,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_RELATIONSHIP,relationship_id,Yes,varchar(20),The relationship between CONCEPT_ID_1 and CONCEPT_ID_2. Please see the [Vocabulary Conventions](https://ohdsi.github.io/CommonDataModel/dataModelConventions.html#concept_relationships). for more information. ,,No,Yes,RELATIONSHIP,RELATIONSHIP_ID,,, +CONCEPT_RELATIONSHIP,valid_start_date,Yes,date,The date when the relationship is first recorded.,,No,No,,,,, +CONCEPT_RELATIONSHIP,valid_end_date,Yes,date,The date when the relationship is invalidated.,,No,No,,,,, +CONCEPT_RELATIONSHIP,invalid_reason,No,varchar(1),"Reason the relationship was invalidated. Possible values are 'D' (deleted), 'U' (updated) or NULL. ",,No,No,,,,, RELATIONSHIP,relationship_id,Yes,varchar(20),"The type of relationship captured by the -relationship record.",,Yes,No,,,,, -RELATIONSHIP,relationship_name,Yes,varchar(255),,,No,No,,,,, +relationship record.",,Yes,No,,,,, +RELATIONSHIP,relationship_name,Yes,varchar(255),,,No,No,,,,, RELATIONSHIP,is_hierarchical,Yes,varchar(1),"Defines whether a relationship defines concepts into classes or hierarchies. Values -are 1 for hierarchical relationship or 0 if not.",,No,No,,,,, +are 1 for hierarchical relationship or 0 if not.",,No,No,,,,, RELATIONSHIP,defines_ancestry,Yes,varchar(1),"Defines whether a hierarchical relationship contributes to the concept_ancestor table. These are subsets of the hierarchical -relationships. Valid values are 1 or 0.",,No,No,,,,, +relationships. Valid values are 1 or 0.",,No,No,,,,, RELATIONSHIP,reverse_relationship_id,Yes,varchar(20),"The identifier for the relationship used to define the reverse relationship between two -concepts.",,No,No,,,,, +concepts.",,No,No,,,,, RELATIONSHIP,relationship_concept_id,Yes,integer,"A foreign key that refers to an identifier in the [CONCEPT](https://ohdsi.github.io/CommonDataModel/cdm531.html#concept) table for the unique -relationship concept.",,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_SYNONYM,concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -CONCEPT_SYNONYM,concept_synonym_name,Yes,varchar(1000),,,No,No,,,,, -CONCEPT_SYNONYM,language_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +relationship concept.",,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_SYNONYM,concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +CONCEPT_SYNONYM,concept_synonym_name,Yes,varchar(1000),,,No,No,,,,, +CONCEPT_SYNONYM,language_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, CONCEPT_ANCESTOR,ancestor_concept_id,Yes,integer,"The Concept Id for the higher-level concept -that forms the ancestor in the relationship.",,No,Yes,CONCEPT,CONCEPT_ID,,, +that forms the ancestor in the relationship.",,No,Yes,CONCEPT,CONCEPT_ID,,, CONCEPT_ANCESTOR,descendant_concept_id,Yes,integer,"The Concept Id for the lower-level concept that forms the descendant in the -relationship.",,No,Yes,CONCEPT,CONCEPT_ID,,, +relationship.",,No,Yes,CONCEPT,CONCEPT_ID,,, CONCEPT_ANCESTOR,min_levels_of_separation,Yes,integer,"The minimum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an attribute -that is used to simplify hierarchic analysis.",,No,No,,,,, +that is used to simplify hierarchic analysis.",,No,No,,,,, CONCEPT_ANCESTOR,max_levels_of_separation,Yes,integer,"The maximum separation in number of levels of hierarchy between ancestor and descendant concepts. This is an attribute -that is used to simplify hierarchic analysis.",,No,No,,,,, +that is used to simplify hierarchic analysis.",,No,No,,,,, SOURCE_TO_CONCEPT_MAP,source_code,Yes,varchar(50),"The source code being translated -into a Standard Concept.",,No,No,,,,, +into a Standard Concept.",,No,No,,,,, SOURCE_TO_CONCEPT_MAP,source_concept_id,Yes,integer,"A foreign key to the Source Concept that is being translated -into a Standard Concept.","This is either 0 or should be a number above 2 billion, which are the Concepts reserved for site-specific codes and mappings. ",No,Yes,CONCEPT,CONCEPT_ID,,, +into a Standard Concept.","This is either 0 or should be a number above 2 billion, which are the Concepts reserved for site-specific codes and mappings. ",No,Yes,CONCEPT,CONCEPT_ID,,, SOURCE_TO_CONCEPT_MAP,source_vocabulary_id,Yes,varchar(20),"A foreign key to the VOCABULARY table defining the vocabulary of the source code that is being translated to a Standard -Concept.",,No,No,,,,, +Concept.",,No,No,,,,, SOURCE_TO_CONCEPT_MAP,source_code_description,No,varchar(255),"An optional description for the source code. This is included as a convenience to compare the description of the source code to -the name of the concept.",,No,No,,,,, +the name of the concept.",,No,No,,,,, SOURCE_TO_CONCEPT_MAP,target_concept_id,Yes,integer,"The target Concept to which the source code is being -mapped.",,No,Yes,CONCEPT,CONCEPT_ID,,, -SOURCE_TO_CONCEPT_MAP,target_vocabulary_id,Yes,varchar(20),The Vocabulary of the target Concept.,,No,Yes,VOCABULARY,VOCABULARY_ID,,, +mapped.",,No,Yes,CONCEPT,CONCEPT_ID,,, +SOURCE_TO_CONCEPT_MAP,target_vocabulary_id,Yes,varchar(20),The Vocabulary of the target Concept.,,No,Yes,VOCABULARY,VOCABULARY_ID,,, SOURCE_TO_CONCEPT_MAP,valid_start_date,Yes,date,"The date when the mapping -instance was first recorded.",,No,No,,,,, +instance was first recorded.",,No,No,,,,, SOURCE_TO_CONCEPT_MAP,valid_end_date,Yes,date,"The date when the mapping instance became invalid because it was deleted or superseded (updated) by a new relationship. -Default value is 31-Dec-2099.",,No,No,,,,, -SOURCE_TO_CONCEPT_MAP,invalid_reason,No,varchar(1),"Reason the mapping instance was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, -DRUG_STRENGTH,drug_concept_id,Yes,integer,The Concept representing the Branded Drug or Clinical Drug Product.,,No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_STRENGTH,ingredient_concept_id,Yes,integer,The Concept representing the active ingredient contained within the drug product.,"Combination Drugs will have more than one record in this table, one for each active Ingredient.",No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_STRENGTH,amount_value,No,float,The numeric value or the amount of active ingredient contained within the drug product.,,No,No,,,,, -DRUG_STRENGTH,amount_unit_concept_id,No,integer,The Concept representing the Unit of measure for the amount of active ingredient contained within the drug product. ,,No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_STRENGTH,numerator_value,No,float,The concentration of the active ingredient contained within the drug product.,,No,No,,,,, -DRUG_STRENGTH,numerator_unit_concept_id,No,integer,The Concept representing the Unit of measure for the concentration of active ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_STRENGTH,denominator_value,No,float,"The amount of total liquid (or other divisible product, such as ointment, gel, spray, etc.).",,No,No,,,,, -DRUG_STRENGTH,denominator_unit_concept_id,No,integer,The Concept representing the denominator unit for the concentration of active ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,,, -DRUG_STRENGTH,box_size,No,integer,The number of units of Clinical Branded Drug or Quantified Clinical or Branded Drug contained in a box as dispensed to the patient.,,No,No,,,,, +Default value is 31-Dec-2099.",,No,No,,,,, +SOURCE_TO_CONCEPT_MAP,invalid_reason,No,varchar(1),"Reason the mapping instance was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, +DRUG_STRENGTH,drug_concept_id,Yes,integer,The Concept representing the Branded Drug or Clinical Drug Product.,,No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_STRENGTH,ingredient_concept_id,Yes,integer,The Concept representing the active ingredient contained within the drug product.,"Combination Drugs will have more than one record in this table, one for each active Ingredient.",No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_STRENGTH,amount_value,No,float,The numeric value or the amount of active ingredient contained within the drug product.,,No,No,,,,, +DRUG_STRENGTH,amount_unit_concept_id,No,integer,The Concept representing the Unit of measure for the amount of active ingredient contained within the drug product. ,,No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_STRENGTH,numerator_value,No,float,The concentration of the active ingredient contained within the drug product.,,No,No,,,,, +DRUG_STRENGTH,numerator_unit_concept_id,No,integer,The Concept representing the Unit of measure for the concentration of active ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_STRENGTH,denominator_value,No,float,"The amount of total liquid (or other divisible product, such as ointment, gel, spray, etc.).",,No,No,,,,, +DRUG_STRENGTH,denominator_unit_concept_id,No,integer,The Concept representing the denominator unit for the concentration of active ingredient.,,No,Yes,CONCEPT,CONCEPT_ID,,, +DRUG_STRENGTH,box_size,No,integer,The number of units of Clinical Branded Drug or Quantified Clinical or Branded Drug contained in a box as dispensed to the patient.,,No,No,,,,, DRUG_STRENGTH,valid_start_date,Yes,date,"The date when the Concept was first recorded. The default value is -1-Jan-1970.",,No,No,,,,, -DRUG_STRENGTH,valid_end_date,Yes,date,The date when then Concept became invalid.,,No,No,,,,, -DRUG_STRENGTH,invalid_reason,No,varchar(1),"Reason the concept was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, -COHORT_DEFINITION,cohort_definition_id,Yes,integer,"This is the identifier given to the cohort, usually by the ATLAS application",,No,No,,,,, -COHORT_DEFINITION,cohort_definition_name,Yes,varchar(255),A short description of the cohort,,No,No,,,,, -COHORT_DEFINITION,cohort_definition_description,No,varchar(MAX),A complete description of the cohort.,,No,No,,,,, -COHORT_DEFINITION,definition_type_concept_id,Yes,integer,Type defining what kind of Cohort Definition the record represents and how the syntax may be executed.,,No,Yes,CONCEPT,CONCEPT_ID,,, -COHORT_DEFINITION,cohort_definition_syntax,No,varchar(MAX),Syntax or code to operationalize the Cohort Definition.,,No,No,,,,, -COHORT_DEFINITION,subject_concept_id,Yes,integer,"This field contains a Concept that represents the domain of the subjects that are members of the cohort (e.g., Person, Provider, Visit).",,No,Yes,CONCEPT,CONCEPT_ID,,, -COHORT_DEFINITION,cohort_initiation_date,No,date,A date to indicate when the Cohort was initiated in the COHORT table.,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_definition_id,Yes,integer,,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_name,Yes,varchar(255),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_description,No,varchar(MAX),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -ATTRIBUTE_DEFINITION,attribute_syntax,No,varchar(MAX),,,No,No,,,,, +1-Jan-1970.",,No,No,,,,, +DRUG_STRENGTH,valid_end_date,Yes,date,The date when then Concept became invalid.,,No,No,,,,, +DRUG_STRENGTH,invalid_reason,No,varchar(1),"Reason the concept was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, +COHORT_DEFINITION,cohort_definition_id,Yes,integer,"This is the identifier given to the cohort, usually by the ATLAS application",,No,No,,,,, +COHORT_DEFINITION,cohort_definition_name,Yes,varchar(255),A short description of the cohort,,No,No,,,,, +COHORT_DEFINITION,cohort_definition_description,No,varchar(MAX),A complete description of the cohort.,,No,No,,,,, +COHORT_DEFINITION,definition_type_concept_id,Yes,integer,Type defining what kind of Cohort Definition the record represents and how the syntax may be executed.,,No,Yes,CONCEPT,CONCEPT_ID,,, +COHORT_DEFINITION,cohort_definition_syntax,No,varchar(MAX),Syntax or code to operationalize the Cohort Definition.,,No,No,,,,, +COHORT_DEFINITION,subject_concept_id,Yes,integer,"This field contains a Concept that represents the domain of the subjects that are members of the cohort (e.g., Person, Provider, Visit).",,No,Yes,CONCEPT,CONCEPT_ID,,, +COHORT_DEFINITION,cohort_initiation_date,No,date,A date to indicate when the Cohort was initiated in the COHORT table.,,No,No,,,,, +ATTRIBUTE_DEFINITION,attribute_definition_id,Yes,integer,,,No,No,,,,, +ATTRIBUTE_DEFINITION,attribute_name,Yes,varchar(255),,,No,No,,,,, +ATTRIBUTE_DEFINITION,attribute_description,No,varchar(MAX),,,No,No,,,,, +ATTRIBUTE_DEFINITION,attribute_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, +ATTRIBUTE_DEFINITION,attribute_syntax,No,varchar(MAX),,,No,No,,,,, \ No newline at end of file From 6414b42f6b9cf07bf86fcbb95156371d92292dcc Mon Sep 17 00:00:00 2001 From: Andryc Date: Thu, 19 Aug 2021 12:46:40 -0400 Subject: [PATCH 5/7] prepping for pull request --- CdmDdlBase.Rproj | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/CdmDdlBase.Rproj b/CdmDdlBase.Rproj index ce013e1..c763d05 100644 --- a/CdmDdlBase.Rproj +++ b/CdmDdlBase.Rproj @@ -1,21 +1,21 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: XeLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: XeLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace From c9463d0cf1509c9723d0f3d67821919bcfa29470 Mon Sep 17 00:00:00 2001 From: Clair Blacketer Date: Thu, 19 Aug 2021 12:58:41 -0400 Subject: [PATCH 6/7] Adding EPISODE and EPISODE event tables --- inst/csv/OMOP_CDMv5.4_Field_Level.csv | 32 +++++++++++++-------------- inst/csv/OMOP_CDMv5.4_Table_Level.csv | 12 ++++------ 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/inst/csv/OMOP_CDMv5.4_Field_Level.csv b/inst/csv/OMOP_CDMv5.4_Field_Level.csv index 0b0ae76..c01a9eb 100644 --- a/inst/csv/OMOP_CDMv5.4_Field_Level.csv +++ b/inst/csv/OMOP_CDMv5.4_Field_Level.csv @@ -40,10 +40,10 @@ VISIT_OCCURRENCE,provider_id,No,integer,"There will only be one provider per vis VISIT_OCCURRENCE,care_site_id,No,integer,This field provides information about the Care Site where the Visit took place.,There should only be one Care Site associated with a Visit.,No,Yes,CARE_SITE,CARE_SITE_ID,,, VISIT_OCCURRENCE,visit_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the visit source value, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, VISIT_OCCURRENCE,visit_source_concept_id,No,integer,,If the visit source value is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -VISIT_OCCURRENCE,admitting_source_concept_id,No,integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_OCCURRENCE,admitting_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, -VISIT_OCCURRENCE,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the discharge_to_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_OCCURRENCE,discharge_to_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, +VISIT_OCCURRENCE,admitted_from_concept_id,No,integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_OCCURRENCE,admitted_from_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, +VISIT_OCCURRENCE,discharged_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the discharge_to_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_OCCURRENCE,discharged_to_source_value,No,varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, VISIT_OCCURRENCE,preceding_visit_occurrence_id,No,integer,Use this field to find the visit that occurred for the person prior to the given visit. There could be a few days or a few years in between.,"This field can be used to link a visit immediately preceding the current visit. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, VISIT_DETAIL,visit_detail_id,Yes,integer,Use this to identify unique interactions between a person and the health care system. This identifier links across the other CDM event tables to associate events with a visit detail.,This should be populated by creating a unique identifier for each unique interaction between a person and the healthcare system where the person receives a medical good or service over a span of time.,Yes,No,,,,, VISIT_DETAIL,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, @@ -63,12 +63,12 @@ VISIT_DETAIL,provider_id,No,integer,"There will only be one provider per **visi VISIT_DETAIL,care_site_id,No,integer,This field provides information about the Care Site where the Visit Detail took place.,There should only be one Care Site associated with a Visit Detail.,No,Yes,CARE_SITE,CARE_SITE_ID,,, VISIT_DETAIL,visit_detail_source_value,No,varchar(50),"This field houses the verbatim value from the source data representing the kind of visit detail that took place (inpatient, outpatient, emergency, etc.)","If there is information about the kind of visit detail in the source data that value should be stored here. If a visit is an amalgamation of visits from the source then use a hierarchy to choose the VISIT_DETAIL_SOURCE_VALUE, such as IP -> ER-> OP. This should line up with the logic chosen to determine how visits are created.",No,No,,,,, VISIT_DETAIL,visit_detail_source_concept_id,No,Integer,,If the VISIT_DETAIL_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, -VISIT_DETAIL,admitting_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, -VISIT_DETAIL,admitting_source_concept_id,No,Integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, -VISIT_DETAIL,discharge_to_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, -VISIT_DETAIL,discharge_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit detail record. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the DISCHARGE_TO_SOURCE_VALUE to a Standard Concept in the Visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_DETAIL,admitted_from_concept_id,No,Integer,"Use this field to determine where the patient was admitted from. This concept is part of the visit domain and can indicate if a patient was admitted to the hospital from a long-term care facility, for example.","If available, map the admitted_from_source_value to a standard concept in the visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, +VISIT_DETAIL,admitted_from_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was admitted from. Typically this applies only to visits that have a length of stay, like inpatient visits or long-term care visits.",No,No,,,,, +VISIT_DETAIL,discharged_to_source_value,No,Varchar(50),,"This information may be called something different in the source data but the field is meant to contain a value indicating where a person was discharged to after a visit, as in they went home or were moved to long-term care. Typically this applies only to visits that have a length of stay of a day or more.",No,No,,,,, +VISIT_DETAIL,discharged_to_concept_id,No,integer,"Use this field to determine where the patient was discharged to after a visit detail record. This concept is part of the visit domain and can indicate if a patient was discharged to home or sent to a long-term care facility, for example.","If available, map the DISCHARGE_TO_SOURCE_VALUE to a Standard Concept in the Visit domain. [Accepted Concepts](https://athena.ohdsi.org/search-terms/terms?domain=Visit&standardConcept=Standard&page=1&pageSize=15&query=).",No,Yes,CONCEPT,CONCEPT_ID,Visit,, VISIT_DETAIL,preceding_visit_detail_id,No,integer,Use this field to find the visit detail that occurred for the person prior to the given visit detail record. There could be a few days or a few years in between.,"The PRECEDING_VISIT_DETAIL_ID can be used to link a visit immediately preceding the current Visit Detail. Note this is not symmetrical, and there is no such thing as a ""following_visit_id"".",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, -VISIT_DETAIL,visit_detail_parent_id,No,integer,Use this field to find the visit detail that subsumes the given visit detail record. This is used in the case that a visit detail record needs to be nested beyond the VISIT_OCCURRENCE/VISIT_DETAIL relationship.,"If there are multiple nested levels to how Visits are represented in the source, the VISIT_DETAIL_PARENT_ID can be used to record this relationship. ",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, +VISIT_DETAIL,parent_visit_detail_id,No,integer,Use this field to find the visit detail that subsumes the given visit detail record. This is used in the case that a visit detail record needs to be nested beyond the VISIT_OCCURRENCE/VISIT_DETAIL relationship.,"If there are multiple nested levels to how Visits are represented in the source, the VISIT_DETAIL_PARENT_ID can be used to record this relationship. ",No,Yes,VISIT_DETAIL,VISIT_DETAIL_ID,,, VISIT_DETAIL,visit_occurrence_id,Yes,integer,Use this field to link the VISIT_DETAIL record to its VISIT_OCCURRENCE.,Put the VISIT_OCCURRENCE_ID that subsumes the VISIT_DETAIL record here.,No,Yes,VISIT_OCCURRENCE,VISIT_OCCURRENCE_ID,,, CONDITION_OCCURRENCE,condition_occurrence_id,Yes,integer,The unique key given to a condition record for a person. Refer to the ETL for how duplicate conditions during the same visit were handled.,"Each instance of a condition present in the source data should be assigned this unique key. In some cases, a person can have multiple records of the same condition within the same visit. It is valid to keep these duplicates and assign them individual, unique, CONDITION_OCCURRENCE_IDs, though it is up to the ETL how they should be handled.",Yes,No,,,,, CONDITION_OCCURRENCE,person_id,Yes,integer,The PERSON_ID of the PERSON for whom the condition is recorded.,,No,Yes,PERSON,PERSON_ID,,, @@ -185,6 +185,7 @@ OBSERVATION,observation_source_value,No,varchar(50),"This field houses the verba OBSERVATION,observation_source_concept_id,No,integer,"This is the concept representing the OBSERVATION_SOURCE_VALUE and may not necessarily be standard. This field is discouraged from use in analysis because it is not required to contain Standard Concepts that are used across the OHDSI community, and should only be used when Standard Concepts do not adequately represent the source detail for the Observation necessary for a given analytic use case. Consider using OBSERVATION_CONCEPT_ID instead to enable standardized analytics that can be consistent across the network.",If the OBSERVATION_SOURCE_VALUE is coded in the source data using an OMOP supported vocabulary put the concept id representing the source value here.,No,Yes,CONCEPT,CONCEPT_ID,,, OBSERVATION,unit_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the unit of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, OBSERVATION,qualifier_source_value,No,varchar(50),This field houses the verbatim value from the source data representing the qualifier of the Observation that occurred. ,This code is mapped to a Standard Condition Concept in the Standardized Vocabularies and the original code is stored here for reference.,No,No,,,,, +OBSERVATION,value_source_value,No,varchar(50),This field houses the verbatim result value of the Observation from the source data. Do not get confused with the Observation_source_value which captures source value of the observation mapped to observation_concept_id. This field is the observation result value from the source.,"If the observation_source_value was a question, for example, or an observation that requires a result then this field is the answer/ result from the source data. Store the verbatim value that represents the result of the observation_source_value.",No,No,,,,, DEATH,person_id,Yes,integer,,,No,Yes,PERSON,PERSON_ID,,, DEATH,death_date,Yes,date,The date the person was deceased.,"If the precise date include day or month is not known or not allowed, December is used as the default month, and the last day of the month the default day.",No,No,,,,, DEATH,death_datetime,No,datetime,,If not available set time to midnight (00:00:00),No,No,,,,, @@ -513,15 +514,14 @@ recorded. The default value is 1-Jan-1970.",,No,No,,,,, DRUG_STRENGTH,valid_end_date,Yes,date,The date when then Concept became invalid.,,No,No,,,,, DRUG_STRENGTH,invalid_reason,No,varchar(1),"Reason the concept was invalidated. Possible values are D (deleted), U (replaced with an update) or NULL when valid_end_date has the default value.",,No,No,,,,, -COHORT_DEFINITION,cohort_definition_id,Yes,integer,"This is the identifier given to the cohort, usually by the ATLAS application",,No,No,,,,, +COHORT,cohort_definition_id,Yes,integer,,,No,No,,,,, +COHORT,subject_id,Yes,integer,,,No,No,,,,, +COHORT,cohort_start_date,Yes,date,,,No,No,,,,, +COHORT,cohort_end_date,Yes,date,,,No,No,,,,, +COHORT_DEFINITION,cohort_definition_id,Yes,integer,"This is the identifier given to the cohort, usually by the ATLAS application",,No,No,COHORT,COHORT_DEFINITION_ID,,, COHORT_DEFINITION,cohort_definition_name,Yes,varchar(255),A short description of the cohort,,No,No,,,,, COHORT_DEFINITION,cohort_definition_description,No,varchar(MAX),A complete description of the cohort.,,No,No,,,,, COHORT_DEFINITION,definition_type_concept_id,Yes,integer,Type defining what kind of Cohort Definition the record represents and how the syntax may be executed.,,No,Yes,CONCEPT,CONCEPT_ID,,, COHORT_DEFINITION,cohort_definition_syntax,No,varchar(MAX),Syntax or code to operationalize the Cohort Definition.,,No,No,,,,, COHORT_DEFINITION,subject_concept_id,Yes,integer,"This field contains a Concept that represents the domain of the subjects that are members of the cohort (e.g., Person, Provider, Visit).",,No,Yes,CONCEPT,CONCEPT_ID,,, -COHORT_DEFINITION,cohort_initiation_date,No,date,A date to indicate when the Cohort was initiated in the COHORT table.,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_definition_id,Yes,integer,,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_name,Yes,varchar(255),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_description,No,varchar(MAX),,,No,No,,,,, -ATTRIBUTE_DEFINITION,attribute_type_concept_id,Yes,integer,,,No,Yes,CONCEPT,CONCEPT_ID,,, -ATTRIBUTE_DEFINITION,attribute_syntax,No,varchar(MAX),,,No,No,,,,, \ No newline at end of file +COHORT_DEFINITION,cohort_initiation_date,No,date,A date to indicate when the Cohort was initiated in the COHORT table.,,No,No,,,,, \ No newline at end of file diff --git a/inst/csv/OMOP_CDMv5.4_Table_Level.csv b/inst/csv/OMOP_CDMv5.4_Table_Level.csv index 19b3ff0..6f668df 100644 --- a/inst/csv/OMOP_CDMv5.4_Table_Level.csv +++ b/inst/csv/OMOP_CDMv5.4_Table_Level.csv @@ -57,6 +57,8 @@ For example, consider a Person who visits her Primary Care Physician (PCP) and w The condition_concept_id field contains Concepts that are identical to those of the CONDITION_OCCURRENCE table records that make up the Condition Era. In contrast to Drug Eras, Condition Eras are not aggregated to contain Conditions of different hierarchical layers. The SQl Script for generating CONDITION_ERA records can be found [here](https://ohdsi.github.io/CommonDataModel/sqlScripts.html#condition_eras) The Condition Era Start Date is the start date of the first Condition Occurrence. The Condition Era End Date is the end date of the last Condition Occurrence. Condition Eras are built with a Persistence Window of 30 days, meaning, if no occurrence of the same condition_concept_id happens within 30 days of any one occurrence, it will be considered the condition_era_end_date." +EPISODE,CDM,No,,No,,,"The EPISODE table aggregates lower-level clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) into a higher-level abstraction representing clinically and analytically relevant disease phases,outcomes and treatments. The EPISODE_EVENT table connects qualifying clinical events (VISIT_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, DEVICE_EXPOSURE) to the appropriate EPISODE entry. For example cancers including their development over time, their treatment, and final resolution. ","Valid Episode Concepts belong to the 'Episode' domain. For cancer episodes please see [article], for non-cancer episodes please see [article]. If your source data does not have all episodes that are relevant to the therapeutic area, write only those you can easily derive from the data. It is understood that that table is not currently expected to be comprehensive. ", +EPISODE_EVENT,CDM,No,,No,,,"The EPISODE_EVENT table connects qualifying clinical events (such as CONDITION_OCCURRENCE, DRUG_EXPOSURE, PROCEDURE_OCCURRENCE, MEASUREMENT) to the appropriate EPISODE entry. For example, linking the precise location of the metastasis (cancer modifier in MEASUREMENT) to the disease episode. ",This connecting table is used instead of the FACT_RELATIONSHIP table for linking low-level events to abstracted Episodes.,"Some episodes may not have links to any underlying clinical events. For such episodes, the EPISODE_EVENT table is not populated." METADATA,CDM,No,,No,,,The METADATA table contains metadata information about a dataset that has been transformed to the OMOP Common Data Model.,, CDM_SOURCE,CDM,No,,No,,,The CDM_SOURCE table contains detail about the source database and the process used to transform the data into the OMOP Common Data Model.,, CONCEPT,VOCAB,No,,No,,,"The Standardized Vocabularies contains records, or Concepts, that uniquely identify each fundamental unit of meaning used to express clinical information in all domain tables of the CDM. Concepts are derived from vocabularies, which represent clinical information across a domain (e.g. conditions, drugs, procedures) through the use of codes and associated descriptions. Some Concepts are designated Standard Concepts, meaning these Concepts can be used as normative expressions of a clinical entity within the OMOP Common Data Model and within standardized analytics. Each Standard Concept belongs to one domain, which defines the location where the Concept would be expected to occur within data tables of the CDM. @@ -75,11 +77,5 @@ CONCEPT_ANCESTOR,VOCAB,No,,No,,,"The CONCEPT_ANCESTOR table is designed to simpl This table is entirely derived from the CONCEPT, CONCEPT_RELATIONSHIP and RELATIONSHIP tables.",, SOURCE_TO_CONCEPT_MAP,VOCAB,No,,No,,,"The source to concept map table is a legacy data structure within the OMOP Common Data Model, recommended for use in ETL processes to maintain local source codes which are not available as Concepts in the Standardized Vocabularies, and to establish mappings for each source code into a Standard Concept as target_concept_ids that can be used to populate the Common Data Model tables. The SOURCE_TO_CONCEPT_MAP table is no longer populated with content within the Standardized Vocabularies published to the OMOP community.",, DRUG_STRENGTH,VOCAB,No,,No,,,The DRUG_STRENGTH table contains structured content about the amount or concentration and associated units of a specific ingredient contained within a particular drug product. This table is supplemental information to support standardized analysis of drug utilization.,, -COHORT_DEFINITION,VOCAB,No,,No,,,"The COHORT_DEFINITION table contains records defining a Cohort derived from the data through the associated description and syntax and upon instantiation (execution of the algorithm) placed into the COHORT table. Cohorts are a set of subjects that satisfy a given combination of inclusion criteria for a duration of time. The COHORT_DEFINITION table provides a standardized structure for maintaining the rules governing the inclusion of a subject into a cohort, and can store operational programming code to instantiate the cohort within the OMOP Common Data Model.",, -ATTRIBUTE_DEFINITION,VOCAB,No,,No,,,"The ATTRIBUTE_DEFINITION table contains records to define each attribute -through an associated description and syntax. Attributes are derived elements -that can be selected or calculated for a subject within a cohort. The -ATTRIBUTE_DEFINITION table provides a standardized structure for -maintaining the rules governing the calculation of covariates for a subject in a -cohort, and can store operational programming code to instantiate the -attributes for a given cohort within the OMOP Common Data Model.",, \ No newline at end of file +COHORT,RESULTS,No,,No,,,The COHORT table contains records of subjects that satisfy a given set of criteria for a duration of time. The definition of the cohort is contained within the COHORT_DEFINITION table. It is listed as part of the RESULTS schema because it is a table that users of the database as well as tools such as ATLAS need to be able to write to. The CDM and Vocabulary tables are all read-only so it is suggested that the COHORT and COHORT_DEFINTION tables are kept in a separate schema to alleviate confusion.,,"Cohorts typically include patients diagnosed with a specific condition, patients exposed to a particular drug, but can also be Providers who have performed a specific Procedure. Cohort records must have a Start Date and an End Date, but the End Date may be set to Start Date or could have an applied censor date using the Observation Period Start Date. Cohort records must contain a Subject Id, which can refer to the Person, Provider, Visit record or Care Site though they are most often Person Ids. The Cohort Definition will define the type of subject through the subject concept id. A subject can belong (or not belong) to a cohort at any moment in time. A subject can only have one record in the cohort table for any moment of time, i.e. it is not possible for a person to contain multiple records indicating cohort membership that are overlapping in time" +COHORT_DEFINITION,RESULTS,No,,No,,,"The COHORT_DEFINITION table contains records defining a Cohort derived from the data through the associated description and syntax and upon instantiation (execution of the algorithm) placed into the COHORT table. Cohorts are a set of subjects that satisfy a given combination of inclusion criteria for a duration of time. The COHORT_DEFINITION table provides a standardized structure for maintaining the rules governing the inclusion of a subject into a cohort, and can store operational programming code to instantiate the cohort within the OMOP Common Data Model.",, \ No newline at end of file From b3fddfbb85ea67cc76e207ec17f4515d1189a984 Mon Sep 17 00:00:00 2001 From: Maxim Moinat Date: Thu, 19 Aug 2021 21:43:34 +0200 Subject: [PATCH 7/7] Function to Build Release Zips (#429) * buildRelease and buildReleaseZip * add buildRelease --- .DS_Store | Bin 10244 -> 0 bytes CommonDataModel.Rproj | 42 ++++++++--------- NAMESPACE | 2 + R/buildRelease.R | 88 +++++++++++++++++++++++++++++++++++ R/listSupportedVersions.R | 9 ++++ extras/codeToRun.R | 8 ++++ man/buildRelease.Rd | 21 +++++++++ man/buildReleaseZip.Rd | 36 ++++++++++++++ man/createDdl.Rd | 6 +-- man/listSupportedDialects.Rd | 11 +++++ man/writeDDL.Rd | 2 +- 11 files changed, 200 insertions(+), 25 deletions(-) delete mode 100644 .DS_Store create mode 100644 R/buildRelease.R create mode 100644 man/buildRelease.Rd create mode 100644 man/buildReleaseZip.Rd create mode 100644 man/listSupportedDialects.Rd diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 94331697f17fbb18725b12338975282e4105c8f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10244 zcmeHMOK%fN5U!3*n1q*w(4ru%G(vzlL{^*)fviC5IL;vw4-+FI76P#|7BR9tUfUtN zc!PXJyNA_s0P*?*fcOJ&fddkV14xJ~|6sZ7ffIcF@T7Zea{_@-w=`YtsrtIRzUt{# zwTXzOmc0a#OGFMHE@K-}btzoWpN`U}-uwi~fG6^(L@CNqoeCY+_Jw7@GGH073|Iy% z1K$DzIJ0?iHb`k}%YbFTG7vDp_Xigbmq{gCQi`nul}G^~qj)U}+Q?M;G$Q6$(gxg#q(EE{&K~ui+-|F z;Wz`%z`58D&F09kyMKIj*li}p#&~;TVs&-E*}gk*Xl9}O$ED_0@j6(Uk!@m`JEb}2>u0xzCQYafE5t9 z88U7A_y|31wTM6a+7TaWHWTCf_YJ$_qax^|`$o~8IM5OF8}JCFXV7m#X)vM(-cT69 zzjg0Y7^p9Rhxt=y@BjChF94$teG&AsF&4t@5p-ep5n2pUDpCbke4()Sy#`JXWnlN+ zhB5H49YX%C1TT&74L$O7ogTX874P8Pmm+ilRu5Y@y%Dk<@6h$yxS?>Zr^DEfr?5jG z#U4Fvet+yekb2M}I0tf6F|8s~-K`7{Y3FuWDZK9A-_L(uh)e$h?b^=NsWp6~f6yrn zVD6K2M4U1iwBU_7LvbeE(axlP>`=?tbE>=!+47U9r>)^r?6-@sHTu#$+qvui$E{cD zqtnLIqu0yE@N#R0d&y|loGIfwsXkL!81tiJa}uY|YU}YmZN6cz&&AXjGidWX3yvpo zo^!6_SPNcgM*MWvXB5G%-f6{GRTr!FX96u2iU1n!49(B4X>^x<-F&EhyeXXSR;Si* zZO2v%|U9giRUI({!6ZYypSR6D6;OG*KUjetYS+x##7XTWE=#tG8( cc4EWb30|71jm`hTjm`gqI|(C2{R;X2M}q+m=l}o! diff --git a/CommonDataModel.Rproj b/CommonDataModel.Rproj index c763d05..ce013e1 100644 --- a/CommonDataModel.Rproj +++ b/CommonDataModel.Rproj @@ -1,21 +1,21 @@ -Version: 1.0 - -RestoreWorkspace: Default -SaveWorkspace: Default -AlwaysSaveHistory: Default - -EnableCodeIndexing: Yes -UseSpacesForTab: Yes -NumSpacesForTab: 2 -Encoding: UTF-8 - -RnwWeave: Sweave -LaTeX: XeLaTeX - -AutoAppendNewline: Yes -StripTrailingWhitespace: Yes - -BuildType: Package -PackageUseDevtools: Yes -PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: XeLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/NAMESPACE b/NAMESPACE index 4946218..fc60bbb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,10 +1,12 @@ # Generated by roxygen2: do not edit by hand +export(buildReleaseZip) export(createDdl) export(createForeignKeys) export(createPrimaryKeys) export(downloadCurrentDdl) export(executeDdl) +export(listSupportedDialects) export(listSupportedVersions) export(parseWiki) export(writeDdl) diff --git a/R/buildRelease.R b/R/buildRelease.R new file mode 100644 index 0000000..53d0bcc --- /dev/null +++ b/R/buildRelease.R @@ -0,0 +1,88 @@ +# Copyright 2019 Observational Health Data Sciences and Informatics +# +# This file is part of CdmDdlBase +# +# 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. + +#' Create OMOP CDM SQL files +#' +#' Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion +#' and targetDialect to the 'ddl' folder in current working directory. +#' +#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4. +#' Defaults to all supported CDM versions. +#' @param targetDialect The target dialect +#' +buildRelease <- function(cdmVersion = listSupportedVersions(), + targetDialect = listSupportedDialects()){ + for (cdmVersion in cdmVersion) { + for (targetDialect in targetDialect) { + writeDdl(targetDialect = targetDialect, + cdmVersion = cdmVersion) + + writePrimaryKeys(targetDialect = targetDialect, + cdmVersion = cdmVersion) + + writeForeignKeys(targetDialect = targetDialect, + cdmVersion = cdmVersion) + + writeIndex(targetDialect = targetDialect, + cdmVersion = cdmVersion) + } + } +} + +#' Create OMOP CDM release zip +#' +#' First calls \code{buildReleaseZips} for given cdmVersions and targetDialects. +#' This writes the ddl sql files to the ddl folder. +#' Then zips all written ddl files into a release zip to given output folder. +#' +#' If no (or multiple) targetDialect is given, +#' then one zip is written with the files of all supported dialects. +#' +#' @param cdmVersion The version of the CDM you are creating, e.g. 5.3, 5.4. +#' Defaults to all supported CDM versions. +#' @param targetDialect The target dialect. Defaults to all supported dialects. +#' @param outputfolder The output folder. Defaults to "output" +#' @return A character string containing the OHDSQL DDL +#' @export +#' @examples +#' buildReleaseZip(cdmVersion='5.3', targetDialect='sql server', outputfolder='.') +#' +buildReleaseZip <- function(cdmVersion, + targetDialect = listSupportedDialects(), + outputfolder = "output"){ + # argument checks + stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions()) + + if (!dir.exists(outputfolder)) { + dir.create(outputfolder) + } + + files <- c() + for (dialect in targetDialect) { + buildRelease(cdmVersion, dialect) + files <- c(files, list.files(file.path('ddl', cdmVersion, gsub(" ", "_", dialect)), + pattern = ".*\\.sql$", + full.names = TRUE)) + } + + if (length(targetDialect) == 1) { + zipName <- file.path(outputfolder, paste0("OMOPCDM", "_", gsub(" ", "_", targetDialect), "_", cdmVersion, '.zip')) + } else { + zipName <- file.path(outputfolder, paste0("OMOPCDM", "_", cdmVersion, '.zip')) + } + + DatabaseConnector::createZipFile(zipFile = zipName, files = files) +} diff --git a/R/listSupportedVersions.R b/R/listSupportedVersions.R index 944ec40..8eb37ff 100644 --- a/R/listSupportedVersions.R +++ b/R/listSupportedVersions.R @@ -6,3 +6,12 @@ listSupportedVersions <- function() { supportedVersions <- c("5.3", "5.4") return(supportedVersions) } + +#' List RDBMS dialects supported by this package +#' +#' @export + +listSupportedDialects <- function() { + supportedDialects <- c("oracle", "postgresql", "pdw", "redshift", "impala", "netezza", "bigquery", "sql server") + return(supportedDialects) +} diff --git a/extras/codeToRun.R b/extras/codeToRun.R index f93dcc3..dda9a81 100644 --- a/extras/codeToRun.R +++ b/extras/codeToRun.R @@ -22,6 +22,14 @@ for (cdmVersion in supportedVersions) { } } +############# +# Zipping release +# All dialects +buildReleaseZip(cdmVersion="5.3", outputfolder="output") + +# One dialect +buildReleaseZip(cdmVersion="5.4", targetDialect="postgresql", outputfolder="output") + ############# # BE SURE TO RUN THE EXTRAS/SITEMAINTENANCE.R BEFORE CREATING THE PDF diff --git a/man/buildRelease.Rd b/man/buildRelease.Rd new file mode 100644 index 0000000..e07fec0 --- /dev/null +++ b/man/buildRelease.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/buildRelease.R +\name{buildRelease} +\alias{buildRelease} +\title{Create OMOP CDM SQL files} +\usage{ +buildRelease( + cdmVersion = listSupportedVersions(), + targetDialect = listSupportedDialects() +) +} +\arguments{ +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4. +Defaults to all supported CDM versions.} + +\item{targetDialect}{The target dialect} +} +\description{ +Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion +and targetDialect to the 'ddl' folder in current working directory. +} diff --git a/man/buildReleaseZip.Rd b/man/buildReleaseZip.Rd new file mode 100644 index 0000000..95e6f55 --- /dev/null +++ b/man/buildReleaseZip.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/buildRelease.R +\name{buildReleaseZip} +\alias{buildReleaseZip} +\title{Create OMOP CDM release zip} +\usage{ +buildReleaseZip( + cdmVersion, + targetDialect = listSupportedDialects(), + outputfolder = "output" +) +} +\arguments{ +\item{cdmVersion}{The version of the CDM you are creating, e.g. 5.3, 5.4. +Defaults to all supported CDM versions.} + +\item{targetDialect}{The target dialect. Defaults to all supported dialects.} + +\item{outputfolder}{The output folder. Defaults to "output"} +} +\value{ +A character string containing the OHDSQL DDL +} +\description{ +First calls \code{buildReleaseZips} for given cdmVersions and targetDialects. +This writes the ddl sql files to the ddl folder. +Then zips all written ddl files into a release zip to given output folder. +} +\details{ +If no (or multiple) targetDialect is given, +then one zip is written with the files of all supported dialects. +} +\examples{ +buildReleaseZip(cdmVersion='5.3', targetDialect='sql server', outputfolder='.') + +} diff --git a/man/createDdl.Rd b/man/createDdl.Rd index c30bec1..8030fa3 100644 --- a/man/createDdl.Rd +++ b/man/createDdl.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/createdDdl.R +% Please edit documentation in R/createDdl.R \name{createDdl} \alias{createDdl} \alias{createPrimaryKeys} @@ -30,9 +30,9 @@ Dashboard. } \section{Functions}{ \itemize{ -\item \code{createPrimaryKeys}: createPrimaryKeys asdfladsfj +\item \code{createPrimaryKeys}: createPrimaryKeys Returns a string containing the OHDSQL for creation of primary keys in the OMOP CDM. -\item \code{createForeignKeys}: createForeignKeys asdfladsf +\item \code{createForeignKeys}: createForeignKeys Returns a string containing the OHDSQL for creation of foreign keys in the OMOP CDM. }} \examples{ diff --git a/man/listSupportedDialects.Rd b/man/listSupportedDialects.Rd new file mode 100644 index 0000000..7c5b7b1 --- /dev/null +++ b/man/listSupportedDialects.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/listSupportedVersions.R +\name{listSupportedDialects} +\alias{listSupportedDialects} +\title{List RDBMS dialects supported by this package} +\usage{ +listSupportedDialects() +} +\description{ +List RDBMS dialects supported by this package +} diff --git a/man/writeDDL.Rd b/man/writeDDL.Rd index c245499..99acf1d 100644 --- a/man/writeDDL.Rd +++ b/man/writeDDL.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/writeDdl.R +% Please edit documentation in R/writeDDL.R \name{writeDdl} \alias{writeDdl} \alias{writePrimaryKeys}