broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    h = 0
    h += 6 if x['dvt_signs'] else 0
    h += 6 if x['pe_most_likely'] else 0
    h += 3 if x['hr'] > 100 else 0
    h += 3 if x['immobile_days'] >= 3 or (x['surgery_weeks_ago'] is not None and x['surgery_weeks_ago'] <= 4) else 0
    h += 3 if x['prior_vte'] else 0
    h += 2 if x['hemoptysis'] else 0
    h += 2 if x['malignancy'] else 0
    likely = h > 8
    recent_surg = x['surgery_weeks_ago'] is not None and x['surgery_weeks_ago'] <= 4
    if likely:
        nxt = 'IMAGING'
    elif x['age'] < 50 and x['hr'] < 100 and x['spo2'] >= 95 and not (x['hemoptysis'] or x['prior_vte'] or recent_surg):
        nxt = 'RULED_OUT'
    else:
        nxt = 'D_DIMER'
    return {'score': h / 2, 'category': 'LIKELY' if likely else 'UNLIKELY', 'next': nxt}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 26,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 4,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 61,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 102,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 6,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 29,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 41,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 27,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 5,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': True,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 5.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 62,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 103,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 7,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 30,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 42,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 28,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 6,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 63,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 104,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 8,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 43,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 29,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 7,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': True,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 5.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 34,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 64,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 105,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 34,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 9,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 44,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 30,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 8,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 65,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 106,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 10,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 45,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})]]
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):
    h = 0
    h += 6 if x['dvt_signs'] else 0
    h += 6 if x['pe_most_likely'] else 0
    h += 3 if x['hr'] > 100 else 0
    h += 3 if x['immobile_days'] >= 3 or (x['surgery_weeks_ago'] is not None and x['surgery_weeks_ago'] <= 4) else 0
    h += 3 if x['prior_vte'] else 0
    h += 2 if x['hemoptysis'] else 0
    h += 2 if x['malignancy'] else 0
    likely = h > 8
    recent_surg = x['surgery_weeks_ago'] is not None and x['surgery_weeks_ago'] <= 4
    if likely:
        nxt = 'IMAGING'
    elif x['age'] < 50 and x['hr'] < 100 and x['spo2'] >= 95 and not (x['hemoptysis'] or x['estrogen'] or recent_surg):
        nxt = 'RULED_OUT'
    else:
        nxt = 'D_DIMER'
    return {'score': h / 2, 'category': 'LIKELY' if likely else 'UNLIKELY', 'next': nxt}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 26,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 4,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 61,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 102,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 6,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 29,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 41,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 27,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 5,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': True,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 5.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 62,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 103,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 7,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 30,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 42,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 28,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 6,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 63,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 104,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 8,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 31,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 43,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 29,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 7,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': True,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 5.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 34,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 64,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 105,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 34,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 9,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 32,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 44,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})],
 [('low risk young patient',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 30,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('immobilised after surgery counted once',
   {'dvt_signs': True,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 8,
    'surgery_weeks_ago': 2,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('surgery on the day counts',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 0,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 40,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.5 is likely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.5, 'category': 'LIKELY', 'next': 'IMAGING'}),
  ('score 4.0 unlikely',
   {'dvt_signs': False,
    'pe_most_likely': True,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': True,
    'age': 65,
    'spo2': 98,
    'estrogen': False},
   {'score': 4.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('half point score reported',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 106,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 55,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('surgery exactly 4 weeks ago excludes rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 4,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('remote surgery allows rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': 10,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 35,
    'spo2': 98,
    'estrogen': False},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'RULED_OUT'}),
  ('estrogen use blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': False,
    'hemoptysis': False,
    'malignancy': False,
    'age': 33,
    'spo2': 98,
    'estrogen': True},
   {'score': 0.0, 'category': 'UNLIKELY', 'next': 'D_DIMER'}),
  ('prior VTE blocks rule-out',
   {'dvt_signs': False,
    'pe_most_likely': False,
    'hr': 80,
    'immobile_days': 0,
    'surgery_weeks_ago': None,
    'prior_vte': True,
    'hemoptysis': False,
    'malignancy': False,
    'age': 45,
    'spo2': 98,
    'estrogen': False},
   {'score': 1.5, 'category': 'UNLIKELY', 'next': 'D_DIMER'})]]
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 patient using estrogen is ruled out without testing.

Input {dvt_signs, pe_most_likely, hr, immobile_days, surgery_weeks_ago (or null), prior_vte, hemoptysis, malignancy, age, spo2, estrogen}. Toy points: DVT signs 3, alternative less likely 3, hr > 100 1.5, immobilisation >= 3 days OR surgery within 4 weeks 1.5 (counted once), prior VTE 1.5, haemoptysis 1, malignancy 1. Score > 4 is LIKELY (next IMAGING). UNLIKELY patients are RULED_OUT when age < 50, hr < 100, spo2 >= 95 and none of haemoptysis, estrogen, prior VTE or surgery within 4 weeks; otherwise next D_DIMER. Return {score, category, next}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea']))
    high_urea = u > 7
    s = sum([bool(x['confusion']), high_urea, x['rr'] >= 30, x['sbp'] < 90 or x['dbp'] <= 60, x['age'] >= 65])
    disp = 'OUTPATIENT' if s <= 1 else 'SHORT_STAY' if s == 2 else 'INPATIENT'
    return {'score': s, 'disposition': disp, 'icu_review': s >= 4}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 31},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '11', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '21', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.1', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 66, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 41},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 81},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 71},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 32},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '12', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '22', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.2', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 67, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 42},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 82},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 72},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 33},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '13', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '23', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.3', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 68, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 43},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 83},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 73},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 34},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '14', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '24', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.4', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 69, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 44},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 84},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 74},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 35},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '15', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '25', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 70, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 45},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 85},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 75},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea']))
    high_urea = u > 7 if x['urea_unit'] == 'mg/dL' else u > 19
    s = sum([bool(x['confusion']), high_urea, x['rr'] >= 30, x['sbp'] < 90 or x['dbp'] <= 60, x['age'] >= 65])
    disp = 'OUTPATIENT' if s <= 1 else 'SHORT_STAY' if s == 2 else 'INPATIENT'
    return {'score': s, 'disposition': disp, 'icu_review': s >= 4}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 31},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '11', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '21', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.1', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 66, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 41},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 81},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 71},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 32},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '12', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '22', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.2', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 67, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 42},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 82},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 72},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 33},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '13', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '23', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.3', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 68, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 43},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 83},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 73},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 34},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '14', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '24', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.4', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 69, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 44},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 84},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 74},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 35},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '15', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '25', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 70, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 45},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 85},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 75},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})]]
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 normal BUN of 12 mg/dL counts as raised urea.

