Merged in bugfix/code-list-format (pull request #781)

Bugfix/code list format

* replace | with comma in lists

* partial revert

* remove test changes

* Merged main into bugfix/code-list-format

* fix list format

* pipeline error fixed

* pipeline error fixed

* pipeline error fixed


Approved-by: Katon Minhas
This commit is contained in:
Mayank Aamseek
2025-11-21 14:59:54 +00:00
committed by Katon Minhas
parent 18d893c40a
commit 8ea69063b1
2 changed files with 17 additions and 10 deletions
+15 -8
View File
@@ -73,7 +73,7 @@ def get_regex_answers(service, code_answer_dict):
rev_pattern = r"\b(?:\d{3}|\d{2}X)(?:\s*(?:-|through)\s*(?:\d{3}|\d{2}X))?\b"
rev_matches = re.findall(rev_pattern, service)
if len(rev_matches) > 0:
code_answer_dict["REVENUE_CD"] = "|".join(rev_matches)
code_answer_dict["REVENUE_CD"] = str(rev_matches)
return code_answer_dict
@@ -149,6 +149,13 @@ def code_category(service, proc_category, hcpcs_level2_mapping, filename):
code_answer_dict["PROCEDURE_CD"].append(code)
code_answer_dict["PROCEDURE_CD_DESC"].append(answer)
if len(code_answer_dict["PROCEDURE_CD"]) == 1:
code_answer_dict["PROCEDURE_CD"] = code_answer_dict["PROCEDURE_CD"][0]
code_answer_dict["PROCEDURE_CD_DESC"] = code_answer_dict["PROCEDURE_CD_DESC"][0]
else:
code_answer_dict["PROCEDURE_CD"] = str(code_answer_dict["PROCEDURE_CD"])
code_answer_dict["PROCEDURE_CD_DESC"] = str(code_answer_dict["PROCEDURE_CD_DESC"])
return code_answer_dict
@@ -334,33 +341,33 @@ def code_implicit_rag(service, implicit_run_dict, filename, constants):
str(key) for key, val in cpt_mapping.items() if val == description
]
if matching_codes:
proc_codes.append("|".join(matching_codes))
proc_codes.extend(matching_codes)
proc_descs.append(description)
if description in hcpcs_mapping.values():
matching_codes = [
str(key) for key, val in hcpcs_mapping.items() if val == description
]
if matching_codes:
proc_codes.append("|".join(matching_codes))
proc_codes.extend(matching_codes)
proc_descs.append(description)
if description in rev_mapping.values():
matching_codes = [
str(key) for key, val in rev_mapping.items() if val == description
]
if matching_codes:
rev_codes.append("|".join(matching_codes))
rev_codes.extend(matching_codes)
rev_descs.append(description)
# Combine answers
if proc_codes:
code_answer_dict["PROCEDURE_CD"] = "|".join(proc_codes)
code_answer_dict["PROCEDURE_CD_DESC"] = "|".join(proc_descs)
code_answer_dict["PROCEDURE_CD"] = proc_codes[0] if len(proc_codes) == 1 else str(proc_codes)
code_answer_dict["PROCEDURE_CD_DESC"] = proc_descs[0] if len(proc_descs) == 1 else str(proc_descs)
code_answer_dict["CODE_METHODOLOGY"] = (
f"Implicit - Level {level_dict['level_suffix']}"
)
if rev_codes:
code_answer_dict["REVENUE_CD"] = "|".join(rev_codes)
code_answer_dict["REVENUE_CD_DESC"] = "|".join(rev_descs)
code_answer_dict["REVENUE_CD"] = rev_codes[0] if len(rev_codes) == 1 else str(rev_codes)
code_answer_dict["REVENUE_CD_DESC"] = rev_descs[0] if len(rev_descs) == 1 else str(rev_descs)
code_answer_dict["CODE_METHODOLOGY"] = (
f"Implicit - Level {level_dict['level_suffix']}"
)