FA-64046 / Medication dosing calculations / Open access
Body-surface-area dose with capping and dose banding: unbanded dose rounding · case 01
A calculated 91.5 mg dose without a matching band is reported as 91 mg.
ROOT CAUSE
The unbanded dose is truncated instead of rounded half-up.
VERIFIED REPAIR
Round the unbanded dose half-up to a whole milligram.
Unsuccessful approach: round() uses half-to-even and still rounds some half milligrams down.
Case contract
Input {height_cm, weight_kg (integers), mg_m2, bands}. BSA (Mosteller) = sqrt(height*weight/3600) rounded half-up to 0.01 m2, computed exactly as (isqrt(100*h*w)+3)//6 hundredths, and capped at 2.00 m2. dose = mg_m2 * BSA. Dose banding: the band with the smallest absolute difference that is within 5% of the dose (difference*20 <= dose) is used, ties going to the lower band; otherwise the dose is rounded half-up to a whole mg. Return {bsa, dose_mg, banded}.
Why this case matters
Dose banding systems take a calculated BSA dose and snap it to prefilled products; BSA rounding, the cap and the tolerance each fail separately.
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):
h = (math.isqrt(100 * x['height_cm'] * x['weight_kg']) + 3) // 6
h = min(h, 200)
dose = Fraction(x['mg_m2'] * h, 100)
best = None
for b in sorted(x['bands']):
d = abs(b - dose)
if d * 20 <= dose and (best is None or d < best[0]):
best = (d, b)
if best is None:
return {'bsa': h / 100, 'dose_mg': math.floor(dose), 'banded': False}
return {'bsa': h / 100, 'dose_mg': best[1], 'banded': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('typical adult banded',
{'height_cm': 170, 'weight_kg': 71, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.83, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 55, 'mg_m2': 10, 'bands': []},
{'bsa': 1.59, 'dose_mg': 16, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 91, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [189, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 151]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 50, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 91, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 56, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.58, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 72, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.84, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 60, 'mg_m2': 10, 'bands': []},
{'bsa': 1.66, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 92, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [188, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 152]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 250, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 453, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 57, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.59, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 73, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.86, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 63, 'mg_m2': 10, 'bands': []},
{'bsa': 1.7, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 93, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [187, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 153]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 450, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 815, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 58, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.61, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 74, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.87, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 72, 'mg_m2': 10, 'bands': []},
{'bsa': 1.82, 'dose_mg': 18, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 94, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [186, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 154]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 650, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1177, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 59, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.62, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 75, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.88, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 76, 'mg_m2': 10, 'bands': []},
{'bsa': 1.87, 'dose_mg': 19, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 95, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [185, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 155]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 850, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1539, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 60, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.63, 'dose_mg': 98, 'banded': False})]]
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 |
|---|---|---|---|
| typical adult banded | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | Passed |
| BSA hundredths rounding | {'banded': False, 'bsa': 1.59, 'dose_mg': 15} | {'banded': False, 'bsa': 1.59, 'dose_mg': 16} | Failed |
| tall patient capped at 2.00 | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | Passed |
| band exactly 5 percent away | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| equidistant bands prefer lower | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| unbanded half milligram rounds up | {'banded': False, 'bsa': 1.81, 'dose_mg': 90} | {'banded': False, 'bsa': 1.81, 'dose_mg': 91} | Failed |
| no band within tolerance | {'banded': False, 'bsa': 1.58, 'dose_mg': 94} | {'banded': False, 'bsa': 1.58, 'dose_mg': 95} | Failed |
SHA-256 / fbd9a8fbac9e156f7fe8af0c74523c987f4f7d203aa231a0de7d598dec08c37f
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):
h = (math.isqrt(100 * x['height_cm'] * x['weight_kg']) + 3) // 6
h = min(h, 200)
dose = Fraction(x['mg_m2'] * h, 100)
best = None
for b in sorted(x['bands']):
d = abs(b - dose)
if d * 20 <= dose and (best is None or d < best[0]):
best = (d, b)
if best is None:
return {'bsa': h / 100, 'dose_mg': round(dose), 'banded': False}
return {'bsa': h / 100, 'dose_mg': best[1], 'banded': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('typical adult banded',
{'height_cm': 170, 'weight_kg': 71, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.83, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 55, 'mg_m2': 10, 'bands': []},
{'bsa': 1.59, 'dose_mg': 16, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 91, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [189, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 151]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 50, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 91, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 56, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.58, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 72, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.84, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 60, 'mg_m2': 10, 'bands': []},
{'bsa': 1.66, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 92, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [188, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 152]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 250, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 453, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 57, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.59, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 73, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.86, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 63, 'mg_m2': 10, 'bands': []},
{'bsa': 1.7, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 93, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [187, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 153]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 450, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 815, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 58, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.61, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 74, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.87, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 72, 'mg_m2': 10, 'bands': []},
{'bsa': 1.82, 'dose_mg': 18, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 94, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [186, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 154]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 650, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1177, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 59, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.62, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 75, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.88, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 76, 'mg_m2': 10, 'bands': []},
{'bsa': 1.87, 'dose_mg': 19, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 95, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [185, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 155]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 850, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1539, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 60, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.63, 'dose_mg': 98, 'banded': False})]]
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 |
|---|---|---|---|
| typical adult banded | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | Passed |
| BSA hundredths rounding | {'banded': False, 'bsa': 1.59, 'dose_mg': 16} | {'banded': False, 'bsa': 1.59, 'dose_mg': 16} | Passed |
| tall patient capped at 2.00 | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | Passed |
| band exactly 5 percent away | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| equidistant bands prefer lower | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| unbanded half milligram rounds up | {'banded': False, 'bsa': 1.81, 'dose_mg': 90} | {'banded': False, 'bsa': 1.81, 'dose_mg': 91} | Failed |
| no band within tolerance | {'banded': False, 'bsa': 1.58, 'dose_mg': 95} | {'banded': False, 'bsa': 1.58, 'dose_mg': 95} | Passed |
SHA-256 / b870a793ec01ecee93080f75bab28a4c116d9d15cd1d3a63801b37fdeb7459de
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):
h = (math.isqrt(100 * x['height_cm'] * x['weight_kg']) + 3) // 6
h = min(h, 200)
dose = Fraction(x['mg_m2'] * h, 100)
best = None
for b in sorted(x['bands']):
d = abs(b - dose)
if d * 20 <= dose and (best is None or d < best[0]):
best = (d, b)
if best is None:
return {'bsa': h / 100, 'dose_mg': math.floor(dose + Fraction(1, 2)), 'banded': False}
return {'bsa': h / 100, 'dose_mg': best[1], 'banded': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('typical adult banded',
{'height_cm': 170, 'weight_kg': 71, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.83, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 55, 'mg_m2': 10, 'bands': []},
{'bsa': 1.59, 'dose_mg': 16, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 91, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [189, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 151]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 50, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 91, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 56, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.58, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 72, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.84, 'dose_mg': 180, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 60, 'mg_m2': 10, 'bands': []},
{'bsa': 1.66, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 92, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [188, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 152]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 250, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 453, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 57, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.59, 'dose_mg': 95, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 73, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.86, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 63, 'mg_m2': 10, 'bands': []},
{'bsa': 1.7, 'dose_mg': 17, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 93, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [187, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 153]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 450, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 815, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 58, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.61, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 74, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.87, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 72, 'mg_m2': 10, 'bands': []},
{'bsa': 1.82, 'dose_mg': 18, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 94, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [186, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 154]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 650, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1177, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 59, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.62, 'dose_mg': 97, 'banded': False})],
[('typical adult banded',
{'height_cm': 170, 'weight_kg': 75, 'mg_m2': 100, 'bands': [170, 180, 190, 200]},
{'bsa': 1.88, 'dose_mg': 190, 'banded': True}),
('BSA hundredths rounding',
{'height_cm': 165, 'weight_kg': 76, 'mg_m2': 10, 'bands': []},
{'bsa': 1.87, 'dose_mg': 19, 'banded': False}),
('tall patient capped at 2.00',
{'height_cm': 200, 'weight_kg': 95, 'mg_m2': 75, 'bands': [140, 150, 160]},
{'bsa': 2.0, 'dose_mg': 150, 'banded': True}),
('band exactly 5 percent away',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [185, 190, 250]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('equidistant bands prefer lower',
{'height_cm': 200, 'weight_kg': 100, 'mg_m2': 100, 'bands': [210, 190, 155]},
{'bsa': 2.0, 'dose_mg': 190, 'banded': True}),
('unbanded half milligram rounds up',
{'height_cm': 150, 'weight_kg': 79, 'mg_m2': 850, 'bands': [1]},
{'bsa': 1.81, 'dose_mg': 1539, 'banded': False}),
('no band within tolerance',
{'height_cm': 160, 'weight_kg': 60, 'mg_m2': 60, 'bands': [50, 150]},
{'bsa': 1.63, 'dose_mg': 98, 'banded': False})]]
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 |
|---|---|---|---|
| typical adult banded | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | {'banded': True, 'bsa': 1.83, 'dose_mg': 180} | Passed |
| BSA hundredths rounding | {'banded': False, 'bsa': 1.59, 'dose_mg': 16} | {'banded': False, 'bsa': 1.59, 'dose_mg': 16} | Passed |
| tall patient capped at 2.00 | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | {'banded': True, 'bsa': 2.0, 'dose_mg': 150} | Passed |
| band exactly 5 percent away | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| equidistant bands prefer lower | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | {'banded': True, 'bsa': 2.0, 'dose_mg': 190} | Passed |
| unbanded half milligram rounds up | {'banded': False, 'bsa': 1.81, 'dose_mg': 91} | {'banded': False, 'bsa': 1.81, 'dose_mg': 91} | Passed |
| no band within tolerance | {'banded': False, 'bsa': 1.58, 'dose_mg': 95} | {'banded': False, 'bsa': 1.58, 'dose_mg': 95} | Passed |
SHA-256 / 8cafda0adce65d21e80978b81b96af6de2af650e1a542b904d988ae7cdcdb48e
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:20.529010+00:00.
Case digest / 8adcd6b4a51ae4b547e42e76a1677ccc7f7eccee293d4b53556d1f8100e2e4c4