Merged in chore/health_plan_state (pull request #304)
refactored code to add recent health plan state hotfixes into the existing postprocessing pipeline * refactored code to add recent health plan state hotfixes into the existing postprocessing pipeline * Merged main into chore/health_plan_state * Merged main into chore/health_plan_state * add debug print statement * debug print statements * more debug print statements * print df columns for debug * move health plan state hotfix functionality to postprocessing_funcs.py * add better error printing * add error message for parent agreement code * remove dots in state abbreviations * remove unused import * also look for state abbreviations * Merged main into chore/health_plan_state * remove print statements * Merged main into chore/health_plan_state Approved-by: Katon Minhas
This commit is contained in:
committed by
Katon Minhas
parent
13119ab499
commit
b2a8e77cca
@@ -9,6 +9,7 @@ import valid
|
||||
from valid import DERIVED_INDICATOR_FIELDS
|
||||
import claude_funcs
|
||||
from utils import is_empty
|
||||
from hotfix_helper_funcs import state_check
|
||||
|
||||
import logging
|
||||
|
||||
@@ -142,10 +143,10 @@ def get_parent_agreement_code(filename):
|
||||
filename = re.sub(r"\([^)]*\)", "", filename)
|
||||
|
||||
match = re.search(r"([^\sa-zA-Z]+)(?=\.\w+$|$)", filename)
|
||||
end = [i for i in match.group(1).split("_") if i]
|
||||
end = [i for i in match.group(1).split("_") if i] # an error is happening here. This function needs a docstring.
|
||||
return end[0]
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
print(f"Error in `get_parent_agreement_code`: {e}; returning `N/A`")
|
||||
return "N/A"
|
||||
|
||||
|
||||
@@ -399,6 +400,35 @@ def clean_health_plan_state(final_df):
|
||||
final_df["HEALTH_PLAN_STATE"] = final_df["HEALTH_PLAN_STATE"].str.title()
|
||||
return final_df
|
||||
|
||||
def clean_health_plan_state_from_hotfix(
|
||||
df: pd.DataFrame,
|
||||
contract_name: str,
|
||||
text_dict: dict[str, str],
|
||||
) -> pd.DataFrame:
|
||||
|
||||
if not isinstance(df, pd.DataFrame):
|
||||
# raise TypeError(f"Expected a dataframe, got {type(df).__name__}")
|
||||
return df
|
||||
|
||||
if contract_name is None:
|
||||
# raise ValueError(
|
||||
# f"Expected 'contract_name' parameter, got {contract_name}"
|
||||
# )
|
||||
return df
|
||||
|
||||
if "HEALTH_PLAN_STATE" not in df.columns:
|
||||
# raise KeyError(
|
||||
# f"Column 'Health Plan State' not found in DataFrame. Available columns are: {list(df.columns)}"
|
||||
# )
|
||||
return df
|
||||
|
||||
health_plan_state = df["HEALTH_PLAN_STATE"].unique().tolist()[0]
|
||||
|
||||
answer = state_check(health_plan_state, text_dict)
|
||||
|
||||
df["HEALTH_PLAN_STATE"] = answer
|
||||
|
||||
return df
|
||||
|
||||
def clean_notice_provider_name_and_address(final_df):
|
||||
if "NOTICE_PROVIDER_NAME" in final_df and "NOTICE_PROVIDER_ADDRESS" in final_df:
|
||||
|
||||
Reference in New Issue
Block a user