FAILURE MAP
← Case archive

FA-64016 / Medication dosing calculations / Open access

Weight-based anticoagulant infusion nomogram: rate floor at zero · case 01

A low rate reduced for aPTT 81 s is returned as a negative infusion rate.

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

ROOT CAUSE

The zero floor is applied only on the hold branch.

VERIFIED REPAIR

Clamp the adjusted rate at zero after every band adjustment.

Unsuccessful approach: Clamping at 1 unit/kg/h prevents negatives but keeps a rate that should be zero.

Case contract

Input {weight_kg, aptt (integer seconds), rate (units/kg/h)}. Toy nomogram with dosing weight capped at 120 kg: aptt < 35 bolus 80 u/kg and rate +4; 35-45 bolus 40 u/kg and rate +2; 46-70 no change; 71-90 rate -2; > 90 hold 60 minutes and rate -3. Rate is never below 0. Bolus units = bolus u/kg * weight rounded half-up to the nearest 100 units. Return {bolus_units, hold_min, rate_u_kg_h, rate_u_h (half-up integer of rate*weight)}.

Why this case matters

Nomogram-driven infusion adjustments combine band lookup, weight caps and pump rounding; each is a separate failure point.

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):
    wt = min(Fraction(str(x['weight_kg'])), 120)
    a = x['aptt']
    r = Fraction(str(x['rate']))
    bolus, hold = 0, 0
    if a < 35:
        bolus, r = 80, r + 4
    elif a <= 45:
        bolus, r = 40, r + 2
    elif a <= 70:
        pass
    elif a <= 90:
        r = r - 2
    else:
        hold, r = 60, r - 3
    r = max(r, Fraction(0)) if hold else r
    bolus_units = math.floor(bolus * wt / 100 + Fraction(1, 2)) * 100
    return {'bolus_units': bolus_units, 'hold_min': hold, 'rate_u_kg_h': float(r), 'rate_u_h': math.floor(r * wt + Fraction(1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('very low aptt bolus',
   {'weight_kg': 71, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5700, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1562}),
  ('aptt exactly 35',
   {'weight_kg': 61, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2400, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1220}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 17},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 19.0, 'rate_u_h': 1520}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 56, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 81, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 96, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 126, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '81.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3300, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1381})],
 [('very low aptt bolus',
   {'weight_kg': 72, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1584}),
  ('aptt exactly 35',
   {'weight_kg': 62, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1240}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 18},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1600}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 57, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 82, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 97, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 127, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '86.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3500, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1466})],
 [('very low aptt bolus',
   {'weight_kg': 73, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1606}),
  ('aptt exactly 35',
   {'weight_kg': 63, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1260}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 19},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 21.0, 'rate_u_h': 1680}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 58, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 83, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 98, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 128, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '91.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3700, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1551})],
 [('very low aptt bolus',
   {'weight_kg': 74, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5900, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1628}),
  ('aptt exactly 35',
   {'weight_kg': 64, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1280}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 20},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1760}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 59, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 84, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 99, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 129, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '76.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3100, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1296})],
 [('very low aptt bolus',
   {'weight_kg': 75, 'aptt': 30, 'rate': 18},
   {'bolus_units': 6000, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1650}),
  ('aptt exactly 35',
   {'weight_kg': 65, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1300}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 21},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 23.0, 'rate_u_h': 1840}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 60, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 85, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 100, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 130, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '71.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 2900, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1211})]]
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
very low aptt bolus{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}Passed
aptt exactly 35{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}Passed
aptt exactly 45{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}Passed
therapeutic control{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}Passed
reduction clamps at zero{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': -70, 'rate_u_kg_h': -1.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 0, 'rate_u_kg_h': 0.0}Failed
supratherapeutic hold{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}Passed
weight above cap{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}Passed
half-hundred bolus rounds up{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}Passed

SHA-256 / da4630546002bd70875a3933876f6f2f629cc09076f8c8ba086489af829cc421

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):
    wt = min(Fraction(str(x['weight_kg'])), 120)
    a = x['aptt']
    r = Fraction(str(x['rate']))
    bolus, hold = 0, 0
    if a < 35:
        bolus, r = 80, r + 4
    elif a <= 45:
        bolus, r = 40, r + 2
    elif a <= 70:
        pass
    elif a <= 90:
        r = r - 2
    else:
        hold, r = 60, r - 3
    r = max(r, Fraction(1))
    bolus_units = math.floor(bolus * wt / 100 + Fraction(1, 2)) * 100
    return {'bolus_units': bolus_units, 'hold_min': hold, 'rate_u_kg_h': float(r), 'rate_u_h': math.floor(r * wt + Fraction(1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('very low aptt bolus',
   {'weight_kg': 71, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5700, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1562}),
  ('aptt exactly 35',
   {'weight_kg': 61, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2400, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1220}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 17},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 19.0, 'rate_u_h': 1520}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 56, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 81, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 96, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 126, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '81.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3300, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1381})],
 [('very low aptt bolus',
   {'weight_kg': 72, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1584}),
  ('aptt exactly 35',
   {'weight_kg': 62, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1240}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 18},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1600}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 57, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 82, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 97, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 127, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '86.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3500, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1466})],
 [('very low aptt bolus',
   {'weight_kg': 73, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1606}),
  ('aptt exactly 35',
   {'weight_kg': 63, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1260}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 19},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 21.0, 'rate_u_h': 1680}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 58, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 83, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 98, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 128, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '91.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3700, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1551})],
 [('very low aptt bolus',
   {'weight_kg': 74, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5900, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1628}),
  ('aptt exactly 35',
   {'weight_kg': 64, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1280}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 20},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1760}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 59, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 84, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 99, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 129, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '76.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3100, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1296})],
 [('very low aptt bolus',
   {'weight_kg': 75, 'aptt': 30, 'rate': 18},
   {'bolus_units': 6000, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1650}),
  ('aptt exactly 35',
   {'weight_kg': 65, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1300}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 21},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 23.0, 'rate_u_h': 1840}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 60, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 85, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 100, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 130, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '71.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 2900, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1211})]]
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
very low aptt bolus{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}Passed
aptt exactly 35{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}Passed
aptt exactly 45{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}Passed
therapeutic control{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}Passed
reduction clamps at zero{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 70, 'rate_u_kg_h': 1.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 0, 'rate_u_kg_h': 0.0}Failed
supratherapeutic hold{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}Passed
weight above cap{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}Passed
half-hundred bolus rounds up{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}Passed

SHA-256 / 30e1db5e7a92f52a5978d1ae597f45e301becedf4ece1369a6085f798ed64c67

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):
    wt = min(Fraction(str(x['weight_kg'])), 120)
    a = x['aptt']
    r = Fraction(str(x['rate']))
    bolus, hold = 0, 0
    if a < 35:
        bolus, r = 80, r + 4
    elif a <= 45:
        bolus, r = 40, r + 2
    elif a <= 70:
        pass
    elif a <= 90:
        r = r - 2
    else:
        hold, r = 60, r - 3
    r = max(r, Fraction(0))
    bolus_units = math.floor(bolus * wt / 100 + Fraction(1, 2)) * 100
    return {'bolus_units': bolus_units, 'hold_min': hold, 'rate_u_kg_h': float(r), 'rate_u_h': math.floor(r * wt + Fraction(1, 2))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('very low aptt bolus',
   {'weight_kg': 71, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5700, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1562}),
  ('aptt exactly 35',
   {'weight_kg': 61, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2400, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1220}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 17},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 19.0, 'rate_u_h': 1520}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 56, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 81, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 96, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 126, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '81.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3300, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1381})],
 [('very low aptt bolus',
   {'weight_kg': 72, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1584}),
  ('aptt exactly 35',
   {'weight_kg': 62, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1240}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 18},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1600}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 57, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 82, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 97, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 127, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '86.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3500, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1466})],
 [('very low aptt bolus',
   {'weight_kg': 73, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5800, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1606}),
  ('aptt exactly 35',
   {'weight_kg': 63, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2500, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1260}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 19},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 21.0, 'rate_u_h': 1680}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 58, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 83, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 98, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 128, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '91.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3700, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1551})],
 [('very low aptt bolus',
   {'weight_kg': 74, 'aptt': 30, 'rate': 18},
   {'bolus_units': 5900, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1628}),
  ('aptt exactly 35',
   {'weight_kg': 64, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1280}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 20},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1760}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 59, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 84, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 99, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 129, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '76.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 3100, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1296})],
 [('very low aptt bolus',
   {'weight_kg': 75, 'aptt': 30, 'rate': 18},
   {'bolus_units': 6000, 'hold_min': 0, 'rate_u_kg_h': 22.0, 'rate_u_h': 1650}),
  ('aptt exactly 35',
   {'weight_kg': 65, 'aptt': 35, 'rate': 18},
   {'bolus_units': 2600, 'hold_min': 0, 'rate_u_kg_h': 20.0, 'rate_u_h': 1300}),
  ('aptt exactly 45',
   {'weight_kg': 80, 'aptt': 45, 'rate': 21},
   {'bolus_units': 3200, 'hold_min': 0, 'rate_u_kg_h': 23.0, 'rate_u_h': 1840}),
  ('therapeutic control',
   {'weight_kg': 75, 'aptt': 60, 'rate': 18},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 18.0, 'rate_u_h': 1350}),
  ('reduction clamps at zero',
   {'weight_kg': 70, 'aptt': 85, 'rate': 1},
   {'bolus_units': 0, 'hold_min': 0, 'rate_u_kg_h': 0.0, 'rate_u_h': 0}),
  ('supratherapeutic hold',
   {'weight_kg': 90, 'aptt': 100, 'rate': 12},
   {'bolus_units': 0, 'hold_min': 60, 'rate_u_kg_h': 9.0, 'rate_u_h': 810}),
  ('weight above cap',
   {'weight_kg': 130, 'aptt': 40, 'rate': 15},
   {'bolus_units': 4800, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 2040}),
  ('half-hundred bolus rounds up',
   {'weight_kg': '71.25', 'aptt': 40, 'rate': 15},
   {'bolus_units': 2900, 'hold_min': 0, 'rate_u_kg_h': 17.0, 'rate_u_h': 1211})]]
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
very low aptt bolus{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}{'bolus_units': 5700, 'hold_min': 0, 'rate_u_h': 1562, 'rate_u_kg_h': 22.0}Passed
aptt exactly 35{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}{'bolus_units': 2400, 'hold_min': 0, 'rate_u_h': 1220, 'rate_u_kg_h': 20.0}Passed
aptt exactly 45{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}{'bolus_units': 3200, 'hold_min': 0, 'rate_u_h': 1520, 'rate_u_kg_h': 19.0}Passed
therapeutic control{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 1350, 'rate_u_kg_h': 18.0}Passed
reduction clamps at zero{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 0, 'rate_u_kg_h': 0.0}{'bolus_units': 0, 'hold_min': 0, 'rate_u_h': 0, 'rate_u_kg_h': 0.0}Passed
supratherapeutic hold{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}{'bolus_units': 0, 'hold_min': 60, 'rate_u_h': 810, 'rate_u_kg_h': 9.0}Passed
weight above cap{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}{'bolus_units': 4800, 'hold_min': 0, 'rate_u_h': 2040, 'rate_u_kg_h': 17.0}Passed
half-hundred bolus rounds up{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}{'bolus_units': 3300, 'hold_min': 0, 'rate_u_h': 1381, 'rate_u_kg_h': 17.0}Passed

SHA-256 / 637bcad27af7138ffa5945198b421dfc36c6d7a6cad95c050add297af9d76b1f

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.344362+00:00.

Case digest / 67dad27e0c164d1fe502d7dae65fff3b8eca30c69d4c5dc85ed42a65665db452