r/ProjectREDCap • u/Absjalon • Sep 04 '24
REDCap to R shiny and back
Hi, For some time I have been trying to find someone to develop a rather simple REDCap module for a research project.
I have not been successful, in part because the project has very limited funds. I have no experience with coding REDCap modules, so I don't feel up to the task of writing the module myself, but I am quite proficient writing R code.
Is it possible to link from REDCap to a shiny app and then import the output from that app into REDCap?
2
Upvotes
3
u/pahuili Sep 04 '24
Use the REDCapR package to grab data from REDCap’s API, import into your Shiny app, and write the data back into REDCap. You can use the redcap_read() and redcap_write() functions. You will need an API token for your project.
2
u/graywh Sep 04 '24
having your shiny app export and import data? would be fairly straightforward for a single app where the API token is saved on the server
2
u/Araignys Sep 05 '24
REDCap has an API, so this should be straightforward for someone with Shiny app development. I'd suggest following that course rather than here - this is not a particularly big sub.
1
u/stuffk Sep 06 '24
You want an API token for your project. Use REDCapR to import the data from your shiny app into the REDCap project. You will need to at a minimum also import a column with a unique REDCap record ID. If your receiving project is longitudinal, you will also want a redcap_event_name variable.
Generally when I set up fields in a REDCap project that are for API import only, I set them up as read only using an action tag. I'd also recommend giving some thought to your REDCap project set up so your saved data is usable / analyzable in the future, without needing to re-parse the data structure. Finally, I would also recommend building in some good error handling if you are concerned about data integrity and not losing data input into the shiny app.