From a9318cf1d2130ecf7905f87b0ef15eaff37f13ab Mon Sep 17 00:00:00 2001 From: VenkataKrishna Reddy Avula Date: Mon, 15 Sep 2025 13:59:36 +0000 Subject: [PATCH] Merged in bugfix/provider_info_tracker_issues (pull request #706) Bugfix/provider info tracker issues to main * testing TIN AND NPI * print statements added * updated condition for header and footer tin and npi check * tin testing for hyphen format * removed print statements * updated comments Approved-by: Katon Minhas --- fieldExtraction/src/investment/tin_npi_funcs.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fieldExtraction/src/investment/tin_npi_funcs.py b/fieldExtraction/src/investment/tin_npi_funcs.py index 02e73e2..bc1beed 100644 --- a/fieldExtraction/src/investment/tin_npi_funcs.py +++ b/fieldExtraction/src/investment/tin_npi_funcs.py @@ -658,16 +658,16 @@ def run_provider_info_fields( } ] else: - # Find pages with TINs or NPIs + # Identify relevant pages containing either NPIs or TINs (with or without hyphen formatting, e.g., 68-0640053) relevant_pages = [ page_num for page_num, page_text in text_dict.items() - if any(tin in page_text for tin in all_tins) + if any(tin in page_text or (tin[:2] + "-" + tin[2:]) in page_text for tin in all_tins) or any(npi in page_text for npi in all_npis) ] # Stopgap for when the TIN is written in the header or footer of every page (or nearly every page) - if len(relevant_pages) >= len(text_dict) - 1 and len(all_tins) == 1: + if len(relevant_pages) >= len(text_dict) - 1 and (len(all_tins) == 1 or len(all_tins) == 0) and (len(all_npis) == 1 or len(all_npis) == 0): relevant_pages = [relevant_pages[0]] # Process each page separately and combine results @@ -678,7 +678,6 @@ def run_provider_info_fields( # Clean and standardize results cleaned_provider_info = clean_provider_info(combined_provider_info) - # Deduplicate providers based on TIN and NPI deduplicated_provider_info = deduplicate_providers(cleaned_provider_info) @@ -697,7 +696,6 @@ def run_provider_info_fields( one_to_one_results = merge_provider_info( one_to_one_results, deduplicated_provider_info ) # Add Group TIN - # What if the TIN/NPI regexes don't find anything? Add PROV_GROUP_NAME_FULL to full context if ( one_to_one_results.get("PROV_OTHER_NAME_FULL") == "NO_IDENTIFIERS_FOUND"