Skip to content

Commit

Permalink
project for testing validation types
Browse files Browse the repository at this point in the history
ref #294
  • Loading branch information
wibeasley committed Nov 30, 2021
1 parent 64141a2 commit 8cab45d
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
1 change: 1 addition & 0 deletions inst/misc/example.credentials
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ redcap_uri,username,project_id,token,comment
"https://bbmc.ouhsc.edu/redcap/api/","myusername","2630","33DDFEF1D68EE5A5119DDF06C602430E","decimal comma and dot"
"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"
2 changes: 2 additions & 0 deletions inst/test-data/validation-types-v1/data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
record_id,alpha_only,date_dmy ,date_mdy ,date_ymd ,datetime_dmy ,datetime_mdy ,datetime_seconds_dmy,datetime_seconds_mdy,datetime_seconds_ymd,datetime_ymd ,email ,integer,mrn_10d ,mrn_generic,number,number_1dp,number_1dp_comma_decimal,number_2dp,number_2dp_comma_decimal,number_3dp,number_3dp_comma_decimal,number_4dp,number_4dp_comma_decimal,number_comma_decimal,phone ,phone_australia,postalcode_australia,postalcode_canada,postalcode_french,postalcode_germany,ssn ,time,time_mm_ss,vmrn,zipcode
1 ,abcde ,2023-12-31,2023-12-31,2023-12-31,2023-12-31 11:45,2023-12-31 11:45,2023-12-31 11:45:55 ,2023-12-31 11:45:55 ,2023-12-31 11:45:55 ,2023-12-31 11:45:55 ,[email protected],1234567,0123456789,abcd-_12345,12.345,1234.5 ,"1234,5" ,1234.56 ,"1234,56" ,1234.567 ,"1234,567" ,1234.5678 ,"1234,5678" ,"1234,56" ,"(321) 222-4444","(04) 4321 4321" ,0123 ,A2C1B3 ,12345 ,12345 ,123-12-1234,12:34,59:59 ,01234,01234
37 changes: 37 additions & 0 deletions inst/test-data/validation-types-v1/dictionary.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
field_name,form_name,section_header,field_type,field_label,select_choices_or_calculations,field_note,text_validation_type_or_show_slider_number,text_validation_min,text_validation_max,identifier,branching_logic,required_field,custom_alignment,question_number,matrix_group_name,matrix_ranking,field_annotation
record_id,form_1,,text,"Record ID",,,,,,,,,,,,,
alpha_only,form_1,,text,Letters only,,,alpha_only,,,,,,,,,,
date_dmy,form_1,,text,Date (D-M-Y),,,date_dmy,,,,,,,,,,
date_mdy,form_1,,text,Date (M-D-Y),,,date_mdy,,,,,,,,,,
date_ymd,form_1,,text,Date (Y-M-D),,,date_ymd,,,,,,,,,,
datetime_dmy,form_1,,text,Datetime (D-M-Y H:M),,,datetime_dmy,,,,,,,,,,
datetime_mdy,form_1,,text,Datetime (M-D-Y H:M),,,datetime_mdy,,,,,,,,,,
datetime_seconds_dmy,form_1,,text,Datetime w/ seconds (D-M-Y H:M:S),,,datetime_seconds_dmy,,,,,,,,,,
datetime_seconds_mdy,form_1,,text,Datetime w/ seconds (M-D-Y H:M:S),,,datetime_seconds_mdy,,,,,,,,,,
datetime_seconds_ymd,form_1,,text,Datetime w/ seconds (Y-M-D H:M:S),,,datetime_seconds_ymd,,,,,,,,,,
datetime_ymd,form_1,,text,Datetime (Y-M-D H:M),,,datetime_ymd,,,,,,,,,,
email,form_1,,text,Email,,,email,,,,,,,,,,
integer,form_1,,text,Integer,,,integer,,,,,,,,,,
mrn_10d,form_1,,text,MRN (10 digits),,,mrn_10d,,,,,,,,,,
mrn_generic,form_1,,text,MRN (generic),,,mrn_generic,,,,,,,,,,
number,form_1,,text,Number,,,number,,,,,,,,,,
number_1dp,form_1,,text,Number (1 decimal place),,,number_1dp,,,,,,,,,,
number_1dp_comma_decimal,form_1,,text,Number (1 decimal place - comma as decimal),,,number_1dp_comma_decimal,,,,,,,,,,
number_2dp,form_1,,text,Number (2 decimal places),,,number_2dp,,,,,,,,,,
number_2dp_comma_decimal,form_1,,text,Number (2 decimal places - comma as decimal),,,number_2dp_comma_decimal,,,,,,,,,,
number_3dp,form_1,,text,Number (3 decimal places),,,number_3dp,,,,,,,,,,
number_3dp_comma_decimal,form_1,,text,Number (3 decimal places - comma as decimal),,,number_3dp_comma_decimal,,,,,,,,,,
number_4dp,form_1,,text,Number (4 decimal places),,,number_4dp,,,,,,,,,,
number_4dp_comma_decimal,form_1,,text,Number (4 decimal places - comma as decimal),,,number_4dp_comma_decimal,,,,,,,,,,
number_comma_decimal,form_1,,text,Number (comma as decimal),,,number_comma_decimal,,,,,,,,,,
phone,form_1,,text,Phone (North America),,,phone,,,,,,,,,,
phone_australia,form_1,,text,Phone (Australia),,,phone_australia,,,,,,,,,,
postalcode_australia,form_1,,text,Postal Code (Australia),,,postalcode_australia,,,,,,,,,,
postalcode_canada,form_1,,text,Postal Code (Canada),,,postalcode_canada,,,,,,,,,,
postalcode_french,form_1,,text,Code Postal 5 characters (France),,,postalcode_french,,,,,,,,,,
postalcode_germany,form_1,,text,Postal Code (Germany),,,postalcode_germany,,,,,,,,,,
ssn,form_1,,text,Social Security Number (U.S.),,,ssn,,,,,,,,,,
time,form_1,,text,Time (HH:MM),,,time,,,,,,,,,,
time_mm_ss,form_1,,text,Time (MM:SS),,,time_mm_ss,,,,,,,,,,
vmrn,form_1,,text,Vanderbilt MRN,,,vmrn,,,,,,,,,,
zipcode,form_1,,text,Zipcode (U.S.),,,zipcode,,,,,,,,,,
9 changes: 2 additions & 7 deletions playgrounds/metadata-2.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,9 @@ fxs <-
) |>
dplyr::left_join(ds_mapping_validation_name, by = "validation_name") |>
tidyr::drop_na(fx_export) |>
{
\(x)
rlang::set_names(
x = x$fx_export,
nm = x$field_name
)
}()
dplyr::pull(fx_export, name = field_name)

d <- tibble::as_tibble(d)
for (variable in names(fxs)) {
fx <- base::eval(base::parse(text = fxs[[variable]]))
d[[variable]] <- fx(d[[variable]])
Expand Down

0 comments on commit 8cab45d

Please sign in to comment.