Added return values to all functions

This commit is contained in:
Clair Blacketer 2024-02-06 15:13:45 -05:00
parent d152472484
commit 67e30a1d10
19 changed files with 59 additions and 16 deletions

View File

@ -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

View File

@ -4,7 +4,7 @@ Title: OMOP CDM DDL and Documentation Generator
Version: 0.2.0
Author: Clair Blacketer [aut, cre]
Maintainer: Clair Blacketer <mblacke@its.jnj.com>
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

View File

@ -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) {

View File

@ -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())

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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() {

View File

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

View File

@ -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

View File

@ -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.
}

View File

@ -7,7 +7,7 @@
buildReleaseZip(
cdmVersion,
targetDialect = listSupportedDialects(),
outputfolder = file.path(getwd(), "output")
outputfolder = file.path(tempdir(), "output")
)
}
\arguments{

View File

@ -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

View File

@ -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}.
}

View File

@ -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.

View File

@ -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
}

View File

@ -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

View File

@ -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.

View File

@ -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