Added return values to all functions
This commit is contained in:
parent
d152472484
commit
67e30a1d10
|
@ -1,3 +1,3 @@
|
||||||
Version: 0.2.0
|
Version: 0.2.0
|
||||||
Date: 2024-02-02 21:50:16 UTC
|
Date: 2024-02-06 20:13:33 UTC
|
||||||
SHA: b9e2be6188f57934df0a7a805ff43bee5a61e74e
|
SHA: d152472484fb2bedd2596e2279a24afbd0084f0b
|
||||||
|
|
|
@ -4,7 +4,7 @@ Title: OMOP CDM DDL and Documentation Generator
|
||||||
Version: 0.2.0
|
Version: 0.2.0
|
||||||
Author: Clair Blacketer [aut, cre]
|
Author: Clair Blacketer [aut, cre]
|
||||||
Maintainer: Clair Blacketer <mblacke@its.jnj.com>
|
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
|
License: Apache License 2.0
|
||||||
Encoding: UTF-8
|
Encoding: UTF-8
|
||||||
LazyData: true
|
LazyData: true
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#'
|
#'
|
||||||
#' @param mdFilesLocation Path to the root folder of the Wiki repository.
|
#' @param mdFilesLocation Path to the root folder of the Wiki repository.
|
||||||
#' @param output_file Path to where the output CSV file should be written.
|
#' @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
|
#' @importFrom utils write.csv
|
||||||
#' @export
|
#' @export
|
||||||
parseWiki <- function(mdFilesLocation, output_file) {
|
parseWiki <- function(mdFilesLocation, output_file) {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#' Create OMOP CDM SQL files
|
#' Create OMOP CDM SQL files
|
||||||
#'
|
#'
|
||||||
#' Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
#' 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.
|
#' @param cdmVersions The versions of the CDM you are creating, e.g. 5.3, 5.4.
|
||||||
#' Defaults to all supported CDM versions.
|
#' Defaults to all supported CDM versions.
|
||||||
|
@ -25,10 +25,12 @@
|
||||||
#' Defaults to all supported dialects.
|
#' Defaults to all supported dialects.
|
||||||
#' @param outputfolder The base folder where the SQL files will be written.
|
#' @param outputfolder The base folder where the SQL files will be written.
|
||||||
#' Subfolders will be created for each cdmVersion and targetDialect.
|
#' 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
|
#' @export
|
||||||
buildRelease <- function(cdmVersions = listSupportedVersions(),
|
buildRelease <- function(cdmVersions = listSupportedVersions(),
|
||||||
targetDialects = listSupportedDialects(),
|
targetDialects = listSupportedDialects(),
|
||||||
outputfolder = file.path(getwd(), "inst", "ddl")){
|
outputfolder = file.path(tempdir(), "inst", "ddl")){
|
||||||
basefolder <- outputfolder
|
basefolder <- outputfolder
|
||||||
for (cdmVersion in cdmVersions) {
|
for (cdmVersion in cdmVersions) {
|
||||||
for (targetDialect in targetDialects) {
|
for (targetDialect in targetDialects) {
|
||||||
|
@ -74,7 +76,7 @@ buildRelease <- function(cdmVersions = listSupportedVersions(),
|
||||||
#'}
|
#'}
|
||||||
buildReleaseZip <- function(cdmVersion,
|
buildReleaseZip <- function(cdmVersion,
|
||||||
targetDialect = listSupportedDialects(),
|
targetDialect = listSupportedDialects(),
|
||||||
outputfolder = file.path(getwd(), "output")){
|
outputfolder = file.path(tempdir(), "output")){
|
||||||
# argument checks
|
# argument checks
|
||||||
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
|
stopifnot(is.character(cdmVersion), length(cdmVersion) == 1, cdmVersion %in% listSupportedVersions())
|
||||||
|
|
||||||
|
|
|
@ -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.
|
#' @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
|
#' @export
|
||||||
createPrimaryKeys <- function(cdmVersion){
|
createPrimaryKeys <- function(cdmVersion){
|
||||||
# prevent check NOTE from occurring due to non-standard evaluation of variables
|
# 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.
|
#' @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
|
#' @export
|
||||||
createForeignKeys <- function(cdmVersion){
|
createForeignKeys <- function(cdmVersion){
|
||||||
# prevent check NOTE from occurring due to non-standard evaluation of variables
|
# prevent check NOTE from occurring due to non-standard evaluation of variables
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#' Get current DDL sitting on the master branch
|
#' Get current DDL sitting on the main branch
|
||||||
#'
|
#'
|
||||||
#' @details
|
#' @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
|
#' The default location is
|
||||||
#' \code{inst/settings/currentOmopDdl.sql}.
|
#' \code{inst/settings/currentOmopDdl.sql}.
|
||||||
#'
|
#'
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
#' @param pathToCsv The path for the snapshot inside the package.
|
#' @param pathToCsv The path for the snapshot inside the package.
|
||||||
#' @param outputFile The path where the file should be saved.
|
#' @param outputFile The path where the file should be saved.
|
||||||
#'
|
#'
|
||||||
|
#' @return The current DDL sitting on the main branch of the CommonDataModel repository.
|
||||||
#' @examples
|
#' @examples
|
||||||
#' \dontrun{
|
#' \dontrun{
|
||||||
#' downloadCurrentDdl("OHDSI/CommonDataModel",
|
#' downloadCurrentDdl("OHDSI/CommonDataModel",
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#' @param executePrimaryKey Should the primary keys be added? TRUE or FALSE
|
#' @param executePrimaryKey Should the primary keys be added? TRUE or FALSE
|
||||||
#' @param executeForeignKey Should the foreign 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.)
|
#' @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
|
#' @export
|
||||||
#'
|
#'
|
||||||
#' @examples
|
#' @examples
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#' List CDM versions supported by this package
|
#' 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
|
#' @export
|
||||||
listSupportedVersions <- function() {
|
listSupportedVersions <- function() {
|
||||||
supportedVersions <- c("5.3", "5.4")
|
supportedVersions <- c("5.3", "5.4")
|
||||||
|
@ -9,6 +9,7 @@ listSupportedVersions <- function() {
|
||||||
|
|
||||||
#' List RDBMS dialects supported by this package
|
#' List RDBMS dialects supported by this package
|
||||||
#'
|
#'
|
||||||
|
#' @return A list containing the supported Structured Query Language (SQL) dialects.
|
||||||
#' @export
|
#' @export
|
||||||
|
|
||||||
listSupportedDialects <- function() {
|
listSupportedDialects <- function() {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#' @param outputfolder The directory or folder where the SQL file should be saved.
|
#' @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.
|
#' @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"
|
#' 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
|
#' @export
|
||||||
writeDdl <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {
|
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.
|
#' @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
|
#' @export
|
||||||
#'
|
#'
|
||||||
writePrimaryKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {
|
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.
|
#' @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
|
#' @export
|
||||||
writeForeignKeys <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {
|
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.
|
#' @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
|
#' @export
|
||||||
writeIndex <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {
|
writeIndex <- function(targetDialect, cdmVersion, outputfolder, cdmDatabaseSchema = "@cdmDatabaseSchema") {
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
# Update based on reviewer feedback
|
# Update based on reviewer feedback
|
||||||
- turned off tests when environment variables are not set
|
- turned off tests when environment variables are not set
|
||||||
- removed vignetteBuilder field from DESCRIPTION
|
- 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
|
0 errors | 0 warnings | 0 notes
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
buildRelease(
|
buildRelease(
|
||||||
cdmVersions = listSupportedVersions(),
|
cdmVersions = listSupportedVersions(),
|
||||||
targetDialects = listSupportedDialects(),
|
targetDialects = listSupportedDialects(),
|
||||||
outputfolder = file.path(getwd(), "inst", "ddl")
|
outputfolder = file.path(tempdir(), "inst", "ddl")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
|
@ -20,7 +20,11 @@ Defaults to all supported dialects.}
|
||||||
\item{outputfolder}{The base folder where the SQL files will be written.
|
\item{outputfolder}{The base folder where the SQL files will be written.
|
||||||
Subfolders will be created for each cdmVersion and targetDialect.}
|
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{
|
\description{
|
||||||
Writes DDL, ForeignKey, PrimaryKey and index SQL files for given cdmVersion
|
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.
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
buildReleaseZip(
|
buildReleaseZip(
|
||||||
cdmVersion,
|
cdmVersion,
|
||||||
targetDialect = listSupportedDialects(),
|
targetDialect = listSupportedDialects(),
|
||||||
outputfolder = file.path(getwd(), "output")
|
outputfolder = file.path(tempdir(), "output")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
\arguments{
|
\arguments{
|
||||||
|
|
|
@ -17,6 +17,10 @@ createForeignKeys(cdmVersion)
|
||||||
}
|
}
|
||||||
\value{
|
\value{
|
||||||
A character string containing the OHDSQL DDL
|
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{
|
\description{
|
||||||
The createDdl, createForeignKeys, and createPrimaryKeys functions each return a character string
|
The createDdl, createForeignKeys, and createPrimaryKeys functions each return a character string
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
% Please edit documentation in R/downloadCurrentDdl.R
|
% Please edit documentation in R/downloadCurrentDdl.R
|
||||||
\name{downloadCurrentDdl}
|
\name{downloadCurrentDdl}
|
||||||
\alias{downloadCurrentDdl}
|
\alias{downloadCurrentDdl}
|
||||||
\title{Get current DDL sitting on the master branch}
|
\title{Get current DDL sitting on the main branch}
|
||||||
\usage{
|
\usage{
|
||||||
downloadCurrentDdl(
|
downloadCurrentDdl(
|
||||||
githubPath = "OHDSI/CommonDataModel",
|
githubPath = "OHDSI/CommonDataModel",
|
||||||
|
@ -17,11 +17,14 @@ downloadCurrentDdl(
|
||||||
|
|
||||||
\item{outputFile}{The path where the file should be saved.}
|
\item{outputFile}{The path where the file should be saved.}
|
||||||
}
|
}
|
||||||
|
\value{
|
||||||
|
The current DDL sitting on the main branch of the CommonDataModel repository.
|
||||||
|
}
|
||||||
\description{
|
\description{
|
||||||
Get current DDL sitting on the master branch
|
Get current DDL sitting on the main branch
|
||||||
}
|
}
|
||||||
\details{
|
\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
|
The default location is
|
||||||
\code{inst/settings/currentOmopDdl.sql}.
|
\code{inst/settings/currentOmopDdl.sql}.
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,9 @@ executeDdl(
|
||||||
|
|
||||||
\item{...}{Other arguments passed on to DatabaseConnector::executeSql. (This allows the user to set the path to errorReportFile.)}
|
\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{
|
\description{
|
||||||
This function will generate the DDL for a specific dbms and CDM version and
|
This function will generate the DDL for a specific dbms and CDM version and
|
||||||
then execute the DDL on a database.
|
then execute the DDL on a database.
|
||||||
|
|
|
@ -6,6 +6,9 @@
|
||||||
\usage{
|
\usage{
|
||||||
listSupportedDialects()
|
listSupportedDialects()
|
||||||
}
|
}
|
||||||
|
\value{
|
||||||
|
A list containing the supported Structured Query Language (SQL) dialects.
|
||||||
|
}
|
||||||
\description{
|
\description{
|
||||||
List RDBMS dialects supported by this package
|
List RDBMS dialects supported by this package
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
listSupportedVersions()
|
listSupportedVersions()
|
||||||
}
|
}
|
||||||
\value{
|
\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{
|
\description{
|
||||||
List CDM versions supported by this package
|
List CDM versions supported by this package
|
||||||
|
|
|
@ -11,6 +11,9 @@ parseWiki(mdFilesLocation, output_file)
|
||||||
|
|
||||||
\item{output_file}{Path to where the output CSV file should be written.}
|
\item{output_file}{Path to where the output CSV file should be written.}
|
||||||
}
|
}
|
||||||
|
\value{
|
||||||
|
CSV files with the OMOP CDM specifications.
|
||||||
|
}
|
||||||
\description{
|
\description{
|
||||||
Parses all .md files in the specified location (or any subfolders), extracting definitions
|
Parses all .md files in the specified location (or any subfolders), extracting definitions
|
||||||
of the Common Data Model.
|
of the Common Data Model.
|
||||||
|
|
|
@ -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.
|
\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"}
|
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{
|
\description{
|
||||||
Write the DDL to a SQL file. The SQL will be rendered (parameters replaced) and translated to the target SQL
|
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
|
dialect. By default the @cdmDatabaseSchema parameter is kept in the SQL file and needs to be replaced before
|
||||||
|
|
Loading…
Reference in New Issue