FAILURE MAP
← Case archive

FA-64751 / Clinical triage scoring / Open access

Mass casualty sorting algorithm: walking check order · case 01

Walking wounded who breathe fast are tagged RED instead of GREEN.

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

ROOT CAUSE

The walking check is omitted, so ambulatory casualties fall into the physiological checks.

VERIFIED REPAIR

Check walking first and tag every ambulatory casualty GREEN.

Unsuccessful approach: Requiring command-following for GREEN re-triages confused walking casualties.

Case contract

Input {walking, breathing, breathing_after_airway, rr, radial_pulse, cap_refill_s, follows_commands}. Toy order: walking -> GREEN; not breathing -> RED if breathing after airway repositioning else BLACK; rr > 30 -> RED; no radial pulse or refill > 2 s -> RED; not following commands -> RED; else YELLOW. Return {tag, reason}.

Why this case matters

Mass casualty sorting is an ordered sequence of quick checks; order and each threshold are distinct defect sites.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if not x['breathing']:
        return {'tag': 'RED' if x['breathing_after_airway'] else 'BLACK', 'reason': 'airway'}
    if x['rr'] > 30:
        return {'tag': 'RED', 'reason': 'respiration'}
    if not x['radial_pulse'] or x['cap_refill_s'] > 2:
        return {'tag': 'RED', 'reason': 'perfusion'}
    if not x['follows_commands']:
        return {'tag': 'RED', 'reason': 'mental'}
    return {'tag': 'YELLOW', 'reason': 'delayed'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 33,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 19,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 26,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 34,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 27,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 35,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 28,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 36,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 24,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 4,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 29,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 37,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 25,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 5,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
walking wounded tachypnoeic{'reason': 'respiration', 'tag': 'RED'}{'reason': 'walking', 'tag': 'GREEN'}Failed
walking but confused{'reason': 'mental', 'tag': 'RED'}{'reason': 'walking', 'tag': 'GREEN'}Failed
apnoeic breathes after repositioning{'reason': 'airway', 'tag': 'RED'}{'reason': 'airway', 'tag': 'RED'}Passed
apnoeic after repositioning{'reason': 'airway', 'tag': 'BLACK'}{'reason': 'airway', 'tag': 'BLACK'}Passed
respiratory rate exactly 30{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
slow breathing but perfusing{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
no radial pulse with quick refill{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
refill exactly 2 seconds{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
refill 3 seconds with pulse{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
cannot follow commands{'reason': 'mental', 'tag': 'RED'}{'reason': 'mental', 'tag': 'RED'}Passed

SHA-256 / 00e3fb4827e992fdd594484ebe9077583901ce98c18fe12169cc68ab072c883d

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if x['walking'] and x['follows_commands']:
        return {'tag': 'GREEN', 'reason': 'walking'}
    if not x['breathing']:
        return {'tag': 'RED' if x['breathing_after_airway'] else 'BLACK', 'reason': 'airway'}
    if x['rr'] > 30:
        return {'tag': 'RED', 'reason': 'respiration'}
    if not x['radial_pulse'] or x['cap_refill_s'] > 2:
        return {'tag': 'RED', 'reason': 'perfusion'}
    if not x['follows_commands']:
        return {'tag': 'RED', 'reason': 'mental'}
    return {'tag': 'YELLOW', 'reason': 'delayed'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 33,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 19,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 26,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 34,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 27,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 35,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 28,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 36,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 24,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 4,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 29,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 37,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 25,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 5,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
walking wounded tachypnoeic{'reason': 'walking', 'tag': 'GREEN'}{'reason': 'walking', 'tag': 'GREEN'}Passed
walking but confused{'reason': 'mental', 'tag': 'RED'}{'reason': 'walking', 'tag': 'GREEN'}Failed
apnoeic breathes after repositioning{'reason': 'airway', 'tag': 'RED'}{'reason': 'airway', 'tag': 'RED'}Passed
apnoeic after repositioning{'reason': 'airway', 'tag': 'BLACK'}{'reason': 'airway', 'tag': 'BLACK'}Passed
respiratory rate exactly 30{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
slow breathing but perfusing{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
no radial pulse with quick refill{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
refill exactly 2 seconds{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
refill 3 seconds with pulse{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
cannot follow commands{'reason': 'mental', 'tag': 'RED'}{'reason': 'mental', 'tag': 'RED'}Passed

SHA-256 / 59feb2db2befe8ad4dd67a4e96ecb3b281d7c0a2d74ba6ebf225f15764599abe

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(x):
    if x['walking']:
        return {'tag': 'GREEN', 'reason': 'walking'}
    if not x['breathing']:
        return {'tag': 'RED' if x['breathing_after_airway'] else 'BLACK', 'reason': 'airway'}
    if x['rr'] > 30:
        return {'tag': 'RED', 'reason': 'respiration'}
    if not x['radial_pulse'] or x['cap_refill_s'] > 2:
        return {'tag': 'RED', 'reason': 'perfusion'}
    if not x['follows_commands']:
        return {'tag': 'RED', 'reason': 'mental'}
    return {'tag': 'YELLOW', 'reason': 'delayed'}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 33,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 19,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 26,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 34,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 27,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 35,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 21,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 28,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 36,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 24,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 4,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 8,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 29,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})],
 [('walking wounded tachypnoeic',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 37,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('walking but confused',
   {'walking': True,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 25,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'GREEN', 'reason': 'walking'}),
  ('apnoeic breathes after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': True,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'airway'}),
  ('apnoeic after repositioning',
   {'walking': False,
    'breathing': False,
    'breathing_after_airway': False,
    'rr': 0,
    'radial_pulse': True,
    'cap_refill_s': 5,
    'follows_commands': True},
   {'tag': 'BLACK', 'reason': 'airway'}),
  ('respiratory rate exactly 30',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('slow breathing but perfusing',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 9,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('no radial pulse with quick refill',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 20,
    'radial_pulse': False,
    'cap_refill_s': 1,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('refill exactly 2 seconds',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 23,
    'radial_pulse': True,
    'cap_refill_s': 2,
    'follows_commands': True},
   {'tag': 'YELLOW', 'reason': 'delayed'}),
  ('refill 3 seconds with pulse',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 22,
    'radial_pulse': True,
    'cap_refill_s': 3,
    'follows_commands': True},
   {'tag': 'RED', 'reason': 'perfusion'}),
  ('cannot follow commands',
   {'walking': False,
    'breathing': True,
    'breathing_after_airway': False,
    'rr': 30,
    'radial_pulse': True,
    'cap_refill_s': 1,
    'follows_commands': False},
   {'tag': 'RED', 'reason': 'mental'})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
walking wounded tachypnoeic{'reason': 'walking', 'tag': 'GREEN'}{'reason': 'walking', 'tag': 'GREEN'}Passed
walking but confused{'reason': 'walking', 'tag': 'GREEN'}{'reason': 'walking', 'tag': 'GREEN'}Passed
apnoeic breathes after repositioning{'reason': 'airway', 'tag': 'RED'}{'reason': 'airway', 'tag': 'RED'}Passed
apnoeic after repositioning{'reason': 'airway', 'tag': 'BLACK'}{'reason': 'airway', 'tag': 'BLACK'}Passed
respiratory rate exactly 30{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
slow breathing but perfusing{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
no radial pulse with quick refill{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
refill exactly 2 seconds{'reason': 'delayed', 'tag': 'YELLOW'}{'reason': 'delayed', 'tag': 'YELLOW'}Passed
refill 3 seconds with pulse{'reason': 'perfusion', 'tag': 'RED'}{'reason': 'perfusion', 'tag': 'RED'}Passed
cannot follow commands{'reason': 'mental', 'tag': 'RED'}{'reason': 'mental', 'tag': 'RED'}Passed

SHA-256 / a19cdbec220e247407686d00e0b23247d34e599e88e213561ecd744e47799e32

Verification & scope

A deterministic toy software model with explicitly stipulated thresholds and formulas; it is not clinical guidance, not a validated medical calculator, and makes no claim of conformance to any published protocol. Numbered variants vary patient and order inputs. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:47:27.460240+00:00.

Case digest / 531b775565ac68df31a697b5bf3025299810b8dff2c0f906738eeb3fd2771a64