Input {confusion, urea, urea_unit ("mmol/L" or "mg/dL" as BUN), rr, sbp, dbp, age}. Toy criteria: confusion; urea > 7 mmol/L or BUN > 19 mg/dL; rr >= 30; sbp < 90 or dbp <= 60; age >= 65. Disposition: 0-1 OUTPATIENT, 2 SHORT_STAY, >=3 INPATIENT; icu_review when score >= 4. Return {score, disposition, icu_review}.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea']))
    high_urea = u > 7 if x['urea_unit'] == 'mmol/L' else u > 19
    s = sum([bool(x['confusion']), high_urea, x['rr'] >= 30, x['sbp'] < 90 and x['dbp'] <= 60, x['age'] >= 65])
    disp = 'OUTPATIENT' if s <= 1 else 'SHORT_STAY' if s == 2 else 'INPATIENT'
    return {'score': s, 'disposition': disp, 'icu_review': s >= 4}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 31},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '11', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '21', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.1', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 66, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 41},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 81},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 71},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 32},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '12', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '22', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.2', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 67, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 42},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 82},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 72},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 33},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '13', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '23', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.3', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 68, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 43},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 83},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 73},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 34},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '14', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '24', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.4', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 69, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 44},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 84},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 74},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 35},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '15', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '25', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 70, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 45},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 85},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 75},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(x):
    u = Fraction(str(x['urea']))
    high_urea = u > 7 if x['urea_unit'] == 'mmol/L' else u > 19
    s = sum([bool(x['confusion']), high_urea, x['rr'] >= 30, x['sbp'] <= 90 or x['dbp'] < 60, x['age'] >= 65])
    disp = 'OUTPATIENT' if s <= 1 else 'SHORT_STAY' if s == 2 else 'INPATIENT'
    return {'score': s, 'disposition': disp, 'icu_review': s >= 4}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 31},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '11', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '21', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.1', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 66, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 41},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 81},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 71},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 32},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '12', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '22', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.2', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 67, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 42},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 82},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 72},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 33},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '13', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '23', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.3', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 68, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 43},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 83},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 73},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 34},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '14', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '24', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.4', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 60, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 69, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 64},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 44},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 84},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 74},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})],
 [('healthy control',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 35},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL below threshold',
   {'confusion': False, 'urea': '15', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 70},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('BUN in mg/dL above threshold',
   {'confusion': False, 'urea': '25', 'urea_unit': 'mg/dL', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('urea in mmol/L above threshold',
   {'confusion': False, 'urea': '7.5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 66},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('low diastolic only',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 110, 'dbp': 59, 'age': 50},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('systolic exactly 90',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 90, 'dbp': 70, 'age': 50},
   {'score': 0, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('respiratory rate exactly 30',
   {'confusion': False, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 30, 'sbp': 120, 'dbp': 75, 'age': 65},
   {'score': 2, 'disposition': 'SHORT_STAY', 'icu_review': False}),
  ('single criterion outpatient with confusion',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 20, 'sbp': 120, 'dbp': 75, 'age': 45},
   {'score': 1, 'disposition': 'OUTPATIENT', 'icu_review': False}),
  ('three criteria inpatient',
   {'confusion': True, 'urea': '5', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 85},
   {'score': 3, 'disposition': 'INPATIENT', 'icu_review': False}),
  ('four criteria review',
   {'confusion': True, 'urea': '9', 'urea_unit': 'mmol/L', 'rr': 32, 'sbp': 120, 'dbp': 75, 'age': 75},
   {'score': 4, 'disposition': 'INPATIENT', 'icu_review': True})]]
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:
Isolated diastolic hypotension is not counted.

Input {confusion, urea, urea_unit ("mmol/L" or "mg/dL" as BUN), rr, sbp, dbp, age}. Toy criteria: confusion; urea > 7 mmol/L or BUN > 19 mg/dL; rr >= 30; sbp < 90 or dbp <= 60; age >= 65. Disposition: 0-1 OUTPATIENT, 2 SHORT_STAY, >=3 INPATIENT; icu_review when score >= 4. Return {score, disposition, icu_review}.

split: open-access