From 0e3cd3f6c52943e54903648979abec628355c96d Mon Sep 17 00:00:00 2001 From: VenkataKrishna Reddy Avula Date: Mon, 23 Jun 2025 13:11:31 +0000 Subject: [PATCH] Merged in bugfix/reimb_pct_rate_fix (pull request #583) bugfix/reimb pct rate fix to main * updated pct rate post process * postprocess pct rate * Merged main into bugfix/reimb_pct_rate_fix * removed comments Approved-by: Katon Minhas --- .../investment_postprocessing_funcs.py | 33 ++++++++++++------- fieldExtraction/src/investment/postprocess.py | 6 ++-- .../src/prompts/investment_prompts.py | 1 + 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/fieldExtraction/src/investment/investment_postprocessing_funcs.py b/fieldExtraction/src/investment/investment_postprocessing_funcs.py index 78e0998..65b0380 100644 --- a/fieldExtraction/src/investment/investment_postprocessing_funcs.py +++ b/fieldExtraction/src/investment/investment_postprocessing_funcs.py @@ -486,18 +486,27 @@ def update_lob_for_duals(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'. + Fill 'REIMB_PCT_RATE' based on reimbursement method: + - Set 'REIMB_PCT_RATE' to '100' for rows where: + - 'REIMB_PCT_RATE', 'REIMB_FEE_RATE', and 'REIMB_CONVERSION_FACTOR' are all empty. + - Set 'REIMB_PCT_RATE' to 'N/A' for rows where: + - 'AARETE_DERIVED_REIMB_METHOD' contains specific grouper. """ - required_cols = ["REIMB_PCT_RATE", "REIMB_FEE_RATE", "AARETE_DERIVED_REIMB_METHOD"] + required_cols = ["REIMB_PCT_RATE", "REIMB_FEE_RATE", "REIMB_CONVERSION_FACTOR", "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 - + # Fill with '100' when all three rate fields are empty + pct_empty = string_utils.is_empty(df["REIMB_PCT_RATE"]) + fee_empty = string_utils.is_empty(df["REIMB_FEE_RATE"]) + conversion_empty = string_utils.is_empty(df["REIMB_CONVERSION_FACTOR"]) + + fill_mask = pct_empty & fee_empty & conversion_empty + df.loc[fill_mask, "REIMB_PCT_RATE"] = "100" + + # Set to N/A for specific reimbursement methods + na_methods = ["Grouper", "Per Diem", "Flat Rate", "Per Visit", "Case Rate"] + + na_mask = df["AARETE_DERIVED_REIMB_METHOD"].isin(na_methods) + df.loc[na_mask, "REIMB_PCT_RATE"] = "N/A" + return df \ No newline at end of file diff --git a/fieldExtraction/src/investment/postprocess.py b/fieldExtraction/src/investment/postprocess.py index 5909441..9f92b57 100644 --- a/fieldExtraction/src/investment/postprocess.py +++ b/fieldExtraction/src/investment/postprocess.py @@ -28,9 +28,6 @@ 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: @@ -56,6 +53,9 @@ def postprocess(df): # Standardize the 'AARETE_DERIVED_REIMB_METHOD' column and updates the 'AARETE_DERIVED_FEE_SCHEDULE' column based on specific values. df = investment_postprocessing_funcs.standardize_reimb_method_and_fee_schedule(df) + # update reimb_pct_rate + df = investment_postprocessing_funcs.fill_empty_reimb_pct_rate(df) + df = investment_postprocessing_funcs.update_reimb_prov_name(df) df = investment_postprocessing_funcs.add_aarete_derived_amendment_num(df) diff --git a/fieldExtraction/src/prompts/investment_prompts.py b/fieldExtraction/src/prompts/investment_prompts.py index c0d8e7c..49d08d5 100644 --- a/fieldExtraction/src/prompts/investment_prompts.py +++ b/fieldExtraction/src/prompts/investment_prompts.py @@ -545,6 +545,7 @@ For any fields that don't apply to a particular methodology, use "N/A" as the va - If the methodology includes **additional reimbursement terms** beyond the “lesser of” structure (e.g., administrative fees, per diem charges, or carve-out payments): - **These must also be extracted as separate JSON dictionaries** in the same list. - These are often found in follow-on sentences or clauses and may not be part of a comparative limit but are still enforceable and reimbursable. +- For each dictionary, only one of the following fields should be present: REIMB_FEE_RATE, REIMB_PCT_RATE, or REIMB_CONVERSION_FACTOR. The others should be "N/A". [C: ANALYSIS CONTEXT] Here is the text to analyze and respond to: