Merged in bugfix/bill_type_code_fixes (pull request #819)
Bugfix/bill type code fixes * 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 Resolved merge conflicts in: - fieldExtraction/src/investment/dynamic_funcs.py (merged debug print statements) - fieldExtraction/src/investment/file_processing.py (merged debug statements and exhibit inheritance code) All conflicts resolved successfully. * Update FILL_BILL_TYPE prompt with place-of-service priority and optional exhibit_text - Add optional exhibit_text parameter to FILL_BILL_TYPE function - Update instructions to prioritize place-of-service over service-only terminology - Add new examples: 'home dialysis' and 'dialysis' while keeping original examples - Add conditional exhibit context section when exhibit_text is provided - Maintains backward compatibility (exhibit_text defaults to None) Ref: PLAN_BILL_TYPE_CD_IMPROVEMENTS.md * Implement two-step bill type CD determination with exhibit text fallback - Add EXHIBIT_TEXT to answer_dict in combine_one_to_n() for contextual analysis - Update fill_bill_type() to use two-step approach: 1. First attempt: service term only (no exhibit text) 2. Second attempt: service term + exhibit text (only if first fails) - Update extract_codes_from_service() to pass exhibit_text to fill_bill_type() - Add debug print when full exhibit text context is used - More efficient: only makes second LLM call when service term alone fails Ref: PLAN_BILL_TYPE_CD_IMPROVEMENTS.md * Remove debug print statement and merge main into bill_type_code_fixes - Remove debug print statement from fill_bill_type() in code_funcs.py - Merge latest changes from main branch - Includes updates to prompt_templates.py (payer_name parameter) - Includes updates to file_processing.py (provider info ordering) - Includes updates to aarete_derived.py, crosswalk mappings, and tin_npi_funcs * Remove remaining debug print statements from dynamic_funcs.py and file_processing.py Approved-by: Katon Minhas
This commit is contained in:
committed by
Katon Minhas
parent
b64e1fe4cc
commit
85f2c8cecc
@@ -408,24 +408,41 @@ def code_last_check(service, filename):
|
||||
return claude_answer_final
|
||||
|
||||
|
||||
def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MAPPING):
|
||||
def fill_bill_type(service, answer_dict, BILL_TYPE_MAPPING, BILL_TYPE_REVERSE_MAPPING, exhibit_text=None):
|
||||
"""
|
||||
Fills the BILL_TYPE_CD and BILL_TYPE_CD_DESC fields in the answer dictionary.
|
||||
|
||||
Args:
|
||||
service (str): The service term.
|
||||
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.
|
||||
exhibit_text (str, optional): Full exhibit text for contextual analysis.
|
||||
|
||||
Returns:
|
||||
dict: The updated answer dictionary.
|
||||
"""
|
||||
|
||||
valid_bill_type = sorted(list(set(BILL_TYPE_MAPPING.values())))
|
||||
|
||||
# First attempt: Service term only
|
||||
claude_answer_raw = llm_utils.invoke_claude(
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type), "sonnet_latest", ""
|
||||
prompt_templates.FILL_BILL_TYPE(service, valid_bill_type, 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)
|
||||
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),
|
||||
"sonnet_latest",
|
||||
""
|
||||
)
|
||||
claude_answer_final = string_utils.universal_json_load(claude_answer_raw)
|
||||
|
||||
# Keep legacy behavior: return answer_dict unchanged if no result found
|
||||
if not claude_answer_final:
|
||||
return answer_dict
|
||||
|
||||
@@ -581,11 +598,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)
|
||||
answer_dict = fill_bill_type(
|
||||
service,
|
||||
answer_dict,
|
||||
constants.BILL_TYPE_MAPPING,
|
||||
constants.BILL_TYPE_REVERSE_MAPPING,
|
||||
exhibit_text=exhibit_text,
|
||||
)
|
||||
|
||||
# Get list of codes we want implicit - based on claim type
|
||||
|
||||
Reference in New Issue
Block a user