Merged in bugfix/dynamic_issuefixes-clean (pull request #813)

Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

* Fix LOB_PROGRAM_RELATIONSHIP extraction and preserve debugging code

- Add format requirements to LOB_RELATIONSHIP_INSTRUCTION for proper caching
- Strengthen LOB_RELATIONSHIP prompt with explicit pipe delimiter requirements
- Preserve all DEBUG blocks and print statements in dynamic_funcs.py and file_processing.py
- Update crosswalk mappings and gitignore
- Ensure format instructions are cached at API level to prevent missing pipe delimiters

* Merge main into bugfix/dynamic_issuefixes-clean and remove all debug print statements

* Remove redundant one_to_one_fields initialization to match main


Approved-by: Katon Minhas
This commit is contained in:
Praneel Panchigar
2025-12-17 20:42:13 +00:00
committed by Katon Minhas
parent f26b83bd0b
commit d3bfec0b6b
8 changed files with 21 additions and 11 deletions
@@ -19,7 +19,7 @@
},
"Fidelis" : {
"Medicaid Managed Care" : "Medicaid"
},
"Parkland" : {
"HEALTHfirst" : "Medicaid",
@@ -7,6 +7,7 @@
"Children's Health Insurance Program (CHIP)" : "CHIP",
"Children's Health Insurance Program Perinate (CHIP-P)" : "CHIPP",
"Healthy Kids" : "CHIP",
"Medicaid Managed Care" : "MMC",
"Affordable Care Act (ACA)" : "ACA",
"Aged, Blind, and Disabled (ABD)" : "ABD",
"Alternative Benefit Plan (ABP)" : "ABP",
@@ -6,6 +6,7 @@
"mapping": {
"CHIP" : "Medicaid",
"CHIPP" : "Medicaid",
"MMC" : "Medicaid",
"ACA" : "Marketplace",
"ABD" : "Medicaid",
"ABP" : "Medicaid",
@@ -35,7 +35,7 @@ def dynamic_primary(
dynamic_reimbursement_fields = FieldSet()
exhibit_level_answer_dict = {}
for field in dynamic_primary_fields.fields:
exhibit_text_answer = prompt_calls.prompt_dynamic_primary(
exhibit_text,
@@ -240,7 +240,7 @@ def get_dynamic_one_to_one_fields(answer_dicts: list[dict[str, str]], constants:
) # Try base_field first, fall back to field_name if base_field is None/empty
one_to_one_fields = add_one_to_one_field(
one_to_one_fields, field_to_add, answer_dicts, constants
)
)
return one_to_one_fields
@@ -59,7 +59,7 @@ def process_file(file_object, constants: Constants, run_timestamp):
logging.info(f"{datetime_str()} Fields not configured for One to N, Skipping - {filename}")
# ONE TO ONE PROCESSING
if process_one_to_one:
if process_one_to_one:
one_to_one_results = run_one_to_one_prompts(
filename,
contract_text,
@@ -262,7 +262,7 @@ def run_one_to_n_prompts(text_dict: dict[str, str],
dynamic_one_to_one_fields = dynamic_funcs.get_dynamic_one_to_one_fields(
one_to_n_results, constants
)
################## CONVERT TO DF ##################
one_to_n_df = pd.DataFrame(one_to_n_results)
@@ -273,7 +273,7 @@ def process_page_one_to_n(text_dict: dict[str, str], exhibit_page_nums: list[str
page_text = text_dict[page_num]
exhibit_text_simplified = preprocessing_funcs.simplify_exhibit(text_dict, exhibit_page_nums, page_num)
############################### Reimbursement Primary ###############################
reimbursement_level_answers = one_to_n_funcs.reimbursement_level(
page_text,
@@ -209,7 +209,6 @@ def prompt_carveout_check(
instruction=prompt_templates.CARVEOUT_CHECK_INSTRUCTION(),
usage_label="CARVEOUT_CHECK",
)
logging.debug(f"Carveout/ special case check for {filename}: {llm_answer_raw}")
carveout_answer = string_utils.extract_text_from_delimiters(
llm_answer_raw, Delimiter.PIPE
@@ -1359,14 +1359,15 @@ It was previously identified that the Exhibit contains the following LOB and Pro
- Some examples of language indicating an exlusive relationship are "Medicaid: CHIP", "Medicare advantage only", and "Duals - only the following SNP programs"
- If the programs are represented with different sections of the Exhibit under the same higher-level LOB section, this is indicative of an Exclusive relationship.
- For example, if an exhibit has a header that says "Medicaid & CHIP", but then there are different subsections within the Exhibit for "Medicaid" and "CHIP", this is an Exclusive relationship even though the "&" language is Inclusive.
- Closely read the text, then write either |Inclusive| or |Exclusive| to indicate the nature of the relationship.
[CONTEXT]
Here is the Exhibit to be analyzed:
{exhibit_text.replace('"', "'")}
[OUTPUT]
Briefly explain your reasoning, then put your final answer in |pipes|.
[OUTPUT FORMAT - REQUIRED]
You MUST format your response with pipe delimiters. Example format:
"Based on the analysis... |Inclusive|" or "The relationship is... |Exclusive|"
Your final answer MUST be enclosed in pipe delimiters: |Inclusive| or |Exclusive|
"""
@@ -1389,7 +1390,13 @@ def DERIVED_TERM_DATE_PROMPT(
def LOB_RELATIONSHIP_INSTRUCTION() -> str:
return (
"[OBJECTIVE]\n"
"Determine if LOB and Program relationship in the exhibit is Inclusive or Exclusive."
"Determine if LOB and Program relationship in the exhibit is Inclusive or Exclusive.\n\n"
"[OUTPUT FORMAT - CRITICAL]\n"
"You MUST format your response as follows:\n"
"1. Briefly explain your reasoning\n"
"2. Then put your final answer in pipe delimiters: |Inclusive| or |Exclusive|\n"
"Example: 'The contract shows... |Inclusive|'\n"
"Your response MUST include the pipe delimiters (|) around your final answer."
)