From 722d8aa14ab724e283de9ecf91c4ec12154185b8 Mon Sep 17 00:00:00 2001 From: Mayank Aamseek Date: Mon, 17 Feb 2025 19:43:55 +0000 Subject: [PATCH] Merged in feature/daip2-101 (pull request #399) Feature/daip2 101 * missing group tin fixed * use tin prompt in full context when N/A * fixed N/A TIN and applied same to NPI * null tin fixed * Merged main into feature/daip2-101 * if PROV_GROUP_TIN is still N/A, pick first value from tin_other * Merge branch 'feature/daip2-101' of https://bitbucket.org/aarete/doczy.ai into feature/daip2-101 pulled latest changes from main Approved-by: Katon Minhas --- fieldExtraction/src/investment/one_to_one_funcs.py | 5 +++++ fieldExtraction/src/postprocessing_funcs.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fieldExtraction/src/investment/one_to_one_funcs.py b/fieldExtraction/src/investment/one_to_one_funcs.py index 0113d3c..e363869 100644 --- a/fieldExtraction/src/investment/one_to_one_funcs.py +++ b/fieldExtraction/src/investment/one_to_one_funcs.py @@ -19,6 +19,11 @@ def run_regex_fields(one_to_one_fields: FieldSet, # One to One TIN Fields tin_answers = get_tin_fields(filename, text_dict, top_sheet_dict) + if tin_answers['PROV_GROUP_TIN_SIGNATORY'] != 'N/A': + if tin_answers['PROV_TIN_OTHER'] != 'N/A': + tin_answers['PROV_TIN_OTHER'] = tin_answers['PROV_GROUP_TIN_SIGNATORY'] + ', ' + tin_answers['PROV_TIN_OTHER'] + else: + tin_answers['PROV_TIN_OTHER'] = tin_answers['PROV_GROUP_TIN_SIGNATORY'] tin_answers = {k:v for k, v in tin_answers.items() if k in ['PROV_GROUP_TIN', 'PROV_TIN_OTHER']} tin_answers['PROV_GROUP_TIN'] = str(tin_answers['PROV_GROUP_TIN']).replace("-","") tin_answers['PROV_TIN_OTHER'] = str(tin_answers['PROV_TIN_OTHER']).replace("-","") diff --git a/fieldExtraction/src/postprocessing_funcs.py b/fieldExtraction/src/postprocessing_funcs.py index d3d5998..b57a564 100644 --- a/fieldExtraction/src/postprocessing_funcs.py +++ b/fieldExtraction/src/postprocessing_funcs.py @@ -752,10 +752,14 @@ def clean_tin_npi_other(final_df: pd.DataFrame) -> pd.DataFrame: pd.DataFrame: The cleaned DataFrame with square brackets removed from the specified columns. """ if "PROV_TIN_OTHER" in final_df and "PROV_GROUP_TIN" in final_df: - final_df["PROV_TIN_OTHER"] = final_df.apply(lambda row: row.PROV_TIN_OTHER.replace(row.PROV_GROUP_TIN+', ','').replace(row.PROV_GROUP_TIN,''), axis=1) + # if PROV_GROUP_TIN is still N/A, pick first value from tin_other + final_df["PROV_GROUP_TIN"] = final_df.apply(lambda row: row.PROV_TIN_OTHER[:9] if row.PROV_GROUP_TIN == 'N/A' and len(row.PROV_TIN_OTHER) >= 9 else row.PROV_GROUP_TIN, axis=1) + final_df["PROV_TIN_OTHER"] = final_df.apply(lambda row: row.PROV_TIN_OTHER.replace(row.PROV_GROUP_TIN+', ','').replace(', '+row.PROV_GROUP_TIN,'').replace(row.PROV_GROUP_TIN,''), axis=1) if "PROV_NPI_OTHER" in final_df and "PROV_GROUP_NPI" in final_df: - final_df["PROV_NPI_OTHER"] = final_df.apply(lambda row: row.PROV_NPI_OTHER.replace(row.PROV_GROUP_NPI+', ','').replace(row.PROV_GROUP_NPI,''), axis=1) + # if PROV_GROUP_NPI is still N/A, pick first value from npi_other + final_df["PROV_GROUP_NPI"] = final_df.apply(lambda row: row.PROV_NPI_OTHER[:10] if row.PROV_GROUP_NPI == 'N/A' and len(row.PROV_NPI_OTHER) >= 10 else row.PROV_GROUP_NPI, axis=1) + final_df["PROV_NPI_OTHER"] = final_df.apply(lambda row: row.PROV_NPI_OTHER.replace(row.PROV_GROUP_NPI+', ','').replace(', '+row.PROV_GROUP_NPI,'').replace(row.PROV_GROUP_NPI,''), axis=1) if "PROV_TIN_OTHER" in final_df: final_df["PROV_TIN_OTHER"] = (