Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for older version of REDCap #468

Merged
merged 7 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck
extra-packages: rcmdcheck, DBI=?ignore, odbc=?ignore

- uses: r-lib/actions/check-r-package@v2
# with:
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Description: Encapsulates functions to streamline calls from R to the REDCap
University. The Application Programming Interface (API) offers an avenue
to access and modify data programmatically, improving the capacity for
literate and reproducible programming.
Version: 1.1.9004
Version: 1.1.9005
Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email =
"[email protected]", comment = c(ORCID = "0000-0002-5613-5006")),
person("David", "Bard", role = "ctb", comment = c(ORCID = "0000-0002-3922-8489")),
Expand All @@ -32,7 +32,8 @@ Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email =
role = "ctb",
comment = c(ORCID = "0000-0003-2996-8034")), person("Ezra", "Porter",
role = "ctb",
comment = c(ORCID = "0000-0002-4690-8343")))
comment = c(ORCID = "0000-0002-4690-8343")), person("Matthew", "Schuelke",
role = "ctb", email="[email protected]"))
URL: https://ouhscbbmc.github.io/REDCapR/, https:/OuhscBbmc/REDCapR, https://www.ouhsc.edu/bbmc/, https://project-redcap.org
BugReports: https:/OuhscBbmc/REDCapR/issues
Depends:
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ This will help extract forms from longitudinal & repeating projects.

* `redcap_dag_read()` has new `data_access_group_id` field (introduced maybe in [13.1.0](https://community.projectredcap.org/articles/13/index.html)) (#459)
* `redcap_users_export()` has new `mycap_participants` field (introduced maybe in [13.0.0](https://community.projectredcap.org/articles/13/index.html)) (#459)
* 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)


Version 1.1.0 (released 2022-08-10)
==========================================================
Expand Down
13 changes: 13 additions & 0 deletions R/redcap-metadata-coltypes.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,19 @@ redcap_metadata_internal <- function(
)
}

if (is.na(d_proj$has_repeating_instruments_or_events[1])) { # nocov start
# Don't test coverage for this block b/c it only executes for old versions of REDCap
stop(
sprintf(
paste(
"The REDCap instance at %s failed to report if the",
"current project uses repeatable instruments or events."
),
redcap_uri
)
)
} # nocov end

if (d_proj$has_repeating_instruments_or_events[1]) {
d_again <-
d_again %>%
Expand Down
47 changes: 38 additions & 9 deletions R/redcap-project-info-read.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ redcap_project_info_read <- function(
handle_httr = handle_httr
)

col_types <- readr::cols(
all_col_types <- readr::cols(
project_id = readr::col_integer(),
project_title = readr::col_character(),
creation_time = readr::col_datetime(format = ""),
Expand Down Expand Up @@ -204,14 +204,43 @@ redcap_project_info_read <- function(

if (kernel$success) {
try(
# Convert the raw text to a dataset.
ds <-
readr::read_csv(
file = I(kernel$raw_text),
locale = locale,
col_types = col_types,
show_col_types = FALSE
),
{
# Read column names returned by the API.
present_names <-
names(
readr::read_csv(
file = I(kernel$raw_text),
locale = locale,
n_max = 0,
show_col_types = FALSE
)
)

# Build a column specification that matches the API response.
col_types <- readr::cols()
for(present_name in present_names)
col_types$cols <- c(col_types$cols, all_col_types$cols[present_name])

# Convert the raw text to a dataset.
ds <-
readr::read_csv(
file = I(kernel$raw_text),
locale = locale,
col_types = col_types,
show_col_types = FALSE
)

# Add any missing columns as NA.
absent_names <- setdiff(names(all_col_types$cols), names(col_types$cols))
# Don't test coverage for this block b/c it only executes for old versions of REDCap
# nocov start
for(absent_name in absent_names) {
ds[absent_name] <- NA
attr(ds, "spec")$cols <-
c(attr(ds, "spec")$cols, all_col_types$cols[absent_name])
}
# nocov end
},

# Don't print the warning in the try block. Print it below,
# where it's under the control of the caller.
Expand Down