broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t >= 380 or t <= 360 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] is not None and x['paco2'] < 32) else 0
    s += 1 if w > 12 or w < 4 or x['bands_pct'] > 10 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t > 380 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] is not None and x['paco2'] < 32) else 0
    s += 1 if w > 12 or w < 4 or x['bands_pct'] > 10 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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 temperature of exactly 38.0 counts as an inflammatory criterion.

Input {temp (1 dp), hr, rr, paco2 (or null), wbc, bands_pct, sbp, gcs, suspected_infection}. Toy inflammatory criteria (count): temp > 38.0 or < 36.0; hr > 90; rr > 20 or paco2 < 32 when measured; wbc > 12 or < 4 or bands > 10%. Bedside score: rr >= 22, sbp <= 100, gcs < 15. Without suspected infection the alert is NONE; otherwise SEPSIS_ALERT when the bedside score >= 2, else SIRS_ALERT when criteria >= 2, else NONE. Return {sirs, qsofa, alert}.

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):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t > 380 or t < 360 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] or 0) < 32 else 0
    s += 1 if w > 12 or w < 4 or x['bands_pct'] > 10 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t > 380 or t < 360 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] is None or x['paco2'] < 32) and rr > 20 else 0
    s += 1 if w > 12 or w < 4 or x['bands_pct'] > 10 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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 without a blood gas meets the respiratory criterion.

Input {temp (1 dp), hr, rr, paco2 (or null), wbc, bands_pct, sbp, gcs, suspected_infection}. Toy inflammatory criteria (count): temp > 38.0 or < 36.0; hr > 90; rr > 20 or paco2 < 32 when measured; wbc > 12 or < 4 or bands > 10%. Bedside score: rr >= 22, sbp <= 100, gcs < 15. Without suspected infection the alert is NONE; otherwise SEPSIS_ALERT when the bedside score >= 2, else SIRS_ALERT when criteria >= 2, else NONE. Return {sirs, qsofa, alert}.

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):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t > 380 or t < 360 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] is not None and x['paco2'] < 32) else 0
    s += 1 if w > 12 or w < 4 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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):
    t = Fraction(str(x['temp'])) * 10
    w = Fraction(str(x['wbc']))
    rr = x['rr']
    s = 0
    s += 1 if t > 380 or t < 360 else 0
    s += 1 if x['hr'] > 90 else 0
    s += 1 if rr > 20 or (x['paco2'] is not None and x['paco2'] < 32) else 0
    s += 1 if w > 12 or x['bands_pct'] > 10 else 0
    q = 0
    q += 1 if rr >= 22 else 0
    q += 1 if x['sbp'] <= 100 else 0
    q += 1 if x['gcs'] < 15 else 0
    if not x['suspected_infection']:
        alert = 'NONE'
    elif q >= 2:
        alert = 'SEPSIS_ALERT'
    elif s >= 2:
        alert = 'SIRS_ALERT'
    else:
        alert = 'NONE'
    return {'sirs': s, 'qsofa': q, 'alert': alert}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('hypothermia counts',
   {'temp': '35.5',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 93,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.5',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.1',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 12,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 97,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 89,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.6',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 94,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.6',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.2',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 13,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 98,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 90,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.7',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 98,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 28,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.7',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.3',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 14,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 99,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 91,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.8',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 96,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 29,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.8',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.4',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 15,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 94,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 92,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})],
 [('hypothermia counts',
   {'temp': '35.9',
    'hr': 95,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('temperature exactly 38.0 not counted',
   {'temp': '38.0',
    'hr': 100,
    'rr': 18,
    'paco2': None,
    'wbc': '8',
    'bands_pct': 2,
    'sbp': 120,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('missing blood gas not counted',
   {'temp': '37.0',
    'hr': 97,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 0, 'alert': 'NONE'}),
  ('low carbon dioxide with normal rate',
   {'temp': '37.0',
    'hr': 80,
    'rr': 16,
    'paco2': 30,
    'wbc': '13',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('leukopenia counts',
   {'temp': '38.9',
    'hr': 80,
    'rr': 16,
    'paco2': None,
    'wbc': '3.5',
    'bands_pct': 0,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('band forms count',
   {'temp': '37.0',
    'hr': 99,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 16,
    'sbp': 125,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 2, 'qsofa': 0, 'alert': 'SIRS_ALERT'}),
  ('respiratory rate exactly 22',
   {'temp': '37.0',
    'hr': 80,
    'rr': 22,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 101,
    'gcs': 15,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 1, 'alert': 'NONE'}),
  ('rate 21 only meets inflammatory criterion',
   {'temp': '37.0',
    'hr': 80,
    'rr': 21,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 100,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 1, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('bedside positive without inflammatory criteria',
   {'temp': '37.0',
    'hr': 80,
    'rr': 18,
    'paco2': None,
    'wbc': '9',
    'bands_pct': 0,
    'sbp': 95,
    'gcs': 13,
    'suspected_infection': True},
   {'sirs': 0, 'qsofa': 2, 'alert': 'SEPSIS_ALERT'}),
  ('both scores positive',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 88,
    'gcs': 14,
    'suspected_infection': True},
   {'sirs': 4, 'qsofa': 3, 'alert': 'SEPSIS_ALERT'}),
  ('no suspected infection',
   {'temp': '38.9',
    'hr': 120,
    'rr': 26,
    'paco2': None,
    'wbc': '15',
    'bands_pct': 0,
    'sbp': 93,
    'gcs': 14,
    'suspected_infection': False},
   {'sirs': 4, 'qsofa': 3, 'alert': 'NONE'})]]
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:
Band forms above 10% never count toward the criteria.

Input {temp (1 dp), hr, rr, paco2 (or null), wbc, bands_pct, sbp, gcs, suspected_infection}. Toy inflammatory criteria (count): temp > 38.0 or < 36.0; hr > 90; rr > 20 or paco2 < 32 when measured; wbc > 12 or < 4 or bands > 10%. Bedside score: rr >= 22, sbp <= 100, gcs < 15. Without suspected infection the alert is NONE; otherwise SEPSIS_ALERT when the bedside score >= 2, else SIRS_ALERT when criteria >= 2, else NONE. Return {sirs, qsofa, alert}.

split: open-access