From 102f3007b8272dde65b41a73af5fa994eb4529c5 Mon Sep 17 00:00:00 2001 From: Todd Seidelmann Date: Mon, 13 Jun 2022 14:32:35 -0700 Subject: [PATCH] Add new encounter class mapping 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. --- .../id3c/cli/command/etl/redcap_det_uw_retrospectives.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/seattleflu/id3c/cli/command/etl/redcap_det_uw_retrospectives.py b/lib/seattleflu/id3c/cli/command/etl/redcap_det_uw_retrospectives.py index 3ea2048d..7bd94d36 100644 --- a/lib/seattleflu/id3c/cli/command/etl/redcap_det_uw_retrospectives.py +++ b/lib/seattleflu/id3c/cli/command/etl/redcap_det_uw_retrospectives.py @@ -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( @@ -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]