From ca800b0d7e526b62e074f3f7ad8d3c76b3205d22 Mon Sep 17 00:00:00 2001 From: Mayank Aamseek Date: Tue, 24 Feb 2026 15:35:34 +0000 Subject: [PATCH] Merged in bugfix/DAIP2-1913-lesser-of-indicator-issues (pull request #889) Bugfix/DAIP2-1913 lesser of indicator issues * contract title fixes * Add instruction to strip hyphens from TIN and NPI * prompt update * Merge branch 'bugfix/auto-renewal-term' into bugfix/DAIP2-1699-issue-tracker-fixes-one-to-one-dates-prov-info * removed print statements * pipeline error fixed * signed_ind logic changed * signatory_ind logic updated * prompt update * prompt update * pipeline error fixed * Merge branch 'DEV' into bugfix/DAIP2-1699-issue-tracker-fixes-one-to-one-dates-prov-info * Merge branch 'DEV' into bugfix/DAIP2-1699-issue-tracker-fixes-one-to-one-dates-prov-info * requested changes applied * test case added * prompt update * contract title prompt update * prompt update * Merge branch 'DEV' into DAIP2-1898-one-to-one-issues-filename-tin-auto-renewal-and-contract-title * handle nested cases of lesser_of and greater_of * Merge branch 'DEV' into bugfix/DAIP2-1913-lesser-of-indicator-issues * pipeline error fixed Approved-by: Siddhant Medar --- src/pipelines/saas/prompts/prompt_calls.py | 3 +++ src/prompts/prompt_templates.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pipelines/saas/prompts/prompt_calls.py b/src/pipelines/saas/prompts/prompt_calls.py index 5df1bf8..eb06b3e 100644 --- a/src/pipelines/saas/prompts/prompt_calls.py +++ b/src/pipelines/saas/prompts/prompt_calls.py @@ -760,6 +760,9 @@ def prompt_lesser_of_distribution( instruction=prompt_templates.LESSER_OF_DISTRIBUTION_INSTRUCTION(), usage_label="LESSER_OF_DISTRIBUTION", ) + logging.debug( + f"LLM raw output for lesser-of distribution on page {page_num} for service '{service_term}': {llm_answer_raw}" + ) # Check if LLM determined no lesser-of applies if "N/A" in llm_answer_raw: diff --git a/src/prompts/prompt_templates.py b/src/prompts/prompt_templates.py index 739cb0c..7d12b97 100644 --- a/src/prompts/prompt_templates.py +++ b/src/prompts/prompt_templates.py @@ -694,7 +694,7 @@ DECISION LOGIC: - Preserve original phrasing exactly — do not paraphrase, abbreviate, or alter wording - Do not include service code or description in the output - Deduplicate identical constraints - - Join multiple terms: "lesser of X, Y, or Z" + - Join multiple terms preserving meaning through nesting or other structures: e.g., "[the lesser of [the greater of A or B] and C]", "lesser of X, Y, or Z". Ensure brackets and nesting are used appropriately to maintain the original meaning. Validation: - The output string MUST contain METHODOLOGY value @@ -704,6 +704,7 @@ DECISION LOGIC: Examples: - ["lesser of $100, billed charges, or 110% Medicare"] - ["$30.00 not to exceed Provider's billed charges"] + - ["the lesser of [the greater of 100% of the State Medicaid fee schedule or Affinity's standard fee schedule] and billed charges"] - ["N/A"] Example — Intra-exhibit statement references another exhibit → N/A: @@ -954,6 +955,7 @@ Analyze a given term from a Payer-Provider contract and extract key fields. - Carefully extract **every individual reimbursement clause within the comparison**. - For example: "Lesser of (i) 80% of billed charges, (ii) Medicare rate, or (iii) $400" should yield **three separate JSON dictionaries**. - **Do not skip any clause**. Every item compared under "lesser of", "greater of", "equal to", or similar comparative logic must be represented as its own dictionary in the output list. + - If the comparative structure includes nested comparisons (e.g., "the lesser of [the greater of A or B] and C"), each one of A,B and C must be extracted as its own dictionary. LESSER_OF and GREATER_OF are determined only by the immediate parent comparison. So even if it is part of outer LESSER_OF comparison, LESSER_OF should be "N" if GREATER_OF is "Y". In the case of the above example, dictionaries A and B should have GREATER_OF as "Y" and LESSER_OF as "N". Dictionary C should have LESSER_OF as "Y" and GREATER_OF as "N". - **IMPORTANT**: For each component, classify the `AARETE_DERIVED_REIMB_METHOD` based on the INDIVIDUAL component, not the overall structure. - If the methodology includes **additional reimbursement terms** beyond the "lesser of" structure (e.g., per diem charges, or carve-out payments): - **These must also be extracted as separate JSON dictionaries** in the same list.