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"] = (