From 67e30a1d10c75b95a5736225f7b015c99bad3347 Mon Sep 17 00:00:00 2001 From: Clair Blacketer Date: Tue, 6 Feb 2024 15:13:45 -0500 Subject: [PATCH] Added return values to all functions --- CRAN-SUBMISSION | 4 ++-- DESCRIPTION | 2 +- R/WikiParser.R | 1 + R/buildRelease.R | 8 +++++--- R/createDdl.R | 2 ++ R/downloadCurrentDdl.R | 5 +++-- R/executeDdl.R | 1 + R/listSupportedVersions.R | 3 ++- R/writeDDL.R | 4 ++++ cran-comments.md | 2 ++ man/buildRelease.Rd | 8 ++++++-- man/buildReleaseZip.Rd | 2 +- man/createDdl.Rd | 4 ++++ man/downloadCurrentDdl.Rd | 9 ++++++--- man/executeDdl.Rd | 3 +++ man/listSupportedDialects.Rd | 3 +++ man/listSupportedVersions.Rd | 2 +- man/parseWiki.Rd | 3 +++ man/writeDdl.Rd | 9 +++++++++ 19 files changed, 59 insertions(+), 16 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 9dadd4f..d26684c 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 0.2.0 -Date: 2024-02-02 21:50:16 UTC -SHA: b9e2be6188f57934df0a7a805ff43bee5a61e74e +Date: 2024-02-06 20:13:33 UTC +SHA: d152472484fb2bedd2596e2279a24afbd0084f0b diff --git a/DESCRIPTION b/DESCRIPTION index a7a0aa6..cb3ad9e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,7 @@ Title: OMOP CDM DDL and Documentation Generator Version: 0.2.0 Author: Clair Blacketer [aut, cre] Maintainer: Clair Blacketer -Description: Generates the scripts required to create an OMOP CDM database and associated documentation for supported database platforms. Leverages the 'SqlRender' package to convert the DDL script written in OHDSql to the other supported dialects. +Description: Generates the scripts required to create an Observational Medical Outcomes Partnership (OMOP) Common Data Model (CDM) database and associated documentation for supported database platforms. Leverages the 'SqlRender' package to convert the Data Definition Language (DDL) script written in parameterized Structured Query Language (SQL) to the other supported dialects. License: Apache License 2.0 Encoding: UTF-8 LazyData: true diff --git a/R/WikiParser.R b/R/WikiParser.R index 1e5ee13..6c155f5 100644 --- a/R/WikiParser.R +++ b/R/WikiParser.R @@ -23,6 +23,7 @@ #' #' @param mdFilesLocation Path to the root folder of the Wiki repository. #' @param output_file Path to where the output CSV file should be written. +#' @return CSV files with the OMOP CDM specifications. #' @importFrom utils write.csv #' @export parseWiki <- function(mdFilesLocation, output_file) { diff --git a/R/buildRelease.R b/R/buildRelease.R index 733e106..5d83fdb 100644 --- a/R/buildRelease.R +++ b/R/buildRelease.R @@ -17,7 +17,7 @@ #' 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. +#' and targetDialect to the 'ddl' folder in specifed output folder. #' #' @param cdmVersions The versions of the CDM you are creating, e.g. 5.3, 5.4. #' Defaults to all supported CDM versions. @@ -25,10 +25,12 @@ #' Defaults to all supported dialects. #' @param outputfolder The base folder where the SQL files will be written. #' Subfolders will be created for each cdmVersion and targetDialect. +#' @return Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion +#' and targetDialect to the 'ddl' folder in specifed output folder. #' @export buildRelease <- function(cdmVersions = listSupportedVersions(), targetDialects = listSupportedDialects(), - outputfolder = file.path(getwd(), "inst", "ddl")){ + outputfolder = file.path(tempdir(), "inst", "ddl")){ basefolder <- outputfolder for (cdmVersion in cdmVersions) { for (targetDialect in targetDialects) { @@ -74,7 +76,7 @@ buildRelease <- function(cdmVersions = listSupportedVersions(), #'} buildReleaseZip <- function(cdmVersion, targetDialect = listSupportedDialects(), - outputfolder = file.path(getwd(), "output")){ + outputfolder = file.path(tempdir(), "output")){ # argument checks stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions()) diff --git a/R/createDdl.R b/R/createDdl.R index 018b73a..8ecb711 100644 --- a/R/createDdl.R +++ b/R/createDdl.R @@ -97,6 +97,7 @@ createDdl <- function(cdmVersion){ #' @describeIn createDdl createPrimaryKeys Returns a string containing the OHDSQL for creation of primary keys in the OMOP CDM. +#' @return A string containing the OHDSQL for creation of primary keys in the OMOP CDM. #' @export createPrimaryKeys <- function(cdmVersion){ # prevent check NOTE from occurring due to non-standard evaluation of variables @@ -123,6 +124,7 @@ createPrimaryKeys <- function(cdmVersion){ } #' @describeIn createDdl createForeignKeys Returns a string containing the OHDSQL for creation of foreign keys in the OMOP CDM. +#' @return A string containing the OHDSQL for creation of foreign keys in the OMOP CDM. #' @export createForeignKeys <- function(cdmVersion){ # prevent check NOTE from occurring due to non-standard evaluation of variables diff --git a/R/downloadCurrentDdl.R b/R/downloadCurrentDdl.R index 469208b..2244e4f 100644 --- a/R/downloadCurrentDdl.R +++ b/R/downloadCurrentDdl.R @@ -1,7 +1,7 @@ -#' Get current DDL sitting on the master branch +#' Get current DDL sitting on the main branch #' #' @details -#' This function gets the current ddl on the CDM master branch. It will be taken from the Sql Server folder. +#' This function gets the current ddl on the CDM main branch. It will be taken from the Sql Server folder. #' The default location is #' \code{inst/settings/currentOmopDdl.sql}. #' @@ -9,6 +9,7 @@ #' @param pathToCsv The path for the snapshot inside the package. #' @param outputFile The path where the file should be saved. #' +#' @return The current DDL sitting on the main branch of the CommonDataModel repository. #' @examples #' \dontrun{ #' downloadCurrentDdl("OHDSI/CommonDataModel", diff --git a/R/executeDdl.R b/R/executeDdl.R index 98fad37..22fdac0 100644 --- a/R/executeDdl.R +++ b/R/executeDdl.R @@ -26,6 +26,7 @@ #' @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.) +#' @return Writes the fully specified DDLs, primary keys, foreign keys, and indices to a file and then executes on a database. #' @export #' #' @examples diff --git a/R/listSupportedVersions.R b/R/listSupportedVersions.R index ac559e1..870ca6d 100644 --- a/R/listSupportedVersions.R +++ b/R/listSupportedVersions.R @@ -1,6 +1,6 @@ #' List CDM versions supported by this package #' -#' @return A character vector containing the support CDM versions in major.minor format. +#' @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") @@ -9,6 +9,7 @@ listSupportedVersions <- function() { #' List RDBMS dialects supported by this package #' +#' @return A list containing the supported Structured Query Language (SQL) dialects. #' @export listSupportedDialects <- function() { diff --git a/R/writeDDL.R b/R/writeDDL.R index 9371b51..35de110 100644 --- a/R/writeDDL.R +++ b/R/writeDDL.R @@ -25,6 +25,7 @@ #' @param outputfolder 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" +#' @return Writes SQL file with the OMOP CDM DDL for the specified CDM version and target dialect in the output folder. #' #' @export writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") { @@ -50,6 +51,7 @@ writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema } #' @describeIn writeDdl writePrimaryKeys Write the SQL code that creates the primary keys to a file. +#' @return Writes a SQL file with the primary keys for the OMOP CDM based on the specified target dialect and CDM version. #' @export #' writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") { @@ -75,6 +77,7 @@ writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas } #' @describeIn writeDdl writeForeignKeys Write the SQL code that creates the foreign keys to a file. +#' @return Writes a SQL file with the foreign keys for the OMOP CDM based on the specified target dialect and CDM version. #' @export writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") { @@ -99,6 +102,7 @@ writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabas } #' @describeIn writeDdl writeIndex Write the rendered and translated sql that creates recommended indexes to a file. +#' @return Writes a SQL file with the indices for the OMOP CDM based on the specified target dialect and CDM version. #' @export writeIndex <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") { diff --git a/cran-comments.md b/cran-comments.md index 3c1a4d5..ccba245 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -5,6 +5,8 @@ # Update based on reviewer feedback - turned off tests when environment variables are not set - removed vignetteBuilder field from DESCRIPTION + - added return values in function documentation + - updated buildRelease.R default output folder to tempdir() 0 errors | 0 warnings | 0 notes diff --git a/man/buildRelease.Rd b/man/buildRelease.Rd index 17c23b6..400b6d4 100644 --- a/man/buildRelease.Rd +++ b/man/buildRelease.Rd @@ -7,7 +7,7 @@ buildRelease( cdmVersions = listSupportedVersions(), targetDialects = listSupportedDialects(), - outputfolder = file.path(getwd(), "inst", "ddl") + outputfolder = file.path(tempdir(), "inst", "ddl") ) } \arguments{ @@ -20,7 +20,11 @@ Defaults to all supported dialects.} \item{outputfolder}{The base folder where the SQL files will be written. Subfolders will be created for each cdmVersion and targetDialect.} } +\value{ +Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion + and targetDialect to the 'ddl' folder in specifed output folder. +} \description{ Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion -and targetDialect to the 'ddl' folder in current working directory. +and targetDialect to the 'ddl' folder in specifed output folder. } diff --git a/man/buildReleaseZip.Rd b/man/buildReleaseZip.Rd index 7489f45..10b5ecb 100644 --- a/man/buildReleaseZip.Rd +++ b/man/buildReleaseZip.Rd @@ -7,7 +7,7 @@ buildReleaseZip( cdmVersion, targetDialect = listSupportedDialects(), - outputfolder = file.path(getwd(), "output") + outputfolder = file.path(tempdir(), "output") ) } \arguments{ diff --git a/man/createDdl.Rd b/man/createDdl.Rd index b7866fa..f2202ea 100644 --- a/man/createDdl.Rd +++ b/man/createDdl.Rd @@ -17,6 +17,10 @@ createForeignKeys(cdmVersion) } \value{ A character string containing the OHDSQL DDL + +A string containing the OHDSQL for creation of primary keys in the OMOP CDM. + +A string containing the OHDSQL for creation of foreign keys in the OMOP CDM. } \description{ The createDdl, createForeignKeys, and createPrimaryKeys functions each return a character string diff --git a/man/downloadCurrentDdl.Rd b/man/downloadCurrentDdl.Rd index f3068d2..53b0ee7 100644 --- a/man/downloadCurrentDdl.Rd +++ b/man/downloadCurrentDdl.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/downloadCurrentDdl.R \name{downloadCurrentDdl} \alias{downloadCurrentDdl} -\title{Get current DDL sitting on the master branch} +\title{Get current DDL sitting on the main branch} \usage{ downloadCurrentDdl( githubPath = "OHDSI/CommonDataModel", @@ -17,11 +17,14 @@ downloadCurrentDdl( \item{outputFile}{The path where the file should be saved.} } +\value{ +The current DDL sitting on the main branch of the CommonDataModel repository. +} \description{ -Get current DDL sitting on the master branch +Get current DDL sitting on the main branch } \details{ -This function gets the current ddl on the CDM master branch. It will be taken from the Sql Server folder. +This function gets the current ddl on the CDM main branch. It will be taken from the Sql Server folder. The default location is \code{inst/settings/currentOmopDdl.sql}. } diff --git a/man/executeDdl.Rd b/man/executeDdl.Rd index 6a49797..c648d5f 100644 --- a/man/executeDdl.Rd +++ b/man/executeDdl.Rd @@ -29,6 +29,9 @@ executeDdl( \item{...}{Other arguments passed on to DatabaseConnector::executeSql. (This allows the user to set the path to errorReportFile.)} } +\value{ +Writes the fully specified DDLs, primary keys, foreign keys, and indices to a file and then executes on a database. +} \description{ This function will generate the DDL for a specific dbms and CDM version and then execute the DDL on a database. diff --git a/man/listSupportedDialects.Rd b/man/listSupportedDialects.Rd index 7c5b7b1..980df80 100644 --- a/man/listSupportedDialects.Rd +++ b/man/listSupportedDialects.Rd @@ -6,6 +6,9 @@ \usage{ listSupportedDialects() } +\value{ +A list containing the supported Structured Query Language (SQL) dialects. +} \description{ List RDBMS dialects supported by this package } diff --git a/man/listSupportedVersions.Rd b/man/listSupportedVersions.Rd index c578f84..05b321c 100644 --- a/man/listSupportedVersions.Rd +++ b/man/listSupportedVersions.Rd @@ -7,7 +7,7 @@ listSupportedVersions() } \value{ -A character vector containing the support CDM versions in major.minor format. +A character vector containing the supported Common Data Model (CDM) versions in major.minor format. } \description{ List CDM versions supported by this package diff --git a/man/parseWiki.Rd b/man/parseWiki.Rd index cac1471..a794ee1 100644 --- a/man/parseWiki.Rd +++ b/man/parseWiki.Rd @@ -11,6 +11,9 @@ parseWiki(mdFilesLocation, output_file) \item{output_file}{Path to where the output CSV file should be written.} } +\value{ +CSV files with the OMOP CDM specifications. +} \description{ Parses all .md files in the specified location (or any subfolders), extracting definitions of the Common Data Model. diff --git a/man/writeDdl.Rd b/man/writeDdl.Rd index bfadb76..7cf0b71 100644 --- a/man/writeDdl.Rd +++ b/man/writeDdl.Rd @@ -45,6 +45,15 @@ writeIndex( \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"} } +\value{ +Writes SQL file with the OMOP CDM DDL for the specified CDM version and target dialect in the output folder. + +Writes a SQL file with the primary keys for the OMOP CDM based on the specified target dialect and CDM version. + +Writes a SQL file with the foreign keys for the OMOP CDM based on the specified target dialect and CDM version. + +Writes a SQL file with the indices for the OMOP CDM based on the specified target dialect and CDM version. +} \description{ 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