Merged in bugfix/default_ind_postprocess (pull request #887)
Bugfix/default ind postprocess * Add logic to standardize UNIT_OF_MEASURE for flat-rate reimbursement methods - Implemented functionality in `standardize_reimb_method_and_fee_schedule` to set UNIT_OF_MEASURE to blank for rows where DEFAULT_IND is 'Y' and AARETE_DERIVED_REIMB_METHOD is 'flat rate'. - Added unit tests to verify behavior for various scenarios, including case insensitivity and non-default conditions. - Ensured that UNIT_OF_MEASURE remains unchanged for non-flat rate methods. * Enhance child rank handling and ensure column consistency in parent-child mapping - Added initialization for the `child_rank` column in both parents and children DataFrames to prevent KeyError during concatenation when no children exist. - Updated `cols_to_keep` in `parent_child_mapping` to filter out columns not present in `pc_df`, ensuring robustness in data processing. * Ran Black * made a small change in code_last_check, fixed so it returns string and not single char * Made changes to make sure that default_ind postprocess only happens to the cc output and not dashboard * Merged DEV into bugfix/default_ind_postprocess * Restore deleted AARETE_DERIVED_PAYER_NAME functions Functions were removed during previous commit. Restored from DEV to fix AttributeError in prompt_calls.py. * Simplify code_last_check return logic and add error logging - Simplified return to single line with fallback - Added error logging for failed LLM response parsing Approved-by: Siddhant Medar
This commit is contained in:
committed by
Siddhant Medar
parent
7571d3e3b1
commit
ddefa2ff30
@@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patch
|
||||
import pandas as pd
|
||||
import pytest
|
||||
from src.pipelines.shared.postprocessing.postprocessing_funcs import (
|
||||
blank_uom_for_default_flat_rate_cc,
|
||||
clean_na_values,
|
||||
deduplicate_provider_columns,
|
||||
fill_claim_type_from_title,
|
||||
@@ -21,6 +22,7 @@ from src.pipelines.shared.postprocessing.postprocessing_funcs import (
|
||||
remove_hyphens,
|
||||
remove_redundant_reimb_info,
|
||||
rename_columns,
|
||||
standardize_reimb_method_and_fee_schedule,
|
||||
validate_and_reformat_date,
|
||||
)
|
||||
from src.pipelines.shared.postprocessing.postprocess import standard_postprocess
|
||||
@@ -920,6 +922,82 @@ class TestPostprocessFunctions(unittest.TestCase):
|
||||
self.assertEqual(result_df.loc[1, "CONTRACT_TITLE"], "Another Valid")
|
||||
|
||||
|
||||
class TestStandardizeReimbMethodAndFeeScheduleUOM(unittest.TestCase):
|
||||
"""Tests for UNIT_OF_MEASURE post-processing when DEFAULT_IND='Y' and flat rate."""
|
||||
|
||||
def test_cc_default_flat_rate_uom_blank(self):
|
||||
"""CC only: DEFAULT_IND='Y' and Flat Rate -> UNIT_OF_MEASURE blank."""
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"DEFAULT_IND": ["Y"],
|
||||
"AARETE_DERIVED_REIMB_METHOD": ["Flat Rate"],
|
||||
"UNIT_OF_MEASURE": ["Per Unit"],
|
||||
}
|
||||
)
|
||||
result = blank_uom_for_default_flat_rate_cc(df)
|
||||
self.assertEqual(result.loc[0, "UNIT_OF_MEASURE"], "")
|
||||
|
||||
def test_cc_default_flat_rate_case_insensitive(self):
|
||||
"""CC only: DEFAULT_IND='Y' and 'flat rate' (lowercase) -> UNIT_OF_MEASURE blank."""
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"DEFAULT_IND": ["Y"],
|
||||
"AARETE_DERIVED_REIMB_METHOD": ["flat rate"],
|
||||
"UNIT_OF_MEASURE": ["Per Visit"],
|
||||
}
|
||||
)
|
||||
result = blank_uom_for_default_flat_rate_cc(df)
|
||||
self.assertEqual(result.loc[0, "UNIT_OF_MEASURE"], "")
|
||||
|
||||
def test_standardize_does_not_blank_default_flat_rate(self):
|
||||
"""Shared path: default flat rate keeps UOM (blanking is CC-only)."""
|
||||
constants = Constants()
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"DEFAULT_IND": ["Y"],
|
||||
"AARETE_DERIVED_REIMB_METHOD": ["Flat Rate"],
|
||||
"UNIT_OF_MEASURE": ["Per Unit"],
|
||||
"REIMB_TERM": [""],
|
||||
}
|
||||
)
|
||||
result = standardize_reimb_method_and_fee_schedule(
|
||||
df, constants.VALID_UNIT_OF_MEASURE
|
||||
)
|
||||
self.assertEqual(result.loc[0, "UNIT_OF_MEASURE"], "Per Unit")
|
||||
|
||||
def test_non_default_flat_rate_uom_per_unit(self):
|
||||
"""DEFAULT_IND='N', flat rate, empty UOM -> UNIT_OF_MEASURE becomes Per Unit."""
|
||||
constants = Constants()
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"DEFAULT_IND": ["N"],
|
||||
"AARETE_DERIVED_REIMB_METHOD": ["Flat Rate"],
|
||||
"UNIT_OF_MEASURE": [""],
|
||||
"REIMB_TERM": [""],
|
||||
}
|
||||
)
|
||||
result = standardize_reimb_method_and_fee_schedule(
|
||||
df, constants.VALID_UNIT_OF_MEASURE
|
||||
)
|
||||
self.assertEqual(result.loc[0, "UNIT_OF_MEASURE"], "Per Unit")
|
||||
|
||||
def test_default_non_flat_rate_uom_unchanged(self):
|
||||
"""DEFAULT_IND='Y' and Fee Schedule -> UNIT_OF_MEASURE unchanged."""
|
||||
constants = Constants()
|
||||
df = pd.DataFrame(
|
||||
{
|
||||
"DEFAULT_IND": ["Y"],
|
||||
"AARETE_DERIVED_REIMB_METHOD": ["Fee Schedule"],
|
||||
"UNIT_OF_MEASURE": ["Per Visit"],
|
||||
"REIMB_TERM": [""],
|
||||
}
|
||||
)
|
||||
result = standardize_reimb_method_and_fee_schedule(
|
||||
df, constants.VALID_UNIT_OF_MEASURE
|
||||
)
|
||||
self.assertEqual(result.loc[0, "UNIT_OF_MEASURE"], "Per Visit")
|
||||
|
||||
|
||||
class TestOutputFileStructure(unittest.TestCase):
|
||||
"""Test that the new output file structure is generated correctly."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user