Skip to content

Commit

Permalink
Add new encounter class mapping
Browse files Browse the repository at this point in the history
Also make error messages more informative when we get an unknown
encounter class/status so it's easier to track down where they're
coming from.
  • Loading branch information
Todd Seidelmann committed Jun 14, 2022
1 parent 2fe2b0a commit 102f300
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,15 @@ def create_encounter_class(redcap_record: dict) -> dict:
"obv" : "IMP",
"observation" : "IMP",
"field" : "FLD",
"surgery overnight stay" : "IMP",
}

standardized_encounter_class = standardize_whitespace(encounter_class.lower())

if standardized_encounter_class and standardized_encounter_class not in mapper:
raise Exception(f"Unknown encounter class «{encounter_class}».")
raise Exception(f"Unknown encounter class «{encounter_class}» found in "
f"REDCAP_URL: {REDCAP_URL} PROJECT_ID: {PROJECT_ID} barcode: "
f"{redcap_record.get('barcode', 'UNKNOWN')}.")

# Default to 'AMB' if encounter_class not defined
return create_coding(
Expand Down Expand Up @@ -480,7 +483,9 @@ def create_encounter_status(redcap_record: dict) -> str:
if standardized_status in mapper.values():
return standardized_status
elif standardized_status not in mapper:
raise Exception(f"Unknown encounter status «{standardized_status}».")
raise Exception(f"Unknown encounter status «{standardized_status}» found in "
f"REDCAP_URL: {REDCAP_URL} PROJECT_ID: {PROJECT_ID} barcode: "
f"{redcap_record.get('barcode', 'UNKNOWN')}.")

return mapper[standardized_status]

Expand Down

0 comments on commit 102f300

Please sign in to comment.