Skip to content

Commit

Permalink
redcap_read_eav_oneshot()
Browse files Browse the repository at this point in the history
close #437
  • Loading branch information
wibeasley committed Oct 2, 2022
1 parent 2b8ceec commit f4ed590
Show file tree
Hide file tree
Showing 15 changed files with 1,273 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ These features are not yet on CRAN. Install with `remotes::install_github("Ouhs
* New parameter `blank_for_gray_form_status` in the functions `redcap_read()`, `redcap_read_oneshot()`, and `redcap_read_oneshot_eav()`. (@greg-botwin, #386, #389)
* A `httr::handle` value is accepted by functions that contact the server. This will accommodate some institutions with unconventional environments. (Suggested by @brandonpotvin, #429)
* `sanitized_token()` now accepts an alternative regex pattern. (Suggested by @maeon & @michalkouril, #370)
* `redcap_read_eav_oneshot()` is an UNexported function that returns data in an EAV format (#437)

### Minor Enhancements

Expand Down
371 changes: 371 additions & 0 deletions R/redcap-read-eav-oneshot.R

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
structure(list(record = c("1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4",
"4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5",
"5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5",
"5", "5", "5", "5", "5", "6", "6", "6", "6"), field_name = c("address",
"age", "bmi", "comments", "demographics_complete", "dob", "email",
"ethnicity", "health_complete", "height", "interpreter_needed",
"mugshot", "name_first", "name_last", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "interpreter_needed", "mugshot",
"name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "interpreter_needed", "mugshot",
"name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "mugshot", "name_first", "name_last",
"race", "race", "race_and_ethnicity_complete", "record_id", "sex",
"telephone", "weight", "address", "age", "bmi", "comments", "demographics_complete",
"dob", "email", "ethnicity", "health_complete", "height", "interpreter_needed",
"mugshot", "name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "name_first", "name_last",
"demographics_complete", "record_id"), value = c("14 Rose Cottage St.\nKenning UK, 323232",
"11", "204.1", "Character in a book, with some guessing", "2",
"2003-08-30", "[email protected]", "1", "1", "7", "0", "324901",
"Nutmeg", "Nutmouse", "5", "2", "1", "0", "(405) 321-1111", "1",
"14 Rose Cottage Blvd.\nKenning UK 34243", "11", "277.8", "A mouse character from a good book",
"2", "2003-03-10", "[email protected]", "1", "0", "6", "0", "324902",
"Tumtum", "Nutmouse", "3", "5", "0", "2", "1", "(405) 321-2222",
"1", "243 Hill St.\nGuthrie OK 73402", "80", "24.7", "completely made up",
"2", "1934-04-09", "[email protected]", "0", "2", "180", "1", "324903",
"Marcus", "Wood", "4", "5", "2", "3", "1", "(405) 321-3333",
"80", "342 Elm\nDuncanville TX, 75116", "61", "19.8", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"2", "1952-11-02", "[email protected]", "1", "2", "165", "324904",
"Trudy", "DAG", "2", "5", "2", "4", "0", "(405) 321-4444", "54",
"Hotel Suite\nNew Orleans LA, 70115", "59", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
"2", "1955-04-15", "[email protected]", "2", "0", "193.04",
"0", "324905", "John Lee", "Walker", "1", "6", "2", "5", "1",
"(405) 321-5555", "104", "blank-for-gray", "blank-for-gray",
"0", "6")), row.names = c(NA, -107L), spec = structure(list(cols = list(
record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
structure(list(record = c("1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4",
"4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5",
"5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5",
"5", "5", "5", "5", "5", "6", "6", "6", "6"), field_name = c("address",
"age", "bmi", "comments", "demographics_complete", "dob", "email",
"ethnicity", "health_complete", "height", "interpreter_needed",
"mugshot", "name_first", "name_last", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "interpreter_needed", "mugshot",
"name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "interpreter_needed", "mugshot",
"name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "address", "age",
"bmi", "comments", "demographics_complete", "dob", "email", "ethnicity",
"health_complete", "height", "mugshot", "name_first", "name_last",
"race", "race", "race_and_ethnicity_complete", "record_id", "sex",
"telephone", "weight", "address", "age", "bmi", "comments", "demographics_complete",
"dob", "email", "ethnicity", "health_complete", "height", "interpreter_needed",
"mugshot", "name_first", "name_last", "race", "race", "race_and_ethnicity_complete",
"record_id", "sex", "telephone", "weight", "name_first", "name_last",
"demographics_complete", "record_id"), value = c("14 Rose Cottage St.\nKenning UK, 323232",
"11", "204.1", "Character in a book, with some guessing", "2",
"2003-08-30", "[email protected]", "1", "1", "7", "0", "324901",
"Nutmeg", "Nutmouse", "5", "2", "1", "0", "(405) 321-1111", "1",
"14 Rose Cottage Blvd.\nKenning UK 34243", "11", "277.8", "A mouse character from a good book",
"2", "2003-03-10", "[email protected]", "1", "0", "6", "0", "324902",
"Tumtum", "Nutmouse", "3", "5", "0", "2", "1", "(405) 321-2222",
"1", "243 Hill St.\nGuthrie OK 73402", "80", "24.7", "completely made up",
"2", "1934-04-09", "[email protected]", "0", "2", "180", "1", "324903",
"Marcus", "Wood", "4", "5", "2", "3", "1", "(405) 321-3333",
"80", "342 Elm\nDuncanville TX, 75116", "61", "19.8", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"2", "1952-11-02", "[email protected]", "1", "2", "165", "324904",
"Trudy", "DAG", "2", "5", "2", "4", "0", "(405) 321-4444", "54",
"Hotel Suite\nNew Orleans LA, 70115", "59", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
"2", "1955-04-15", "[email protected]", "2", "0", "193.04",
"0", "324905", "John Lee", "Walker", "1", "6", "2", "5", "1",
"(405) 321-5555", "104", "blank-for-gray", "blank-for-gray",
"0", "6")), row.names = c(NA, -107L), spec = structure(list(cols = list(
record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
51 changes: 51 additions & 0 deletions inst/test-data/specific-redcapr/read-eav-oneshot/default.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
structure(list(record = c("1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4",
"4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5",
"5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5",
"5", "5", "5", "5", "5"), field_name = c("address", "telephone",
"email", "dob", "age", "ethnicity", "sex", "height", "weight",
"bmi", "comments", "demographics_complete", "record_id", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "age", "ethnicity", "sex", "height", "weight",
"bmi", "comments", "demographics_complete", "record_id", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "age", "ethnicity", "race", "sex", "height",
"weight", "bmi", "comments", "demographics_complete", "record_id",
"name_first", "name_last", "health_complete", "race_and_ethnicity_complete",
"race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "ethnicity", "sex", "height", "weight", "bmi",
"demographics_complete", "record_id", "comments", "age", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "race", "mugshot", "address", "demographics_complete",
"record_id", "telephone", "email", "dob", "age", "ethnicity",
"sex", "height", "weight", "bmi", "comments", "name_first", "name_last",
"health_complete", "race_and_ethnicity_complete", "race", "race",
"mugshot", "interpreter_needed"), value = c("14 Rose Cottage St.\nKenning UK, 323232",
"(405) 321-1111", "[email protected]", "2003-08-30", "11", "1",
"0", "7", "1", "204.1", "Character in a book, with some guessing",
"2", "1", "Nutmeg", "Nutmouse", "1", "2", "5", "197977", "0",
"14 Rose Cottage Blvd.\nKenning UK 34243", "(405) 321-2222",
"[email protected]", "2003-03-10", "11", "1", "1", "6", "1", "277.8",
"A mouse character from a good book", "2", "2", "Tumtum", "Nutmouse",
"0", "0", "3", "5", "197978", "0", "243 Hill St.\nGuthrie OK 73402",
"(405) 321-3333", "[email protected]", "1934-04-09", "80", "0", "4",
"1", "180", "80", "24.7", "completely made up", "2", "3", "Marcus",
"Wood", "2", "2", "5", "197979", "1", "342 Elm\nDuncanville TX, 75116",
"(405) 321-4444", "[email protected]", "1952-11-02", "1", "0",
"165", "54", "19.8", "2", "4", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"61", "Trudy", "DAG", "2", "2", "2", "5", "198002", "Hotel Suite\nNew Orleans LA, 70115",
"2", "5", "(405) 321-5555", "[email protected]", "1955-04-15",
"59", "2", "1", "193.04", "104", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
"John Lee", "Walker", "0", "2", "1", "6", "198021", "0")), row.names = c(NA,
-103L), spec = structure(list(cols = list(record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
structure(list(record = c("5", "5", "5", "5", "5", "5", "5",
"5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5",
"5"), field_name = c("address", "demographics_complete", "record_id",
"telephone", "email", "dob", "age", "ethnicity", "sex", "height",
"weight", "bmi", "comments", "name_first", "name_last", "health_complete",
"race_and_ethnicity_complete", "race", "race", "mugshot", "interpreter_needed"
), value = c("Hotel Suite\nNew Orleans LA, 70115", "2", "5",
"(405) 321-5555", "[email protected]", "1955-04-15", "59", "2",
"1", "193.04", "104", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
"John Lee", "Walker", "0", "2", "1", "6", "198021", "0")), row.names = c(NA,
-21L), spec = structure(list(cols = list(record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
24 changes: 24 additions & 0 deletions inst/test-data/specific-redcapr/read-eav-oneshot/filter-numeric.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
structure(list(record = c("3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4",
"4", "4", "4", "4", "4", "4", "4", "4"), field_name = c("address",
"telephone", "email", "dob", "age", "ethnicity", "race", "sex",
"height", "weight", "bmi", "comments", "demographics_complete",
"record_id", "name_first", "name_last", "health_complete", "race_and_ethnicity_complete",
"race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "ethnicity", "sex", "height", "weight", "bmi",
"demographics_complete", "record_id", "comments", "age", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "race", "mugshot"), value = c("243 Hill St.\nGuthrie OK 73402",
"(405) 321-3333", "[email protected]", "1934-04-09", "80", "0", "4",
"1", "180", "80", "24.7", "completely made up", "2", "3", "Marcus",
"Wood", "2", "2", "5", "197979", "1", "342 Elm\nDuncanville TX, 75116",
"(405) 321-4444", "[email protected]", "1952-11-02", "1", "0",
"165", "54", "19.8", "2", "4", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"61", "Trudy", "DAG", "2", "2", "2", "5", "198002")), row.names = c(NA,
-41L), spec = structure(list(cols = list(record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
structure(list(record = c("1", "1", "1", "1", "1", "1", "1",
"1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
"2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2", "2",
"2", "2", "2", "2", "2", "2", "2", "2", "3", "3", "3", "3", "3",
"3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3", "3",
"3", "3", "3", "4", "4", "4", "4", "4", "4", "4", "4", "4", "4",
"4", "4", "4", "4", "4", "4", "4", "4", "4", "4", "5", "5", "5",
"5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5", "5",
"5", "5", "5", "5", "5"), field_name = c("address", "telephone",
"email", "dob", "age", "ethnicity", "sex", "height", "weight",
"bmi", "comments", "demographics_complete", "record_id", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "age", "ethnicity", "sex", "height", "weight",
"bmi", "comments", "demographics_complete", "record_id", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "age", "ethnicity", "race", "sex", "height",
"weight", "bmi", "comments", "demographics_complete", "record_id",
"name_first", "name_last", "health_complete", "race_and_ethnicity_complete",
"race", "mugshot", "interpreter_needed", "address", "telephone",
"email", "dob", "ethnicity", "sex", "height", "weight", "bmi",
"demographics_complete", "record_id", "comments", "age", "name_first",
"name_last", "health_complete", "race_and_ethnicity_complete",
"race", "race", "mugshot", "address", "demographics_complete",
"record_id", "telephone", "email", "dob", "age", "ethnicity",
"sex", "height", "weight", "bmi", "comments", "name_first", "name_last",
"health_complete", "race_and_ethnicity_complete", "race", "race",
"mugshot", "interpreter_needed"), value = c("14 Rose Cottage St.\nKenning UK, 323232",
"(405) 321-1111", "[email protected]", "2003-08-30", "11", "1",
"0", "7", "1", "204.1", "Character in a book, with some guessing",
"2", "1", "Nutmeg", "Nutmouse", "1", "2", "5", "197977", "0",
"14 Rose Cottage Blvd.\nKenning UK 34243", "(405) 321-2222",
"[email protected]", "2003-03-10", "11", "1", "1", "6", "1", "277.8",
"A mouse character from a good book", "2", "2", "Tumtum", "Nutmouse",
"0", "0", "3", "5", "197978", "0", "243 Hill St.\nGuthrie OK 73402",
"(405) 321-3333", "[email protected]", "1934-04-09", "80", "0", "4",
"1", "180", "80", "24.7", "completely made up", "2", "3", "Marcus",
"Wood", "2", "2", "5", "197979", "1", "342 Elm\nDuncanville TX, 75116",
"(405) 321-4444", "[email protected]", "1952-11-02", "1", "0",
"165", "54", "19.8", "2", "4", "This record doesn't have a DAG assigned\n\nSo call up Trudy on the telephone\nSend her a letter in the mail",
"61", "Trudy", "DAG", "2", "2", "2", "5", "198002", "Hotel Suite\nNew Orleans LA, 70115",
"2", "5", "(405) 321-5555", "[email protected]", "1955-04-15",
"59", "2", "1", "193.04", "104", "27.9", "Had a hand for trouble and a eye for cash\n\nHe had a gold watch chain and a black mustache",
"John Lee", "Walker", "0", "2", "1", "6", "198021", "0")), row.names = c(NA,
-103L), spec = structure(list(cols = list(record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
15 changes: 15 additions & 0 deletions inst/test-data/specific-redcapr/read-eav-oneshot/specify-fields.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
structure(list(record = c("1", "1", "1", "1", "2", "2", "2",
"2", "3", "3", "3", "3", "4", "4", "4", "4", "5", "5", "5", "5"
), field_name = c("age", "record_id", "name_first", "name_last",
"age", "record_id", "name_first", "name_last", "age", "record_id",
"name_first", "name_last", "record_id", "age", "name_first",
"name_last", "record_id", "age", "name_first", "name_last"),
value = c("11", "1", "Nutmeg", "Nutmouse", "11", "2", "Tumtum",
"Nutmouse", "80", "3", "Marcus", "Wood", "4", "61", "Trudy",
"DAG", "5", "59", "John Lee", "Walker")), row.names = c(NA,
-20L), spec = structure(list(cols = list(record = structure(list(), class = c("collector_character",
"collector")), field_name = structure(list(), class = c("collector_character",
"collector")), value = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
Loading

0 comments on commit f4ed590

Please sign in to comment.