FA-63926 / Medication dosing calculations / Open access
Cockcroft-Gault renal dose adjustment: creatinine floor direction · case 01
Elderly patients with impaired function are assigned a creatinine of 0.8 and look healthy.
ROOT CAUSE
The floor is written with min(), capping creatinine at 0.8 instead of raising it to at least 0.8.
VERIFIED REPAIR
Use max(scr, 0.8) so only values below 0.8 are raised.
Unsuccessful approach: Overwriting creatinine with 0.8 unconditionally discards genuinely elevated values.
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 = min(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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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': 105, 'dose_mg': 500, 'interval_h': 8} | {'action': 'GIVE', 'crcl': 79, 'dose_mg': 500, 'interval_h': 8} | Failed |
| 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': 71, 'dose_mg': 500, 'interval_h': 12} | {'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24} | Failed |
| clearance 59.7 truncates into moderate band | {'action': 'GIVE', 'crcl': 74, 'dose_mg': 260, 'interval_h': 12} | {'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24} | Failed |
| clearance exactly 30 | {'action': 'GIVE', 'crcl': 75, 'dose_mg': 300, 'interval_h': 6} | {'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12} | Failed |
| severe band halves dose | {'action': 'GIVE', 'crcl': 75, 'dose_mg': 175, 'interval_h': 8} | {'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16} | Failed |
| clearance under 15 avoided | {'action': 'GIVE', 'crcl': 63, 'dose_mg': 300, 'interval_h': 12} | {'action': 'AVOID', 'crcl': 8} | Failed |
SHA-256 / 3c250e8d93a12014fabc411cde9fb3250663e4d7181a94f268e8bf673fa9c2b4
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 = 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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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': 71, 'dose_mg': 500, 'interval_h': 12} | {'action': 'GIVE', 'crcl': 40, 'dose_mg': 500, 'interval_h': 24} | Failed |
| clearance 59.7 truncates into moderate band | {'action': 'GIVE', 'crcl': 74, 'dose_mg': 260, 'interval_h': 12} | {'action': 'GIVE', 'crcl': 59, 'dose_mg': 260, 'interval_h': 24} | Failed |
| clearance exactly 30 | {'action': 'GIVE', 'crcl': 75, 'dose_mg': 300, 'interval_h': 6} | {'action': 'GIVE', 'crcl': 30, 'dose_mg': 300, 'interval_h': 12} | Failed |
| severe band halves dose | {'action': 'GIVE', 'crcl': 75, 'dose_mg': 175, 'interval_h': 8} | {'action': 'GIVE', 'crcl': 20, 'dose_mg': 85, 'interval_h': 16} | Failed |
| clearance under 15 avoided | {'action': 'GIVE', 'crcl': 63, 'dose_mg': 300, 'interval_h': 12} | {'action': 'AVOID', 'crcl': 8} | Failed |
SHA-256 / 2120cea32123fa8e4ad411a6bcf024ce462415be668d43c30e8cbc202754a285
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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| 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.295037+00:00.
Case digest / 012a35bc2e02478d14e7b01ac2ac8ab764feec2585d2d60aafef5074b1efa5fe