From 0b00cc5ddd88ac30aa60befc14e37ea073cf2d17 Mon Sep 17 00:00:00 2001 From: Katon Minhas Date: Thu, 4 Sep 2025 18:22:35 +0000 Subject: [PATCH] Merged in feature/initialize-phase-5 (pull request #696) Feature/initialize phase 5 * Initialize at Exhibit-Level * Merge branch 'main' into feature/initialize-phase-5 * Add all breakout fields * Prep for merge Approved-by: Alex Galarce --- .../src/investment/file_processing.py | 3 +- .../src/investment/one_to_n_funcs.py | 13 +++ .../src/prompts/investment_prompts.json | 80 ++++++++++++++++++- .../src/prompts/prompt_templates.py | 23 ++++++ 4 files changed, 117 insertions(+), 2 deletions(-) diff --git a/fieldExtraction/src/investment/file_processing.py b/fieldExtraction/src/investment/file_processing.py index 56636a4..b9f17dc 100644 --- a/fieldExtraction/src/investment/file_processing.py +++ b/fieldExtraction/src/investment/file_processing.py @@ -152,7 +152,7 @@ def run_one_to_n_prompts(filename, exhibit_dict, all_exhibit_headers, constants) ) # Accumulator for tracking duplicate pairs of (`SERVICE_TERM`, `REIMB_TERM`) for exhibit_page in exhibit_dict.keys(): - + exhibit_text = exhibit_dict[exhibit_page] ################# GET EXHIBIT-LEVEL ANSWERS ################## @@ -162,6 +162,7 @@ def run_one_to_n_prompts(filename, exhibit_dict, all_exhibit_headers, constants) ) ) + ################# GET DYNAMIC ANSWERS ################## exhibit_level_answers, reimbursement_level_fields = one_to_n_funcs.get_dynamic( exhibit_text, exhibit_header, exhibit_level_answers, constants, filename diff --git a/fieldExtraction/src/investment/one_to_n_funcs.py b/fieldExtraction/src/investment/one_to_n_funcs.py index ee3448e..44816c2 100644 --- a/fieldExtraction/src/investment/one_to_n_funcs.py +++ b/fieldExtraction/src/investment/one_to_n_funcs.py @@ -19,6 +19,17 @@ from src.prompts.fieldset import FieldSet import src.investment.dynamic_funcs as dynamic_funcs +def get_exhibit_level_breakout(exhibit_level_answers, filename): + + if not string_utils.is_empty(exhibit_level_answers.get("FACILITY_ADJUSTMENT_TERM")): + facility_adjustment_breakout_fields = FieldSet(config.FIELD_JSON_PATH, field_type="facility_adjustments_breakout") + prompt = prompt_templates.FACILITY_ADJUSTMENT_BREAKOUT(exhibit_level_answers.get("FACILITY_ADJUSTMENT_TERM"), facility_adjustment_breakout_fields.print_prompt_dict()) + llm_answer_raw = llm_utils.invoke_claude(prompt, "sonnet_latest", filename) + llm_answer_final = string_utils.universal_json_load(llm_answer_raw) + exhibit_level_answers.update(llm_answer_final) + + return exhibit_level_answers + def get_exhibit_level( exhibit_text: str, exhibit_page: str, @@ -40,6 +51,8 @@ def get_exhibit_level( exhibit_level_answers["EXHIBIT_PAGE"] = exhibit_page exhibit_level_answers["EXHIBIT_TITLE"] = exhibit_header + exhibit_level_answers = get_exhibit_level_breakout(exhibit_level_answers, filename) + # Extract exhibit lesser-of statement for passing to reimbursement_level exhibit_lesser_of = exhibit_level_answers.get("EXHIBIT_LESSER_OF_STATEMENT", "N/A") diff --git a/fieldExtraction/src/prompts/investment_prompts.json b/fieldExtraction/src/prompts/investment_prompts.json index 80e2f09..31a96ae 100644 --- a/fieldExtraction/src/prompts/investment_prompts.json +++ b/fieldExtraction/src/prompts/investment_prompts.json @@ -890,5 +890,83 @@ "relationship": "one_to_n", "field_type": "rate_escalator", "prompt": "Extract the exact text from the reimbursement that describes when rate increases begin and how frequently they occur. Include the complete timeline phrase showing the starting point and frequency (e.g., 'beginning on the anniversary of the effective date and each year thereafter'). Use the precise wording from the document. If no specific timeline is mentioned, return 'N/A'." - } + }, + { + "field_name": "FACILITY_ADJUSTMENT_TERM", + "relationship": "one_to_n", + "field_type": "exhibit_level", + "prompt": "Extract any language in the Exhibit that relates to Disproportionate Share Hospital ('DSH'), Direct Graduate Medical Education ('GME'), Indirect Medical Education('IME'), New Technology Add-on Payment ('NTAP'), or Uncompensated Care ('UC'). Extract the full sentence or sentences." + }, + { + "field_name": "DSH_IND", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "Are adjustments for Disproportionate Share Hospitals (DSH) included in the reimbursement? Return 'Y' or 'N'." + }, + { + "field_name": "DSH_PCT_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If DSH adjustments are included, and they are listed as a % Rate, write that % rate here. If DSH is not included, write 'N/A'." + }, + { + "field_name": "DSH_FEE_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If DSH adjustments are included, and they are listed as a $ value, write that $ value here. If DSH is not included, write 'N/A'." + }, + { + "field_name": "IME_IND", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "Are adjustments for Indirect Medical Education (IME) included in the reimbursement? Return 'Y' or 'N'." + }, + { + "field_name": "IME_PCT_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If IME adjustments are included, and they are listed as a % Rate, write that % rate here. If IME is not included, write 'N/A'." + }, + { + "field_name": "IME_FEE_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If IME adjustments are included, and they are listed as a $ value, write that $ value here. If IME is not included, write 'N/A'." + }, + { + "field_name": "NTAP_IND", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "Are adjustments for New Technology Add-On Payments (NTAP) included in the reimbursement? Return 'Y' or 'N'." + }, + { + "field_name": "NTAP_PCT_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If NTAP adjustments are included, and they are listed as a % Rate, write that % rate here. If NTAP is not included, write 'N/A'." + }, + { + "field_name": "NTAP_FEE_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If NTAP adjustments are included, and they are listed as a $ value, write that $ value here. If NTAP is not included, write 'N/A'." + }, + { + "field_name": "UC_IND", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "Are adjustments for UC included in the reimbursement? Return 'Y' or 'N'." + }, + { + "field_name": "UC_PCT_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If UC adjustments are included, and they are listed as a % Rate, write that % rate here. If UC is not included, write 'N/A'." + }, + { + "field_name": "UC_FEE_RATE", + "relationship": "one_to_n", + "field_type": "facility_adjustments_breakout", + "prompt": "If UC adjustments are included, and they are listed as a $ value, write that $ value here. If UC is not included, write 'N/A'." + } ] \ No newline at end of file diff --git a/fieldExtraction/src/prompts/prompt_templates.py b/fieldExtraction/src/prompts/prompt_templates.py index ee3d3b4..bb65407 100644 --- a/fieldExtraction/src/prompts/prompt_templates.py +++ b/fieldExtraction/src/prompts/prompt_templates.py @@ -1188,3 +1188,26 @@ def FULL_CONTEXT_ADDITIONAL_INSTRUCTIONS(allow_na): return " Only provide an answer if that answer clearly applies to the ENTIRE contract. Otherwise, answer N/A." else: return " Do NOT leave this field N/A. Choose the most appropriate answer based on the context." + + +def FACILITY_ADJUSTMENT_BREAKOUT(adjustment_term, questions): + return f"""[OBJECTIVE] +Analyze a given term from a Payer-Provider contract: + +[A: OUTPUT FORMAT] +Populate a JSON dictionary with the following fields: +{questions} + +For each _IND field - if the answer is 'Y', then either the _PCT_RATE field or the _FEE_RATE field MUST be populated. +If it is not clear which should be populated, then populate '100%' for the _PCT_RATE field. + +Here is the term to analyze: +{adjustment_term} + +Briefly explain your answer, then put your final answer in JSON dictionary format. +""" + + + + +