Extending REDCap API hooks and plugins for Vanderbilts

Extending REDCap: API, hooks, and plugins for Vanderbilt's IRB Jason Tan Application Developer Vanderbilt Institute for Clinical and Translational Research REDCap Weekly Consortium Call July 17, 2015

Vanderbilt IRB’s “DISCOVR-e” • IRB = Institutional Review Board • DISCOVR-e = ? ? ? – Web-based application for creating and processing IRB submissions • • New study applications Amendments Reporting adverse events Etc.

New version • • • Rewrite the whole thing! Streamline submission process … … Convert Word document applications into structured forms for data capture

REDCap to the rescue!

How will we… • Allow users to reopen completed surveys without return codes? • Keep track of who made each change? • Access and manage data stored in REDCap?

How will we… • • Add comments? Track and highlight changes? Generate PDFs? Capture information that used to be in a table in Microsoft Word?

Hooks, plugins, and APIs!

Overview of solutions • REDCap hooks – Customize layout and functionality of surveys – Perform post-save operations • REDCap plugins – Reopen surveys – Generate changelog – Expose metadata • REDCap API – Create, retrieve, and manipulate data records

REDCap Hooks: redcap_survey_page • Inject CSS and JS to adjust layout – Fluid width – Remove background, unused space, save and return button, etc. • Communicate between parent frame and survey

REDCap Hooks: redcap_survey_page

REDCap Hooks: redcap_survey_page

REDCap Hooks: redcap_survey_page

REDCap Hooks: redcap_survey_page

REDCap Hooks: redcap_survey_page

REDCap Hooks: Tables • Example – list all radiation procedures and frequencies – Procedure 1 name: – Procedure 1 frequency: – Procedure 2 name: – Procedure 2 frequency: – Procedure 3 name: – Procedure 3 frequency: – Add another…

REDCap Hooks: Tables • Define table using field notes text • Hide text area and replace with Java. Script table editor • Store data as JSON-encoded array into original text area • Render table upon reopening survey

REDCap Hooks: Tables

REDCap Hooks: redcap_save_record • Pass information back to application • Check completeness of other forms

REDCap Plugins • Created a common framework for all of our IRB plugins – Web-accessible – Can verify and authenticate requests • Plugins can be used as custom APIs

REDCap Plugin: reopen • Put access control into our application • Programmatically reopen a survey if user has access • Pass user credentials to REDCap

REDCap Plugin: changelog • Uses REDCap logged events (redcap_log_event table) to reconstruct change log for a single record • Created logs by time and by form/field SELECT user, ts, description, data_values FROM redcap_log_event WHERE. . . event IN ('INSERT', 'UPDATE') AND description in ('Create record’, 'Update record', 'Update record (API)', 'Create record (API)', 'Update survey response', 'Create survey response’ )

REDCap Plugin: metadata • Application needs to know about: – Project-level information – Form/survey-level information – Field-level information • Created plugin “API” that serves up this data

REDCap API • Preemptively create records to match record ids to internal ids • Copy records to create new versions of the same application across multiple submissions • Lookup specific record values to determine available and necessary actions

REDCap API: Custom PDFs

REDCap API: Track Changes • Use API to get data for current and previous application • Compare each field for differences – Handles text, checkboxes, radio buttons, etc. • Renders changes in using the same custom PDF builder

REDCap API: Track Changes

A+++ would choose REDCap again • With a combination of hooks, plugins, and the REDCap API, (just about) anything is possible • Continuing to improve and refine existing integration • Planning to use REDCap for more components as we replace more of the IRB’s tools and workflow

- Slides: 28