Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0271020
Creates CDM v5.5 control files
clairblacketer Aug 4, 2026
5677160
Adds value_as_date to observation table
clairblacketer Aug 4, 2026
6214300
Add unit_source_concept_id to Observation
clairblacketer Aug 4, 2026
a77f3db
Adds pack_content table
clairblacketer Aug 4, 2026
b95f158
Adds tables concept_metadata and concept_relationship_metadata
clairblacketer Aug 4, 2026
3c1efe7
Adds value_as_source_concept_id to measurement and observation
clairblacketer Aug 4, 2026
7c642c3
adds source_release_version to the cdm_source table
clairblacketer Aug 4, 2026
3bef5a3
adding documentation and ddls for CDM v5.5
clairblacketer Aug 4, 2026
830deb4
updates source_release_version -> cdm_release_identifier
clairblacketer Aug 5, 2026
4ed550b
Removing the note about CDM v5.4 being the latest version
clairblacketer Aug 11, 2026
fd40a04
Support "version row" in vocabulary table
ganisimov Aug 14, 2026
fc343e9
Normalize line endings
ganisimov Aug 14, 2026
f970662
Fix "ZORDER BY RANDOM" and similar invalid clauses
ganisimov Aug 14, 2026
b026a7f
Merge pull request #803 from OHDSI/nullable_vocabulary_id
clairblacketer Aug 14, 2026
622b9c1
Fix missing "PRIMARY KEY" for "spark" dialect
ganisimov Aug 17, 2026
00169dd
Merge pull request #804 from OHDSI/fix_z_order_by_random
clairblacketer Aug 17, 2026
42b0550
add changes v5.5 docs
MaximMoinat Aug 19, 2026
e23e939
update cdm54Changes doc
MaximMoinat Aug 19, 2026
aa13812
add cdm version migration sql
MaximMoinat Aug 19, 2026
b1cc2a0
consistent casing of value_as_source_concept_id
MaximMoinat Aug 19, 2026
8a3a0ad
reformatting after checking change docs
MaximMoinat Aug 19, 2026
77426c5
Merge pull request #805 from OHDSI/doc-cdm-changes
clairblacketer Aug 21, 2026
e226564
update readme and index to refer to v5.5
MaximMoinat Aug 25, 2026
f7bc95e
add previously unlisted pages
MaximMoinat Aug 25, 2026
6c5d846
update v5.5 tooling support section
MaximMoinat Aug 25, 2026
e0aab0a
formatting fixes field specs
MaximMoinat Aug 25, 2026
4f48400
add v5.5 tooling support to home page
MaximMoinat Aug 25, 2026
e82e9cd
Merge pull request #806 from OHDSI/pre-release-check
clairblacketer Aug 25, 2026
7c2d8b8
Final changes and site render before release
clairblacketer Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
19 changes: 13 additions & 6 deletions R/createDdl.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ createDdl <- function(cdmVersion){
if ('person_id' %in% fieldNames){
hintContent <- "--HINT DISTRIBUTE_ON_KEY(person_id)"
} else {
hintContent <- "--HINT DISTRIBUTE_ON_KEY(RANDOM)"
hintContent <- "--HINT DISTRIBUTE_ON_RANDOM"
}

# Add SORT_ON_KEY if table is in sortKeyMap and has all the sort fields
Expand Down Expand Up @@ -148,8 +148,15 @@ createPrimaryKeys <- function(cdmVersion){

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"))

# allow nullable columns to be referenced in FKs
# by using UNIQUE constraint instead of PK
# this is particularly needed for vocabulary.vocabulary_id column
# to maintain convention that vocabulary version is stored in a row with vocabulary_id = NULL
if (subquery$isRequired == "true" || subquery$isRequired == "Yes" || subquery$isRequired == TRUE) {
sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT xpk_", subquery$cdmTableName, " PRIMARY KEY NONCLUSTERED (", subquery$cdmFieldName , ");\n"))
} else {
sql_result <- c(sql_result, paste0("\nALTER TABLE @cdmDatabaseSchema.", subquery$cdmTableName, " ADD CONSTRAINT unq_", subquery$cdmTableName, " UNIQUE (", subquery$cdmFieldName, ");\n"))
}
}
return(paste0(sql_result, collapse = ""))
}
Expand All @@ -168,13 +175,13 @@ createForeignKeys <- function(cdmVersion){
cdmSpecs <- read.csv(cdmFieldCsvLoc, stringsAsFactors = FALSE)

foreignKeys <- subset(cdmSpecs, isForeignKey == "true" | isForeignKey == "Yes" | isForeignKey == TRUE)

sql_result <- c(paste0("--@targetDialect CDM Foreign Key Constraints for OMOP Common Data Model ", cdmVersion, "\n"))

# Only process if there are foreign keys
if (nrow(foreignKeys) > 0) {
foreignKeys$key <- paste0(foreignKeys$cdmTableName, "_", foreignKeys$cdmFieldName)

for (foreignKey in foreignKeys$key){
subquery <- subset(foreignKeys, foreignKeys$key==foreignKey)

Expand Down
2 changes: 1 addition & 1 deletion R/listSupportedVersions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' @return A character vector containing the supported Common Data Model (CDM) versions in major.minor format.
#' @export
listSupportedVersions <- function() {
supportedVersions <- c("5.3", "5.4")
supportedVersions <- c("5.3", "5.4", "5.5")
return(supportedVersions)
}

Expand Down
8 changes: 6 additions & 2 deletions R/writeDDL.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,19 @@ writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema
sql <- createDdl(cdmVersion)
sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect)
sql <- SqlRender::translate(sql, targetDialect = targetDialect)
sql <- gsub("\r\n?", "\n", sql) ## force line endings to be LF

# Post-processing: remove conditional markers and handle dialects
lines <- strsplit(sql, "\n")[[1]]

if (tolower(targetDialect) == "redshift") {
# For Redshift: remove conditional markers but keep the HINT lines
lines <- lines[!grepl("\\{#?if|\\{/if\\}", lines)]
} else {
# For non-Redshift: remove HINT directives and conditional markers
lines <- lines[!grepl("--HINT|\\{#?if|\\{/if\\}", lines)]
}

sql <- paste(lines, collapse = "\n")

filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "ddl.sql", sep = "_")
Expand Down Expand Up @@ -84,6 +85,7 @@ writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas
sql <- createPrimaryKeys(cdmVersion)
sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect)
sql <- SqlRender::translate(sql, targetDialect = targetDialect)
sql <- gsub("\r\n?", "\n", sql) ## force line endings to be LF

