broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age_years']
    if a < 10:
        head, leg = Fraction(18 - a), Fraction(27 + a, 2)
    else:
        head, leg = Fraction(9), Fraction(18)
    pct = {'head': head, 'arm_l': 9, 'arm_r': 9, 'leg_l': leg, 'leg_r': leg, 'trunk_front': 18, 'trunk_back': 18, 'perineum': 1}
    tbsa = sum(pct[k] * Fraction(str(v)) for k, v in x['regions'].items())
    major = tbsa >= (10 if a < 10 else 20)
    if not major:
        return {'tbsa': round(float(tbsa), 1), 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}
    total = 4 * Fraction(str(x['weight_kg'])) * tbsa
    h = Fraction(str(x['hours_since_burn']))
    rate = round(float(total / 2 / 8), 1) if h < 8 else None
    return {'tbsa': round(float(tbsa), 1), 'major': True, 'total_ml': round(float(total)), 'first_rate_ml_h': rate}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 65, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 3, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 22.5, 'major': True, 'total_ml': 1350, 'first_rate_ml_h': 112.5}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 72,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 5760, 'first_rate_ml_h': 480.0}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.3'}, 'hours_since_burn': '2'},
   {'tbsa': 11.7, 'major': True, 'total_ml': 842, 'first_rate_ml_h': 70.2}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.5'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 7560.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '9'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.1'},
    'hours_since_burn': '2'},
   {'tbsa': 10.8, 'major': True, 'total_ml': 346, 'first_rate_ml_h': 28.8})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 4, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 23.2, 'major': True, 'total_ml': 1395, 'first_rate_ml_h': 116.2}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '0'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 74,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 5920, 'first_rate_ml_h': 493.3}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.4'}, 'hours_since_burn': '2'},
   {'tbsa': 12.6, 'major': True, 'total_ml': 907, 'first_rate_ml_h': 75.6}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.25'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 5040.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '10'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 12.6, 'major': True, 'total_ml': 403, 'first_rate_ml_h': 33.6})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 75, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 5, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 24.0, 'major': True, 'total_ml': 1440, 'first_rate_ml_h': 120.0}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 76,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6080, 'first_rate_ml_h': 506.7}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 13.5, 'major': True, 'total_ml': 972, 'first_rate_ml_h': 81.0}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.75'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 15120.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '11'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.3'},
    'hours_since_burn': '2'},
   {'tbsa': 14.4, 'major': True, 'total_ml': 461, 'first_rate_ml_h': 38.4})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 80, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 6, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 24.8, 'major': True, 'total_ml': 1485, 'first_rate_ml_h': 123.8}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '0'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 78,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6240, 'first_rate_ml_h': 520.0}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.6'}, 'hours_since_burn': '2'},
   {'tbsa': 14.4, 'major': True, 'total_ml': 1037, 'first_rate_ml_h': 86.4}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 4725.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '12'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.4'},
    'hours_since_burn': '2'},
   {'tbsa': 16.2, 'major': True, 'total_ml': 518, 'first_rate_ml_h': 43.2})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 85, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 7, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 25.5, 'major': True, 'total_ml': 1530, 'first_rate_ml_h': 127.5}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 80,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6400, 'first_rate_ml_h': 533.3}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.7'}, 'hours_since_burn': '2'},
   {'tbsa': 15.3, 'major': True, 'total_ml': 1102, 'first_rate_ml_h': 91.8}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.6'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 9450.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '13'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.5'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': True, 'total_ml': 576, 'first_rate_ml_h': 48.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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    a = x['age_years']
    if a < 10:
        head, leg = Fraction(18 - a), Fraction(27 + a, 2)
    else:
        head, leg = Fraction(9), Fraction(18)
    pct = {'head': head, 'arm_l': 9, 'arm_r': 9, 'leg_l': leg, 'leg_r': leg, 'trunk_front': 18, 'trunk_back': 18, 'perineum': 1}
    tbsa = sum(pct[k] * Fraction(str(v)) for k, v in x['regions'].items())
    major = tbsa >= (10 if a < 10 else 20)
    if not major:
        return {'tbsa': round(float(tbsa), 1), 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}
    total = 4 * Fraction(str(x['weight_kg'])) * tbsa
    h = Fraction(str(x['hours_since_burn']))
    rate = round(float(total / 2 / max(8 - h, 1)), 1) if h < 8 else None
    return {'tbsa': round(float(tbsa), 1), 'major': True, 'total_ml': round(float(total)), 'first_rate_ml_h': rate}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 65, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 3, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 22.5, 'major': True, 'total_ml': 1350, 'first_rate_ml_h': 112.5}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 72,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 5760, 'first_rate_ml_h': 480.0}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.3'}, 'hours_since_burn': '2'},
   {'tbsa': 11.7, 'major': True, 'total_ml': 842, 'first_rate_ml_h': 70.2}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.5'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 7560.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '9'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.1'},
    'hours_since_burn': '2'},
   {'tbsa': 10.8, 'major': True, 'total_ml': 346, 'first_rate_ml_h': 28.8})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 4, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 23.2, 'major': True, 'total_ml': 1395, 'first_rate_ml_h': 116.2}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '0'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 74,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 5920, 'first_rate_ml_h': 493.3}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.4'}, 'hours_since_burn': '2'},
   {'tbsa': 12.6, 'major': True, 'total_ml': 907, 'first_rate_ml_h': 75.6}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.25'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 5040.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '10'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 12.6, 'major': True, 'total_ml': 403, 'first_rate_ml_h': 33.6})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 75, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 5, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 24.0, 'major': True, 'total_ml': 1440, 'first_rate_ml_h': 120.0}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 76,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6080, 'first_rate_ml_h': 506.7}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 13.5, 'major': True, 'total_ml': 972, 'first_rate_ml_h': 81.0}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.75'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 15120.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '11'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.3'},
    'hours_since_burn': '2'},
   {'tbsa': 14.4, 'major': True, 'total_ml': 461, 'first_rate_ml_h': 38.4})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 80, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 6, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 24.8, 'major': True, 'total_ml': 1485, 'first_rate_ml_h': 123.8}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '0'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 78,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6240, 'first_rate_ml_h': 520.0}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.6'}, 'hours_since_burn': '2'},
   {'tbsa': 14.4, 'major': True, 'total_ml': 1037, 'first_rate_ml_h': 86.4}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 4725.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '12'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.4'},
    'hours_since_burn': '2'},
   {'tbsa': 16.2, 'major': True, 'total_ml': 518, 'first_rate_ml_h': 43.2})],
 [('adult anterior trunk',
   {'age_years': 30, 'weight_kg': 85, 'regions': {'trunk_front': '1'}, 'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': False, 'total_ml': 0, 'first_rate_ml_h': None}),
  ('child legs use adjusted proportion',
   {'age_years': 7, 'weight_kg': 15, 'regions': {'leg_l': '1', 'leg_r': '0.5'}, 'hours_since_burn': '2'},
   {'tbsa': 25.5, 'major': True, 'total_ml': 1530, 'first_rate_ml_h': 127.5}),
  ('ten-year-old uses adult proportions',
   {'age_years': 10,
    'weight_kg': 35,
    'regions': {'head': '1', 'leg_l': '0.5', 'arm_l': '1'},
    'hours_since_burn': '2'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 3780, 'first_rate_ml_h': 315.0}),
  ('adult exactly 20 percent',
   {'age_years': 30,
    'weight_kg': 80,
    'regions': {'trunk_front': '0.5', 'head': '1', 'arm_l': '0.2', 'perineum': '0.2'},
    'hours_since_burn': '2'},
   {'tbsa': 20.0, 'major': True, 'total_ml': 6400, 'first_rate_ml_h': 533.3}),
  ('child 12 percent is major',
   {'age_years': 4, 'weight_kg': 18, 'regions': {'arm_l': '1', 'arm_r': '0.7'}, 'hours_since_burn': '2'},
   {'tbsa': 15.3, 'major': True, 'total_ml': 1102, 'first_rate_ml_h': 91.8}),
  ('late arrival shortens first window',
   {'age_years': 30,
    'weight_kg': 70,
    'regions': {'trunk_front': '1', 'leg_l': '0.5'},
    'hours_since_burn': '7.6'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': 9450.0}),
  ('beyond eight hours',
   {'age_years': 30, 'weight_kg': 70, 'regions': {'trunk_back': '1', 'arm_l': '1'}, 'hours_since_burn': '13'},
   {'tbsa': 27.0, 'major': True, 'total_ml': 7560, 'first_rate_ml_h': None}),
  ('infant head burn',
   {'age_years': 0,
    'weight_kg': 8,
    'regions': {'head': '0.5', 'trunk_front': '0.5'},
    'hours_since_burn': '2'},
   {'tbsa': 18.0, 'major': True, 'total_ml': 576, 'first_rate_ml_h': 48.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)

prompt:
Patients arriving hours after the burn get a first-window rate that is too slow.

Input {age_years (int), weight_kg, regions {name: fraction burned}, hours_since_burn}. Toy rule of nines: arms 9, trunk front 18, trunk back 18, perineum 1; age >= 10 head 9 and each leg 18; age < 10 head 18-age and each leg (27+age)/2. TBSA = sum(region % x fraction). Major burn when TBSA >= 20 (age >= 10) or >= 10 (age < 10); minor burns return total_ml 0 and no rate. Major: total = 4 mL x kg x TBSA; half is given over the remainder of the first 8 hours measured from the burn; rate is null once 8 hours have passed. Return {tbsa (1 dp), major, total_ml, first_rate_ml_h (1 dp)}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u <= 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if math.floor(u / 10) < 7 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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)

prompt:
A urea of exactly 6.5 mmol/L scores 0.

Input {urea (mmol/L), hb (g/dL), sex, sbp, hr, melena, syncope, hepatic, cardiac}. Toy points: urea < 6.5:0, 6.5-7.9:2, 8.0-9.9:3, 10.0-24.9:4, >=25:6. Hb male >=13:0, 12-12.9:1, 10-11.9:3, <10:6; female >=12:0, 10-11.9:1, <10:6. SBP >=110:0, 100-109:1, 90-99:2, <90:3. hr >= 100:1, melena 1, syncope 2, hepatic disease 2, cardiac failure 2. Disposition: 0 DISCHARGE, 1-6 ADMIT, >= 7 URGENT. Return {score, disposition}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea'])) * 10
    hb = Fraction(str(x['hb'])) * 10
    p_u = 0 if u < 65 else 2 if u < 80 else 3 if u < 100 else 4 if u < 250 else 6
    if x['sex'] == 'M':
        p_hb = 0 if hb >= 130 else 1 if hb >= 120 else 3 if hb >= 100 else 6
    else:
        p_hb = 0 if hb >= 120 else 1 if hb >= 100 else 3
    bp = x['sbp']
    p_bp = 0 if bp >= 110 else 1 if bp >= 100 else 2 if bp >= 90 else 3
    s = p_u + p_hb + p_bp
    s += 1 if x['hr'] >= 100 else 0
    s += 1 if x['melena'] else 0
    s += 2 if x['syncope'] else 0
    s += 2 if x['hepatic'] else 0
    s += 2 if x['cardiac'] else 0
    disp = 'DISCHARGE' if s == 0 else 'ADMIT' if s < 7 else 'URGENT'
    return {'score': s, 'disposition': disp}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 121,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 111,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.1',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 91,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 84,
    'hr': 101,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.1',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.1',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.1',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 122,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.6',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 112,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.2',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 92,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 83,
    'hr': 102,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.2',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.2',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.2',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 123,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.7',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 113,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.3',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 93,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 82,
    'hr': 103,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.3',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.3',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.3',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 124,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.8',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 114,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.4',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.6',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 94,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 81,
    'hr': 104,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.4',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.4',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.4',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})],
 [('all normal discharge',
   {'urea': '5.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 0, 'disposition': 'DISCHARGE'}),
  ('urea 6.5 to 6.9',
   {'urea': '6.9',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('urea exactly 6.5',
   {'urea': '6.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 115,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('female haemoglobin 11',
   {'urea': '5.0',
    'hb': '11.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('female haemoglobin below 10',
   {'urea': '5.0',
    'hb': '9.5',
    'sex': 'F',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 6, 'disposition': 'ADMIT'}),
  ('male haemoglobin 12.5',
   {'urea': '5.0',
    'hb': '12.7',
    'sex': 'M',
    'sbp': 125,
    'hr': 80,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('systolic exactly 90',
   {'urea': '7.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 90,
    'hr': 95,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 4, 'disposition': 'ADMIT'}),
  ('systolic below 90 with tachycardia',
   {'urea': '9.0',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 80,
    'hr': 105,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 7, 'disposition': 'URGENT'}),
  ('tachycardia alone',
   {'urea': '5.0',
    'hb': '13.5',
    'sex': 'M',
    'sbp': 125,
    'hr': 100,
    'melena': False,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 1, 'disposition': 'ADMIT'}),
  ('melena with tachycardia',
   {'urea': '5.5',
    'hb': '14.0',
    'sex': 'M',
    'sbp': 125,
    'hr': 105,
    'melena': True,
    'syncope': False,
    'hepatic': False,
    'cardiac': False},
   {'score': 2, 'disposition': 'ADMIT'}),
  ('high risk bleed',
   {'urea': '26',
    'hb': '8.5',
    'sex': 'M',
    'sbp': 85,
    'hr': 80,
    'melena': False,
    'syncope': True,
    'hepatic': False,
    'cardiac': False},
   {'score': 17, 'disposition': 'URGENT'})]]
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)

prompt:
Women with haemoglobin 11 g/dL score 3 points.

Input {urea (mmol/L), hb (g/dL), sex, sbp, hr, melena, syncope, hepatic, cardiac}. Toy points: urea < 6.5:0, 6.5-7.9:2, 8.0-9.9:3, 10.0-24.9:4, >=25:6. Hb male >=13:0, 12-12.9:1, 10-11.9:3, <10:6; female >=12:0, 10-11.9:1, <10:6. SBP >=110:0, 100-109:1, 90-99:2, <90:3. hr >= 100:1, melena 1, syncope 2, hepatic disease 2, cardiac failure 2. Disposition: 0 DISCHARGE, 1-6 ADMIT, >= 7 URGENT. Return {score, disposition}.

split: open-access