Files
doczyai-pipelines/src/pipelines/clients/bcbs_promise/prompts/prompt_calls.py
T
Praneel Panchigar a936e0ce05 Merged in bugfix/retire_stale_client_file_processing (pull request #961)
Return None for dashboard output when dashboard postprocessing is off

* Return None for dashboard output when dashboard postprocessing is off

FINAL_RESULT_DF_DASHBOARD was initialized as an empty DataFrame even
when RUN_DASHBOARD_POSTPROCESSING was False, causing downstream code
to needlessly process it (reorder_columns, etc). Now returns None
when dashboard is not requested, matching the postprocess() contract.

* Merged dev into bugfix/retire_stale_client_file_processing

* Merge dev (with revert) into feature branch

* Re-apply retire stale client file_processing changes

Revert of the revert (4f53b528) to restore the original changes
from the feature branch for proper PR review.

* Merge branch 'bugfix/retire_stale_client_file_processing' of bitbucket.org:aarete/doczy.ai into bugfix/retire_stale_client_file_processing


Approved-by: Katon Minhas
2026-04-16 21:43:00 +00:00

54 lines
2.0 KiB
Python

"""BCBS Promise client prompt_calls overrides.
Only functions that MUST differ from SaaS live here. Everything else falls
through to `src/pipelines/saas/prompts/prompt_calls.py` via the resolver shim
at `src/pipelines/shared/prompts/prompt_calls.py`.
See `docs/client_prompt_calls_drift_analysis.md` for the audit that retired
the previous override set.
"""
import logging
import src.prompts.prompt_templates as prompt_templates
from src.utils import llm_utils, string_utils
# CLIENT OVERRIDE — INTENTIONAL DIVERGENCE FROM SAAS
# Reason: BCBS requires strict YES equality (`final_answer == "YES"`) rather
# than SaaS's tolerant `"YES" in final_answer`. Borderline LLM responses
# ("Yes.", "YES, ...") must be treated as NOT valid reimbursements for this
# client. Requires business sign-off before alignment.
# Reviewed: 2026-04-07
def validate_reimbursements_for_llm(answer_dict: dict[str, str], filename: str) -> bool:
"""Use LLM to determine if a service has actual reimbursement methodology."""
if isinstance(answer_dict, str):
answer_dict = {"SERVICE_TERM": "", "REIMB_TERM": answer_dict}
if string_utils.is_empty(
answer_dict.get("SERVICE_TERM", None)
) or string_utils.is_empty(answer_dict.get("REIMB_TERM", None)):
logging.warning(
f"Missing SERVICE_TERM or REIMB_TERM in {filename}: {answer_dict}"
)
return False
service_term, reimb_term = answer_dict["SERVICE_TERM"], answer_dict["REIMB_TERM"]
prompt, _parser = prompt_templates.VALIDATE_REIMBURSEMENTS_PROMPT(
service_term, reimb_term
)
logging.debug(f"Prompt for reimbursement validation in {filename}:\n{prompt}")
llm_response = llm_utils.invoke_claude(
prompt,
"sonnet_latest",
filename,
cache=True,
instruction=prompt_templates.VALIDATE_REIMBURSEMENTS_INSTRUCTION(),
)
logging.debug(
f"LLM response for reimbursement validation in {filename}:\n{llm_response}"
)
final_answer = _parser(llm_response)
return "YES" in final_answer