Loris icon indicating copy to clipboard operation
Loris copied to clipboard

[redcap] REDCap import records script

Open MaximeBICMTL opened this issue 6 months ago • 2 comments

Builds on #9839 #9840 #9904 (all merged now !)

Alternative (non-exclusive) to #9808.

Description

This pull request adds a REDCap records importer script to the REDCap module.

The script works as follows: For a given REDCap instance and project, find all the records in REDCap that match the visit mappings in the REDCap module configuration (that is, all the records whose arm and event are present in the configuration), and import them in LORIS. This approach is notably useful when the automatic visit creation feature is enabled, as it also creates the corresponding sessions in LORIS. However, it can also work without that feature, in which case the script just outputs an error for each session present in REDCap but not in LORIS.

Details:

  • This script relies on visit mapping configurations to know which records to import from REDCap, if those are absent, it just imports 0 records.
  • Import is incremental, that is, the script ignores records that are already imported in LORIS, making it possible to run the importer multiple times on the same project.
  • Errors are handled on a per-record basis. As such, if one record fails to import, other records are not affected.
  • The script displays a nice import summary at the end (number of records successfully imported, already present, and failed).
  • I originally wanted to put the script in modules/redcap/tools/ but it resulted in PHP linting static errors that I have no idea how to fix (see this job). So I've placed the script in tools/ for now.

MaximeBICMTL avatar Jul 10 '25 07:07 MaximeBICMTL

How do you disable the visit creation feature (for candidates whose visits are already created in LORIS) ? I am testing this right now.

adamdaudrich avatar Nov 17 '25 13:11 adamdaudrich

@adamdaudrich visit creation is handled according the configuration, if you do not have <create-visit> nodes, no visit will be created.

MaximeBICMTL avatar Nov 18 '25 08:11 MaximeBICMTL

I have used the record importer, it works! So LGTM !!!

adamdaudrich avatar Dec 16 '25 01:12 adamdaudrich

As discussed in today's meeting, @regisoc unfortunately does not have the time to do a deeper review and testing of this PR. He did do a shallow review that did not find blatant mistakes, and @adamdaudrich did a succesful review and testing. As such, we (me, Adam, and Régis) agree we should merge this PR first and we will integrate Régis' importer on top of it later.

I stay available to help Régis with integrating his importer onto this one whenever he comes back to it.

MaximeBICMTL avatar Dec 16 '25 16:12 MaximeBICMTL