Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -79,6 +79,13 @@ openenv push
|
|
| 79 |
|
| 80 |
### Observation (MedObservation)
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
| Field | Type | Description |
|
| 83 |
|---|---|---|
|
| 84 |
| `case_id` | str | Unique case identifier |
|
|
@@ -97,6 +104,139 @@ openenv push
|
|
| 97 |
| `lab_results` | str/None | Lab findings |
|
| 98 |
| `medications` | list[str] | Current medications |
|
| 99 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
### Reward System
|
| 101 |
|
| 102 |
**Grader Components (Deterministic, 0.0β1.0):**
|
|
@@ -110,7 +250,56 @@ openenv push
|
|
| 110 |
| Risk flag identification | 5% |
|
| 111 |
| Confidence calibration | 5% |
|
| 112 |
|
| 113 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
- Wrong approval: -0.25 | Wrong denial: -0.20
|
| 115 |
- Upcoding: -0.15 | Missing primary code: -0.15
|
| 116 |
- Undercoding: -0.10 | Unnecessary procedure: -0.10
|
|
@@ -198,10 +387,7 @@ my_env/
|
|
| 198 |
βββ requirements.txt # Server dependencies
|
| 199 |
```
|
| 200 |
|
| 201 |
-
##
|
| 202 |
|
| 203 |
This environment is a **simulation for AI training and evaluation only**. It does not use real patient data and should not be used for actual medical coding or billing. All clinical cases are synthetic.
|
| 204 |
|
| 205 |
-
## License
|
| 206 |
-
|
| 207 |
-
MIT License
|
|
|
|
| 79 |
|
| 80 |
### Observation (MedObservation)
|
| 81 |
|
| 82 |
+
### Clinical Case Input Format
|
| 83 |
+
|
| 84 |
+
This JSON represents a single clinical case used as input (state) for the MedCodeRL environment.
|
| 85 |
+
The agent uses this data to analyze the case and decide the correct medical coding or action.
|
| 86 |
+
|
| 87 |
+
---
|
| 88 |
+
|
| 89 |
| Field | Type | Description |
|
| 90 |
|---|---|---|
|
| 91 |
| `case_id` | str | Unique case identifier |
|
|
|
|
| 104 |
| `lab_results` | str/None | Lab findings |
|
| 105 |
| `medications` | list[str] | Current medications |
|
| 106 |
|
| 107 |
+
|
| 108 |
+
### π§Ύ Example Input
|
| 109 |
+
|
| 110 |
+
```json
|
| 111 |
+
{
|
| 112 |
+
"case_id": "easy_123",
|
| 113 |
+
"difficulty": "easy",
|
| 114 |
+
"clinical_note": "Patient presents with severe sore throat...",
|
| 115 |
+
"symptoms": ["sore throat", "fever"],
|
| 116 |
+
"treatments": ["amoxicillin prescribing"],
|
| 117 |
+
"insurance_type": "Private",
|
| 118 |
+
"prior_auth_required": false,
|
| 119 |
+
"treatment_cost": "low",
|
| 120 |
+
"patient_age": 34,
|
| 121 |
+
"patient_sex": "F",
|
| 122 |
+
"provider_specialty": "Family Medicine",
|
| 123 |
+
"visit_type": "outpatient",
|
| 124 |
+
"comorbidities": [],
|
| 125 |
+
"medications": ["Ibuprofen"]
|
| 126 |
+
}
|
| 127 |
+
```
|
| 128 |
+
|
| 129 |
+
---
|
| 130 |
+
|
| 131 |
+
## π Field Descriptions
|
| 132 |
+
|
| 133 |
+
### π `case_id`
|
| 134 |
+
|
| 135 |
+
* Unique identifier for the clinical case
|
| 136 |
+
* Helps track and reference specific cases
|
| 137 |
+
|
| 138 |
+
---
|
| 139 |
+
|
| 140 |
+
### π― `difficulty`
|
| 141 |
+
|
| 142 |
+
* Indicates complexity level of the case
|
| 143 |
+
* Values: `easy`, `medium`, `hard`
|
| 144 |
+
* Used for training and evaluation scaling
|
| 145 |
+
|
| 146 |
+
---
|
| 147 |
+
|
| 148 |
+
### π `clinical_note`
|
| 149 |
+
|
| 150 |
+
* Free-text description of the patient's condition
|
| 151 |
+
* Contains detailed clinical information
|
| 152 |
+
* **Most important field for decision-making**
|
| 153 |
+
|
| 154 |
+
---
|
| 155 |
+
|
| 156 |
+
### π€ `symptoms`
|
| 157 |
+
|
| 158 |
+
* List of symptoms observed in the patient
|
| 159 |
+
* Structured version of the clinical note
|
| 160 |
+
* Helps simplify reasoning and rule-based checks
|
| 161 |
+
|
| 162 |
+
---
|
| 163 |
+
|
| 164 |
+
### π `treatments`
|
| 165 |
+
|
| 166 |
+
* Treatments or procedures performed by the provider
|
| 167 |
+
* Used to validate correctness of medical actions
|
| 168 |
+
|
| 169 |
+
---
|
| 170 |
+
|
| 171 |
+
### π₯ `insurance_type`
|
| 172 |
+
|
| 173 |
+
* Type of patient insurance (e.g., Private, Government)
|
| 174 |
+
* Affects billing rules and claim approvals
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
### π `prior_auth_required`
|
| 179 |
+
|
| 180 |
+
* Indicates if prior authorization is needed for treatment
|
| 181 |
+
* `true` β approval required
|
| 182 |
+
* `false` β no approval needed
|
| 183 |
+
|
| 184 |
+
---
|
| 185 |
+
|
| 186 |
+
### π° `treatment_cost`
|
| 187 |
+
|
| 188 |
+
* Estimated cost category of treatment
|
| 189 |
+
* Values: `low`, `medium`, `high`
|
| 190 |
+
* Used in reward logic (penalizing unnecessary expensive treatments)
|
| 191 |
+
|
| 192 |
+
---
|
| 193 |
+
|
| 194 |
+
### π€ `patient_age`
|
| 195 |
+
|
| 196 |
+
* Age of the patient
|
| 197 |
+
* Important for diagnosis and treatment decisions
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
### β§ `patient_sex`
|
| 202 |
+
|
| 203 |
+
* Gender of the patient (`M` or `F`)
|
| 204 |
+
* Required for gender-specific conditions
|
| 205 |
+
|
| 206 |
+
---
|
| 207 |
+
|
| 208 |
+
### π©Ί `provider_specialty`
|
| 209 |
+
|
| 210 |
+
* Medical specialty of the healthcare provider
|
| 211 |
+
* Example: `Family Medicine`, `Cardiology`
|
| 212 |
+
* Used to validate if treatment is appropriate
|
| 213 |
+
|
| 214 |
+
---
|
| 215 |
+
|
| 216 |
+
### π₯ `visit_type`
|
| 217 |
+
|
| 218 |
+
* Type of medical visit
|
| 219 |
+
* Values: `outpatient`, `inpatient`, `emergency`
|
| 220 |
+
* Affects billing and coding rules
|
| 221 |
+
|
| 222 |
+
---
|
| 223 |
+
|
| 224 |
+
### π€ `comorbidities`
|
| 225 |
+
|
| 226 |
+
* List of additional diseases or conditions
|
| 227 |
+
* Example: diabetes, hypertension
|
| 228 |
+
* Increases case complexity
|
| 229 |
+
|
| 230 |
+
---
|
| 231 |
+
|
| 232 |
+
### π `medications`
|
| 233 |
+
|
| 234 |
+
* Medications currently taken by the patient
|
| 235 |
+
* Helps check for drug interactions and treatment safety
|
| 236 |
+
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
|
| 240 |
### Reward System
|
| 241 |
|
| 242 |
**Grader Components (Deterministic, 0.0β1.0):**
|
|
|
|
| 250 |
| Risk flag identification | 5% |
|
| 251 |
| Confidence calibration | 5% |
|
| 252 |
|
| 253 |
+
## output example
|
| 254 |
+
```json
|
| 255 |
+
{
|
| 256 |
+
"diagnosis_codes": ["J02.9", "R50.9"],
|
| 257 |
+
"procedure_codes": ["99213"],
|
| 258 |
+
"decision": "approve",
|
| 259 |
+
"confidence": 0.85,
|
| 260 |
+
"reasoning": "Patient presented with acute pharyngitis and fever. E&M level 3 is appropriate for this outpatient visit. Medical necessity is documented.",
|
| 261 |
+
"modifier_codes": [],
|
| 262 |
+
"risk_flags": []
|
| 263 |
+
}
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
#### How each field is useful (How the Grader Uses Them)
|
| 267 |
+
there is a strict grading rubric that looks at the agent's output to calculate its final reward score. Here is exactly why each field is useful and how it literally affects the score:
|
| 268 |
+
|
| 269 |
+
#### diagnosis_codes (Worth 35% of the grade)
|
| 270 |
+
|
| 271 |
+
*Use*: These are the ICD-10 medical condition codes.
|
| 272 |
+
*Impact*: The grader uses mathematical sets to compare the AI's codes with the hidden ground truth. If the AI misses the primary code or "undercodes," it is heavily penalized (e.g., -0.15 points).
|
| 273 |
+
|
| 274 |
+
#### procedure_codes (Worth 20% of the grade)
|
| 275 |
+
|
| 276 |
+
*Use*: These are the CPT billing codes for the work the doctor actually did.
|
| 277 |
+
*Impact*: The grader compares these against the ground truth. If the AI hallucinates an extra, expensive procedure, it gets penalized for "upcoding" (a form of medical fraud).
|
| 278 |
+
|
| 279 |
+
#### decision (Worth 25% of the grade)
|
| 280 |
+
|
| 281 |
+
Use: The AI must choose to "approve", "reject", or "review" the billing claim based on whether the clinic notes legally justify the codes.
|
| 282 |
+
Impact: This is very heavily weighted. If the AI chooses "reject" when it should be "approve" (wrong denial), it loses 20% of its score.
|
| 283 |
+
#### reasoning (Worth 10% of the grade)
|
| 284 |
+
|
| 285 |
+
Use: A short clinical justification explaining why the AI picked those codes.
|
| 286 |
+
Impact: Your grader literally scans this text. It checks the length (longer explanations get more points) and specifically searches for medical keywords like "medically necessary", "guideline", "compliance", and "documentation". Missing these keywords lowers the grade.
|
| 287 |
+
|
| 288 |
+
#### risk_flags (Worth 5% of the grade)
|
| 289 |
+
|
| 290 |
+
Use: Identifying potential compliance violations like "upcoding_risk" or "bundling_violation".
|
| 291 |
+
Impact: If the hidden answer key has risk flags and the AI successfully spots them, it gets a direct bonus multiplier. If it misses them, it loses out on that 5%.
|
| 292 |
+
|
| 293 |
+
#### confidence (Worth 5% of the grade)
|
| 294 |
+
|
| 295 |
+
Use: A number from 0.0 to 1.0 representing how sure the AI is about its answers.
|
| 296 |
+
Impact: The grader tests for "confidence calibration." If the AI is 99% confident but gets all the codes completely wrong, it is penalized for being overconfident. If it's right but claims 10% confidence, it is penalized for being overly timid.
|
| 297 |
+
|
| 298 |
+
#### modifier_codes
|
| 299 |
+
|
| 300 |
+
Use: Special two-digit modifiers for complex billing scenarios. Included mainly for standardization, though they don't explicitly carry a separate mathematical weight in the current exact base grader.
|
| 301 |
+
|
| 302 |
+
#### **Shaped Penalties** (scaled by difficulty):
|
| 303 |
- Wrong approval: -0.25 | Wrong denial: -0.20
|
| 304 |
- Upcoding: -0.15 | Missing primary code: -0.15
|
| 305 |
- Undercoding: -0.10 | Unnecessary procedure: -0.10
|
|
|
|
| 387 |
βββ requirements.txt # Server dependencies
|
| 388 |
```
|
| 389 |
|
| 390 |
+
## Disclaimer
|
| 391 |
|
| 392 |
This environment is a **simulation for AI training and evaluation only**. It does not use real patient data and should not be used for actual medical coding or billing. All clinical cases are synthetic.
|
| 393 |
|
|
|
|
|
|
|
|
|