FAILURE MAP
← Case archive

FA-63946 / Medication dosing calculations / Open access

Cockcroft-Gault renal dose adjustment: severe band interval extension · case 01

Severe impairment halves the dose but keeps the original interval.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The severe band tuple omits the interval doubling that the moderate band applies.

VERIFIED REPAIR

Double the interval in the severe band as well as halving the dose.

Unsuccessful approach: Adding 12 hours only equals doubling for q12h orders.

Case contract

Input {age, weight_kg, scr, sex, dose_mg, interval_h}. Toy rule: if age >= 65, serum creatinine is raised to at least 0.8 mg/dL. CrCl = (140-age)*weight/(72*scr), times 0.85 for sex "F", then truncated to an integer. Bands: CrCl >= 60 unchanged; 30-59 same dose, interval doubled; 15-29 dose halved and rounded down to a 5 mg multiple, interval doubled; < 15 action AVOID. Return {crcl, action, dose_mg, interval_h} (AVOID omits dose and interval).

Why this case matters

Renal dose adjustment chains a creatinine clearance estimate with band lookups; each stage has a distinct boundary and ordering rule.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    scr = Fraction(str(x['scr']))
    if x['age'] >= 65:
        scr = max(scr, Fraction(4, 5))
    crcl = Fraction(140 - x['age']) * Fraction(str(x['weight_kg'])) / (72 * scr)
    if x['sex'] == 'F':
        crcl = crcl * Fraction(17, 20)
    c = math.floor(crcl)
    dose, tau = x['dose_mg'], x['interval_h']
    if c >= 60:
        pass
    elif c >= 30:
        tau = tau * 2
    elif c >= 15:
        dose, tau = dose // 2 // 5 * 5, tau
    else:
        return {'crcl': c, 'action': 'AVOID'}
    return {'crcl': c, 'action': 'GIVE', 'dose_mg': dose, 'interval_h': tau}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('young adult normal function',
   {'age': 31, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 79, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 141, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 71, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 260, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 260, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 6},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 12}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 175, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 85, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 32, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 80, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 143, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 72, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 270, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 270, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 195, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 95, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 33, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 104, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 82, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 145, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 73, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 39, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 280, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 280, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 18},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 36}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 395, 'interval_h': 24},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 195, 'interval_h': 48}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 34, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 103, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 83, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 148, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 74, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 290, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 290, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 24},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 48}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 155, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 75, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 35, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 102, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 84, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 150, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 75, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 30},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 60}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 135, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 65, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
young adult normal function{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}Passed
65-year-old low creatinine floored{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}Passed
young adult low creatinine not floored{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}Passed
elderly high creatinine kept{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}Passed
clearance 59.7 truncates into moderate band{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}Passed
clearance exactly 30{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}Passed
severe band halves dose{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 8}{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16}Failed
clearance under 15 avoided{'action': 'AVOID', 'crcl': 8}{'action': 'AVOID', 'crcl': 8}Passed

SHA-256 / fc71b8ed1f64ae8c288d0b611ff23fc6ff7469f66990571d2c6f9613e23a97fb

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    scr = Fraction(str(x['scr']))
    if x['age'] >= 65:
        scr = max(scr, Fraction(4, 5))
    crcl = Fraction(140 - x['age']) * Fraction(str(x['weight_kg'])) / (72 * scr)
    if x['sex'] == 'F':
        crcl = crcl * Fraction(17, 20)
    c = math.floor(crcl)
    dose, tau = x['dose_mg'], x['interval_h']
    if c >= 60:
        pass
    elif c >= 30:
        tau = tau * 2
    elif c >= 15:
        dose, tau = dose // 2 // 5 * 5, tau + 12
    else:
        return {'crcl': c, 'action': 'AVOID'}
    return {'crcl': c, 'action': 'GIVE', 'dose_mg': dose, 'interval_h': tau}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('young adult normal function',
   {'age': 31, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 79, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 141, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 71, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 260, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 260, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 6},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 12}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 175, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 85, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 32, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 80, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 143, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 72, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 270, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 270, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 195, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 95, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 33, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 104, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 82, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 145, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 73, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 39, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 280, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 280, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 18},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 36}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 395, 'interval_h': 24},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 195, 'interval_h': 48}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 34, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 103, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 83, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 148, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 74, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 290, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 290, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 24},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 48}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 155, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 75, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 35, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 102, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 84, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 150, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 75, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 30},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 60}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 135, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 65, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
