Skip to content

Commit

Permalink
Update regex in swab and send ETLs to include all negative responses
Browse files Browse the repository at this point in the history
REDCap responses for travel fields are being cast to boolean, but the regex used to match to responses of "No" was excluding them because they contain a dash instead of the comma, resulting in only "Yes" responses being ingested. Updating to handle commas and dashes.
  • Loading branch information
davereinhart committed Apr 11, 2024
1 parent 34ac43b commit 72156ca
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def cast_to_integer(string: str) -> Optional[int]:
def cast_to_boolean(string: str) -> Optional[bool]:
if string == 'Yes':
return True
elif re.match(r'^No($|,[\w\s\'\.]*)$', string): # Starts with "No", has optional comma and text
elif re.match(r'^No($|(,|\s-)[\w\s\'\.]*)$', string): # Starts with "No", has optional comma or space+dash followed by text
return False
return None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def cast_to_integer(string: str) -> Optional[int]:
def cast_to_boolean(string: str) -> Optional[bool]:
if string == 'Yes':
return True
elif re.match(r'^No($|,[\w\s\'\.]*)$', string): # Starts with "No", has optional comma and text
elif re.match(r'^No($|(,|\s-)[\w\s\'\.]*)$', string): # Starts with "No", has optional comma or space+dash followed by text
return False
return None

Expand Down

0 comments on commit 72156ca

Please sign in to comment.