Skip to content

Commit

Permalink
expectations to file
Browse files Browse the repository at this point in the history
ref #308
  • Loading branch information
wibeasley committed Sep 27, 2020
1 parent a0a801c commit 76b23d9
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 245 deletions.
2 changes: 2 additions & 0 deletions R/helpers-testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ retrieve_credential_testing <- function(project_id = 153L) {

save_expected <- function (o, path) {
path <- file.path("inst", path)
if (!dir.exists(dirname(path))) dir.create(dirname(path), recursive = FALSE)

dput(o, path)
}

Expand Down
80 changes: 80 additions & 0 deletions inst/test-data/specific-redcapr/metadata-read/normal.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
structure(list(field_name = c("record_id", "name_first", "name_last",
"address", "telephone", "email", "dob", "age", "sex", "height",
"weight", "bmi", "comments", "mugshot", "race", "ethnicity",
"interpreter_needed"), form_name = c("demographics", "demographics",
"demographics", "demographics", "demographics", "demographics",
"demographics", "demographics", "demographics", "health", "health",
"health", "health", "health", "race_and_ethnicity", "race_and_ethnicity",
"race_and_ethnicity"), section_header = c(NA, "Contact Information",
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, "General Comments", NA,
NA, NA, NA), field_type = c("text", "text", "text", "notes",
"text", "text", "text", "text", "radio", "text", "text", "calc",
"notes", "file", "checkbox", "radio", "truefalse"), field_label = c("Study ID",
"First Name", "Last Name", "Street, City, State, ZIP", "Phone number",
"E-mail", "Date of birth", "Age (years)", "Gender", "Height (cm)",
"Weight (kilograms)", "BMI", "Comments", "Mugshot", "Race (Select all that apply)",
"Ethnicity", "Are interpreter services requested?"), select_choices_or_calculations = c(NA,
NA, NA, NA, NA, NA, NA, NA, "0, Female | 1, Male", NA, NA, "round(([weight]*10000)/(([height])^(2)),1)",
NA, NA, "1, American Indian/Alaska Native | 2, Asian | 3, Native Hawaiian or Other Pacific Islander | 4, Black or African American | 5, White | 6, Unknown / Not Reported",
"0, Unknown / Not Reported | 1, NOT Hispanic or Latino | 2, Hispanic or Latino",
NA), field_note = c(NA, NA, NA, NA, "Include Area Code", NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA), text_validation_type_or_show_slider_number = c(NA,
NA, NA, NA, "phone", "email", "date_ymd", NA, NA, "number", "integer",
NA, NA, NA, NA, NA, NA), text_validation_min = c(NA, NA, NA,
NA, NA, NA, NA, NA, NA, "130", "35", NA, NA, NA, NA, NA, NA),
text_validation_max = c(NA, NA, NA, NA, NA, NA, NA, NA, NA,
"215", "200", NA, NA, NA, NA, NA, NA), identifier = c(NA,
"y", "y", "y", "y", "y", "y", NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA), branching_logic = c(NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), required_field = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), custom_alignment = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_), question_number = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), matrix_group_name = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_), matrix_ranking = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_
), field_annotation = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_)), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -17L), spec = structure(list(
cols = list(field_name = structure(list(), class = c("collector_character",
"collector")), form_name = structure(list(), class = c("collector_character",
"collector")), section_header = structure(list(), class = c("collector_character",
"collector")), field_type = structure(list(), class = c("collector_character",
"collector")), field_label = structure(list(), class = c("collector_character",
"collector")), select_choices_or_calculations = structure(list(), class = c("collector_character",
"collector")), field_note = structure(list(), class = c("collector_character",
"collector")), text_validation_type_or_show_slider_number = structure(list(), class = c("collector_character",
"collector")), text_validation_min = structure(list(), class = c("collector_character",
"collector")), text_validation_max = structure(list(), class = c("collector_character",
"collector")), identifier = structure(list(), class = c("collector_character",
"collector")), branching_logic = structure(list(), class = c("collector_character",
"collector")), required_field = structure(list(), class = c("collector_character",
"collector")), custom_alignment = structure(list(), class = c("collector_character",
"collector")), question_number = structure(list(), class = c("collector_character",
"collector")), matrix_group_name = structure(list(), class = c("collector_character",
"collector")), matrix_ranking = structure(list(), class = c("collector_character",
"collector")), field_annotation = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), skip = 1), class = "col_spec"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
structure(list(field_name = c("record_id", "v1", "curly_quote_single",
"curly_quote_double_left", "curly_quote_double_right", "long_dash"
), form_name = c("form_1", "form_1", "form_1", "form_1", "form_1",
"form_1"), section_header = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), field_type = c("text",
"dropdown", "radio", "radio", "radio", "radio"), field_label = c("Record ID",
"Is the laser mounted on the shark?�?�", "My child doesn't like candy",
"Maybe I don't \"look the part\"", "Maybe I don't \"look comfortable on camera\"",
"Maybe I don't \"wear the latest clothes\" −or even ones that don't \"reek\""
), select_choices_or_calculations = c(NA, "0, No | 1, Yes | 3, I should find out",
"0, (0) Never or Almost Never | 1, (1) Sometimes | 2, (2) Often",
"0, Bennett | 1, Brauer", "0, Bennett | 1, Brauer", "0, Bennett | 1, Brauer"
), field_note = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), text_validation_type_or_show_slider_number = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), text_validation_min = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), text_validation_max = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), identifier = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), branching_logic = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), required_field = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), custom_alignment = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), question_number = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), matrix_group_name = c(NA_character_,
NA_character_, NA_character_, NA_character_, NA_character_, NA_character_
), matrix_ranking = c(NA_character_, NA_character_, NA_character_,
NA_character_, NA_character_, NA_character_), field_annotation = c(NA,
NA, NA, "https://github.com/OuhscBbmc/REDCapR/issues/290", "https://github.com/OuhscBbmc/REDCapR/issues/290",
"https://github.com/OuhscBbmc/REDCapR/issues/290")), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"), row.names = c(NA, -6L), spec = structure(list(
cols = list(field_name = structure(list(), class = c("collector_character",
"collector")), form_name = structure(list(), class = c("collector_character",
"collector")), section_header = structure(list(), class = c("collector_character",
"collector")), field_type = structure(list(), class = c("collector_character",
"collector")), field_label = structure(list(), class = c("collector_character",
"collector")), select_choices_or_calculations = structure(list(), class = c("collector_character",
"collector")), field_note = structure(list(), class = c("collector_character",
"collector")), text_validation_type_or_show_slider_number = structure(list(), class = c("collector_character",
"collector")), text_validation_min = structure(list(), class = c("collector_character",
"collector")), text_validation_max = structure(list(), class = c("collector_character",
"collector")), identifier = structure(list(), class = c("collector_character",
"collector")), branching_logic = structure(list(), class = c("collector_character",
"collector")), required_field = structure(list(), class = c("collector_character",
"collector")), custom_alignment = structure(list(), class = c("collector_character",
"collector")), question_number = structure(list(), class = c("collector_character",
"collector")), matrix_group_name = structure(list(), class = c("collector_character",
"collector")), matrix_ranking = structure(list(), class = c("collector_character",
"collector")), field_annotation = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), skip = 1), class = "col_spec"))
98 changes: 47 additions & 51 deletions inst/test-data/specific-redcapr/read-batch-simple/label-header.R
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
structure(list(record_id = c(1, 2, 3, 4, 5), name_first = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee"), name_last = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker"), address = c("14 Rose Cottage St.\nKenning UK, 323232",
structure(list(`Study ID` = c(1, 2, 3, 4, 5), `First Name` = c("Nutmeg",
"Tumtum", "Marcus", "Trudy", "John Lee"), `Last Name` = c("Nutmouse",
"Nutmouse", "Wood", "DAG", "Walker"), `Street, City, State, ZIP` = 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"
), telephone = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555"), email = c("[email protected]",
), `Phone number` = c("(405) 321-1111", "(405) 321-2222", "(405) 321-3333",
"(405) 321-4444", "(405) 321-5555"), `E-mail` = c("[email protected]",
"[email protected]", "[email protected]", "[email protected]", "[email protected]"
), dob = structure(c(12294, 12121, -13051, -6269, -5375), class = "Date"),
age = c(11, 11, 80, 61, 59), sex = c("Female", "Male", "Male",
"Female", "Male"), demographics_complete = c("Complete",
"Complete", "Complete", "Complete", "Complete"), height = c(7,
6, 180, 165, 193.04), weight = c(1, 1, 80, 54, 104), bmi = c(204.1,
277.8, 24.7, 19.8, 27.9), 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",
), `Date of birth` = structure(c(12294, 12121, -13051, -6269,
-5375), class = "Date"), `Age (years)` = c(11, 11, 80, 61, 59
), Gender = c(0, 1, 1, 0, 1), `Complete?` = c(2, 2, 2, 2, 2),
`Height (cm)` = c(7, 6, 180, 165, 193.04), `Weight (kilograms)` = c(1,
1, 80, 54, 104), BMI = c(204.1, 277.8, 24.7, 19.8, 27.9),
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"
), mugshot = c("[document]", "[document]", "[document]",
"[document]", "[document]"), health_complete = c("Unverified",
"Incomplete", "Complete", "Complete", "Incomplete"), race___1 = c(NA,
NA, NA, NA, "American Indian/Alaska Native"), race___2 = c(NA,
NA, NA, "Asian", NA), race___3 = c(NA, "Native Hawaiian or Other Pacific Islander",
NA, NA, NA), race___4 = c(NA, NA, "Black or African American",
NA, NA), race___5 = c("White", "White", "White", "White",
NA), race___6 = c(NA, NA, NA, NA, "Unknown / Not Reported"
), ethnicity = c("NOT Hispanic or Latino", "NOT Hispanic or Latino",
"Unknown / Not Reported", "NOT Hispanic or Latino", "Hispanic or Latino"
), interpreter_needed = c(FALSE, FALSE, TRUE, NA, FALSE),
race_and_ethnicity_complete = c("Complete", "Incomplete",
"Complete", "Complete", "Complete")), row.names = c(NA, -5L
), spec = structure(list(cols = list(record_id = structure(list(), class = c("collector_character",
"collector")), name_first = structure(list(), class = c("collector_character",
"collector")), name_last = structure(list(), class = c("collector_character",
"collector")), address = structure(list(), class = c("collector_character",
"collector")), telephone = structure(list(), class = c("collector_character",
"collector")), email = structure(list(), class = c("collector_character",
"collector")), dob = structure(list(), class = c("collector_character",
"collector")), age = structure(list(), class = c("collector_character",
"collector")), sex = structure(list(), class = c("collector_character",
"collector")), demographics_complete = structure(list(), class = c("collector_character",
"collector")), height = structure(list(), class = c("collector_character",
"collector")), weight = structure(list(), class = c("collector_character",
"collector")), bmi = structure(list(), class = c("collector_character",
"collector")), comments = structure(list(), class = c("collector_character",
"collector")), mugshot = structure(list(), class = c("collector_character",
"collector")), health_complete = structure(list(), class = c("collector_character",
"collector")), race___1 = structure(list(), class = c("collector_character",
"collector")), race___2 = structure(list(), class = c("collector_character",
"collector")), race___3 = structure(list(), class = c("collector_character",
"collector")), race___4 = structure(list(), class = c("collector_character",
"collector")), race___5 = structure(list(), class = c("collector_character",
"collector")), race___6 = structure(list(), class = c("collector_character",
"collector")), ethnicity = structure(list(), class = c("collector_character",
"collector")), interpreter_needed = structure(list(), class = c("collector_character",
"collector")), race_and_ethnicity_complete = structure(list(), class = c("collector_character",
), Mugshot = c("[document]", "[document]", "[document]",
"[document]", "[document]"), `Complete?_1` = c(1, 0, 2, 2,
0), `Race (Select all that apply) (choice=American Indian/Alaska Native)` = c(0,
0, 0, 0, 1), `Race (Select all that apply) (choice=Asian)` = c(0,
0, 0, 1, 0), `Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)` = c(0,
1, 0, 0, 0), `Race (Select all that apply) (choice=Black or African American)` = c(0,
0, 1, 0, 0), `Race (Select all that apply) (choice=White)` = c(1,
1, 1, 1, 0), `Race (Select all that apply) (choice=Unknown / Not Reported)` = c(0,
0, 0, 0, 1), Ethnicity = c(1, 1, 0, 1, 2), `Are interpreter services requested?` = c(0,
0, 1, NA, 0), `Complete?_2` = c(2, 0, 2, 2, 2)), row.names = c(NA,
-5L), spec = structure(list(cols = list(`Study ID` = structure(list(), class = c("collector_character",
"collector")), `First Name` = structure(list(), class = c("collector_character",
"collector")), `Last Name` = structure(list(), class = c("collector_character",
"collector")), `Street, City, State, ZIP` = structure(list(), class = c("collector_character",
"collector")), `Phone number` = structure(list(), class = c("collector_character",
"collector")), `E-mail` = structure(list(), class = c("collector_character",
"collector")), `Date of birth` = structure(list(), class = c("collector_character",
"collector")), `Age (years)` = structure(list(), class = c("collector_character",
"collector")), Gender = structure(list(), class = c("collector_character",
"collector")), `Complete?` = structure(list(), class = c("collector_character",
"collector")), `Height (cm)` = structure(list(), class = c("collector_character",
"collector")), `Weight (kilograms)` = structure(list(), class = c("collector_character",
"collector")), BMI = structure(list(), class = c("collector_character",
"collector")), Comments = structure(list(), class = c("collector_character",
"collector")), Mugshot = structure(list(), class = c("collector_character",
"collector")), `Complete?_1` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=American Indian/Alaska Native)` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=Asian)` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=Native Hawaiian or Other Pacific Islander)` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=Black or African American)` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=White)` = structure(list(), class = c("collector_character",
"collector")), `Race (Select all that apply) (choice=Unknown / Not Reported)` = structure(list(), class = c("collector_character",
"collector")), Ethnicity = structure(list(), class = c("collector_character",
"collector")), `Are interpreter services requested?` = structure(list(), class = c("collector_character",
"collector")), `Complete?_2` = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_character",
"collector")), skip = 1), class = "col_spec"), class = "data.frame")
Loading

0 comments on commit 76b23d9

Please sign in to comment.