Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose export_blankforgray_form_status #389

Merged
merged 3 commits into from
Aug 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion R/redcap-read-oneshot-eav.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
#' (https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.POSIXlt.html)
#' value.
#' If not specified, REDCap will assume no end time.
#' @param export_blankforgray_form_status A boolean value that specifies whether
#' or not to export blank values for instrument complete status fields that have
#' a gray status icon. All instrument complete status fields having a gray icon
#' can be exported either as a blank value or as "0" (Incomplete). Blank values
#' are recommended in a data export if the data will be re-imported into a
#' REDCap project. Default is `FALSE`.
#'
#' @param verbose A boolean value indicating if `message`s should be printed
#' to the R console during the operation. The verbose output might contain
Expand Down Expand Up @@ -155,6 +161,7 @@ redcap_read_oneshot_eav <- function(
filter_logic = "",
datetime_range_begin = as.POSIXct(NA),
datetime_range_end = as.POSIXct(NA),
export_blankforgray_form_status = FALSE,

# placeholder: guess_type
# placeholder: guess_max
Expand Down Expand Up @@ -183,6 +190,7 @@ redcap_read_oneshot_eav <- function(
checkmate::assert_character(filter_logic , any.missing=FALSE, len=1, pattern="^.{0,}$")
checkmate::assert_posixct( datetime_range_begin , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_posixct( datetime_range_end , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_logical(export_blankforgray_form_status , any.missing=FALSE, len=1)

# placeholder: checkmate::assert_logical( guess_type , any.missing=FALSE, len=1)
# placeholder: checkmate::assert_integerish(guess_max , any.missing=FALSE, len=1, lower=1)
Expand Down Expand Up @@ -215,7 +223,8 @@ redcap_read_oneshot_eav <- function(
exportDataAccessGroups = export_data_access_groups,
filterLogic = filter_logic,
dateRangeBegin = datetime_range_begin,
dateRangeEnd = datetime_range_end
dateRangeEnd = datetime_range_end,
exportBlankForGrayFormStatus = export_blankforgray_form_status
# record, fields, forms & events are specified below
)

Expand Down
12 changes: 11 additions & 1 deletion R/redcap-read-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
#' [POSIXct](https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.POSIXlt.html)
#' value.
#' If not specified, REDCap will assume no end time.
#' @param export_blankforgray_form_status A boolean value that specifies whether
#' or not to export blank values for instrument complete status fields that have
#' a gray status icon. All instrument complete status fields having a gray icon
#' can be exported either as a blank value or as "0" (Incomplete). Blank values
#' are recommended in a data export if the data will be re-imported into a
#' REDCap project. Default is `FALSE`.
#'
#' @param col_types A [readr::cols()] object passed internally to
#' [readr::read_csv()]. Optional.
#' @param guess_type A boolean value indicating if all columns should be
Expand Down Expand Up @@ -181,6 +188,7 @@ redcap_read_oneshot <- function(
filter_logic = "",
datetime_range_begin = as.POSIXct(NA),
datetime_range_end = as.POSIXct(NA),
export_blankforgray_form_status = FALSE,

col_types = NULL,
guess_type = TRUE,
Expand Down Expand Up @@ -212,6 +220,7 @@ redcap_read_oneshot <- function(
checkmate::assert_character(filter_logic , any.missing=FALSE, len=1, pattern="^.{0,}$")
checkmate::assert_posixct( datetime_range_begin , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_posixct( datetime_range_end , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_logical(export_blankforgray_form_status , any.missing=FALSE, len=1)

checkmate::assert_logical( guess_type , any.missing=FALSE, len=1)
checkmate::assert_integerish(guess_max , any.missing=FALSE, len=1, lower=1)
Expand Down Expand Up @@ -249,7 +258,8 @@ redcap_read_oneshot <- function(
exportDataAccessGroups = tolower(as.character(export_data_access_groups)),
filterLogic = filter_logic,
dateRangeBegin = datetime_range_begin,
dateRangeEnd = datetime_range_end
dateRangeEnd = datetime_range_end,
exportBlankForGrayFormStatus = export_blankforgray_form_status
# record, fields, forms & events are specified below
)

Expand Down
11 changes: 11 additions & 0 deletions R/redcap-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@
#' [POSIXct](https://stat.ethz.ch/R-manual/R-devel/library/base/html/as.POSIXlt.html)
#' value.
#' If not specified, REDCap will assume no end time.
#' @param export_blankforgray_form_status A boolean value that specifies whether
#' or not to export blank values for instrument complete status fields that have
#' a gray status icon. All instrument complete status fields having a gray icon
#' can be exported either as a blank value or as "0" (Incomplete). Blank values
#' are recommended in a data export if the data will be re-imported into a
#' REDCap project. Default is `FALSE`.
#'
#' @param col_types A [readr::cols()] object passed internally to
#' [readr::read_csv()]. Optional.
#' @param guess_type A boolean value indicating if all columns should be
Expand Down Expand Up @@ -196,6 +203,7 @@ redcap_read <- function(
filter_logic = "",
datetime_range_begin = as.POSIXct(NA),
datetime_range_end = as.POSIXct(NA),
export_blankforgray_form_status = FALSE,

col_types = NULL,
guess_type = TRUE,
Expand Down Expand Up @@ -227,6 +235,7 @@ redcap_read <- function(
checkmate::assert_logical( export_data_access_groups , any.missing=FALSE, len=1)
checkmate::assert_posixct( datetime_range_begin , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_posixct( datetime_range_end , any.missing=TRUE , len=1, null.ok=TRUE)
checkmate::assert_logical(export_blankforgray_form_status , any.missing=FALSE, len=1)

checkmate::assert_logical( guess_type , any.missing=FALSE, len=1)
if (!is.null(guess_max)) warning("The `guess_max` parameter in `REDCapR::redcap_read()` is deprecated.")
Expand Down Expand Up @@ -278,6 +287,7 @@ redcap_read <- function(
filter_logic = filter_logic,
datetime_range_begin = datetime_range_begin,
datetime_range_end = datetime_range_end,
export_blankforgray_form_status = export_blankforgray_form_status,
guess_type = guess_type,
http_response_encoding = http_response_encoding,
locale = locale,
Expand Down Expand Up @@ -352,6 +362,7 @@ redcap_read <- function(
filter_logic = filter_logic,
datetime_range_begin = datetime_range_begin,
datetime_range_end = datetime_range_end,
export_blankforgray_form_status = export_blankforgray_form_status,

col_types = col_types,
guess_type = FALSE,
Expand Down
1 change: 1 addition & 0 deletions inst/misc/example.credentials
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ redcap_uri,username,project_id,token,comment
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2631","D2A6FF48D266C0CFAAED8842CDCC7CED","decimal comma"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2632","D7DDE242E717619E17F7DF0D3CE582B1","decimal dot"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2634","8F5313CAA266789F560D79EFCEE2E2F1","Validation Types"
"https://bbmc.ouhsc.edu/redcap/api/","myusername","3003","1F2EC7059AC339DFDCD5800225DC7A95","Blank for Gray Status"
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
structure(list(record_id = c(1, 2, 3, 4, 5, 6), name_first = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA
), class = "Date"), age = c(11, 11, 80, 61, 59, NA), sex = c(0,
1, 1, 0, 1, NA), demographics_complete = c(2, 2, 2, 2, 2, 0),
height = c(7, 6, 180, 165, 193.04, NA), weight = c(1, 1,
80, 54, 104, NA), bmi = c(204.1, 277.8, 24.7, 19.8, 27.9,
NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg",
"mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1,
0, 2, 2, 0, 0), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0,
0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0,
0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0,
0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0,
0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2,
2, 2, 0)), row.names = c(NA, -6L), class = "data.frame")
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
structure(list(record_id = c(1, 2, 3, 4, 5, 6), name_first = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA
), class = "Date"), age = c(11, 11, 80, 61, 59, NA), sex = c(0,
1, 1, 0, 1, NA), demographics_complete = c(2, 2, 2, 2, 2, 0),
height = c(7, 6, 180, 165, 193.04, NA), weight = c(1, 1,
80, 54, 104, NA), bmi = c(204.1, 277.8, 24.7, 19.8, 27.9,
NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg",
"mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1,
0, 2, 2, 0, NA), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0,
0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0,
0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0,
0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0,
0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2,
2, 2, NA)), row.names = c(NA, -6L), class = "data.frame")
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
structure(list(record_id = 1:6, name_first = c("Nutmeg", "Tumtum",
"Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02",
"1955-04-15", NA), age = c(11L, 11L, 80L, 61L, 59L, NA), sex = c(0L,
1L, 1L, 0L, 1L, NA), height = c(7, 6, 180, 165, 193.04, NA),
weight = c(1L, 1L, 80L, 54L, 104L, NA), bmi = c(204.1, 277.8,
24.7, 19.8, 27.9, NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c(324901L, 324902L, 324903L, 324904L, 324905L,
NA), race___1 = c(FALSE, FALSE, FALSE, FALSE, TRUE, FALSE
), race___2 = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE),
race___3 = c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE), race___4 = c(FALSE,
FALSE, TRUE, FALSE, FALSE, FALSE), race___5 = c(TRUE, TRUE,
TRUE, TRUE, FALSE, FALSE), race___6 = c(FALSE, FALSE, FALSE,
FALSE, TRUE, FALSE), ethnicity = c(1L, 1L, 0L, 1L, 2L, NA
), interpreter_needed = c(0L, 0L, 1L, NA, 0L, NA), demographics_complete = c(2L,
2L, 2L, 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L,
0L, NA), race_and_ethnicity_complete = c(2L, 0L, 2L, 2L,
2L, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
structure(list(record_id = 1:6, name_first = c("Nutmeg", "Tumtum",
"Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = c("2003-08-30", "2003-03-10", "1934-04-09", "1952-11-02",
"1955-04-15", NA), age = c(11L, 11L, 80L, 61L, 59L, NA), sex = c(0L,
1L, 1L, 0L, 1L, NA), height = c(7, 6, 180, 165, 193.04, NA),
weight = c(1L, 1L, 80L, 54L, 104L, NA), bmi = c(204.1, 277.8,
24.7, 19.8, 27.9, NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c(324901L, 324902L, 324903L, 324904L, 324905L,
NA), race___1 = c(FALSE, FALSE, FALSE, FALSE, TRUE, FALSE
), race___2 = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE),
race___3 = c(FALSE, TRUE, FALSE, FALSE, FALSE, FALSE), race___4 = c(FALSE,
FALSE, TRUE, FALSE, FALSE, FALSE), race___5 = c(TRUE, TRUE,
TRUE, TRUE, FALSE, FALSE), race___6 = c(FALSE, FALSE, FALSE,
FALSE, TRUE, FALSE), ethnicity = c(1L, 1L, 0L, 1L, 2L, NA
), interpreter_needed = c(0L, 0L, 1L, NA, 0L, NA), demographics_complete = c(2L,
2L, 2L, 2L, 2L, 0L), health_complete = c(1L, 0L, 2L, 2L,
0L, NA), race_and_ethnicity_complete = c(2L, 0L, 2L, 2L,
2L, NA)), row.names = c(NA, -6L), class = c("tbl_df", "tbl",
"data.frame"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
structure(list(record_id = c(1, 2, 3, 4, 5, 6), name_first = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA
), class = "Date"), age = c(11, 11, 80, 61, 59, NA), sex = c(0,
1, 1, 0, 1, NA), demographics_complete = c(2, 2, 2, 2, 2, 0),
height = c(7, 6, 180, 165, 193.04, NA), weight = c(1, 1,
80, 54, 104, NA), bmi = c(204.1, 277.8, 24.7, 19.8, 27.9,
NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg",
"mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1,
0, 2, 2, 0, 0), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0,
0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0,
0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0,
0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0,
0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2,
2, 2, 0)), row.names = c(NA, -6L), class = "data.frame")
25 changes: 25 additions & 0 deletions inst/test-data/specific-redcapr/read-oneshot/blank-for-gray-true.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
structure(list(record_id = c(1, 2, 3, 4, 5, 6), name_first = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee", "blank-for-gray"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker", "blank-for-gray"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
"14 Rose Cottage Blvd.\nKenning UK 34243", "243 Hill St.\nGuthrie OK 73402",
"342 Elm\nDuncanville TX, 75116", "Hotel Suite\nNew Orleans LA, 70115",
NA), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555", NA), email = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]",
NA), dob = structure(c(12294, 12121, -13051, -6269, -5375, NA
), class = "Date"), age = c(11, 11, 80, 61, 59, NA), sex = c(0,
1, 1, 0, 1, NA), demographics_complete = c(2, 2, 2, 2, 2, 0),
height = c(7, 6, 180, 165, 193.04, NA), weight = c(1, 1,
80, 54, 104, NA), bmi = c(204.1, 277.8, 24.7, 19.8, 27.9,
NA), comments = c("Character in a book, with some guessing",
"A mouse character from a good book", "completely made up",
"This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
NA), mugshot = c("mugshot-1.jpg", "mugshot-2.jpg", "mugshot-3.jpg",
"mugshot-4.jpg", "mugshot-5.jpg", NA), health_complete = c(1,
0, 2, 2, 0, NA), race___1 = c(0, 0, 0, 0, 1, 0), race___2 = c(0,
0, 0, 1, 0, 0), race___3 = c(0, 1, 0, 0, 0, 0), race___4 = c(0,
0, 1, 0, 0, 0), race___5 = c(1, 1, 1, 1, 0, 0), race___6 = c(0,
0, 0, 0, 1, 0), ethnicity = c(1, 1, 0, 1, 2, NA), interpreter_needed = c(0,
0, 1, NA, 0, NA), race_and_ethnicity_complete = c(2, 0, 2,
2, 2, NA)), row.names = c(NA, -6L), class = "data.frame")
8 changes: 8 additions & 0 deletions man/redcap_read.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading