Skip to content

Commit

Permalink
message if a pseudofield is requested
Browse files Browse the repository at this point in the history
ref #477
  • Loading branch information
wibeasley committed Apr 22, 2023
1 parent c601dcd commit ae2d7b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This will help extract forms from longitudinal & repeating projects.
* Accommodate older versions of REDCap that don't return project-level variable, like `has_repeating_instruments_or_events`, `missing_data_codes`, `external_modules`, `bypass_branching_erase_field_prompt` (@the-mad-statter, #465, #466)
* `redcap_meta_coltypes()` correctly determines data type for autonumber `record_id` fields. It suggests a character if the project has DAGs, and an integer if not. (@pwildenhain, #472)
* `redcap_log_read()` now returns a new column reflecting the affected record id value (ref #478)
* `redcap_read()` and `redcap_read_oneshot()` now remove "pseudofields" (e.g., `redcap_event_name`, `redcap_repeat_instrument`, & `redcap_repeat_instance`) from the `fields` parameter. Starting with REDCap v13.4.10, an error is thrown by the server.
* `redcap_read()` and `redcap_read_oneshot()` now remove "pseudofields" (e.g., `redcap_event_name`, `redcap_repeat_instrument`, & `redcap_repeat_instance`) from the `fields` parameter. Starting with REDCap v13.4.10, an error is thrown by the server. REDCap will return a message if a common pseudofield is requested explicitly by the user. (#477)

Version 1.1.0 (released 2022-08-10)
==========================================================
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 @@ -229,7 +229,17 @@ redcap_read_oneshot <- function(

validate_field_names(fields, stop_on_error = TRUE)

fields <- setdiff(fields, c("redcap_event_name", "redcap_repeat_instrument", "redcap_repeat_instance"))
pseudofields <- c("redcap_event_name", "redcap_repeat_instrument", "redcap_repeat_instance")
if (1L <= length(fields) && any(fields %in% pseudofields)) {
fields <- setdiff(fields, pseudofields) # Remove any that are requested.
message(
"At least one 'pseudofield' was requested and will be suppressed before calling the server. ",
"The server will return it if it's appropriate for the project structure.\n\n",
"Common pseudofields are: ",
paste(pseudofields, collapse = ", "),
"."
)
}

token <- sanitize_token(token)
records_collapsed <- collapse_vector(records)
Expand Down

0 comments on commit ae2d7b3

Please sign in to comment.