diff --git a/src/prompts/prompt_templates.py b/src/prompts/prompt_templates.py index 01eebc4..abd8e58 100644 --- a/src/prompts/prompt_templates.py +++ b/src/prompts/prompt_templates.py @@ -650,26 +650,52 @@ DECISION LOGIC: Keep only statements whose scope matches SERVICE: - "All services in this exhibit" / "All services" / "All covered services" → applies to any service - "Inpatient services only" → does NOT apply to outpatient services - - Lesser-of statements containing "listed below", "rates below", "set forth below" + - Lesser-of statements containing "listed below", "rates below", "set forth below" → applies to ANY service rate that appears after that statement in the exhibit text, - regardless of section headers - + regardless of section headers + + EXCEPTION CLAUSE HANDLING: + - If a lesser-of statement has an exception clause (e.g., "except for services in Table X", + "excluding procedures listed below"), and SERVICE appears in that exception list: + + a) The ENTIRE payment rule in that sentence/paragraph does NOT apply to SERVICE. + This includes all comparisons, caps, and conditions within that grammatical unit. + + b) ONLY overarching constraints still apply to SERVICE. + Test: Can this constraint be read independently without referencing the excepted statement? + If YES → it still applies + If NO → it's part of the excepted rule and does NOT apply + + c) ALWAYS re-scan the exhibit text for standalone constraints after excluding the payment rule. + Do not stop at step (a) — even if the main rule is excluded, independent constraints MUST be applied. + + Examples: + - SEPARATE sentence: "In no event shall reimbursement exceed the amount billed by Provider." + → Still applies (passes independence test — standalone constraint) + - SAME sentence: "Compensation shall be the lesser of 80% of the scheduled fee or usual + and customary charges, capped at the Provider's submitted amount" + → Does NOT apply (entire grammatical unit is the excepted rule) + If nothing applies → return N/A 3. COMBINE & FORMAT - Substitution rules: + Substitution: - Replace generic "rates" / "contracted rates" with METHODOLOGY value - - Preserve original "lesser of" phrasing (don't add if not present) + - 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" -OUTPUT FORMAT: -Return a JSON list with a single string containing the combined statement. - -Examples: -- ["Lab Test paid at lesser of $100, billed charges, or 110% Medicare"] -- ["Radiology paid at $250 or charges"] -- ["N/A"] + Validation: + - The output string MUST contain METHODOLOGY value + - If METHODOLOGY is a simple rate (e.g., "$30.00") and is missing from the final string, prepend it + - If METHODOLOGY is a complex formula (e.g., "80% of State Medicaid fee schedule", "the lesser of (i) X or (ii) Y"), verify it appears as the base of the output + + Examples: + - ["lesser of $100, billed charges, or 110% Medicare"] + - ["$30.00 not to exceed Provider's billed charges"] + - ["N/A"] Example — Intra-exhibit statement references another exhibit → N/A: - METHODOLOGY: "per visit basis at payment rates established in Attachment A"