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

tests for Remove repeat_instrument param from redcap_file_download_oneshot PR #531

Merged
merged 22 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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 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.9005
Version: 1.1.9007
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 Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ This will help extract forms from longitudinal & repeating projects.
* `read_read_oneshot()`'s parameter `guess_max` now allows floating point values to support `readr::read_csv()` ability to accept a Inf value. (Suggested by @eveyp, #392)
* pkgdown pages run & display the examples, but CRAN still doesn't run them. It's illegal to call external resources/APIs from CRAN computers --mostly because they are occasionally unavailable, so the code breaks. (#419)
* Renamed some functions to follow a consistent pattern. Old names will be soft-deprecated for a while before being removed. (#416)
* `redcap_download_file_oneshot()` to `redcap_file_download_opneshot()`
* `redcap_file_upload_oneshot()` to `redcap_file_upload_opneshot()`
* `redcap_download_file_oneshot()` to `redcap_file_download_oneshot()`
* `redcap_file_upload_oneshot()` to `redcap_file_upload_oneshot()`
* `redcap_download_instrument()` to `redcap_instrument_download()`

* `redcap_dag_read()` has new `data_access_group_id` field (introduced maybe in [13.1.0](https://redcap.vanderbilt.edu/community/post.php?id=13)) (#459)
Expand All @@ -93,6 +93,7 @@ This will help extract forms from longitudinal & repeating projects.
* `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493)
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495, #501)
* `redcap_log_read()` assumes all columns are character, except for `timestamp` (#525)
* `redcap_file_download_oneshot()` no longer asks for the unnecessary parameter for `repeating_instrument` (that the REDCap server ignores). (@BlairCooper, #506, #530)

Version 1.1.0 (released 2022-08-10)
==========================================================
Expand Down
17 changes: 3 additions & 14 deletions R/redcap-file-download-oneshot.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#' Required
#' @param event The name of the event where the file is saved in REDCap.
#' Optional
#' @param repeat_instrument The name of the instrument that is repeating
#' for a given event.
#' Optional
#' @param repeat_instance (only for projects with repeating instruments/events)
#' The repeat instance number of the repeating event (if longitudinal) or the
#' repeating instrument (if classic or longitudinal). Default value is '1'.
Expand Down Expand Up @@ -61,9 +58,8 @@
#' the name stored in REDCap is used (which is the default).
#'
#' @details
#' Currently, the function doesn't modify any variable types to conform to
#' REDCap's supported variables. See [validate_for_write()] for a helper
#' function that checks for some common important conflicts.
#' For files in a repeating instrument, don't specify `repeating_instrument`.
#' The server only needs `field` (name) and `repeating_instance`.
#'
#' The function `redcap_download_file_oneshot()` is soft-deprecated
#' as of REDCapR 1.2.0.
Expand Down Expand Up @@ -127,7 +123,6 @@ redcap_file_download_oneshot <- function(
record,
field,
event = "",
repeat_instrument = NULL,
repeat_instance = NULL,
verbose = TRUE,
config_options = NULL,
Expand Down Expand Up @@ -161,13 +156,7 @@ redcap_file_download_oneshot <- function(

if (0L < nchar(event)) post_body$event <- event

if (!is.null(repeat_instrument)) {
if (is.null(repeat_instance)) {
stop("You must specify repeat_instance when specified repeat_instrument")
}
post_body$repeat_instrument <- repeat_instrument
post_body$repeat_instance <- repeat_instance
}
if (!is.null(repeat_instance)) post_body$repeat_instance <- repeat_instance

# This is the first of two important lines in the function.
# It retrieves the information from the server and stores it in RAM.
Expand Down
27 changes: 12 additions & 15 deletions inst/test-data/longitudinal-single-arm/project.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<ODM xmlns="http://www.cdisc.org/ns/odm/v1.3" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:redcap="https://projectredcap.org" xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.3 schema/odm/ODM1-3-1.xsd" ODMVersion="1.3.1" FileOID="000-00-0000" FileType="Snapshot" Description="REDCapR Longitudinal Single Arm" AsOfDateTime="2022-12-13T16:42:57" CreationDateTime="2022-12-13T16:42:57" SourceSystem="REDCap" SourceSystemVersion="12.5.5">
<ODM xmlns="http://www.cdisc.org/ns/odm/v1.3" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:redcap="https://projectredcap.org" xsi:schemaLocation="http://www.cdisc.org/ns/odm/v1.3 schema/odm/ODM1-3-1.xsd" ODMVersion="1.3.1" FileOID="000-00-0000" FileType="Snapshot" Description="REDCapR Longitudinal Single Arm" AsOfDateTime="2024-09-06T14:13:17" CreationDateTime="2024-09-06T14:13:17" SourceSystem="REDCap" SourceSystemVersion="14.6.4">
<Study OID="Project.REDCapRLongitudinalSingleArm">
<GlobalVariables>
<StudyName>REDCapR Longitudinal Single Arm</StudyName>
Expand All @@ -8,33 +8,30 @@
<redcap:RecordAutonumberingEnabled>1</redcap:RecordAutonumberingEnabled>
<redcap:CustomRecordLabel></redcap:CustomRecordLabel>
<redcap:SecondaryUniqueField></redcap:SecondaryUniqueField>
<redcap:SecondaryUniqueFieldDisplayValue>1</redcap:SecondaryUniqueFieldDisplayValue>
<redcap:SecondaryUniqueFieldDisplayLabel>1</redcap:SecondaryUniqueFieldDisplayLabel>
<redcap:SchedulingEnabled>0</redcap:SchedulingEnabled>
<redcap:SurveysEnabled>0</redcap:SurveysEnabled>
<redcap:SurveyInvitationEmailField></redcap:SurveyInvitationEmailField>
<redcap:DisplayTodayNowButton>1</redcap:DisplayTodayNowButton>
<redcap:PreventBranchingEraseValues>0</redcap:PreventBranchingEraseValues>
<redcap:RequireChangeReason>0</redcap:RequireChangeReason>
<redcap:DataHistoryPopup>1</redcap:DataHistoryPopup>
<redcap:OrderRecordsByField></redcap:OrderRecordsByField>
<redcap:MyCapEnabled>0</redcap:MyCapEnabled>
<redcap:Purpose>4</redcap:Purpose>
<redcap:PurposeOther></redcap:PurposeOther>
<redcap:ProjectNotes>Longitudinal project with only one arm</redcap:ProjectNotes>
<redcap:SurveyQueueCustomText></redcap:SurveyQueueCustomText>
<redcap:SurveyQueueHide>0</redcap:SurveyQueueHide>
<redcap:DataMartProjectEnabled>0</redcap:DataMartProjectEnabled>
<redcap:DatamartAllowRepeatRevision>0</redcap:DatamartAllowRepeatRevision>
<redcap:DatamartAllowCreateRevision>0</redcap:DatamartAllowCreateRevision>
<redcap:DatamartCronEnabled>0</redcap:DatamartCronEnabled>
<redcap:HideFilledForms>1</redcap:HideFilledForms>
<redcap:FormActivationSurveyAutocontinue>0</redcap:FormActivationSurveyAutocontinue>
<redcap:MissingDataCodes></redcap:MissingDataCodes>
<redcap:ProtectedEmailMode>0</redcap:ProtectedEmailMode>
<redcap:ProtectedEmailModeCustomText></redcap:ProtectedEmailModeCustomText>
<redcap:ProtectedEmailModeTrigger>ALL</redcap:ProtectedEmailModeTrigger>
<redcap:ProtectedEmailModeLogo></redcap:ProtectedEmailModeLogo>
<redcap:UserRolesGroup>
<redcap:UserRoles role_name="api" unique_role_name="U-767DA9JEKR" lock_record="0" lock_record_multiform="0" lock_record_customize="0" data_export_tool="" data_export_instruments="[collection,1]" data_import_tool="0" data_comparison_tool="0" data_logging="0" file_repository="0" double_data="0" user_rights="0" data_access_groups="0" graphical="1" reports="1" design="0" calendar="0" data_entry="[collection,1]" api_export="1" api_import="0" mobile_app="0" mobile_app_download_data="0" record_create="0" record_rename="0" record_delete="0" dts="0" participants="1" data_quality_design="0" data_quality_execute="0" data_quality_resolution="1" random_setup="0" random_dashboard="0" random_perform="0" realtime_webservice_mapping="0" realtime_webservice_adjudicate="0" external_module_config=""/>
<redcap:UserRoles role_name="api" unique_role_name="U-767DA9JEKR" lock_record="0" lock_record_multiform="0" lock_record_customize="0" data_export_tool="" data_export_instruments="[collection,1]" data_import_tool="0" data_comparison_tool="0" data_logging="0" email_logging="0" file_repository="0" double_data="0" user_rights="0" data_access_groups="0" graphical="1" reports="1" design="0" alerts="0" calendar="0" data_entry="[collection,1]" api_export="1" api_import="0" api_modules="0" mobile_app="0" mobile_app_download_data="0" record_create="0" record_rename="0" record_delete="0" dts="0" participants="1" data_quality_design="0" data_quality_execute="0" data_quality_resolution="1" random_setup="0" random_dashboard="0" random_perform="0" realtime_webservice_mapping="0" realtime_webservice_adjudicate="0" external_module_config="" mycap_participants="0"/>
</redcap:UserRolesGroup>
<redcap:MultilanguageSettingsGroup>
<redcap:MultilanguageSettings settings="YToxNjp7czo3OiJ2ZXJzaW9uIjtzOjY6IjEyLjUuNSI7czo1OiJsYW5ncyI7YTowOnt9czo5OiJwcm9qZWN0SWQiO3M6NDoiMjYyOSI7czoxNToiZGVzaWduYXRlZEZpZWxkIjtzOjA6IiI7czo2OiJzdGF0dXMiO3M6MzoiZGV2IjtzOjU6ImRlYnVnIjtiOjA7czo3OiJyZWZMYW5nIjtzOjA6IiI7czoxMjoiZmFsbGJhY2tMYW5nIjtzOjA6IiI7czo4OiJkaXNhYmxlZCI7YjowO3M6MjU6ImhpZ2hsaWdodE1pc3NpbmdEYXRhZW50cnkiO2I6MDtzOjIyOiJoaWdobGlnaHRNaXNzaW5nU3VydmV5IjtiOjA7czoyMToiYXV0b0RldGVjdEJyb3dzZXJMYW5nIjtiOjA7czoxMjoiYWxlcnRTb3VyY2VzIjthOjA6e31zOjE0OiJleGNsdWRlZEFsZXJ0cyI7YTowOnt9czoxNDoiZXhjbHVkZWRGaWVsZHMiO2E6MDp7fXM6MTY6ImV4Y2x1ZGVkU2V0dGluZ3MiO2E6MDp7fX0="/>
</redcap:MultilanguageSettingsGroup>
</GlobalVariables>
<MetaDataVersion OID="Metadata.REDCapRLongitudinalSingleArm_2022-12-13_1642" Name="REDCapR Longitudinal Single Arm" redcap:RecordIdField="record_id">
<MetaDataVersion OID="Metadata.REDCapRLongitudinalSingleArm_2024-09-06_1413" Name="REDCapR Longitudinal Single Arm" redcap:RecordIdField="record_id">
<Protocol>
<StudyEventRef StudyEventOID="Event.intake_arm_1" OrderNumber="1" Mandatory="No"/>
<StudyEventRef StudyEventOID="Event.dischage_arm_1" OrderNumber="2" Mandatory="No"/>
Expand Down Expand Up @@ -81,7 +78,7 @@
</CodeList>
</MetaDataVersion>
</Study>
<ClinicalData StudyOID="Project.REDCapRLongitudinalSingleArm" MetaDataVersionOID="Metadata.REDCapRLongitudinalSingleArm_2022-12-13_1642">
<ClinicalData StudyOID="Project.REDCapRLongitudinalSingleArm" MetaDataVersionOID="Metadata.REDCapRLongitudinalSingleArm_2024-09-06_1413">
<SubjectData SubjectKey="1" redcap:RecordIdField="record_id">
<StudyEventData StudyEventOID="Event.intake_arm_1" StudyEventRepeatKey="1" redcap:UniqueEventName="intake_arm_1">
<FormData FormOID="Form.collection" FormRepeatKey="1">
Expand Down
43 changes: 25 additions & 18 deletions inst/test-data/specific-redcapr/read-batch-plumbing/repeated.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
structure(list(record_id = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
2), redcap_repeat_instrument = c(NA, "blood_pressure", "blood_pressure",
"blood_pressure", "laboratory", "laboratory", NA, "blood_pressure",
"blood_pressure", "blood_pressure", "laboratory", "laboratory"
), redcap_repeat_instance = c(NA, 1, 2, 3, 1, 2, NA, 1, 2, 3,
1, 2), height = c(1, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA
), weight = c(11, NA, NA, NA, NA, NA, 22, NA, NA, NA, NA, NA),
bmi = c(111, NA, NA, NA, NA, NA, 222, NA, NA, NA, NA, NA),
demographics_complete = c(2, NA, NA, NA, NA, NA, 2, NA, NA,
NA, NA, NA), sbp = c(NA, 1.1, 1.2, 1.3, NA, NA, NA, 2.1,
2.2, 2.3, NA, NA), dbp = c(NA, 11.1, 11.2, 11.3, NA, NA,
NA, 22.1, 22.2, 22.3, NA, NA), blood_pressure_complete = c(NA,
2, 2, 2, NA, NA, NA, 2, 2, 2, NA, NA), lab = c(NA, NA, NA,
NA, "aa1", "aa2", NA, NA, NA, NA, "bb1", "bb2"), conc = c(NA,
NA, NA, NA, "1.1 ppm", "1.2 ppm", NA, NA, NA, NA, "2.1 ppm",
"2.2 ppm"), laboratory_complete = c(NA, NA, NA, NA, 2, 2,
NA, NA, NA, NA, 2, 2)), row.names = c(NA, -12L), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
structure(list(record_id = c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2, 2, 2, 2, 2, 2), redcap_repeat_instrument = c(NA, "blood_pressure",
"blood_pressure", "blood_pressure", "laboratory", "laboratory",
"image", "image", NA, "blood_pressure", "blood_pressure", "blood_pressure",
"laboratory", "laboratory", "image", "image", "image"), redcap_repeat_instance = c(NA,
1, 2, 3, 1, 2, 1, 2, NA, 1, 2, 3, 1, 2, 1, 2, 3), height = c(1,
NA, NA, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA
), weight = c(11, NA, NA, NA, NA, NA, NA, NA, 22, NA, NA, NA,
NA, NA, NA, NA, NA), bmi = c(111, NA, NA, NA, NA, NA, NA, NA,
222, NA, NA, NA, NA, NA, NA, NA, NA), intake_complete = c(2,
NA, NA, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA
), sbp = c(NA, 1.1, 1.2, 1.3, NA, NA, NA, NA, NA, 2.1, 2.2, 2.3,
NA, NA, NA, NA, NA), dbp = c(NA, 11.1, 11.2, 11.3, NA, NA, NA,
NA, NA, 22.1, 22.2, 22.3, NA, NA, NA, NA, NA), blood_pressure_complete = c(NA,
2, 2, 2, NA, NA, NA, NA, NA, 2, 2, 2, NA, NA, NA, NA, NA), lab = c(NA,
NA, NA, NA, "aa1", "aa2", NA, NA, NA, NA, NA, NA, "bb1", "bb2",
NA, NA, NA), conc = c(NA, NA, NA, NA, "1.1 ppm", "1.2 ppm", NA,
NA, NA, NA, NA, NA, "2.1 ppm", "2.2 ppm", NA, NA, NA), laboratory_complete = c(NA,
NA, NA, NA, 2, 2, NA, NA, NA, NA, NA, NA, 2, 2, NA, NA, NA),
image_profile = c(NA, NA, NA, NA, NA, NA, "levon-and-barry.jpg",
"mugshot-1.jpg", NA, NA, NA, NA, NA, NA, "mugshot-2.jpg",
"mugshot-3.jpg", "mugshot-4.jpg"), image_complete = c(NA,
NA, NA, NA, NA, NA, 2, 0, NA, NA, NA, NA, NA, NA, 2, 1, 0
)), row.names = c(NA, -17L), class = c("spec_tbl_df", "tbl_df",
"tbl", "data.frame"))
4 changes: 2 additions & 2 deletions inst/test-data/vignette-repeating/data.csv
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
record_id,redcap_repeat_instrument,redcap_repeat_instance,height,weight,bmi,demographics_complete,sbp,dbp,blood_pressure_complete,lab,conc,laboratory_complete
record_id,redcap_repeat_instrument,redcap_repeat_instance,height,weight,bmi,intake_complete,sbp,dbp,blood_pressure_complete,lab,conc,laboratory_complete
1,,,1.0,11.0,111.0,2,,,,,,
1,blood_pressure,1,,,,,1.1,11.1,2,,,
1,blood_pressure,2,,,,,1.2,11.2,2,,,
1,blood_pressure,3,,,,,1.3,11.3,2,,,
1,laboratory,1,,,,,,,,aa1,"1.1 ppm",2
1,laboratory,2,,,,,,,,aa2,"11.2 ppm",2
1,laboratory,2,,,,,,,,aa2,"1.2 ppm",2
2,,,2.0,22.0,222.0,2,,,,,,
2,blood_pressure,1,,,,,2.1,22.1,2,,,
2,blood_pressure,2,,,,,2.2,22.2,2,,,
Expand Down
Loading