FAILURE MAP
← Case archive

FA-63916 / Medication dosing calculations / Open access

mcg/kg/min infusion converted to pump mL/h: zero-rate resolution guard · case 01

A rate of 0.04 mL/h is returned as OK with a 0.0 mL/h program.

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

ROOT CAUSE

The resolution guard tests the unrounded rate for exact zero instead of the rounded pump value.

VERIFIED REPAIR

Test the rounded tenths value for zero.

Unsuccessful approach: Rejecting any unrounded rate under 0.1 also rejects 0.07 mL/h, which rounds to a programmable 0.1.

Case contract

Input {dose (mcg/kg/min), weight_kg, drug_mg, bag_ml}. Concentration = drug_mg*1000/bag_ml mcg/mL. Rate mL/h = dose*weight*60/concentration, rounded half-up to 0.1 mL/h. Pump accepts 0.1-999.9 mL/h: a rounded rate above 999.9 returns status EXCEEDS_PUMP, a rounded rate of 0.0 returns BELOW_RESOLUTION; otherwise status OK with rate_ml_h. conc_mcg_ml is always reported.

Why this case matters

Weight-based infusion programming is a classic unit-conversion fault surface: mg vs mcg, per-minute vs per-hour, and pump resolution limits.

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):
    conc = Fraction(x['drug_mg']) * 1000 / Fraction(str(x['bag_ml']))
    rate = Fraction(str(x['dose'])) * Fraction(str(x['weight_kg'])) * 60 / conc
    tenths = math.floor(rate * 10 + Fraction(1, 2))
    if tenths > 9999:
        return {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': float(conc)}
    if rate == 0:
        return {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': float(conc)}
    return {'status': 'OK', 'conc_mcg_ml': float(conc), 'rate_ml_h': tenths / 10}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard adult infusion',
   {'dose': '5', 'weight_kg': 71, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 5, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 101, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 101},
   {'status': 'OK', 'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 67, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 8, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 72, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.5}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.5}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 102, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 102},
   {'status': 'OK', 'conc_mcg_ml': 588.2352941176471, 'rate_ml_h': 153.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 68, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 73, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.7}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 13, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.7}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 103, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 103},
   {'status': 'OK', 'conc_mcg_ml': 582.5242718446602, 'rate_ml_h': 154.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 69, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 10, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 74, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.9}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 17, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.9}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 104, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 104},
   {'status': 'OK', 'conc_mcg_ml': 576.9230769230769, 'rate_ml_h': 156.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 70, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 11, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 75, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 14.1}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 21, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 1.1}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 105, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 105},
   {'status': 'OK', 'conc_mcg_ml': 571.4285714285714, 'rate_ml_h': 157.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 71, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 12, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.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 fixtureActualExpectedOutcome
standard adult infusion{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}Passed
half-tenth rate rounds up{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}Passed
rate exactly at pump maximum{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}Passed
rate above pump maximum{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}Passed
high but valid rate{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}Passed
tiny rate that rounds to 0.1{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1, 'status': 'OK'}Passed
rate that rounds to zero{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.0, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}Failed

SHA-256 / 6214a758c58a2f75067a67019ffc90abbbeb1baaaa5d29251315ccec99de6bff

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):
    conc = Fraction(x['drug_mg']) * 1000 / Fraction(str(x['bag_ml']))
    rate = Fraction(str(x['dose'])) * Fraction(str(x['weight_kg'])) * 60 / conc
    tenths = math.floor(rate * 10 + Fraction(1, 2))
    if tenths > 9999:
        return {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': float(conc)}
    if rate < Fraction(1, 10):
        return {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': float(conc)}
    return {'status': 'OK', 'conc_mcg_ml': float(conc), 'rate_ml_h': tenths / 10}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard adult infusion',
   {'dose': '5', 'weight_kg': 71, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 5, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 101, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 101},
   {'status': 'OK', 'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 67, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 8, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 72, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.5}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.5}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 102, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 102},
   {'status': 'OK', 'conc_mcg_ml': 588.2352941176471, 'rate_ml_h': 153.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 68, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 73, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.7}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 13, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.7}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 103, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 103},
   {'status': 'OK', 'conc_mcg_ml': 582.5242718446602, 'rate_ml_h': 154.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 69, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 10, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 74, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.9}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 17, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.9}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 104, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 104},
   {'status': 'OK', 'conc_mcg_ml': 576.9230769230769, 'rate_ml_h': 156.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 70, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 11, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 75, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 14.1}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 21, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 1.1}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 105, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 105},
   {'status': 'OK', 'conc_mcg_ml': 571.4285714285714, 'rate_ml_h': 157.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 71, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 12, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.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 fixtureActualExpectedOutcome
standard adult infusion{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}Passed
half-tenth rate rounds up{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}Passed
rate exactly at pump maximum{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}Passed
rate above pump maximum{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}Passed
high but valid rate{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}Passed
tiny rate that rounds to 0.1{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1, 'status': 'OK'}Failed
rate that rounds to zero{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}Passed

SHA-256 / 84b8bd0609a124cdb8d6f14b898486cc5341ca6365c8e4644be974e77507423c

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):
    conc = Fraction(x['drug_mg']) * 1000 / Fraction(str(x['bag_ml']))
    rate = Fraction(str(x['dose'])) * Fraction(str(x['weight_kg'])) * 60 / conc
    tenths = math.floor(rate * 10 + Fraction(1, 2))
    if tenths > 9999:
        return {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': float(conc)}
    if tenths == 0:
        return {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': float(conc)}
    return {'status': 'OK', 'conc_mcg_ml': float(conc), 'rate_ml_h': tenths / 10}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard adult infusion',
   {'dose': '5', 'weight_kg': 71, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 5, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 101, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 101},
   {'status': 'OK', 'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 67, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 8, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 72, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.5}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.5}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 102, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 102},
   {'status': 'OK', 'conc_mcg_ml': 588.2352941176471, 'rate_ml_h': 153.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 68, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 9, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 73, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.7}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 13, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.7}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 103, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 103},
   {'status': 'OK', 'conc_mcg_ml': 582.5242718446602, 'rate_ml_h': 154.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 69, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 10, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 74, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.9}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 17, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.9}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 104, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 104},
   {'status': 'OK', 'conc_mcg_ml': 576.9230769230769, 'rate_ml_h': 156.0}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 70, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 11, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.0})],
 [('standard adult infusion',
   {'dose': '5', 'weight_kg': 75, 'drug_mg': 400, 'bag_ml': 250},
   {'status': 'OK', 'conc_mcg_ml': 1600.0, 'rate_ml_h': 14.1}),
  ('half-tenth rate rounds up',
   {'dose': '0.5', 'weight_kg': 21, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 1.1}),
  ('rate exactly at pump maximum',
   {'dose': '99.99', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9}),
  ('rate above pump maximum',
   {'dose': '100', 'weight_kg': 105, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'EXCEEDS_PUMP', 'conc_mcg_ml': 600.0}),
  ('high but valid rate',
   {'dose': '15', 'weight_kg': 100, 'drug_mg': 60, 'bag_ml': 105},
   {'status': 'OK', 'conc_mcg_ml': 571.4285714285714, 'rate_ml_h': 157.5}),
  ('tiny rate that rounds to 0.1',
   {'dose': '0.01', 'weight_kg': 71, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'OK', 'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1}),
  ('rate that rounds to zero',
   {'dose': '0.005', 'weight_kg': 12, 'drug_mg': 60, 'bag_ml': 100},
   {'status': 'BELOW_RESOLUTION', 'conc_mcg_ml': 600.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 fixtureActualExpectedOutcome
standard adult infusion{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}{'conc_mcg_ml': 1600.0, 'rate_ml_h': 13.3, 'status': 'OK'}Passed
half-tenth rate rounds up{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.3, 'status': 'OK'}Passed
rate exactly at pump maximum{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 999.9, 'status': 'OK'}Passed
rate above pump maximum{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}{'conc_mcg_ml': 600.0, 'status': 'EXCEEDS_PUMP'}Passed
high but valid rate{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}{'conc_mcg_ml': 594.059405940594, 'rate_ml_h': 151.5, 'status': 'OK'}Passed
tiny rate that rounds to 0.1{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1, 'status': 'OK'}{'conc_mcg_ml': 600.0, 'rate_ml_h': 0.1, 'status': 'OK'}Passed
rate that rounds to zero{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}{'conc_mcg_ml': 600.0, 'status': 'BELOW_RESOLUTION'}Passed

SHA-256 / d166ca32b8d6ca0fa57992c3379a7d11da99af3f37478e24953351496009c95d

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

Case digest / 95e40d04997fe8f7ccbf9de973cbd3b2c36eed9bfa53f395507e6b0444b0c046