GettingStarted_CommonDataModel

Aedin Culhane

11/9/2021

This vignette used the R code presented by Claire, at the OHDSI tutorial session on 9th November 2021 and hopefully presented a useful starter on this package

Before we start we’ll make a local folder for output

currentfolder= here::here()
outputfolder = paste0(currentfolder,"out")

To install this package from Github, we’ll check if you already have devtools (you likely do if not this code will install it)

if (!"devtools" %in% installed.packages()) 
  install.packages("devtools") else
  print("Found devtools")
## [1] "Found devtools"

Now install the R package CommonDataModel from the OHDSI repository on github

devtools::install_github("OHDSI/CommonDataModel")
## 
##   
   checking for file ‘/private/var/folders/c0/dz9xv0qd32n4y0dsc85jskph0000gq/T/RtmpV5iCGl/remotes1700120c0b28e/OHDSI-CommonDataModel-c768fa7/DESCRIPTION’ ...
  
✓  checking for file ‘/private/var/folders/c0/dz9xv0qd32n4y0dsc85jskph0000gq/T/RtmpV5iCGl/remotes1700120c0b28e/OHDSI-CommonDataModel-c768fa7/DESCRIPTION’
## 
  
─  preparing ‘CommonDataModel’: (359ms)
## 
  
   checking DESCRIPTION meta-information ...
  
✓  checking DESCRIPTION meta-information
## 
  
─  checking for LF line-endings in source and make files and shell scripts
## 
  
─  checking for empty or unneeded directories
## 
  
   Omitted ‘LazyData’ from DESCRIPTION
## 
  
─  building ‘CommonDataModel_0.1.0.tar.gz’
## 
  
   
## 

Introduction to the CommonDataModel package

List the currently supported SQL dialets

CommonDataModel::listSupportedDialects()
## [1] "oracle"     "postgresql" "pdw"        "redshift"   "impala"    
## [6] "netezza"    "bigquery"   "sql server"

List the currently supported Common Data Model (CDM)

CommonDataModel::listSupportedVersions()
## [1] "5.3" "5.4"

To generate DDLs

There are multiple way to generate DDLs

  1. Use the buildRelease function to generate text files in the dialect of your choice This function will put the output files in the folder you specify
CommonDataModel::buildRelease(cdmVersions = "5.4",
                              targetDialects = "postgresql",
                              outputfolder = outputfolder)
  1. If you have an empty schema ready to go, the package will connect and instantiate the tables for you

2a. To start you need to download DatabaseConnector in order to connect to your database

to install DatabaseConnector

devtools::install_github("OHDSI/DatabaseConnector")
library(DatabaseConnector)

Please replace with your own username/password and path to the file DatabaseConnector_Jars

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

CommonDataModel::executeDdl(connectionDetails = cdm,
                            cdmVersion = "5.4",
                            cdmDatabaseSchema = "ohdsi_demo")