broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    a = x['age']
    sbp_lim = 110 if a >= 65 else 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] < 10 or x['rr'] > 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] > 0 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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

N = 1
observations = []
def solve(x):
    a = x['age']
    sbp_lim = 110 if a >= 65 else 90
    if x['gcs'] <= 13 or x['sbp'] < sbp_lim or x['rr'] < 10 or x['rr'] > 29:
        return {'tier': 'TIER1', 'step': 1}
    if x['penetrating_torso'] or x['flail_chest'] or x['two_long_bone_fx']:
        return {'tier': 'TIER1', 'step': 2}
    fall_lim = 3 if a < 15 else 6
    if x['fall_m'] > fall_lim or x['ejection']:
        return {'tier': 'TIER2', 'step': 3}
    if x['anticoag'] or x['pregnant_weeks'] >= 20 or a >= 65:
        return {'tier': 'TIER3', 'step': 4}
    return {'tier': 'LOCAL', 'step': 0}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 101,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 21,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 1,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 51,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 29,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 11},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 102,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 22,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 2,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 52,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 30,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 10},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 103,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 23,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 3,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 53,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 9},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 34,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 104,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 8,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 24,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 54,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 4,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 32,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 8},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})],
 [('uninjured control',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 35,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('65-year-old with systolic 100',
   {'gcs': 15,
    'sbp': 105,
    'rr': 16,
    'age': 65,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('bradypnoea',
   {'gcs': 15,
    'sbp': 130,
    'rr': 9,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('respiratory rate exactly 10',
   {'gcs': 15,
    'sbp': 130,
    'rr': 10,
    'age': 25,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'LOCAL', 'step': 0}),
  ('GCS exactly 13',
   {'gcs': 13,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('GCS 12',
   {'gcs': 12,
    'sbp': 130,
    'rr': 16,
    'age': 55,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER1', 'step': 1}),
  ('eight-year-old falls 4 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 8,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('twelve-year-old falls 5 metres',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 12,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 5,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 0},
   {'tier': 'TIER2', 'step': 3}),
  ('pregnant at 20 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 33,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 20},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 12 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 40,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 7},
   {'tier': 'LOCAL', 'step': 0}),
  ('pregnant at 24 weeks',
   {'gcs': 15,
    'sbp': 130,
    'rr': 16,
    'age': 31,
    'penetrating_torso': False,
    'flail_chest': False,
    'two_long_bone_fx': False,
    'fall_m': 0,
    'ejection': False,
    'anticoag': False,
    'pregnant_weeks': 24},
   {'tier': 'TIER3', 'step': 4})]]
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:
Any pregnancy, even at 12 weeks, triggers special consideration.

Input {gcs, sbp, rr, age, penetrating_torso, flail_chest, two_long_bone_fx, fall_m, ejection, anticoag, pregnant_weeks}. Toy steps in order: (1) gcs <= 13, sbp below 90 (below 110 when age >= 65), rr < 10 or rr > 29 -> TIER1 step 1; (2) penetrating torso, flail chest or two long-bone fractures -> TIER1 step 2; (3) fall above 6 m (above 3 m when age < 15) or ejection -> TIER2 step 3; (4) anticoagulation, pregnancy beyond 20 weeks or age >= 65 -> TIER3 step 4; else LOCAL step 0. Return {tier, step}.

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):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + dbp, 2)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

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):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(2 * sbp + dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Mean arterial pressure is overstated for wide pulse pressures.

Input {hr, sbp, dbp}. Invalid when sbp <= 0, dbp <= 0 or dbp >= sbp ({error INVALID_BP}). SI = hr/sbp; MAP = (sbp + 2*dbp)/3; modified SI = hr/MAP. Category: SI >= 1.0 SHOCK_LIKELY, SI >= 0.7 ELEVATED, else NORMAL. msi_flag when modified SI > 1.3; map_low when MAP < 65. SI and MAP are reported rounded half-up to 2 decimals. Return {si, map, category, msi_flag, map_low}.

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):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr // sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(round(hr / sbp, 1))
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
Every patient with heart rate below systolic pressure gets a shock index of 0.

Input {hr, sbp, dbp}. Invalid when sbp <= 0, dbp <= 0 or dbp >= sbp ({error INVALID_BP}). SI = hr/sbp; MAP = (sbp + 2*dbp)/3; modified SI = hr/MAP. Category: SI >= 1.0 SHOCK_LIKELY, SI >= 0.7 ELEVATED, else NORMAL. msi_flag when modified SI > 1.3; map_low when MAP < 65. SI and MAP are reported rounded half-up to 2 decimals. Return {si, map, category, msi_flag, map_low}.

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):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 > 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 and hr > 100 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A shock index of exactly 0.7 is reported as normal.

Input {hr, sbp, dbp}. Invalid when sbp <= 0, dbp <= 0 or dbp >= sbp ({error INVALID_BP}). SI = hr/sbp; MAP = (sbp + 2*dbp)/3; modified SI = hr/MAP. Category: SI >= 1.0 SHOCK_LIKELY, SI >= 0.7 ELEVATED, else NORMAL. msi_flag when modified SI > 1.3; map_low when MAP < 65. SI and MAP are reported rounded half-up to 2 decimals. Return {si, map, category, msi_flag, map_low}.

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):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp <= 0 or dbp > sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    def r2(v):
        return float(Fraction(math.floor(v * 100 + Fraction(1, 2)), 100))
    hr, sbp, dbp = x['hr'], x['sbp'], x['dbp']
    if sbp <= 0 or dbp >= sbp:
        return {'error': 'INVALID_BP'}
    si = Fraction(hr, sbp)
    mp = Fraction(sbp + 2 * dbp, 3)
    msi = hr / mp
    cat = 'SHOCK_LIKELY' if si >= 1 else 'ELEVATED' if si * 10 >= 7 else 'NORMAL'
    return {'si': r2(si), 'map': r2(mp), 'category': cat, 'msi_flag': msi * 10 > 13, 'map_low': mp < 65}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('normal haemodynamics',
   {'hr': 71, 'sbp': 125, 'dbp': 80},
   {'si': 0.57, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 61},
   {'si': 0.69, 'map': 74.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 56},
   {'si': 0.7, 'map': 70.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 105, 'sbp': 105, 'dbp': 60},
   {'si': 1.0, 'map': 75.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 51},
   {'si': 0.6, 'map': 84.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 91},
   {'si': 0.67, 'map': 127.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 91, 'dbp': 91}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 81, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 51},
   {'si': 1.29, 'map': 62.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 72, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 62},
   {'si': 0.69, 'map': 74.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 57},
   {'si': 0.7, 'map': 71.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 110, 'sbp': 110, 'dbp': 60},
   {'si': 1.0, 'map': 76.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 52},
   {'si': 0.6, 'map': 84.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 92},
   {'si': 0.67, 'map': 128.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 92, 'dbp': 92}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 82, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 52},
   {'si': 1.29, 'map': 63.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 73, 'sbp': 125, 'dbp': 80},
   {'si': 0.58, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 63},
   {'si': 0.69, 'map': 75.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 58},
   {'si': 0.7, 'map': 72.0, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 115, 'sbp': 115, 'dbp': 60},
   {'si': 1.0, 'map': 78.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 53},
   {'si': 0.6, 'map': 85.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 93},
   {'si': 0.67, 'map': 128.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 93, 'dbp': 93}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 83, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 53},
   {'si': 1.29, 'map': 63.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 74, 'sbp': 125, 'dbp': 80},
   {'si': 0.59, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 64},
   {'si': 0.69, 'map': 76.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 59},
   {'si': 0.7, 'map': 72.67, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 120, 'sbp': 120, 'dbp': 60},
   {'si': 1.0, 'map': 80.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 54},
   {'si': 0.6, 'map': 86.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 94},
   {'si': 0.67, 'map': 129.33, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 94, 'dbp': 94}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 84, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 54},
   {'si': 1.29, 'map': 64.33, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': True})],
 [('normal haemodynamics',
   {'hr': 75, 'sbp': 125, 'dbp': 80},
   {'si': 0.6, 'map': 95.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index just under 0.7',
   {'hr': 69, 'sbp': 100, 'dbp': 65},
   {'si': 0.69, 'map': 76.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 0.7',
   {'hr': 70, 'sbp': 100, 'dbp': 60},
   {'si': 0.7, 'map': 73.33, 'category': 'ELEVATED', 'msi_flag': False, 'map_low': False}),
  ('shock index exactly 1',
   {'hr': 125, 'sbp': 125, 'dbp': 60},
   {'si': 1.0, 'map': 81.67, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False}),
  ('wide pulse pressure mean pressure',
   {'hr': 90, 'sbp': 150, 'dbp': 55},
   {'si': 0.6, 'map': 86.67, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('half-hundredth shock index',
   {'hr': 133, 'sbp': 200, 'dbp': 95},
   {'si': 0.67, 'map': 130.0, 'category': 'NORMAL', 'msi_flag': False, 'map_low': False}),
  ('equal systolic and diastolic invalid', {'hr': 80, 'sbp': 95, 'dbp': 95}, {'error': 'INVALID_BP'}),
  ('zero diastolic invalid', {'hr': 85, 'sbp': 90, 'dbp': 0}, {'error': 'INVALID_BP'}),
  ('low mean pressure',
   {'hr': 110, 'sbp': 85, 'dbp': 55},
   {'si': 1.29, 'map': 65.0, 'category': 'SHOCK_LIKELY', 'msi_flag': True, 'map_low': False})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
A reading with diastolic equal to systolic is accepted.

Input {hr, sbp, dbp}. Invalid when sbp <= 0, dbp <= 0 or dbp >= sbp ({error INVALID_BP}). SI = hr/sbp; MAP = (sbp + 2*dbp)/3; modified SI = hr/MAP. Category: SI >= 1.0 SHOCK_LIKELY, SI >= 0.7 ELEVATED, else NORMAL. msi_flag when modified SI > 1.3; map_low when MAP < 65. SI and MAP are reported rounded half-up to 2 decimals. Return {si, map, category, msi_flag, map_low}.

split: open-access