Spaces:
Sleeping
Sleeping
File size: 3,611 Bytes
e324909 eea8d2e e324909 eea8d2e e324909 eea8d2e e324909 | 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 | ---
title: Clinical Trial Patient Screening
emoji: π§ͺ
colorFrom: green
colorTo: indigo
sdk: docker
pinned: false
app_port: 8000
tags:
- openenv
short_description: RL environment for clinical trial patient screening.
---
# Clinical Trial Patient Screening Environment
OpenEnv environment for clinical trial patient screening with three deterministic healthcare tasks:
- `easy`: binary eligibility screening against 5 criteria
- `medium`: ranking 3 patients by protocol fit
- `hard`: protocol deviation and exclusion detection from unstructured clinical text
This environment is designed as a real-world screening workflow rather than a toy game. It uses typed Pydantic models, deterministic programmatic graders, incremental reward shaping for correct data extraction, and terminal rewards for correct screening outcomes.
## Task Overview
### Easy
EGFR-mutated metastatic NSCLC eligibility check using structured oncology data.
### Medium
Rank 3 HER2-positive metastatic breast cancer candidates by fit for a trial.
### Hard
Detect subtle exclusions from an AML screening note, including protocol deviations such as recent investigational treatment, active infection, QTc prolongation, and CYP3A4 inhibitor exposure.
## Reward Design
- `+0.20` for each correct clinical data point or valid deviation extracted
- `+1.00` for a correct final screening decision
- `-0.50` for hallucinated fields, invalid deviation claims, or destructive actions
Each task also produces a deterministic grader score in `(0.0, 1.0)`.
## Project Structure
```text
clinical_trial_env/
βββ .env
βββ Dockerfile
βββ README.md
βββ __init__.py
βββ client.py
βββ env.py
βββ inference.py
βββ models.py
βββ openenv.yaml
βββ pyproject.toml
βββ server/
βββ __init__.py
βββ app.py
βββ clinical_trial_env_environment.py
```
## Build And Run
Build the container from the project root:
```bash
docker build -t clinical-trial-env:latest .
```
Run the server locally:
```bash
docker run --rm -p 8000:8000 clinical-trial-env:latest
```
Validate the environment:
```bash
openenv validate .
```
## Inference
The root [inference.py](/Users/abhishekkanade/Desktop/Hackathon/OpenEnv/clinical_trial_env/inference.py) uses the OpenAI client and emits exactly:
- `[START]`
- `[STEP]`
- `[END]`
Required environment variables:
- `HF_TOKEN`
- `LOCAL_IMAGE_NAME` or `ENV_BASE_URL`
- `API_BASE_URL` optional, defaults to Hugging Face router
- `MODEL_NAME` optional
- `CLINICAL_TRIAL_TASK` with values `easy`, `medium`, or `hard`
Example:
```bash
set -a
source .env
set +a
python3 inference.py
```
## Python Usage
```python
import asyncio
from clinical_trial_env import ClinicalTrialAction, ClinicalTrialEnv
async def main() -> None:
env = await ClinicalTrialEnv.from_docker_image("clinical-trial-env:latest")
try:
result = await env.reset(task_id="easy")
result = await env.step(
ClinicalTrialAction(action_type="extract_data", field_name="age", value="56")
)
print(result.reward, result.observation.reward_details.grader_score)
finally:
await env.close()
asyncio.run(main())
```
## Audit Notes
- `reset()`, `step(action)`, and OpenEnv `state` access are implemented in [env.py](/Users/abhishekkanade/Desktop/Hackathon/OpenEnv/clinical_trial_env/env.py).
- Gold answers are not exposed through observation metadata.
- Graders are deterministic and bounded in `(0.0, 1.0)`.
- The hard task uses unstructured medical text and clinically realistic exclusion criteria.
|