From d84141b5d8fdb986301c5710943c2b5377d0ea67 Mon Sep 17 00:00:00 2001 From: Adam Black Date: Fri, 20 Aug 2021 13:00:03 -0400 Subject: [PATCH 1/2] add changes to v5.4 (#433) * Add github actions workflow to build package and run tests. * update Description file * rename .Rproj file. * Consolidate 'create' functions into one file. * Add tests for create functions. * update description * removed spaces in file and folder names. Regenerated ddl output. Tried to fix Field_Level.csv file. * consolidate write functions into one file. Add execute function. * update docs * add tests for write and execute functions * update documentation * Add windows and linux runners in github actions. * update github actions * download drivers before running tests * fix small error in setup test file. * debug github actions * debug github actions * debug github actions * debug github actions * fix tiny bug * comment out execute ddl test * fix bug in test * Add execute test back in * revert accidental change in description * add print statement for debugging schema error on github actions. * Fix schema environment variable name * Add comment to github actions workflow file. * remove placeholder text in function documentation. * Rename createdDdl.R to createDdl.R * Hack-a-thon updates Closes #81, #387, #239, #412, #391, #330, #408, #365, #306, #264 * Changed bigint to integer for consistency * Updated DDLs * Add tests for redshift. Clean up test setup file. * Foreign key fixes * Add imports and update docs. * Fix bug in setup test script. * update setup file * Add tests for oracle and sql server. Move setup.R file. * fix bug in setup * debug tests on github * debug github actions * debug actions. * debug actions * debug actions. * Add missing secrets to yaml!! * debug actions * test connection on all platforms * add ddl execution * add windows and linux runners * Resolving conflicts * Removing unnecessary file * Trying again to remove .DS_Store, adding to gitignore * Allow user to specify output location in buildRelease * replace outputpath with outputfolder for consitent argument names in the package. * Add test for buildRelease. * replace outputpath with outputfolder for consistency. update documentation. * move ddl folder to inst so it is accessible from tests * update documentation * Add OMOP header genearator function Co-authored-by: Adam Black Co-authored-by: Clair Blacketer Co-authored-by: clairblacketer --- .gitignore | 10 +++++++++ R/createDdl.R | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/.gitignore b/.gitignore index 5d6a798..dc712cc 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,13 @@ .RData .Ruserdata extras/CodeToRun.R + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db diff --git a/R/createDdl.R b/R/createDdl.R index d1a66dc..06bbca6 100644 --- a/R/createDdl.R +++ b/R/createDdl.R @@ -139,3 +139,63 @@ createForeignKeys <- function(cdmVersion){ } return(paste0(sql_result, collapse = "")) } + + + +# A helper function that will return a character string with the omop ascii art given a major and minor cdm version +# example: cat(createAsciiHeader(5, 3)) +createAsciiHeader <- function(major, minor) { + + stopifnot(is.numeric(major), is.numeric(minor), length(major) == 1, length(minor) == 1) + stopifnot(major %in% 0:99, minor %in% 0:99) + + # An inner function that returns an ascii art matrix for any number between 0 and 99 + numberMatrix <- function(num){ + stopifnot(is.numeric(num), num %in% 0:99) + + # An inner function that returns a 7x7 matrix of number ascii art for the number 0 through 9 + # for the number 1 a 7x5 matrix is returned because 1 is narrower than other numbers. + singleDigit <- function(num) { + nums <- c(' ### # ##### ##### # ####### ##### ####### ##### ##### # # ## # ## ## # # # ## # # ## ## # # # # ## # # # # # ## ## # # ##### ##### # # ###### ###### # ##### ####### # # # ######## ## # # # # # # # # # # # # # ## # # # ## # ### ##### ####### ##### # ##### ##### # ##### ##### ') + numsMatrix <- matrix(data = strsplit(nums, character(0))[[1]], nrow = 7, byrow = T) + cols <- seq(num*7+1, num*7+7, by = 1) + out <- numsMatrix[1:7, cols] + # the number 1 is narrower than the other numbers + if(num == 1) out<- out[1:7, 2:6] + out + } + + if(num < 10){ + return(singleDigit(num)) + } else { + space <- matrix(rep(" ", 7), nrow = 7) + return(cbind(singleDigit(floor(num/10)), space, singleDigit(num %% 10))) + } + } + + omop <- c('. + ####### # # ####### ###### ##### ###### # # . + # # ## ## # # # # # # # # ## ## # #. + # # # # # # # # # # # # # # # # # # #. + # # # # # # # ###### # # # # # # # #. + # # # # # # # # # # # # # #. + # # # # # # # # # # # # # # # . + ####### # # ####### # ##### ###### # # ## ') + + # convert to matrix and remove first column + omop <- matrix(strsplit(omop, character(0))[[1]], nrow = 7, byrow = TRUE) + omop <- omop[,c(-1, -2)] + + dot <- matrix(c(rep(" ", 3*4), rep("#", 3*3)), nrow = 7, byrow = TRUE) + space <- matrix(rep(" ", 7), nrow = 7) + newline <- matrix(rep("\n", 7, nrow = 7)) + + + header <- character(0) + headerMatrix <- cbind(omop, space, numberMatrix(major), space, dot, space, numberMatrix(minor), newline) + for(i in 1:7) { + header <- c(header, as.character(headerMatrix[i,])) + } + header <- paste(header, collapse = "") + return(header) +} From 63e2979481c1304694268c0f400ebb9833264f99 Mon Sep 17 00:00:00 2001 From: Adam Black Date: Fri, 20 Aug 2021 13:30:34 -0400 Subject: [PATCH 2/2] V5.4 (#435) * Add github actions workflow to build package and run tests. * update Description file * rename .Rproj file. * Consolidate 'create' functions into one file. * Add tests for create functions. * update description * removed spaces in file and folder names. Regenerated ddl output. Tried to fix Field_Level.csv file. * consolidate write functions into one file. Add execute function. * update docs * add tests for write and execute functions * update documentation * Add windows and linux runners in github actions. * update github actions * download drivers before running tests * fix small error in setup test file. * debug github actions * debug github actions * debug github actions * debug github actions * fix tiny bug * comment out execute ddl test * fix bug in test * Add execute test back in * revert accidental change in description * add print statement for debugging schema error on github actions. * Fix schema environment variable name * Add comment to github actions workflow file. * remove placeholder text in function documentation. * Rename createdDdl.R to createDdl.R * Hack-a-thon updates Closes #81, #387, #239, #412, #391, #330, #408, #365, #306, #264 * Changed bigint to integer for consistency * Updated DDLs * Add tests for redshift. Clean up test setup file. * Foreign key fixes * Add imports and update docs. * Fix bug in setup test script. * update setup file * Add tests for oracle and sql server. Move setup.R file. * fix bug in setup * debug tests on github * debug github actions * debug actions. * debug actions * debug actions. * Add missing secrets to yaml!! * debug actions * test connection on all platforms * add ddl execution * add windows and linux runners * Resolving conflicts * Removing unnecessary file * Trying again to remove .DS_Store, adding to gitignore * Allow user to specify output location in buildRelease * replace outputpath with outputfolder for consitent argument names in the package. * Add test for buildRelease. * replace outputpath with outputfolder for consistency. update documentation. * move ddl folder to inst so it is accessible from tests * update documentation * Add OMOP header genearator function Co-authored-by: Adam Black Co-authored-by: Clair Blacketer Co-authored-by: clairblacketer