OHDSI CommonDataModel

repository·main·Indexed 21 days ago

https://github.com/ohdsi/commondatamodel

An R package providing tools to generate and manage SQL DDLs for the OMOP Common Data Model. It enables users to instantiate CDM tables via executeDdl, generate DDL files using buildRelease, and identify supported SQL dialects and CDM versions. Includes migration scripts for transitioning from CDM v5.3 to v5.4.

Tokens
850
Snippets
3
Records
6
Agent score
27%

What's inside CommonDataModel

  1. Note on CDM v6.0 compatibility

    main

    CDM v6.0 is not fully supported by the OHDSI suite of tools. The primary change in v6.0 is that *_datetime fields are mandatory rather than optional, which changes assumptions regarding exposure and outcome timing.

    Recommendation: Transform your data to CDM v5.4 instead of using v6.0 until the community has fully defined the role of dates vs datetimes.

  2. Migrate CDM from v5.3 to v5.4

    main

    To migrate a Common Data Model (CDM) from version 5.3 to version 5.4, use the provided *_v53_to_v54_migration.sql scripts.

    Requirements and Usage:

    • Schema Placeholder: Before executing the scripts, you must replace the @cdmDatabaseSchema placeholder with your actual database schema name.
    • Reference Documentation: The specific changes implemented in this migration are documented at http://ohdsi.github.io/CommonDataModel/cdm54Changes.html.
    • Debugging: Each SQL script contains links to database documentation to assist with troubleshooting during the migration process.
  3. Install the CommonDataModel R package

    main

    To use the CommonDataModel functions in R, you must install the devtools package and then install the CommonDataModel package directly from GitHub.

    Prerequisites:

    • R-Studio installed.
    • DatabaseConnector package installed.
    • SqlRender package installed.
    install.packages("devtools")
    devtools::install_github("OHDSI/CommonDataModel")
  4. Instantiate CDM tables using `executeDdl`

    main

    If you have an empty schema, you can use executeDdl to connect to your database and automatically create the CDM tables.

    Workflow:

    1. Install DatabaseConnector via GitHub.
    2. Create connection details using DatabaseConnector::createConnectionDetails.
    3. Call CommonDataModel::executeDdl with your connection details, the desired CDM version, and the target schema name.
    # 1. Install DatabaseConnector
    devtools::install_github("ohdsi/DatabaseConnector")
    
    # 2. Create connection details
    cd <- DatabaseConnector::createConnectionDetails(
      dbms = "postgresql",
      server = "localhost/ohdsi",
      user = "postgres",
      password = "postgres",
      pathToDriver = "/pathToDriver"
    )
    
    # 3. Execute DDL
    CommonDataModel::executeDdl(
      connectionDetails = cd,
      cdmVersion = "5.4",
      cdmDatabaseSchema = "ohdsi_demo"
    )
  5. List supported SQL dialects and CDM versions

    main

    Use the following functions to identify which SQL dialects and CDM versions are currently supported by the package:

    • CommonDataModel::listSupportedDialects(): Returns a list of supported SQL dialects.
    • CommonDataModel::listSupportedVersions(): Returns a list of supported CDM versions.
    CommonDataModel::listSupportedDialects()
    CommonDataModel::listSupportedVersions()
  6. Generate CDM DDL files using `buildRelease`

    main

    The buildRelease function generates SQL DDL text files for a specific CDM version and target dialect. This is useful for users who want to generate the scripts locally in R without manually downloading the source code.

    Arguments:

    • cdmVersions: The version string (e.g., `