From 48c2d1ad5173a56992d1eaab371f1dbc21432ef7 Mon Sep 17 00:00:00 2001 From: VenkataKrishna Reddy Avula Date: Mon, 27 Oct 2025 16:22:43 +0000 Subject: [PATCH] Merged in bugfix/claim_type_cd (pull request #749) Bugfix/claim type cd to main * test claim type cd * Merged main into bugfix/claim_type_cd * updated claim type prompt * updated prompt * empty one to n results initiated * remove print statements * src/investment/prompt_calls.py * full context prompt update Approved-by: Katon Minhas --- fieldExtraction/src/investment/dynamic_funcs.py | 6 ++++++ fieldExtraction/src/investment/file_processing.py | 1 + fieldExtraction/src/investment/one_to_n_funcs.py | 4 +++- fieldExtraction/src/prompts/investment_prompts.json | 4 ++-- fieldExtraction/src/prompts/prompt_templates.py | 3 ++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fieldExtraction/src/investment/dynamic_funcs.py b/fieldExtraction/src/investment/dynamic_funcs.py index 2297896..83728a6 100644 --- a/fieldExtraction/src/investment/dynamic_funcs.py +++ b/fieldExtraction/src/investment/dynamic_funcs.py @@ -23,6 +23,12 @@ def add_full_context_field(one_to_one_fields, field_to_add, answer_dicts): if len(non_empty_lobs) > 1: return one_to_one_fields + if field_to_add.field_name == "CLAIM_TYPE_CD": + field_to_add.prompt = ( + field_to_add.prompt + + prompt_templates.FULL_CONTEXT_CLAIM_TYPES_ADDITIONAL_INSTRUCTION() + ) + field_to_add.prompt = ( field_to_add.prompt + prompt_templates.FULL_CONTEXT_ADDITIONAL_INSTRUCTIONS(field_to_add.allow_na) diff --git a/fieldExtraction/src/investment/file_processing.py b/fieldExtraction/src/investment/file_processing.py index 6da69b8..0aadb95 100644 --- a/fieldExtraction/src/investment/file_processing.py +++ b/fieldExtraction/src/investment/file_processing.py @@ -45,6 +45,7 @@ def process_file(file_object, constants: Constants, run_timestamp): ) # ONE TO N PROCESSING + one_to_n_results = pd.DataFrame() # Initialize empty DataFrame for one_to_n_results if process_one_to_n: exhibit_dict, all_exhibit_headers = preprocess.one_to_n_exhibit_chunking( text_dict, constants.EXHIBIT_HEADER_MARKERS, filename diff --git a/fieldExtraction/src/investment/one_to_n_funcs.py b/fieldExtraction/src/investment/one_to_n_funcs.py index 0f4e4b9..3273c6e 100644 --- a/fieldExtraction/src/investment/one_to_n_funcs.py +++ b/fieldExtraction/src/investment/one_to_n_funcs.py @@ -490,7 +490,9 @@ def special_case_breakout( """ final_answer_dict = {} - + # if not dict and empty special_case_primary_answers, return empty dict + if not isinstance(special_case_primary_answers, dict) and string_utils.is_empty(special_case_primary_answers): + return final_answer_dict for term_field_name, term_answers in special_case_primary_answers.items(): if not term_answers: diff --git a/fieldExtraction/src/prompts/investment_prompts.json b/fieldExtraction/src/prompts/investment_prompts.json index b792e65..80194f6 100644 --- a/fieldExtraction/src/prompts/investment_prompts.json +++ b/fieldExtraction/src/prompts/investment_prompts.json @@ -161,11 +161,11 @@ "field_name" : "CLAIM_TYPE_CD", "relationship" : "one_to_n", "field_type" : "exhibit_level", - "prompt": "What is the Claim Type of the contract, exhibit, or services mentioned? Choose ONLY from the following: {valid_values}. Guidelines:\n- If the contract refers to services rendered by individual healthcare providers or provider groups, return 'Professional'.\n- If the document mentions services provided by hospitals, facilities or institutions, return 'Institutional'.\n- If the services include Home Health, Durable Medical Equipment (DME), Laboratory, Radiology, Dialysis, Diagnostic Imaging, Genetic Testing, Blood Testing, Sleep Lab Services, Telemedicine, Behavioral & Mental Health Services, or other services commonly performed in an ancillary setting, return 'Ancillary'.\n- If multiple claim types are mentioned for different services, return the one most closely associated with the compensation or service description in question.", + "prompt": "What is the Claim Type of the contract, exhibit, or services mentioned in the text? Choose ONLY from the following: {valid_values}.\n\nGuidelines:\n- Return 'Professional' if the text refers to services rendered by individual healthcare providers or provider groups (e.g., physician services, office visits, outpatient procedures).\n- Return 'Institutional' if the text refers to services provided by hospitals, facilities, or institutions (e.g., inpatient, outpatient facility, or surgery centers).\n- Return 'Ancillary' if the text refers to services such as Home Health, Durable Medical Equipment (DME), Laboratory, Radiology, Dialysis, Diagnostic Imaging, Genetic Testing, Blood Testing, Sleep Lab Services, Telemedicine, Behavioral or Mental Health, or other ancillary settings.\n- If multiple claim types are mentioned, return the one most closely associated with the compensation or service description in the context.\n- If no claim type is mentioned or cannot be determined, return 'N/A'.\nDo not infer or guess.", "valid_values" : "VALID_CLAIM_TYPE", "keywords" : [], "smart_chunking_methodology" : "TBD", - "allow_na" : false + "allow_na" : true }, { "field_name": "AARETE_DERIVED_CLAIM_TYPE_CD", diff --git a/fieldExtraction/src/prompts/prompt_templates.py b/fieldExtraction/src/prompts/prompt_templates.py index f7cba0b..850b0a4 100644 --- a/fieldExtraction/src/prompts/prompt_templates.py +++ b/fieldExtraction/src/prompts/prompt_templates.py @@ -918,7 +918,8 @@ def GROUP_TIN_NPI_TEMPLATE(key_sections: str, provider_list: str) -> str: Feel free to justify your answer, but enclose your final answer in |pipes|. """ - +def FULL_CONTEXT_CLAIM_TYPES_ADDITIONAL_INSTRUCTION(): + return "Additionally Check the contract text for the provider name from the preamble or signature section to help determine the claim type." def FULL_CONTEXT_ADDITIONAL_INSTRUCTIONS(allow_na): if allow_na: