Merged in bugfix/generic_lesser_of (pull request #880)

Bugfix/generic lesser of

* Updated lesser of ditribution and lesser of check prompt

* Remove excessive logging

* Updated prompt for combining and formatting lesser of statement and reimb term

* Code clean upt

* Removed unneeded instruction on output format

* style: format prompt_calls.py with black


Approved-by: Katon Minhas
This commit is contained in:
Sha Brown
2026-02-11 22:17:50 +00:00
committed by Katon Minhas
parent 93547e7b0d
commit 70215bbc69
+38 -12
View File
@@ -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"