File size: 2,939 Bytes
d680a4d
 
 
 
 
df660ab
d680a4d
 
 
 
 
 
11a8435
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d680a4d
11a8435
 
 
 
d680a4d
11a8435
 
 
 
 
 
 
 
 
 
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
---
title: MedTriage OpenEnv
emoji: ๐Ÿฅ
sdk: docker
pinned: false
app_port: 8002
tags:
  - openenv
  - healthcare
  - ai-agents
---

# MedTriage OpenEnv

A real-world medical triage simulation environment built for the Meta PyTorch OpenEnv Hackathon. This environment allows AI agents to learn how to categorize patient symptoms into appropriate clinical triage levels using the standard OpenEnv API.

## ๐Ÿ“‹ Environment Overview

**MedTriage** simulates the decision-making process of a clinical triage officer. The agent receives patient demographics, vitals, and unstructured symptom text, and must decide on the safest and most efficient path for care.

### ๐ŸŽฏ Real-World Utility
In real healthcare settings, accurate triage is critical for:
1. **Patient Safety**: Ensuring life-threatening conditions (like heart attacks) are seen immediately.
2. **Resource Optimization**: Preventing hospital ERs from being overwhelmed by minor cases that can be treated at home.

---

## ๐ŸŽฎ Action Space

The agent interacts via the `triage_patient` tool:

- **level**: (IntEnum)
  - `0`: **Self-Care** (Over-the-counter/rest)
  - `1`: **Clinic** (Primary Care appointment in 24-48h)
  - `2`: **Urgent Care** (Same-day care)
  - `3`: **Emergency** (Immediate ER/Ambulance)
- **reasoning**: (String) A medical justification for the triage level.

---

## ๐Ÿ“ฅ Observation Space

Each observation provides:
- **patient_id**: Unique identifier.
- **age / gender**: Basic demographics.
- **symptoms_text**: Unstructured description of the patient's complaint.
- **vitals**: Dictionary containing `temp`, `bp` (Blood Pressure), `hr` (Heart Rate), and `spo2` (Oxygen).
- **history**: List of prior medical conditions or medications.

---

## ๐Ÿš€ Tasks & Difficulty

The environment includes 3 built-in tasks with automated graders:

| Task ID | Name | Difficulty | Ground Truth |
|---------|------|------------|--------------|
| `TASK_EASY` | Seasonal Allergies | Easy | Self-Care (0) |
| `TASK_MEDIUM` | Possible Appendicitis | Medium | Urgent Care (2) |
| `TASK_HARD` | Atypical MI | Hard | Emergency (3) |

---

## ๐Ÿ“ˆ Reward Function (Grader)

Scores range from **0.0 to 1.0**:
- **1.0**: Perfect match with ground truth.
- **0.5**: Over-triage (Safe but resource-intensive).
- **0.2**: Minor under-triage.
- **0.0**: Dangerous under-triage (e.g., sending a heart attack to self-care).

---

## ๐Ÿ› ๏ธ Setup & Usage

### Local Development
1. **Install Dependencies**:
   ```bash
   pip install -e .
   ```
2. **Start the Server**:
   ```bash
   python server/app.py
   ```
3. **Run Baseline**:
   ```bash
   python inference.py
   ```

### Docker
```bash
docker build -t med-triage-env:latest .
docker run -p 8002:8002 med-triage-env:latest
```

---

## ๐ŸŒ API Endpoints
- `/tasks`: List all available tasks.
- `/baseline`: Run the baseline inference.
- `/grader`: Get the score of the last episode.
- `/health`: Environment health check.