-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
106 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: redcapcustodian | ||
Type: Package | ||
Title: Data automation for R-centric workflows with a nod towards REDCap | ||
Version: 1.19.0 | ||
Version: 1.20.0 | ||
Authors@R: c( | ||
person("Philip", "Chase", | ||
email = "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#' Retrieve REDCap Credentials Based on Specified Parameters | ||
#' | ||
#' Fetches REDCap credentials from the CREDENTIALS_DB, allowing filtering based on | ||
#' project ID, server short name, project short name, and username. At least one filtering | ||
#' criterion must be provided. | ||
#' | ||
#' @param project_pid Optional project ID for filtering. | ||
#' @param server_short_name Optional server short name for filtering. | ||
#' @param project_short_name Optional project short name for filtering. | ||
#' @param username Optional username for filtering. | ||
#' | ||
#' @return A dataframe of filtered REDCap credentials, including a 'url' column added for convenience. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' source_credentials <- get_redcap_credentials(project_pid = "123") | ||
#' prod_credentials <- get_redcap_credentials(server_short_name = "prod") | ||
#' target_credentials <- prod_credentials |> | ||
#' filter(str_detect(project_name, "biospecimens")) | ||
#' } | ||
#' | ||
#' @export | ||
#' | ||
get_redcap_credentials <- function(project_pid = NA, | ||
server_short_name = NA, | ||
project_short_name = NA, | ||
username = NA) { | ||
|
||
# Verify that there is at least one parameter | ||
if ( | ||
all(is.na( | ||
c( | ||
server_short_name, | ||
username, | ||
project_pid, | ||
project_short_name | ||
) | ||
)) | ||
) { | ||
stop("At least one parameter must be defined") | ||
} | ||
|
||
credentials_conn <- DBI::dbConnect(RSQLite::SQLite(), Sys.getenv("CREDENTIALS_DB")) | ||
|
||
redcap_credentials <- dplyr::tbl(credentials_conn, "credentials") |> | ||
# Filter on any non-NA parameter | ||
# Parameters have to be localized so that will not be seen as columns in the data frame | ||
dplyr::filter(is.na(!!project_pid) | .data$project_id == !!project_pid) |> | ||
dplyr::filter(is.na(!!server_short_name) | .data$server_short_name == !!server_short_name) |> | ||
dplyr::filter(is.na(!!project_short_name) | .data$project_short_name == !!project_short_name) |> | ||
dplyr::filter(is.na(!!username) | .data$username == !!username) |> | ||
dplyr::collect() |> | ||
# Make a copy of redcap_uri to make redcapAPI coding a tiny bit simpler | ||
dplyr::mutate(url = .data$redcap_uri) | ||
|
||
DBI::dbDisconnect(credentials_conn) | ||
|
||
return(redcap_credentials) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
1.19.0 | ||
1.20.0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.