-
Notifications
You must be signed in to change notification settings - Fork 8
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
10 changed files
with
271 additions
and
2 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
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,46 @@ | ||
#' read_project_data Read data from a REDCap project | ||
#' | ||
#' @param ... parameters to pass on to `REDCapR::redcap_read` | ||
#' @param conn Connection object to the credentials database | ||
#' @param project_pid the project PID in the REDCap system. | ||
#' This string will be used to search through a REDCap custodian | ||
#' credentials database to locate the `token` and `redcap_uri` | ||
#' @param server_short_name an optional name of the server that | ||
#' houses the REDCap project of interest. This will prevent | ||
#' project PID clashes. | ||
#' | ||
#' @return a dataframe of data read from a REDCap project | ||
#' @export | ||
#' @importFrom rlang .data | ||
#' @examples | ||
#' \dontrun{ | ||
#' library(redcapcustodian) | ||
#' library(DBI) | ||
#' | ||
#' dotenv::load_dot_env("testing.env") | ||
#' init_etl("dummy") | ||
#' | ||
#' support_data <- read_project_data( | ||
#' conn = DBI::dbConnect(RSQLite::SQLite(), Sys.getenv("CREDENTIALS_DB")), | ||
#' project_pid = Sys.getenv("MY_PROJECT_PID")) | ||
#' } | ||
read_project_data <- function(..., conn, project_pid, server_short_name = as.character(NA)) { | ||
redcap_credentials <- dplyr::tbl(conn, "credentials") |> | ||
dplyr::filter(.data$project_id == project_pid) |> | ||
dplyr::filter(is.na(server_short_name) | .data$server_short_name == server_short_name) |> | ||
dplyr::collect() | ||
|
||
# Get the data from the REDCap Project | ||
data_read <- REDCapR::redcap_read( | ||
redcap_uri = redcap_credentials$redcap_uri, | ||
token = redcap_credentials$token, | ||
batch_size = 2000, | ||
... | ||
) | ||
|
||
if (data_read$success) { | ||
data <- data_read$data | ||
} | ||
|
||
return(data_read) | ||
} |
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,45 @@ | ||
#' read_project_metadata Read data from a REDCap project | ||
#' | ||
#' @param ... parameters to pass on to `REDCapR::redcap_metadata_read` | ||
#' @param conn Connection object to the credentials database | ||
#' @param project_pid the project PID in the REDCap system. | ||
#' This string will be used to search through a REDCap custodian | ||
#' credentials database to locate the `token` and `redcap_uri` | ||
#' @param server_short_name an optional name of the server that | ||
#' houses the REDCap project of interest. This will prevent | ||
#' project PID clashes. | ||
#' | ||
#' @return a dataframe of metadata read from a REDCap project | ||
#' @export | ||
#' @importFrom rlang .data | ||
#' @examples | ||
#' \dontrun{ | ||
#' library(redcapcustodian) | ||
#' library(DBI) | ||
#' | ||
#' dotenv::load_dot_env("testing.env") | ||
#' init_etl("dummy") | ||
#' | ||
#' support_data <- read_project_metadata( | ||
#' conn = DBI::dbConnect(RSQLite::SQLite(), Sys.getenv("CREDENTIALS_DB")), | ||
#' project_pid = Sys.getenv("MY_PROJECT_PID")) | ||
#' } | ||
read_project_metadata <- function(..., conn, project_pid, server_short_name = as.character(NA)) { | ||
redcap_credentials <- dplyr::tbl(conn, "credentials") |> | ||
dplyr::filter(.data$project_id == project_pid) |> | ||
dplyr::filter(is.na(server_short_name) | .data$server_short_name == server_short_name) |> | ||
dplyr::collect() | ||
|
||
# Get the data from the REDCap Project | ||
data_read <- REDCapR::redcap_metadata_read ( | ||
redcap_uri = redcap_credentials$redcap_uri, | ||
token = redcap_credentials$token, | ||
... | ||
) | ||
|
||
if (data_read$success) { | ||
data <- data_read$data | ||
} | ||
|
||
return(data_read) | ||
} |
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,42 @@ | ||
#' write_project_data Write data from a REDCap project | ||
#' | ||
#' @param ... parameters to pass on to `REDCapR::redcap_write` | ||
#' @param conn Connection object to the credentials database | ||
#' @param project_pid the project PID in the REDCap system. | ||
#' This string will be used to search through a REDCap custodian | ||
#' credentials database to locate the `token` and `redcap_uri` | ||
#' @param server_short_name an optional name of the server that | ||
#' houses the REDCap project of interest. This will prevent | ||
#' project PID clashes. | ||
#' | ||
#' @return a dataframe of data write from a REDCap project | ||
#' @export | ||
#' @importFrom rlang .data | ||
#' @examples | ||
#' \dontrun{ | ||
#' library(redcapcustodian) | ||
#' library(DBI) | ||
#' | ||
#' dotenv::load_dot_env("testing.env") | ||
#' init_etl("dummy") | ||
#' | ||
#' support_data <- write_project_data( | ||
#' conn = DBI::dbConnect(RSQLite::SQLite(), Sys.getenv("CREDENTIALS_DB")), | ||
#' project_pid = Sys.getenv("MY_PROJECT_PID")) | ||
#' } | ||
write_project_data <- function(..., conn, project_pid, server_short_name = as.character(NA)) { | ||
redcap_credentials <- dplyr::tbl(conn, "credentials") |> | ||
dplyr::filter(.data$project_id == project_pid) |> | ||
dplyr::filter(is.na(server_short_name) | .data$server_short_name == server_short_name) |> | ||
dplyr::collect() | ||
|
||
# Get the data from the REDCap Project | ||
data_write <- REDCapR::redcap_write( | ||
redcap_uri = redcap_credentials$redcap_uri, | ||
token = redcap_credentials$token, | ||
batch_size = 2000, | ||
... | ||
) | ||
|
||
return(data_write) | ||
} |
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.18.0 | ||
1.19.0 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.