Skip to content

Commit 0a3e83b

Browse files
authoredJul 13, 2020
Merge pull request #387 from sibis-platform/bug/386_ls_yesno_extras
Fix #386 - only treat YN fields when yes and no are the only options
2 parents bbec03c + 26a9011 commit 0a3e83b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎scripts/import/laptops/update_visit_data

+4-2
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,13 @@ if not redcap_project :
401401
summary_field_names = [field['field_name'] for field in redcap_project.metadata]
402402

403403
# Get list of all 0/1 encoded Yes/No fields (either radio or dropdown) - these need to be recoded when copied
404-
# NOTE: Regex altered to work with either order of Yes/No options
404+
# NOTE: Regex altered to work with either order of Yes/No options, and *only*
405+
# when these are the only two options
406+
yesno_regex = r'^( *0, *No *\| *1, *Yes| *1, *Yes *\| *0, *No *)$'
405407
summary_fields_yn = [field['field_name'] for field in redcap_project.metadata
406408
if ((field['field_type'] == "yesno") or
407409
(field['field_type'] in ['radio', 'dropdown'] and
408-
re.match('([^0-9]*0, No[^0-9]*1, Yes.*|[^0-9]*1, Yes[^0-9]*0, No.*)',
410+
re.match(yesno_regex,
409411
field['select_choices_or_calculations'])))]
410412

411413
# What forms are at what event?

0 commit comments

Comments
 (0)
Please sign in to comment.