From 3e5fcfef638c368e0490d0f23df5605e916e0c43 Mon Sep 17 00:00:00 2001 From: aedin Date: Wed, 10 Nov 2021 00:40:30 +0000 Subject: [PATCH 1/2] Create GettingStarted.Rmd Adding vignetter --- vignettes/GettingStarted.Rmd | 87 ++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 vignettes/GettingStarted.Rmd diff --git a/vignettes/GettingStarted.Rmd b/vignettes/GettingStarted.Rmd new file mode 100644 index 00000000..4e81695c --- /dev/null +++ b/vignettes/GettingStarted.Rmd @@ -0,0 +1,87 @@ +--- +title: "GettingStarted_CommonDataModel" +author: "Aedin Culhane" +date: "11/9/2021" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Vignette Title} + %\VignetteEngine{knitr::rmarkdown} + \usepackage[utf8]{inputenc} +--- +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 + +```{r setup, include=FALSE} +knitr::opts_chunk$set(echo = TRUE) +``` + +Before we start we'll make a local folder for output +```{r} +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) +```{r message=FALSE} +if (!"devtools" %in% installed.packages()) + install.packages("devtools") else + print("Found devtools") + +``` + +Now install the R package CommonDataModel from the OHDSI repository on github +```{r message=FALSE} +devtools::install_github("OHDSI/CommonDataModel") +``` + +## Introduction to the CommonDataModel package + +List the currently supported SQL dialets +```{r} +CommonDataModel::listSupportedDialects() +``` + +List the currently supported Common Data Model (CDM) +```{r} +CommonDataModel::listSupportedVersions() +``` + + +## 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 + + + +```{r} +CommonDataModel::buildRelease(cdmVersions = "5.4", + targetDialects = "postgresql", + outputfolder = outputfolder) +``` + +2. 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 +```{r message=FALSE} +devtools::install_github("OHDSI/DatabaseConnector") +``` + +```{r} +library(DatabaseConnector) +``` + +Please replace with your own username/password and path to the file DatabaseConnector_Jars +```{r, eval=FALSE} +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") +``` \ No newline at end of file From 468dee18338f901ee8523646ddf586e6ce209255 Mon Sep 17 00:00:00 2001 From: aedin Date: Wed, 10 Nov 2021 00:40:44 +0000 Subject: [PATCH 2/2] Create GettingStarted.html --- inst/doc/GettingStarted.html | 241 +++++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 inst/doc/GettingStarted.html diff --git a/inst/doc/GettingStarted.html b/inst/doc/GettingStarted.html new file mode 100644 index 00000000..63716721 --- /dev/null +++ b/inst/doc/GettingStarted.html @@ -0,0 +1,241 @@ + + + + + + + + + + + + + + + +GettingStarted_CommonDataModel + + + + + + + + + + + + + + + + + + + + + + + + + +

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
  2. +
+
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
  2. +
+

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