diff --git a/fieldExtraction/src/codes/code_funcs.py b/fieldExtraction/src/codes/code_funcs.py index 0982fa3..66a0dee 100644 --- a/fieldExtraction/src/codes/code_funcs.py +++ b/fieldExtraction/src/codes/code_funcs.py @@ -333,21 +333,21 @@ def code_implicit_rag(service, implicit_run_dict, filename, constants): if description in cpt_mapping.values(): matching_codes = [ - key for key, val in cpt_mapping.items() if val == description + str(key) for key, val in cpt_mapping.items() if val == description ] if matching_codes: proc_codes.append("|".join(matching_codes)) proc_descs.append(description) if description in hcpcs_mapping.values(): matching_codes = [ - key for key, val in hcpcs_mapping.items() if val == description + str(key) for key, val in hcpcs_mapping.items() if val == description ] if matching_codes: proc_codes.append("|".join(matching_codes)) proc_descs.append(description) if description in rev_mapping.values(): matching_codes = [ - key for key, val in rev_mapping.items() if val == description + str(key) for key, val in rev_mapping.items() if val == description ] if matching_codes: rev_codes.append("|".join(matching_codes)) @@ -490,6 +490,9 @@ def extract_codes_from_service(answer_dict, constants: Constants): "BILL_TYPE_CD_DESC" ) + if string_utils.is_empty(service): + return {} + # Fill Bill Type if not filled if string_utils.is_empty(bill_type): answer_dict = fill_bill_type( diff --git a/fieldExtraction/src/investment/aarete_derived.py b/fieldExtraction/src/investment/aarete_derived.py index 08259a9..d139c09 100644 --- a/fieldExtraction/src/investment/aarete_derived.py +++ b/fieldExtraction/src/investment/aarete_derived.py @@ -39,7 +39,7 @@ def fill_na_mapping(answer_dicts): answer_dict, "AARETE_DERIVED_LOB", "AARETE_DERIVED_PROGRAM", - "crosswalk/mappings/crosswalk_program_lob.json", + "constants/mappings/crosswalk_program_lob.json", ) # Fill AARETE_DERIVED_LOB from PRODUCT @@ -48,7 +48,7 @@ def fill_na_mapping(answer_dicts): answer_dict, "AARETE_DERIVED_LOB", "PRODUCT", - "crosswalk/mappings/crosswalk_product_lob.json", + "constants/mappings/crosswalk_product_lob.json", ) return answer_dicts diff --git a/fieldExtraction/src/investment/one_to_n_funcs.py b/fieldExtraction/src/investment/one_to_n_funcs.py index 2192f7f..8d3fa4d 100644 --- a/fieldExtraction/src/investment/one_to_n_funcs.py +++ b/fieldExtraction/src/investment/one_to_n_funcs.py @@ -724,7 +724,7 @@ def split_compound_reimbursements( if has_compound: # Use LLM to split the compound reimbursement split_result = split_compound_reimbursement_llm( - answer_dict, COMPOUND_INDICATORS, filename + answer_dict, filename ) if split_result and len(split_result) > 1: diff --git a/fieldExtraction/src/investment/row_funcs.py b/fieldExtraction/src/investment/row_funcs.py index 1e111f7..85478aa 100644 --- a/fieldExtraction/src/investment/row_funcs.py +++ b/fieldExtraction/src/investment/row_funcs.py @@ -67,11 +67,20 @@ def inject_global_lesser_of_rows( Returns: pd.DataFrame: Updated one_to_n_results with new rows injected for global lesser of logic. """ - # Find rows that need global lesser of injection - rows_needing_injection = one_to_n_results[ - one_to_n_results["LESSER_OF_IND"] == "N" - ].copy() + # Sanity Check: Ensure LESSER_OF_IND is populated + if "LESSER_OF_IND" in one_to_n_results.columns: + # Find rows that need global lesser of injection + rows_needing_injection = one_to_n_results[ + one_to_n_results["LESSER_OF_IND"] == "N" + ].copy() + elif "LESSER_OF_IND" not in one_to_n_results.columns: + if "SERVICE_TERM" not in one_to_n_results.columns: + return one_to_n_results + else: + one_to_n_results["LESSER_OF_IND"] = "N" + rows_needing_injection = one_to_n_results.copy() + if rows_needing_injection.empty: logging.debug(f"No rows needing global lesser of injection for {filename}.") # Still need to set tracking flag for all existing rows