FA-64091 / Medication dosing calculations / Open access
Pharmacokinetic loading and maintenance doses: clearance unit conversion · case 01
Maintenance doses are sixty times too small.
ROOT CAUSE
mL/min is converted to L/min, not L/h: the x60 minutes factor is missing.
VERIFIED REPAIR
Convert clearance with x60/1000 to L/h.
Unsuccessful approach: Inverting the conversion factor produces enormous maintenance doses.
Case contract
Input {target, current, vd_l_kg, weight_kg, f, cl_ml_min, tau_h, unit_mg}. Toy one-compartment rule: loading = max(0, (target-current)*Vd*weight/F); maintenance = target*CL*tau/F with CL in L/h = cl_ml_min*60/1000. Both are rounded half-up to a multiple of unit_mg. Return {loading_mg, maintenance_mg}.
Why this case matters
Loading and maintenance calculations chain unit conversions and bioavailability; each factor is an independent defect site.
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):
tgt, cur = Fraction(str(x['target'])), Fraction(str(x['current']))
f = Fraction(str(x['f']))
u = x['unit_mg']
vd = Fraction(str(x['vd_l_kg']))
wt = Fraction(str(x['weight_kg']))
cl = Fraction(x['cl_ml_min']) / 1000
def rnd(v):
return float(math.floor(v / u + Fraction(1, 2)) * u)
load = max(Fraction(0), (tgt - cur) * vd * wt / f)
maint = tgt * cl * x['tau_h'] / f
return {'loading_mg': rnd(load), 'maintenance_mg': rnd(maint)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 71,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 6,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 700.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 13,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.5',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 240.0, 'maintenance_mg': 290.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 65,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 175.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 10,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 14.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 72,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 7,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 650.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 14,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.8',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 150.0, 'maintenance_mg': 180.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 25,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 75.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 20,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 29.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 73,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 8,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 600.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 15,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.25',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 480.0, 'maintenance_mg': 575.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 45,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 125.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 30,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 43.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 74,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 9,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 550.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 16,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.4',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 300.0, 'maintenance_mg': 360.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 85,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 225.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 40,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 58.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 75,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 10,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 500.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 17,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.6',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 200.0, 'maintenance_mg': 240.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 105,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 275.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 72.0})]]
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 |
|---|---|---|---|
| drug-naive loading | {'loading_mg': 750.0, 'maintenance_mg': 0.0} | {'loading_mg': 750.0, 'maintenance_mg': 1100.0} | Failed |
| partial existing level credited | {'loading_mg': 700.0, 'maintenance_mg': 25.0} | {'loading_mg': 700.0, 'maintenance_mg': 950.0} | Failed |
| level above target gives no load | {'loading_mg': 0.0, 'maintenance_mg': 0.0} | {'loading_mg': 0.0, 'maintenance_mg': 650.0} | Failed |
| oral bioavailability maintenance | {'loading_mg': 240.0, 'maintenance_mg': 5.0} | {'loading_mg': 240.0, 'maintenance_mg': 290.0} | Failed |
| half unit rounds up | {'loading_mg': 175.0, 'maintenance_mg': 0.0} | {'loading_mg': 175.0, 'maintenance_mg': 50.0} | Failed |
| slow clearance long interval | {'loading_mg': 10.0, 'maintenance_mg': 0.0} | {'loading_mg': 10.0, 'maintenance_mg': 14.0} | Failed |
SHA-256 / 5221a00cbbd82e87925f2d725bc4f8a6c72505062d2b62037f4a7b9ed1be4c37
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):
tgt, cur = Fraction(str(x['target'])), Fraction(str(x['current']))
f = Fraction(str(x['f']))
u = x['unit_mg']
vd = Fraction(str(x['vd_l_kg']))
wt = Fraction(str(x['weight_kg']))
cl = Fraction(x['cl_ml_min']) * 1000 / 60
def rnd(v):
return float(math.floor(v / u + Fraction(1, 2)) * u)
load = max(Fraction(0), (tgt - cur) * vd * wt / f)
maint = tgt * cl * x['tau_h'] / f
return {'loading_mg': rnd(load), 'maintenance_mg': rnd(maint)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 71,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 6,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 700.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 13,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.5',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 240.0, 'maintenance_mg': 290.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 65,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 175.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 10,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 14.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 72,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 7,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 650.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 14,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.8',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 150.0, 'maintenance_mg': 180.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 25,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 75.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 20,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 29.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 73,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 8,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 600.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 15,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.25',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 480.0, 'maintenance_mg': 575.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 45,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 125.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 30,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 43.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 74,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 9,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 550.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 16,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.4',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 300.0, 'maintenance_mg': 360.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 85,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 225.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 40,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 58.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 75,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 10,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 500.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 17,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.6',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 200.0, 'maintenance_mg': 240.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 105,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 275.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 72.0})]]
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 |
|---|---|---|---|
| drug-naive loading | {'loading_mg': 750.0, 'maintenance_mg': 300000.0} | {'loading_mg': 750.0, 'maintenance_mg': 1100.0} | Failed |
| partial existing level credited | {'loading_mg': 700.0, 'maintenance_mg': 266675.0} | {'loading_mg': 700.0, 'maintenance_mg': 950.0} | Failed |
| level above target gives no load | {'loading_mg': 0.0, 'maintenance_mg': 180000.0} | {'loading_mg': 0.0, 'maintenance_mg': 650.0} | Failed |
| oral bioavailability maintenance | {'loading_mg': 240.0, 'maintenance_mg': 80000.0} | {'loading_mg': 240.0, 'maintenance_mg': 290.0} | Failed |
| half unit rounds up | {'loading_mg': 175.0, 'maintenance_mg': 12500.0} | {'loading_mg': 175.0, 'maintenance_mg': 50.0} | Failed |
| slow clearance long interval | {'loading_mg': 10.0, 'maintenance_mg': 4000.0} | {'loading_mg': 10.0, 'maintenance_mg': 14.0} | Failed |
SHA-256 / 8def2aed4cb8b99f92d8b5758177944b5111fadc14a489129e6284b0aaf88e83
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):
tgt, cur = Fraction(str(x['target'])), Fraction(str(x['current']))
f = Fraction(str(x['f']))
u = x['unit_mg']
vd = Fraction(str(x['vd_l_kg']))
wt = Fraction(str(x['weight_kg']))
cl = Fraction(x['cl_ml_min']) * 60 / 1000
def rnd(v):
return float(math.floor(v / u + Fraction(1, 2)) * u)
load = max(Fraction(0), (tgt - cur) * vd * wt / f)
maint = tgt * cl * x['tau_h'] / f
return {'loading_mg': rnd(load), 'maintenance_mg': rnd(maint)}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 71,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 6,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 700.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 13,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.5',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 240.0, 'maintenance_mg': 290.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 65,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 175.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 10,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 14.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 72,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 7,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 650.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 14,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.8',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 150.0, 'maintenance_mg': 180.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 25,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 75.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 20,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 29.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 73,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 750.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 8,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 600.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 15,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.25',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 480.0, 'maintenance_mg': 575.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 45,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 125.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 30,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 43.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 74,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 9,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 550.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 16,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.4',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 300.0, 'maintenance_mg': 360.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 85,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 225.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 40,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 58.0})],
[('drug-naive loading',
{'target': 15,
'current': 0,
'vd_l_kg': '0.7',
'weight_kg': 75,
'f': 1,
'cl_ml_min': 100,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 800.0, 'maintenance_mg': 1100.0}),
('partial existing level credited',
{'target': 20,
'current': 10,
'vd_l_kg': '0.5',
'weight_kg': 80,
'f': '0.8',
'cl_ml_min': 80,
'tau_h': 8,
'unit_mg': 25},
{'loading_mg': 500.0, 'maintenance_mg': 950.0}),
('level above target gives no load',
{'target': 10,
'current': 17,
'vd_l_kg': '0.6',
'weight_kg': 70,
'f': 1,
'cl_ml_min': 90,
'tau_h': 12,
'unit_mg': 50},
{'loading_mg': 0.0, 'maintenance_mg': 650.0}),
('oral bioavailability maintenance',
{'target': 2,
'current': 0,
'vd_l_kg': '1.0',
'weight_kg': 60,
'f': '0.6',
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 5},
{'loading_mg': 200.0, 'maintenance_mg': 240.0}),
('half unit rounds up',
{'target': 5,
'current': 0,
'vd_l_kg': '0.5',
'weight_kg': 105,
'f': 1,
'cl_ml_min': 25,
'tau_h': 6,
'unit_mg': 25},
{'loading_mg': 275.0, 'maintenance_mg': 50.0}),
('slow clearance long interval',
{'target': 1,
'current': 0,
'vd_l_kg': '0.2',
'weight_kg': 50,
'f': 1,
'cl_ml_min': 50,
'tau_h': 24,
'unit_mg': 1},
{'loading_mg': 10.0, 'maintenance_mg': 72.0})]]
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 |
|---|---|---|---|
| drug-naive loading | {'loading_mg': 750.0, 'maintenance_mg': 1100.0} | {'loading_mg': 750.0, 'maintenance_mg': 1100.0} | Passed |
| partial existing level credited | {'loading_mg': 700.0, 'maintenance_mg': 950.0} | {'loading_mg': 700.0, 'maintenance_mg': 950.0} | Passed |
| level above target gives no load | {'loading_mg': 0.0, 'maintenance_mg': 650.0} | {'loading_mg': 0.0, 'maintenance_mg': 650.0} | Passed |
| oral bioavailability maintenance | {'loading_mg': 240.0, 'maintenance_mg': 290.0} | {'loading_mg': 240.0, 'maintenance_mg': 290.0} | Passed |
| half unit rounds up | {'loading_mg': 175.0, 'maintenance_mg': 50.0} | {'loading_mg': 175.0, 'maintenance_mg': 50.0} | Passed |
| slow clearance long interval | {'loading_mg': 10.0, 'maintenance_mg': 14.0} | {'loading_mg': 10.0, 'maintenance_mg': 14.0} | Passed |
SHA-256 / 4a5c087edd33bbaa8185795ebebbce007304e402cb18f237577b6034e6b14f75
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:21.156929+00:00.
Case digest / 7d159a45dfa171a39c92f844218f8d5752da1ab0a894b45fc9798a80243322bd