diff --git a/fieldExtraction/src/investment/investment_postprocessing_funcs.py b/fieldExtraction/src/investment/investment_postprocessing_funcs.py index 9dfbd64..1e237e9 100644 --- a/fieldExtraction/src/investment/investment_postprocessing_funcs.py +++ b/fieldExtraction/src/investment/investment_postprocessing_funcs.py @@ -491,3 +491,21 @@ def update_lob_for_duals(answer_dicts): answer_dict["AARETE_DERIVED_LOB"] = claude_answer_extracted final_answer_dicts.append(answer_dict) return final_answer_dicts + +def fill_empty_reimb_pct_rate(df): + """ + Fill 'REIMB_PCT_RATE' with '100' for rows where: + - 'REIMB_PCT_RATE' is empty, + - 'REIMB_FEE_RATE' is empty, + - and 'AARETE_DERIVED_REIMB_METHOD' is either 'Fee Schedule' or 'Grouper'. + """ + required_cols = ["REIMB_PCT_RATE", "REIMB_FEE_RATE", "AARETE_DERIVED_REIMB_METHOD"] + if all(col in df.columns for col in required_cols): + pct_empty = string_utils.is_empty(df["REIMB_PCT_RATE"]) # Series mask + fee_empty = string_utils.is_empty(df["REIMB_FEE_RATE"]) # Series mask + method_mask = df["AARETE_DERIVED_REIMB_METHOD"].isin(["Fee Schedule", "Grouper"]) + + mask = pct_empty & fee_empty & method_mask # Final combined mask + df.loc[mask, "REIMB_PCT_RATE"] = "100" # Apply change + + return df \ No newline at end of file diff --git a/fieldExtraction/src/investment/postprocess.py b/fieldExtraction/src/investment/postprocess.py index 2fc7ef8..ad97d03 100644 --- a/fieldExtraction/src/investment/postprocess.py +++ b/fieldExtraction/src/investment/postprocess.py @@ -18,6 +18,9 @@ def postprocess(df): df['REIMB_FEE_RATE'] = df['REIMB_FEE_RATE'].apply(investment_postprocessing_funcs.format_rate_fields_with_commas) if "REIMB_PCT_RATE" in df.columns: df['REIMB_PCT_RATE'] = df['REIMB_PCT_RATE'].apply(investment_postprocessing_funcs.format_rate_fields_with_commas) + + # default reimb_pct_rate to 100 when both reimb_pct_rate and reimb_fee_rate are empty + df = investment_postprocessing_funcs.fill_empty_reimb_pct_rate(df) for col in df.columns: if "_IND" in col: diff --git a/fieldExtraction/src/prompts/investment_prompts.json b/fieldExtraction/src/prompts/investment_prompts.json index d837aa6..ee17977 100644 --- a/fieldExtraction/src/prompts/investment_prompts.json +++ b/fieldExtraction/src/prompts/investment_prompts.json @@ -46,7 +46,7 @@ "field_name": "REIMB_PCT_RATE", "relationship": "one_to_n", "field_type": "methodology_breakout", - "prompt": "If the rate of reimbursement is a percentage of something, what is that percentage rate of reimbursement? Extract only the final percentage value from the text. If no specific percentage is explicitly mentioned and no dollar amount is mentioned either, return 100 as the default value." + "prompt": "What is the percentage rate of reimbursement? Extract only the numeric percentage value (without % symbol). If a percentage is explicitly stated, return that number. If no percentage is found AND no specific dollar amount is mentioned in the text, return 100 as default. If a specific dollar amount is mentioned, return 'N/A'." }, { "field_name": "REIMB_EFFECTIVE_DT",