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

Update redcap-survey-link-export-oneshot.R #526

Merged
merged 3 commits into from
Aug 12, 2024
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
19 changes: 11 additions & 8 deletions R/redcap-survey-link-export-oneshot.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @title
#' Download a file from a REDCap project record
#' Get survey link from REDCap
#'
#' @description
#' This function uses REDCap's API to download a file.
#' This function uses REDCap's API to get the link for a survey.
#'
#' @param redcap_uri The
#' [uri](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)/url
Expand All @@ -11,10 +11,12 @@
#' Required.
#' @param token The user-specific string that serves as the password for a
#' project. Required.
#' @param record The record ID where the file is to be imported. Required
#' @param record The record ID associated with the
#' survey link. Required
#' @param instrument The name of the instrument associated with the
#' survey link. Required
#' @param event The name of the event where the file is saved in REDCap.
#' @param event The name of the event associated with the
#' survey link.
#' Optional
#' @param verbose A boolean value indicating if `message`s should be printed
#' to the R console during the operation. Optional.
Expand All @@ -27,21 +29,22 @@
#'
#' @return
#' Currently, a list is returned with the following elements,
#' * `survey_link`: a character string containing the URL for the survey.
#' * `success`: A boolean value indicating if the operation was apparently
#' successful.
#' * `status_code`: The
#' [http status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
#' of the operation.
#' * `outcome_message`: A human readable string indicating the operation's
#' outcome.
#' * `records_affected_count`: The number of records inserted or updated.
#' * `affected_ids`: The subject IDs of the inserted or updated records.
#' * `instrument`: The instrument associated with the survey link.
#' * `records_affected_count`: The number of records associated with
#' the survey link.
#' * `affected_ids`: The subject IDs associated with the survey link.
#' * `elapsed_seconds`: The duration of the function.
#' * `raw_text`: If an operation is NOT successful, the text returned by
#' REDCap. If an operation is successful, the `raw_text` is returned as an
#' empty string to save RAM.
#' * `file_name`: The name of the file persisted to disk. This is useful if
#' the name stored in REDCap is used (which is the default).
#'
#' @details
#' Currently, the function doesn't modify any variable types to conform to
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-survey-link-export-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test_that("Nonexistent Record ID", {
expect_equal(result$instrument, "participant_morale_questionnaire")
expect_equal(result$records_affected_count, 0L)
expect_equal(result$affected_ids, character(0))
expect_equal(result$raw_text, "ERROR: The record '-1' does not exist")
expect_equal(result$raw_text, "ERROR: The record \"-1\" does not exist")
})

rm(credential, record, instrument)
Loading