Skip to content

Commit

Permalink
[ENH] Allow redcap records to be ignored based on a regex
Browse files Browse the repository at this point in the history
  • Loading branch information
DESm1th committed Mar 16, 2024
1 parent 01bd074 commit 230d249
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bin/dm_redcap_scan_completed.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@
dm_redcap_scan_completed.py [options] <study>
Arguments:
<study> Name of the study to process
<study> Name of the study to process
Options:
-q --quiet Less logging
-v --verbose Verbose logging
-d --debug Debug logging
--ignore <regex> An optional regex used to ignore records with
a matching subject ID field. Regex must follow the
python 're' library rules.
-q --quiet Less logging
-v --verbose Verbose logging
-d --debug Debug logging
"""

import os
import re
import sys
import requests
import logging
Expand Down Expand Up @@ -179,6 +183,7 @@ def main():

arguments = docopt(__doc__)
study = arguments['<study>']
ignore_re = arguments['--ignore']
quiet = arguments['--quiet']
verbose = arguments['--verbose']
debug = arguments['--debug']
Expand Down Expand Up @@ -240,6 +245,11 @@ def main():
# only grab records where instrument has been marked complete
if not (item[date_field] and item[status_field] in status_val):
continue
# Filter out records when the subject ID matches an optional regex
if ignore_re and re.match(ignore_re,
item[get_setting('RedcapSubj',
default='par_id')]):
continue
project_records.append(item)

for record in project_records:
Expand Down

0 comments on commit 230d249

Please sign in to comment.