File size: 5,570 Bytes
27158b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"""
tasks.py β€” Deterministic task definitions for MediRoute OpenEnv.

Each task is a fully specified medical scenario with:
  - Initial state (symptoms, labs, location, nearby hospitals, specialists)
  - Ground-truth expectations used by the grader
  - Difficulty metadata

Tasks are purely data; no side-effects happen here.
"""

from __future__ import annotations

from typing import Any, Dict

# ─────────────────────────────────────────────
#  Task Registry
# ─────────────────────────────────────────────

TASKS: Dict[str, Dict[str, Any]] = {
    # ── EASY ──────────────────────────────────────────────────────────────────
    "easy": {
        "difficulty": "easy",
        "description": "Mild illness β€” fever and sore throat.",
        "symptoms": "Patient reports fever (101.5 Β°F) and sore throat for 2 days.",
        "lab_report_summary": {
            "temperature_f": 101.5,
            "strep_rapid_test": "positive",
            "wbc": "11,200 / Β΅L (mildly elevated)",
        },
        # Initial severity β€” agent must classify this
        "severity_score": 0.0,
        "location": "Downtown",
        "nearby_hospitals": [
            "City Clinic",
            "Downtown Medical Center",
            "Northside Hospital",
        ],
        "available_specialists": [
            "General Physician",
            "ENT Specialist",
            "Cardiologist",
            "Emergency Doctor",
        ],
        # Ground-truth answers for graders
        "expected_severity": "low",
        "expected_specialist": "General Physician",
        "expected_hospital": "City Clinic",
        "requires_ambulance": False,
        "terminal_actions": {"book_appointment", "provide_temp_guidance"},
        "max_steps": 6,
    },

    # ── MEDIUM ────────────────────────────────────────────────────────────────
    "medium": {
        "difficulty": "medium",
        "description": "Cardiology case β€” chest pain, high BP, ECG abnormality.",
        "symptoms": (
            "55-year-old male with crushing chest pain radiating to left arm, "
            "persistent for 30 minutes. Hypertension history."
        ),
        "lab_report_summary": {
            "blood_pressure": "165/105 mmHg",
            "ecg_finding": "ST-segment elevation in leads II, III, aVF",
            "troponin_i": "0.9 ng/mL (elevated)",
            "heart_rate": "102 bpm",
        },
        "severity_score": 0.0,
        "location": "Westside",
        "nearby_hospitals": [
            "Westside Heart Center",
            "General Hospital",
            "City Clinic",
        ],
        "available_specialists": [
            "Cardiologist",
            "General Physician",
            "Emergency Doctor",
            "ENT Specialist",
        ],
        "expected_severity": "high",
        "expected_specialist": "Cardiologist",
        "expected_hospital": "Westside Heart Center",
        "requires_ambulance": False,
        "terminal_actions": {"book_appointment", "provide_temp_guidance"},
        "max_steps": 8,
    },

    # ── HARD ──────────────────────────────────────────────────────────────────
    "hard": {
        "difficulty": "hard",
        "description": "Life-threatening emergency β€” severe chest pain, SpOβ‚‚ crash, unresponsive.",
        "symptoms": (
            "Elderly female found unresponsive. Bystander reports sudden "
            "severe chest pain followed by collapse. Lips cyanotic."
        ),
        "lab_report_summary": {
            "spo2": "78 % (critical)",
            "pulse": "thready / barely palpable",
            "consciousness": "GCS 3 β€” unresponsive",
            "respiratory_rate": "6 breaths/min",
        },
        "severity_score": 0.0,
        "location": "Northside",
        "nearby_hospitals": [
            "Northside Hospital (ICU)",
            "General Hospital",
            "Westside Heart Center",
        ],
        "available_specialists": [
            "Emergency Doctor",
            "Cardiologist",
            "General Physician",
        ],
        "expected_severity": "critical",
        "expected_specialist": "Emergency Doctor",
        "expected_hospital": "Northside Hospital (ICU)",
        "requires_ambulance": True,
        "terminal_actions": {"call_ambulance", "book_appointment", "provide_temp_guidance"},
        "max_steps": 6,
    },
}


def get_task(difficulty: str) -> Dict[str, Any]:
    """Return a defensive copy of the task definition for the given difficulty."""
    key = difficulty.lower().strip()
    if key not in TASKS:
        raise ValueError(
            f"Unknown difficulty '{difficulty}'. "
            f"Available options: {sorted(TASKS.keys())}"
        )
    # Deep copy primitive fields; lists/dicts are re-created automatically
    import copy
    return copy.deepcopy(TASKS[key])


def list_tasks() -> Dict[str, str]:
    """Return a {difficulty: description} summary for logging / display."""
    return {k: v["description"] for k, v in TASKS.items()}