Skip to content

Commit

Permalink
return form_name with metadata
Browse files Browse the repository at this point in the history
ref #405
  • Loading branch information
wibeasley committed Oct 2, 2022
1 parent e93cefd commit 84e3de6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
35 changes: 25 additions & 10 deletions R/redcap-metadata-coltypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ redcap_metadata_internal <- function(
# Determine status of autonumbering, instrument complete status, and decimal mark
.record_field <- d_var$original_field_name[1]
.autonumber <- d_proj$record_autonumbering_enabled[1]
.form_complete_boxes <- paste0(d_inst$instrument_name, "_complete")
decimal_period <- (locale$decimal_mark == ".")
decimal_comma <- (locale$decimal_mark == ",")

Expand All @@ -252,17 +251,31 @@ redcap_metadata_internal <- function(
)

d_complete <-
tibble::tibble(
field_name = .form_complete_boxes,
field_type = "complete",
vt = NA_character_,
d_inst %>%
dplyr::select(
form_name = .data$instrument_name,
) %>%
dplyr::mutate(
field_name = paste0(.data$form_name, "_complete"),
field_name_base = .data$field_name, # same for *_complete checkboxes
field_type = "complete",
vt = NA_character_,
) %>%
dplyr::select(
.data$field_name,
.data$field_name_base,
.data$form_name,
.data$field_type,
.data$vt,
)

d_again <-
tibble::tibble(
field_name = character(0),
field_type = character(0),
vt = character(0),
field_name = character(0),
field_name_base = character(0),
form_name = character(0),
field_type = character(0),
vt = character(0),
)

if (d_proj$is_longitudinal[1]) {
Expand Down Expand Up @@ -294,6 +307,7 @@ redcap_metadata_internal <- function(
d_meta %>%
dplyr::select(
field_name_base = .data$field_name,
.data$form_name,
.data$field_type,
.data$text_validation_type_or_show_slider_number,
) %>%
Expand All @@ -305,6 +319,7 @@ redcap_metadata_internal <- function(
dplyr::select(
.data$field_name,
.data$field_name_base,
.data$form_name,
.data$field_type,
vt = .data$text_validation_type_or_show_slider_number,
) %>%
Expand All @@ -314,8 +329,7 @@ redcap_metadata_internal <- function(
# setdiff(d_meta$field_name_base, d_var$original_field_name)
# [1] "signature" "file_upload" "descriptive"

# Translate the four datasets into a single `readr:cols()` string printed to the console
# meat <-
# Translate the four datasets into a single cohesive dataset.
d <-
d_meta %>%
dplyr::mutate(
Expand Down Expand Up @@ -407,6 +421,7 @@ redcap_metadata_internal <- function(
) %>%
dplyr::select(
.data$field_name,
.data$form_name,
.data$field_type,
validation_type = .data$vt,
.data$autonumber,
Expand Down
3 changes: 2 additions & 1 deletion inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ SecurityDatabase
Sys
Timezones
Translational
UNexported
URI
VPN
Xie
Expand All @@ -83,6 +84,7 @@ datetime
dbp
dp
dropdown
eav
edu
eg
ethz
Expand Down Expand Up @@ -120,7 +122,6 @@ programmatically
projectredcap
qqq
rdoc
rds
readr
readr's
redcapAPI
Expand Down
2 changes: 2 additions & 0 deletions playgrounds/eav-playground-2.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ token <- "5007DC786DBE39CE77ED8DD0C68069A6" # PHI-free demo: Checkboxes 1
# token <- "5C1526186C4D04AE0A0630743E69B53C" # PHI-free demo: super-wide #3--35,000 columns
# token <- "56F43A10D01D6578A46393394D76D88F" # PHI-free demo: Repeating Instruments --Sparse

fields

# ---- load-data ---------------------------------------------------------------
system.time(
ds_expected <- REDCapR::redcap_read_oneshot(redcap_uri, token)$data
Expand Down

0 comments on commit 84e3de6

Please sign in to comment.