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:
Praneel Panchigar
2026-01-08 22:41:52 +00:00
committed by Katon Minhas
parent d97a31aa5b
commit 69f23653a1
4 changed files with 20 additions and 11 deletions
+8 -5
View File
@@ -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,
)