Skip to content

Commit 7a6b2ae

Browse files
authored
Merge pull request #531 from OuhscBbmc/dev
tests for `Remove repeat_instrument param from redcap_file_download_oneshot` PR
2 parents a345d78 + c95eeca commit 7a6b2ae

File tree

10 files changed

+593
-63
lines changed

10 files changed

+593
-63
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Description: Encapsulates functions to streamline calls from R to the REDCap
66
University. The Application Programming Interface (API) offers an avenue
77
to access and modify data programmatically, improving the capacity for
88
literate and reproducible programming.
9-
Version: 1.1.9005
9+
Version: 1.1.9007
1010
Authors@R: c(person("Will", "Beasley", role = c("aut", "cre"), email =
1111
"[email protected]", comment = c(ORCID = "0000-0002-5613-5006")),
1212
person("David", "Bard", role = "ctb", comment = c(ORCID = "0000-0002-3922-8489")),

NEWS.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ This will help extract forms from longitudinal & repeating projects.
7272
* `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)
7373
* 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)
7474
* Renamed some functions to follow a consistent pattern. Old names will be soft-deprecated for a while before being removed. (#416)
75-
* `redcap_download_file_oneshot()` to `redcap_file_download_opneshot()`
76-
* `redcap_file_upload_oneshot()` to `redcap_file_upload_opneshot()`
75+
* `redcap_download_file_oneshot()` to `redcap_file_download_oneshot()`
76+
* `redcap_file_upload_oneshot()` to `redcap_file_upload_oneshot()`
7777
* `redcap_download_instrument()` to `redcap_instrument_download()`
7878
7979
* `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)
@@ -93,6 +93,7 @@ This will help extract forms from longitudinal & repeating projects.
9393
* `redcap_read()` checks the `event` parameter and throws an error if a value is not recognized, or the project is not longitudinal (#493)
9494
* The regex in `regex_named_captures()` is forgiving if there's an unnecessary leading space (@BlairCooper, #495, #501)
9595
* `redcap_log_read()` assumes all columns are character, except for `timestamp` (#525)
96+
* `redcap_file_download_oneshot()` no longer asks for the unnecessary parameter for `repeating_instrument` (that the REDCap server ignores). (@BlairCooper, #506, #530)
9697
9798
Version 1.1.0 (released 2022-08-10)
9899
==========================================================

R/redcap-file-download-oneshot.R

+3-14
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
#' Required
2727
#' @param event The name of the event where the file is saved in REDCap.
2828
#' Optional
29-
#' @param repeat_instrument The name of the instrument that is repeating
30-
#' for a given event.
31-
#' Optional
3229
#' @param repeat_instance (only for projects with repeating instruments/events)
3330
#' The repeat instance number of the repeating event (if longitudinal) or the
3431
#' repeating instrument (if classic or longitudinal). Default value is '1'.
@@ -61,9 +58,8 @@
6158
#' the name stored in REDCap is used (which is the default).
6259
#'
6360
#' @details
64-
#' Currently, the function doesn't modify any variable types to conform to
65-
#' REDCap's supported variables. See [validate_for_write()] for a helper
66-
#' function that checks for some common important conflicts.
61+
#' For files in a repeating instrument, don't specify `repeating_instrument`.
62+
#' The server only needs `field` (name) and `repeating_instance`.
6763
#'
6864
#' The function `redcap_download_file_oneshot()` is soft-deprecated
6965
#' as of REDCapR 1.2.0.
@@ -127,7 +123,6 @@ redcap_file_download_oneshot <- function(
127123
record,
128124
field,
129125
event = "",
130-
repeat_instrument = NULL,
131126
repeat_instance = NULL,
132127
verbose = TRUE,
133128
config_options = NULL,
@@ -161,13 +156,7 @@ redcap_file_download_oneshot <- function(
161156

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

164-
if (!is.null(repeat_instrument)) {
165-
if (is.null(repeat_instance)) {
166-
stop("You must specify repeat_instance when specified repeat_instrument")
167-
}
168-
post_body$repeat_instrument <- repeat_instrument
169-
post_body$repeat_instance <- repeat_instance
170-
}
159+
if (!is.null(repeat_instance)) post_body$repeat_instance <- repeat_instance
171160

172161
# This is the first of two important lines in the function.
173162
# It retrieves the information from the server and stores it in RAM.

inst/test-data/longitudinal-single-arm/project.xml

+12-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<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">
2+
<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">
33
<Study OID="Project.REDCapRLongitudinalSingleArm">
44
<GlobalVariables>
55
<StudyName>REDCapR Longitudinal Single Arm</StudyName>
@@ -8,33 +8,30 @@
88
<redcap:RecordAutonumberingEnabled>1</redcap:RecordAutonumberingEnabled>
99
<redcap:CustomRecordLabel></redcap:CustomRecordLabel>
1010
<redcap:SecondaryUniqueField></redcap:SecondaryUniqueField>
11+
<redcap:SecondaryUniqueFieldDisplayValue>1</redcap:SecondaryUniqueFieldDisplayValue>
12+
<redcap:SecondaryUniqueFieldDisplayLabel>1</redcap:SecondaryUniqueFieldDisplayLabel>
1113
<redcap:SchedulingEnabled>0</redcap:SchedulingEnabled>
1214
<redcap:SurveysEnabled>0</redcap:SurveysEnabled>
1315
<redcap:SurveyInvitationEmailField></redcap:SurveyInvitationEmailField>
16+
<redcap:DisplayTodayNowButton>1</redcap:DisplayTodayNowButton>
17+
<redcap:PreventBranchingEraseValues>0</redcap:PreventBranchingEraseValues>
18+
<redcap:RequireChangeReason>0</redcap:RequireChangeReason>
19+
<redcap:DataHistoryPopup>1</redcap:DataHistoryPopup>
20+
<redcap:OrderRecordsByField></redcap:OrderRecordsByField>
21+
<redcap:MyCapEnabled>0</redcap:MyCapEnabled>
1422
<redcap:Purpose>4</redcap:Purpose>
1523
<redcap:PurposeOther></redcap:PurposeOther>
1624
<redcap:ProjectNotes>Longitudinal project with only one arm</redcap:ProjectNotes>
17-
<redcap:SurveyQueueCustomText></redcap:SurveyQueueCustomText>
18-
<redcap:SurveyQueueHide>0</redcap:SurveyQueueHide>
19-
<redcap:DataMartProjectEnabled>0</redcap:DataMartProjectEnabled>
20-
<redcap:DatamartAllowRepeatRevision>0</redcap:DatamartAllowRepeatRevision>
21-
<redcap:DatamartAllowCreateRevision>0</redcap:DatamartAllowCreateRevision>
22-
<redcap:DatamartCronEnabled>0</redcap:DatamartCronEnabled>
23-
<redcap:HideFilledForms>1</redcap:HideFilledForms>
24-
<redcap:FormActivationSurveyAutocontinue>0</redcap:FormActivationSurveyAutocontinue>
2525
<redcap:MissingDataCodes></redcap:MissingDataCodes>
2626
<redcap:ProtectedEmailMode>0</redcap:ProtectedEmailMode>
2727
<redcap:ProtectedEmailModeCustomText></redcap:ProtectedEmailModeCustomText>
2828
<redcap:ProtectedEmailModeTrigger>ALL</redcap:ProtectedEmailModeTrigger>
2929
<redcap:ProtectedEmailModeLogo></redcap:ProtectedEmailModeLogo>
3030
<redcap:UserRolesGroup>
31-
<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=""/>
31+
<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"/>
3232
</redcap:UserRolesGroup>
33-
<redcap:MultilanguageSettingsGroup>
34-
<redcap:MultilanguageSettings settings="YToxNjp7czo3OiJ2ZXJzaW9uIjtzOjY6IjEyLjUuNSI7czo1OiJsYW5ncyI7YTowOnt9czo5OiJwcm9qZWN0SWQiO3M6NDoiMjYyOSI7czoxNToiZGVzaWduYXRlZEZpZWxkIjtzOjA6IiI7czo2OiJzdGF0dXMiO3M6MzoiZGV2IjtzOjU6ImRlYnVnIjtiOjA7czo3OiJyZWZMYW5nIjtzOjA6IiI7czoxMjoiZmFsbGJhY2tMYW5nIjtzOjA6IiI7czo4OiJkaXNhYmxlZCI7YjowO3M6MjU6ImhpZ2hsaWdodE1pc3NpbmdEYXRhZW50cnkiO2I6MDtzOjIyOiJoaWdobGlnaHRNaXNzaW5nU3VydmV5IjtiOjA7czoyMToiYXV0b0RldGVjdEJyb3dzZXJMYW5nIjtiOjA7czoxMjoiYWxlcnRTb3VyY2VzIjthOjA6e31zOjE0OiJleGNsdWRlZEFsZXJ0cyI7YTowOnt9czoxNDoiZXhjbHVkZWRGaWVsZHMiO2E6MDp7fXM6MTY6ImV4Y2x1ZGVkU2V0dGluZ3MiO2E6MDp7fX0="/>
35-
</redcap:MultilanguageSettingsGroup>
3633
</GlobalVariables>
37-
<MetaDataVersion OID="Metadata.REDCapRLongitudinalSingleArm_2022-12-13_1642" Name="REDCapR Longitudinal Single Arm" redcap:RecordIdField="record_id">
34+
<MetaDataVersion OID="Metadata.REDCapRLongitudinalSingleArm_2024-09-06_1413" Name="REDCapR Longitudinal Single Arm" redcap:RecordIdField="record_id">
3835
<Protocol>
3936
<StudyEventRef StudyEventOID="Event.intake_arm_1" OrderNumber="1" Mandatory="No"/>
4037
<StudyEventRef StudyEventOID="Event.dischage_arm_1" OrderNumber="2" Mandatory="No"/>
@@ -81,7 +78,7 @@
8178
</CodeList>
8279
</MetaDataVersion>
8380
</Study>
84-
<ClinicalData StudyOID="Project.REDCapRLongitudinalSingleArm" MetaDataVersionOID="Metadata.REDCapRLongitudinalSingleArm_2022-12-13_1642">
81+
<ClinicalData StudyOID="Project.REDCapRLongitudinalSingleArm" MetaDataVersionOID="Metadata.REDCapRLongitudinalSingleArm_2024-09-06_1413">
8582
<SubjectData SubjectKey="1" redcap:RecordIdField="record_id">
8683
<StudyEventData StudyEventOID="Event.intake_arm_1" StudyEventRepeatKey="1" redcap:UniqueEventName="intake_arm_1">
8784
<FormData FormOID="Form.collection" FormRepeatKey="1">
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
1-
structure(list(record_id = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
2-
2), redcap_repeat_instrument = c(NA, "blood_pressure", "blood_pressure",
3-
"blood_pressure", "laboratory", "laboratory", NA, "blood_pressure",
4-
"blood_pressure", "blood_pressure", "laboratory", "laboratory"
5-
), redcap_repeat_instance = c(NA, 1, 2, 3, 1, 2, NA, 1, 2, 3,
6-
1, 2), height = c(1, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA
7-
), weight = c(11, NA, NA, NA, NA, NA, 22, NA, NA, NA, NA, NA),
8-
bmi = c(111, NA, NA, NA, NA, NA, 222, NA, NA, NA, NA, NA),
9-
demographics_complete = c(2, NA, NA, NA, NA, NA, 2, NA, NA,
10-
NA, NA, NA), sbp = c(NA, 1.1, 1.2, 1.3, NA, NA, NA, 2.1,
11-
2.2, 2.3, NA, NA), dbp = c(NA, 11.1, 11.2, 11.3, NA, NA,
12-
NA, 22.1, 22.2, 22.3, NA, NA), blood_pressure_complete = c(NA,
13-
2, 2, 2, NA, NA, NA, 2, 2, 2, NA, NA), lab = c(NA, NA, NA,
14-
NA, "aa1", "aa2", NA, NA, NA, NA, "bb1", "bb2"), conc = c(NA,
15-
NA, NA, NA, "1.1 ppm", "1.2 ppm", NA, NA, NA, NA, "2.1 ppm",
16-
"2.2 ppm"), laboratory_complete = c(NA, NA, NA, NA, 2, 2,
17-
NA, NA, NA, NA, 2, 2)), row.names = c(NA, -12L), class = c("spec_tbl_df",
18-
"tbl_df", "tbl", "data.frame"))
1+
structure(list(record_id = c(1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2,
2+
2, 2, 2, 2, 2, 2), redcap_repeat_instrument = c(NA, "blood_pressure",
3+
"blood_pressure", "blood_pressure", "laboratory", "laboratory",
4+
"image", "image", NA, "blood_pressure", "blood_pressure", "blood_pressure",
5+
"laboratory", "laboratory", "image", "image", "image"), redcap_repeat_instance = c(NA,
6+
1, 2, 3, 1, 2, 1, 2, NA, 1, 2, 3, 1, 2, 1, 2, 3), height = c(1,
7+
NA, NA, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA
8+
), weight = c(11, NA, NA, NA, NA, NA, NA, NA, 22, NA, NA, NA,
9+
NA, NA, NA, NA, NA), bmi = c(111, NA, NA, NA, NA, NA, NA, NA,
10+
222, NA, NA, NA, NA, NA, NA, NA, NA), intake_complete = c(2,
11+
NA, NA, NA, NA, NA, NA, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA
12+
), sbp = c(NA, 1.1, 1.2, 1.3, NA, NA, NA, NA, NA, 2.1, 2.2, 2.3,
13+
NA, NA, NA, NA, NA), dbp = c(NA, 11.1, 11.2, 11.3, NA, NA, NA,
14+
NA, NA, 22.1, 22.2, 22.3, NA, NA, NA, NA, NA), blood_pressure_complete = c(NA,
15+
2, 2, 2, NA, NA, NA, NA, NA, 2, 2, 2, NA, NA, NA, NA, NA), lab = c(NA,
16+
NA, NA, NA, "aa1", "aa2", NA, NA, NA, NA, NA, NA, "bb1", "bb2",
17+
NA, NA, NA), conc = c(NA, NA, NA, NA, "1.1 ppm", "1.2 ppm", NA,
18+
NA, NA, NA, NA, NA, "2.1 ppm", "2.2 ppm", NA, NA, NA), laboratory_complete = c(NA,
19+
NA, NA, NA, 2, 2, NA, NA, NA, NA, NA, NA, 2, 2, NA, NA, NA),
20+
image_profile = c(NA, NA, NA, NA, NA, NA, "levon-and-barry.jpg",
21+
"mugshot-1.jpg", NA, NA, NA, NA, NA, NA, "mugshot-2.jpg",
22+
"mugshot-3.jpg", "mugshot-4.jpg"), image_complete = c(NA,
23+
NA, NA, NA, NA, NA, 2, 0, NA, NA, NA, NA, NA, NA, 2, 1, 0
24+
)), row.names = c(NA, -17L), class = c("spec_tbl_df", "tbl_df",
25+
"tbl", "data.frame"))

inst/test-data/vignette-repeating/data.csv

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
record_id,redcap_repeat_instrument,redcap_repeat_instance,height,weight,bmi,demographics_complete,sbp,dbp,blood_pressure_complete,lab,conc,laboratory_complete
1+
record_id,redcap_repeat_instrument,redcap_repeat_instance,height,weight,bmi,intake_complete,sbp,dbp,blood_pressure_complete,lab,conc,laboratory_complete
22
1,,,1.0,11.0,111.0,2,,,,,,
33
1,blood_pressure,1,,,,,1.1,11.1,2,,,
44
1,blood_pressure,2,,,,,1.2,11.2,2,,,
55
1,blood_pressure,3,,,,,1.3,11.3,2,,,
66
1,laboratory,1,,,,,,,,aa1,"1.1 ppm",2
7-
1,laboratory,2,,,,,,,,aa2,"11.2 ppm",2
7+
1,laboratory,2,,,,,,,,aa2,"1.2 ppm",2
88
2,,,2.0,22.0,222.0,2,,,,,,
99
2,blood_pressure,1,,,,,2.1,22.1,2,,,
1010
2,blood_pressure,2,,,,,2.2,22.2,2,,,

0 commit comments

Comments
 (0)