young adult normal function{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}Passed
65-year-old low creatinine floored{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}Passed
young adult low creatinine not floored{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}Passed
elderly high creatinine kept{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}Passed
clearance 59.7 truncates into moderate band{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}Passed
clearance exactly 30{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}Passed
severe band halves dose{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 20}{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16}Failed
clearance under 15 avoided{'action': 'AVOID', 'crcl': 8}{'action': 'AVOID', 'crcl': 8}Passed

SHA-256 / 7a356771adb3c791e764505e385e4e58c8a0b683e02ec18c62198efeac86c7b9

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    scr = Fraction(str(x['scr']))
    if x['age'] >= 65:
        scr = max(scr, Fraction(4, 5))
    crcl = Fraction(140 - x['age']) * Fraction(str(x['weight_kg'])) / (72 * scr)
    if x['sex'] == 'F':
        crcl = crcl * Fraction(17, 20)
    c = math.floor(crcl)
    dose, tau = x['dose_mg'], x['interval_h']
    if c >= 60:
        pass
    elif c >= 30:
        tau = tau * 2
    elif c >= 15:
        dose, tau = dose // 2 // 5 * 5, tau * 2
    else:
        return {'crcl': c, 'action': 'AVOID'}
    return {'crcl': c, 'action': 'GIVE', 'dose_mg': dose, 'interval_h': tau}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('young adult normal function',
   {'age': 31, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 79, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 61, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 141, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 71, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 260, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 260, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 6},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 12}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 175, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 85, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 32, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 105, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 80, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 62, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 143, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 72, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 40, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 270, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 270, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 195, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 95, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 33, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 104, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 82, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 63, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 145, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 73, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 39, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 280, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 280, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 18},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 36}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 395, 'interval_h': 24},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 195, 'interval_h': 48}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 34, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 103, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 83, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 64, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 148, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 74, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 290, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 290, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 24},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 48}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 155, 'interval_h': 8},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 75, 'interval_h': 16}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})],
 [('young adult normal function',
   {'age': 35, 'weight_kg': 70, 'scr': '1.0', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 102, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('65-year-old low creatinine floored',
   {'age': 65, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 84, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('young adult low creatinine not floored',
   {'age': 40, 'weight_kg': 65, 'scr': '0.6', 'sex': 'M', 'dose_mg': 500, 'interval_h': 8},
   {'crcl': 150, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 8}),
  ('elderly high creatinine kept',
   {'age': 75, 'weight_kg': 70, 'scr': '1.4', 'sex': 'F', 'dose_mg': 500, 'interval_h': 12},
   {'crcl': 38, 'action': 'GIVE', 'dose_mg': 500, 'interval_h': 24}),
  ('clearance 59.7 truncates into moderate band',
   {'age': 80, 'weight_kg': '71.6', 'scr': '1.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 59, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 24}),
  ('clearance exactly 30',
   {'age': 80, 'weight_kg': 72, 'scr': '2.0', 'sex': 'M', 'dose_mg': 300, 'interval_h': 30},
   {'crcl': 30, 'action': 'GIVE', 'dose_mg': 300, 'interval_h': 60}),
  ('severe band halves dose',
   {'age': 80, 'weight_kg': 72, 'scr': '3.0', 'sex': 'M', 'dose_mg': 135, 'interval_h': 6},
   {'crcl': 20, 'action': 'GIVE', 'dose_mg': 65, 'interval_h': 12}),
  ('clearance under 15 avoided',
   {'age': 80, 'weight_kg': 72, 'scr': '6.0', 'sex': 'F', 'dose_mg': 300, 'interval_h': 12},
   {'crcl': 8, 'action': 'AVOID'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
young adult normal function{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 105, 'dose_mg': 500, 'interval_h': 8}Passed
65-year-old low creatinine floored{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8}Passed
young adult low creatinine not floored{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}{'action': 'GIVE', 'crcl': 141, 'dose_mg': 500, 'interval_h': 8}Passed
elderly high creatinine kept{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}{'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24}Passed
clearance 59.7 truncates into moderate band{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}{'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24}Passed
clearance exactly 30{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}{'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12}Passed
severe band halves dose{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16}{'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16}Passed
clearance under 15 avoided{'action': 'AVOID', 'crcl': 8}{'action': 'AVOID', 'crcl': 8}Passed

SHA-256 / 3327c3f491dee428cc7c3a2e0dfbde28a988fea4f9787319b0f75603f53717df

Verification & scope

A deterministic toy software model with explicitly stipulated thresholds and formulas; it is not clinical guidance, not a validated medical calculator, and makes no claim of conformance to any published protocol. Numbered variants vary patient and order inputs. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:19.660426+00:00.

Case digest / bfddf9f4fc4054a7bdc4fcdc2d3a7a6467f1b682882d6b0aec604d0de71c868e