Merged in bugfix/dynamic_issues (pull request #832)
Bugfix/dynamic issues * Add debug print statements for dynamic primary field discovery and 1:1 escalation tracking * Add reimb_term to bill type CD determination context - Updated fill_bill_type() to accept reimb_term parameter - Modified FILL_BILL_TYPE prompt to include reimbursement term in context - First attempt now uses: service term + reimbursement term - Second attempt uses: service term + reimbursement term + exhibit text - Updated extract_codes_from_service() to pass REIMB_TERM to fill_bill_type() * Remove debug print statements from dynamic_funcs.py and file_processing.py - Removed all DEBUG print statements for dynamic primary discovery - Removed debug prints for field discovery status and 1:1 escalation evaluation - Removed debug prints for exhibit level answers and final summaries - Removed debug comment about one_to_one_fields creation - Cleaned up all temporary debugging code * Merge branch 'main' into bugfix/dynamic_issues * Remove duplicate one_to_one_fields FieldSet initialization from process_file Approved-by: Katon Minhas
This commit is contained in:
committed by
Katon Minhas
parent
d97a31aa5b
commit
69f23653a1
@@ -408,7 +408,7 @@ def code_last_check(service, filename):
|
||||
return claude_answer_final
|
||||
|
||||
|
||||
def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MAPPING, exhibit_text=None):
|
||||
def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MAPPING, reimb_term=None, exhibit_text=None):
|
||||
"""
|
||||
Fills the BILL_TYPE_CD and BILL_TYPE_CD_DESC fields in the answer dictionary.
|
||||
|
||||
@@ -417,6 +417,7 @@ def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MA
|
||||
answer_dict (dict): The answer dictionary to update.
|
||||
BILL_TYPE_MAPPING (dict): Mapping from codes to descriptions.
|
||||
BILL_TYPE_REVERSE_MAPPING (dict): Mapping from descriptions to codes.
|
||||
reimb_term (str, optional): The reimbursement term for additional context.
|
||||
exhibit_text (str, optional): Full exhibit text for contextual analysis.
|
||||
|
||||
Returns:
|
||||
@@ -425,18 +426,18 @@ def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MA
|
||||
|
||||
valid_bill_type = sorted(list(set(BILL_TYPE_MAPPING.values())))
|
||||
|
||||
# First attempt: Service term only
|
||||
# First attempt: Service term + reimbursement term
|
||||
claude_answer_raw = llm_utils.invoke_claude(
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type, exhibit_text=None),
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type, reimb_term=reimb_term, exhibit_text=None),
|
||||
"sonnet_latest",
|
||||
""
|
||||
)
|
||||
claude_answer_final = string_utils.universal_json_load(claude_answer_raw)
|
||||
|
||||
# Second attempt: Service term + exhibit context (if first attempt failed and context available)
|
||||
# Second attempt: Service term + reimbursement term + exhibit context (if first attempt failed and context available)
|
||||
if not claude_answer_final and exhibit_text:
|
||||
claude_answer_raw = llm_utils.invoke_claude(
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type, exhibit_text=exhibit_text),
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type, reimb_term=reimb_term, exhibit_text=exhibit_text),
|
||||
"sonnet_latest",
|
||||
""
|
||||
)
|
||||
@@ -599,11 +600,13 @@ def extract_codes_from_service(answer_dict, constants: Constants):
|
||||
# Fill Bill Type if not filled
|
||||
if string_utils.is_empty(bill_type):
|
||||
exhibit_text = answer_dict.get("EXHIBIT_TEXT", None)
|
||||
reimb_term = answer_dict.get("REIMB_TERM", None)
|
||||
answer_dict = fill_bill_type(
|
||||
service,
|
||||
answer_dict,
|
||||
constants.BILL_TYPE_MAPPING,
|
||||
constants.BILL_TYPE_REVERSE_MAPPING,
|
||||
reimb_term=reimb_term,
|
||||
exhibit_text=exhibit_text,
|
||||
)
|
||||
|
||||
|
||||
@@ -242,7 +242,6 @@ def get_dynamic_one_to_one_fields(answer_dicts: list[dict[str, str]], constants:
|
||||
one_to_one_fields, field_to_add, answer_dicts, constants
|
||||
)
|
||||
|
||||
|
||||
return one_to_one_fields
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ def process_file(file_object, constants: Constants, run_timestamp):
|
||||
|
||||
# ONE TO ONE PROCESSING
|
||||
if process_one_to_one:
|
||||
|
||||
one_to_one_results = run_one_to_one_prompts(
|
||||
filename,
|
||||
contract_text,
|
||||
@@ -265,7 +264,6 @@ 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)
|
||||
|
||||
@@ -821,13 +821,22 @@ Briefly explain your answer, then put your final answer in |pipes|.
|
||||
"""
|
||||
|
||||
|
||||
def FILL_BILL_TYPE(service, choices, exhibit_text=None):
|
||||
def FILL_BILL_TYPE(service, choices, reimb_term=None, exhibit_text=None):
|
||||
# Build reimbursement term section conditionally
|
||||
reimb_term_section = ""
|
||||
if reimb_term and not string_utils.is_empty(reimb_term):
|
||||
reimb_term_section = f"""
|
||||
[REIMBURSEMENT TERM]
|
||||
Here is the Reimbursement Term associated with the Service Term:
|
||||
{reimb_term.replace('"', "'")}
|
||||
"""
|
||||
|
||||
# Build exhibit context section conditionally
|
||||
exhibit_context_section = ""
|
||||
if exhibit_text:
|
||||
exhibit_context_section = f"""
|
||||
[EXHIBIT CONTEXT]
|
||||
If the Service Term alone does not provide sufficient information, examine the following exhibit text for additional context about where the service is performed:
|
||||
If the Service Term and Reimbursement Term together do not provide sufficient information, examine the following exhibit text for additional context about where the service is performed:
|
||||
{exhibit_text.replace('"', "'")}
|
||||
"""
|
||||
|
||||
@@ -852,7 +861,7 @@ Here are the descriptions to choose from:
|
||||
[CONTEXT]
|
||||
Here is the Service Term to analyze:
|
||||
{service.replace('"', "'")}
|
||||
{exhibit_context_section}
|
||||
{reimb_term_section}{exhibit_context_section}
|
||||
[OUTPUT FORMAT]
|
||||
Briefly explain your answer, then return your final answer in JSON list format.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user