# Post-processing: remove any conditional markers that may have been added
lines <- strsplit(sql, "\n")[[1]]
Expand Down Expand Up @@ -115,6 +117,7 @@ writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas
sql <- createForeignKeys(cdmVersion)
sql <- SqlRender::render(sql = sql, cdmDatabaseSchema = cdmDatabaseSchema, targetDialect = targetDialect)
sql <- SqlRender::translate(sql, targetDialect = targetDialect)
sql <- gsub("\r\n?", "\n", sql) ## force line endings to be LF

# Post-processing: remove any conditional markers that may have been added
lines <- strsplit(sql, "\n")[[1]]
Expand Down Expand Up @@ -147,6 +150,7 @@ writeIndex <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchem
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)
sql <- gsub("\r\n?", "\n", sql) ## force line endings to be LF

filename <- paste("OMOPCDM", gsub(" ", "_", targetDialect), cdmVersion, "indices.sql", sep = "_")
# Use writeLines instead of SqlRender::writeSql to avoid line wrapping
Expand Down
56 changes: 26 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
---
title: "Readme"
output:
pdf_document:
toc: yes
html_document:
toc: yes
toc_float: yes
---
# CommonDataModel

# How to Use this Repository
## How to Use this Repository

If you are looking for the SQL DDLs and don't wish to generate them through R, they can be accessed [here](https://github.com/OHDSI/CommonDataModel/tree/v5.4.0/inst/ddl/5.4).
If you are looking for the SQL DDLs and don't wish to generate them through R, they can be accessed [here](https://github.com/OHDSI/CommonDataModel/tree/main/inst/ddl/5.5).

