Merged in hotfix/molina_files (pull request #473)

Hotfix/molina files

* fix the cpt fields
* None values checking safely

Approved-by: Alex Galarce
This commit is contained in:
Rahul Ailaboina
2025-04-10 15:34:06 +00:00
committed by Alex Galarce
parent bea96b67cf
commit 21e71c4054
@@ -186,7 +186,7 @@ def normalize_cpt_fields(value):
Returns:
list: A normalized list of string codes.
"""
if pd.isna(value): # Handle NaN values
if value is None or (isinstance(value, float) and pd.isna(value)): # Handle NaN values
result = []
elif isinstance(value, (list, tuple)): # If already a list or tuple
result = [str(v).strip() for v in value]
@@ -238,7 +238,6 @@ def postprocess(df):
df.loc[~df['DATE_VALID'], col] = df.loc[~df['DATE_VALID'], col].apply(reformat_to_yyyymmdd)
if "CPT" in col:
df[col] = df[col].apply(normalize_cpt_fields)
df[col] = df[col].apply(lambda x: str(x) if isinstance(x, list) else x)
# Normalize the 'AUTO_RENEWAL_TERM' column
df["AUTO_RENEWAL_TERM"] = df["AUTO_RENEWAL_TERM"].apply(normalize_auto_renewal_term)