OuhscBbmc / REDCapR

R utilities for interacting with REDCap
https://ouhscbbmc.github.io/REDCapR
Other
112 stars 45 forks source link

redcap_download_file_oneshot in longitudinal study issue #508

Closed nadha25 closed 11 months ago

nadha25 commented 11 months ago

I am trying to use the redcap_download_file_oneshot() function to extract files for specific variables from a large REDCap project. This project has several events within a record, and so I am running the function in a loop for all event + record iterations to download all files for each event

However, it appears that the function is only downloading the file when the event name is entered manually

Here's the code that I'm running:

# download report 2282 containing Redcap ID, and event name 
[...]

while (val < length(report$record_id) + 1) {
  record_reg <- paste0(report$record_id[val])

  pdf_file <-
    REDCapR:redcap_download_file_oneshot(
      redcap_uri = url,
      token      = reg_token,
      record     = record_reg, 
      field      = field_name, 
      event      = report$redcap_event_name[val]
    )

If it enter manually "event1_arm_1" this works fine but given the amount of files to download, I require this to work in the loop. Not sure if the issue sits in the loop or with the changes to the function

wibeasley commented 11 months ago
  1. @nadha25, I'll have time to look at this closer. Hopefully tonight. In the meantime, do you think this is related to @BlairCooper's #506 & #507?
  2. Can you further explain "the function is only downloading the file when the event name is entered manually"? When does it work and when does it not?
  3. Consider using a for loop instead of while when the size of the loop can be determined at the start.
nadha25 commented 11 months ago

Hi @wibeasley , Just having a check with our IT department as they did a fix for us around the same time so might be on their end rather than an issue with the function. Will get back to you !

wibeasley commented 11 months ago

Cool. And make sure you're using the most recent version from GitHub (remotes::install_github("OuhscBbmc/REDCapR")).

BlairCooper commented 11 months ago

@nadha25 As it sounds like it never downloads a file when using report$redcap_event_name[val] it isn't the same as #506 which always downloaded the first instance of the file.

If it works when you use a constant event name but not the value from the report, my initial thought is that report$redcap_event_name[val] isn't evaluating to the event name. You might try putting it into a local variable as you are with record_reg to confirm it actually contains the event name.

nadha25 commented 11 months ago

Hi, thanks for the help, turns out it was an issue on our server side of things; not related to the code itself. Apologies as I went into panic mode when I couldn't have my consent process working correctly on a live database

nadha25 commented 11 months ago

Hi, thanks for the help, turns out it was an issue on our server side of things; not related to the code itself. Apologies as I went into panic mode when I couldn't have my consent process working correctly on a live database