If you are looking for information on how to submit a bugfix, skip to the [next section](https://github.com/OHDSI/CommonDataModel#bug-fixesmodel-updates)

## Generating the DDLs

This module will demonstrate two different ways the CDM R package can be used to create the CDM tables in your environment. First, it uses the `buildRelease` function to create the DDL files on your machine, intended for end users that wish to generate these scripts from R without the need to clone or download the source code from github. The SQL scripts that are created through this process are available as zip files as part of the [latest release](https://github.com/OHDSI/CommonDataModel/releases/tag/v5.4.0). They are also available on the master branch [here](https://github.com/OHDSI/CommonDataModel/tree/v5.4.0/inst/ddl/5.4).
This module will demonstrate two different ways the CDM R package can be used to create the CDM tables in your environment. First, it uses the `buildRelease` function to create the DDL files on your machine, intended for end users that wish to generate these scripts from R without the need to clone or download the source code from github. The SQL scripts that are created through this process are available as zip files as part of the [latest release](https://github.com/OHDSI/CommonDataModel/releases/latest). They are also available on the master branch [here](https://github.com/OHDSI/CommonDataModel/tree/main/inst/ddl/5.5).

Second, the script shows the `executeDdl` function that will connect up to your SQL client directly (assuming your dbms is one of the supported dialects) and instantiate the tables through R.

Expand All @@ -40,30 +32,34 @@ devtools::install_github("OHDSI/CommonDataModel")
## 1. Use the `buildRelease` function

This function will generate the text files in the dialect you choose, putting the output files in the folder you specify.
```
CommonDataModel::buildRelease(cdmVersions = "5.4",
targetDialects = "postgresql",
outputfolder = "/pathToOutput")
```R
CommonDataModel::buildRelease(
cdmVersions = "5.5",
targetDialects = "postgresql",
outputfolder = "/pathToOutput"
)
```

## 2. Use the `executeDdl` function

If you have an empty schema ready to go, the package will connect and instantiate the tables for you. To start, you need to download DatabaseConnector in order to connect to your database.

```
```R
devtools::install_github("ohdsi/DatabaseConnector")

cd <- DatabaseConnector::createConnectionDetails(dbms = "postgresql",
server = "localhost/ohdsi",
user = "postgres",
password = "postgres",
pathToDriver = "/pathToDriver"
)

CommonDataModel::executeDdl(connectionDetails = cd,
cdmVersion = "5.4",
cdmDatabaseSchema = "ohdsi_demo"
)
cd <- DatabaseConnector::createConnectionDetails(
dbms = "postgresql",
server = "localhost/ohdsi",
user = "postgres",
password = "postgres",
pathToDriver = "/pathToDriver"
)

CommonDataModel::executeDdl(
connectionDetails = cd,
cdmVersion = "5.5",
cdmDatabaseSchema = "ohdsi_demo"
)
```


Expand All @@ -73,7 +69,7 @@ CommonDataModel::executeDdl(connectionDetails = cd,

*Just looking for the latest version of the CDM and you don't care about the R package? Please visit the [releases tab](https://github.com/OHDSI/CommonDataModel/tags) and download the latest. It will include the DDLs for all currently supported versions of the CDM for all supported SQL dialects.*

Typically, new CDM versions and updates are decided by the CDM working group (details to join meetings on [homepage](https://ohdsi.github.io/CommonDataModel/)). These changes are tracked as issues in the [github repo](https://github.com/OHDSI/CommonDataModel/issues). Once the working group decides which changes make up a version, all the corresponding issues should be tagged with a version number, e.g. v5.4, and added to a project board.
Typically, new CDM versions and updates are decided by the CDM working group (details to join meetings on [homepage](https://ohdsi.github.io/CommonDataModel/)). These changes are tracked as issues in the [github repo](https://github.com/OHDSI/CommonDataModel/issues). Once the working group decides which changes make up a version, all the corresponding issues should be tagged with a version number, e.g. v5.5, and added to a project board.

## Step 0

Expand Down Expand Up @@ -103,4 +99,4 @@ Once all changes are made to the csvs and package as needed, rebuild the package
**NOTE ABOUT CDM v6.0**
====================

Please be aware that v6.0 of the OMOP CDM is **not** fully supported by the OHDSI suite of tools and methods. The major difference in CDM v5.3 and CDM v6.0 involves switching the \*_datetime fields to mandatory rather than optional. This switch radically changes the assumptions related to exposure and outcome timing. Rather than move forward with v6.0, please transform your data to [CDM v5.4](https://github.com/OHDSI/CommonDataModel/releases/tag/v5.4.0) until such time that we as a community have fully defined the role of dates vs datetimes both when it comes to the model and the evidence we generate.
Please be aware that v6.0 of the OMOP CDM is **not** fully supported by the OHDSI suite of tools and methods. The major difference in CDM v5.3 and CDM v6.0 involves switching the `\*_datetime` fields to mandatory rather than optional. This switch radically changes the assumptions related to exposure and outcome timing. Rather than move forward with v6.0, please transform your data to CDM v5.5 until such time that we as a community have fully defined the role of dates vs datetimes both when it comes to the model and the evidence we generate.
16 changes: 16 additions & 0 deletions docs/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@
<li>
<a class="dropdown-item" href="./customConcepts.html">
<span class="dropdown-text">Custom Concepts</span></a>
</li>
<li>
<a class="dropdown-item" href="./drug_dose.html">
<span class="dropdown-text">How to Calculate Drug Dose</span></a>
</li>
<li>
<a class="dropdown-item" href="./ehrObsPeriods.html">
<span class="dropdown-text">Observation Period Considerations for EHR Data</span></a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -350,6 +358,14 @@
<li>
<a class="dropdown-item" href="./cdm54ToolingSupport.html">
<span class="dropdown-text">- CDM v5.4 Tooling Support</span></a>
</li>
<li>
<a class="dropdown-item" href="./cdm55.html">
<span class="dropdown-text">CDM v5.5</span></a>
</li>
<li>
<a class="dropdown-item" href="./cdm55Changes.html">
<span class="dropdown-text">- Changes from CDM v5.4</span></a>
</li>
</ul>
</li>
Expand Down
16 changes: 16 additions & 0 deletions docs/cdm30.html
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@
<li>
<a class="dropdown-item" href="./customConcepts.html">
<span class="dropdown-text">Custom Concepts</span></a>
</li>
<li>
<a class="dropdown-item" href="./drug_dose.html">
<span class="dropdown-text">How to Calculate Drug Dose</span></a>
</li>
<li>
<a class="dropdown-item" href="./ehrObsPeriods.html">
<span class="dropdown-text">Observation Period Considerations for EHR Data</span></a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -350,6 +358,14 @@
<li>
<a class="dropdown-item" href="./cdm54ToolingSupport.html">
<span class="dropdown-text">- CDM v5.4 Tooling Support</span></a>
</li>
<li>
<a class="dropdown-item" href="./cdm55.html">
<span class="dropdown-text">CDM v5.5</span></a>
</li>
<li>
<a class="dropdown-item" href="./cdm55Changes.html">
<span class="dropdown-text">- Changes from CDM v5.4</span></a>
</li>
</ul>
</li>
Expand Down
Loading
Loading