File size: 1,554 Bytes
caa2c8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Quick test script for MedCodeRL in my_env template."""
import sys
import os

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

from server.my_env_environment import MyEnvironment
from models import MedAction

env = MyEnvironment()

# Check tasks loaded
print("Tasks loaded:")
for d in ["easy", "medium", "hard"]:
    print(f"  {d}: {len(env._task_cases[d])} cases")

# Test reset (easy)
obs = env.reset(task_id="easy")
print(f"\nReset OK - case: {obs.case_id}")
print(f"Clinical note: {obs.clinical_note[:80]}...")

# Test step with correct action
action = MedAction(
    diagnosis_codes=["J02.9"],
    procedure_codes=["99213"],
    decision="approve",
    confidence=0.85,
    reasoning="Acute pharyngitis coded correctly with appropriate E&M level for straightforward visit.",
    risk_flags=[],
)
result = env.step(action)
print(f"\nStep OK - Score: {result.reward}, Done: {result.done}")
print(f"Feedback: {result.feedback}")
print(f"State: episode={env.state.episode_id[:8]}... steps={env.state.step_count}")

# Test hard case with wrong action
obs2 = env.reset(task_id="hard")
print(f"\nHard case: {obs2.case_id}")
bad = MedAction(
    diagnosis_codes=["M17.11"],
    procedure_codes=["27447"],
    decision="approve",
    confidence=0.9,
    reasoning="Patient needs knee replacement as documented by the provider notes.",
    risk_flags=[],
)
r2 = env.step(bad)
print(f"Wrong action score: {r2.reward}")

# Test medium
obs3 = env.reset(task_id="medium")
print(f"\nMedium case: {obs3.case_id}")

print("\n✅ All tests passed!")