File size: 19,256 Bytes
85020ae 793d027 85020ae 793d027 | 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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | # AMR-Guard Knowledge Storage Strategy
## Overview
This document defines how each document in the `docs/` folder will be stored and queried to support the **AMR-Guard: Infection Lifecycle Orchestrator** workflow.
---
## Document Classification Summary
| Document | Type | Storage | Purpose in Workflow |
|----------|------|---------|---------------------|
| EML exports (ACCESS/RESERVE/WATCH) | XLSX | **SQLite** | Antibiotic classification & stewardship |
| ATLAS Susceptibility Data | XLSX | **SQLite** | Pathogen resistance patterns |
| MIC Breakpoint Tables | XLSX | **SQLite** | Susceptibility interpretation |
| Drug Interactions | CSV | **SQLite** | Drug safety screening |
| IDSA Guidance (ciae403.pdf) | PDF | **ChromaDB** | Clinical treatment guidelines |
| MIC Breakpoint Tables (PDF) | PDF | **ChromaDB** | Reference documentation |
---
## Part 1: Structured Data (SQLite)
### 1.1 EML Antibiotic Classification Tables
**Source Files:**
- `antibiotic_guidelines/EML export ACCESS group.xlsx`
- `antibiotic_guidelines/EML export RESERVE group.xlsx`
- `antibiotic_guidelines/EML export WATCH group.xlsx`
**Database Table: `eml_antibiotics`**
```sql
CREATE TABLE eml_antibiotics (
id INTEGER PRIMARY KEY AUTOINCREMENT,
medicine_name TEXT NOT NULL,
who_category TEXT NOT NULL, -- 'ACCESS', 'RESERVE', 'WATCH'
eml_section TEXT,
formulations TEXT,
indication TEXT,
atc_codes TEXT,
combined_with TEXT,
status TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_medicine_name ON eml_antibiotics(medicine_name);
CREATE INDEX idx_who_category ON eml_antibiotics(who_category);
CREATE INDEX idx_atc_codes ON eml_antibiotics(atc_codes);
```
**Usage in Workflow:**
- **Agent 1 (Intake Historian):** Query to identify antibiotic stewardship category
- **Agent 4 (Clinical Pharmacologist):** Suggest ACCESS antibiotics first, escalate to WATCH/RESERVE only when necessary
---
### 1.2 ATLAS Pathogen Susceptibility Data
**Source File:** `pathogen_resistance/ATLAS Susceptibility Data Export.xlsx`
**Database Tables:**
```sql
CREATE TABLE atlas_susceptibility_percent (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pathogen TEXT NOT NULL,
antibiotic TEXT NOT NULL,
region TEXT,
year INTEGER,
susceptibility_percent REAL,
sample_size INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE atlas_susceptibility_absolute (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pathogen TEXT NOT NULL,
antibiotic TEXT NOT NULL,
region TEXT,
year INTEGER,
susceptible_count INTEGER,
intermediate_count INTEGER,
resistant_count INTEGER,
total_isolates INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_pathogen ON atlas_susceptibility_percent(pathogen);
CREATE INDEX idx_antibiotic ON atlas_susceptibility_percent(antibiotic);
CREATE INDEX idx_pathogen_abs ON atlas_susceptibility_absolute(pathogen);
```
**Usage in Workflow:**
- **Agent 1 (Empirical Phase):** Retrieve local/regional resistance patterns for empirical therapy
- **Agent 3 (Trend Analyst):** Compare current MIC with population-level trends
---
### 1.3 MIC Breakpoint Tables
**Source File:** `mic_breakpoints/v_16.0__BreakpointTables.xlsx`
**Database Tables:**
```sql
CREATE TABLE mic_breakpoints (
id INTEGER PRIMARY KEY AUTOINCREMENT,
pathogen_group TEXT NOT NULL, -- e.g., 'Enterobacterales', 'Staphylococcus'
antibiotic TEXT NOT NULL,
route TEXT, -- 'IV', 'Oral', 'Topical'
mic_susceptible REAL, -- S breakpoint (mg/L)
mic_resistant REAL, -- R breakpoint (mg/L)
disk_susceptible REAL, -- Zone diameter (mm)
disk_resistant REAL,
notes TEXT,
eucast_version TEXT DEFAULT '16.0',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE dosage_guidance (
id INTEGER PRIMARY KEY AUTOINCREMENT,
antibiotic TEXT NOT NULL,
standard_dose TEXT,
high_dose TEXT,
renal_adjustment TEXT,
notes TEXT
);
CREATE INDEX idx_bp_pathogen ON mic_breakpoints(pathogen_group);
CREATE INDEX idx_bp_antibiotic ON mic_breakpoints(antibiotic);
```
**Usage in Workflow:**
- **Agent 2 (Vision Specialist):** Validate extracted MIC values against breakpoints
- **Agent 3 (Trend Analyst):** Interpret S/I/R classification from MIC values
- **Agent 4 (Clinical Pharmacologist):** Use dosage guidance for prescriptions
---
### 1.4 Drug Interactions Database
**Source File:** `drug_safety/db_drug_interactions.csv`
**Database Table:**
```sql
CREATE TABLE drug_interactions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
drug_1 TEXT NOT NULL,
drug_2 TEXT NOT NULL,
interaction_description TEXT,
severity TEXT, -- Derived: 'major', 'moderate', 'minor'
mechanism TEXT, -- Derived from description
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_drug_1 ON drug_interactions(drug_1);
CREATE INDEX idx_drug_2 ON drug_interactions(drug_2);
CREATE INDEX idx_severity ON drug_interactions(severity);
-- View for bidirectional lookup
CREATE VIEW drug_interaction_lookup AS
SELECT drug_1, drug_2, interaction_description, severity FROM drug_interactions
UNION ALL
SELECT drug_2, drug_1, interaction_description, severity FROM drug_interactions;
```
**Usage in Workflow:**
- **Agent 4 (Clinical Pharmacologist):** Check for interactions with patient's current medications
- **Safety Alerts:** Flag potential toxicity issues
---
## Part 2: Unstructured Data (ChromaDB)
### 2.1 IDSA Clinical Guidelines
**Source File:** `antibiotic_guidelines/ciae403.pdf`
**ChromaDB Collection: `idsa_treatment_guidelines`**
```python
collection_config = {
"name": "idsa_treatment_guidelines",
"metadata": {
"source": "IDSA 2024 Guidance",
"doi": "10.1093/cid/ciae403",
"version": "2024"
},
"embedding_function": "sentence-transformers/all-MiniLM-L6-v2"
}
# Document chunking strategy
chunk_config = {
"chunk_size": 1000,
"chunk_overlap": 200,
"separators": ["\n\n", "\n", ". "],
"metadata_fields": ["section", "pathogen_type", "recommendation_type"]
}
```
**Metadata Schema per Chunk:**
```python
{
"section": "Treatment Recommendations",
"pathogen_type": "ESBL-E | CRE | CRAB | DTR-PA | S.maltophilia",
"recommendation_strength": "Strong | Conditional",
"evidence_quality": "High | Moderate | Low",
"page_number": int
}
```
**Usage in Workflow:**
- **Agent 1 (Empirical Phase):** Retrieve treatment recommendations for suspected pathogens
- **Agent 4 (Clinical Pharmacologist):** Provide evidence-based justification for antibiotic selection
---
### 2.2 MIC Breakpoint Reference (PDF)
**Source File:** `mic_breakpoints/v_16.0_Breakpoint_Tables.pdf`
**ChromaDB Collection: `mic_reference_docs`**
```python
collection_config = {
"name": "mic_reference_docs",
"metadata": {
"source": "EUCAST Breakpoint Tables",
"version": "16.0"
},
"embedding_function": "sentence-transformers/all-MiniLM-L6-v2"
}
```
**Usage in Workflow:**
- **Supplementary Context:** Provide detailed explanations for breakpoint interpretations
- **Edge Cases:** Handle unusual pathogens or antibiotic combinations not in structured tables
---
## Part 3: Query Tools Definition
### Tool 1: `query_antibiotic_info`
**Purpose:** Retrieve antibiotic classification and formulation details
```python
def query_antibiotic_info(
antibiotic_name: str,
include_category: bool = True,
include_formulations: bool = True
) -> dict:
"""
Query EML antibiotic database for classification and details.
Args:
antibiotic_name: Name of the antibiotic (partial match supported)
include_category: Include WHO stewardship category
include_formulations: Include available formulations
Returns:
dict with antibiotic details, category, indications
Used by: Agent 1, Agent 4
"""
```
**SQL Query:**
```sql
SELECT medicine_name, who_category, formulations, indication, combined_with
FROM eml_antibiotics
WHERE LOWER(medicine_name) LIKE LOWER(?)
ORDER BY who_category; -- ACCESS first, then WATCH, then RESERVE
```
---
### Tool 2: `query_resistance_pattern`
**Purpose:** Get susceptibility data for pathogen-antibiotic combinations
```python
def query_resistance_pattern(
pathogen: str,
antibiotic: str = None,
region: str = None,
year: int = None
) -> dict:
"""
Query ATLAS susceptibility data for resistance patterns.
Args:
pathogen: Pathogen name (e.g., "E. coli", "K. pneumoniae")
antibiotic: Optional specific antibiotic to check
region: Optional geographic region filter
year: Optional year filter (defaults to most recent)
Returns:
dict with susceptibility percentages and trends
Used by: Agent 1 (Empirical), Agent 3 (Trend Analysis)
"""
```
**SQL Query:**
```sql
SELECT antibiotic, susceptibility_percent, sample_size, year
FROM atlas_susceptibility_percent
WHERE LOWER(pathogen) LIKE LOWER(?)
AND (antibiotic = ? OR ? IS NULL)
AND (region = ? OR ? IS NULL)
ORDER BY year DESC, susceptibility_percent DESC;
```
---
### Tool 3: `interpret_mic_value`
**Purpose:** Classify MIC as S/I/R based on EUCAST breakpoints
```python
def interpret_mic_value(
pathogen: str,
antibiotic: str,
mic_value: float,
route: str = "IV"
) -> dict:
"""
Interpret MIC value against EUCAST breakpoints.
Args:
pathogen: Pathogen name or group
antibiotic: Antibiotic name
mic_value: MIC value in mg/L
route: Administration route (IV, Oral)
Returns:
dict with interpretation (S/I/R), breakpoint values, dosing notes
Used by: Agent 2, Agent 3
"""
```
**SQL Query:**
```sql
SELECT mic_susceptible, mic_resistant, notes
FROM mic_breakpoints
WHERE LOWER(pathogen_group) LIKE LOWER(?)
AND LOWER(antibiotic) LIKE LOWER(?)
AND (route = ? OR route IS NULL);
```
**Interpretation Logic:**
```python
if mic_value <= mic_susceptible:
return "Susceptible"
elif mic_value > mic_resistant:
return "Resistant"
else:
return "Intermediate (Susceptible, Increased Exposure)"
```
---
### Tool 4: `check_drug_interactions`
**Purpose:** Screen for drug-drug interactions
```python
def check_drug_interactions(
target_drug: str,
patient_medications: list[str],
severity_filter: str = None
) -> list[dict]:
"""
Check for interactions between target drug and patient's medications.
Args:
target_drug: Antibiotic being considered
patient_medications: List of patient's current medications
severity_filter: Optional filter ('major', 'moderate', 'minor')
Returns:
list of interaction dicts with severity and description
Used by: Agent 4 (Safety Check)
"""
```
**SQL Query:**
```sql
SELECT drug_1, drug_2, interaction_description, severity
FROM drug_interaction_lookup
WHERE LOWER(drug_1) LIKE LOWER(?)
AND LOWER(drug_2) IN (SELECT LOWER(value) FROM json_each(?))
AND (severity = ? OR ? IS NULL)
ORDER BY severity DESC;
```
---
### Tool 5: `search_clinical_guidelines`
**Purpose:** RAG search over IDSA guidelines for treatment recommendations
```python
def search_clinical_guidelines(
query: str,
pathogen_filter: str = None,
n_results: int = 5
) -> list[dict]:
"""
Semantic search over IDSA clinical guidelines.
Args:
query: Natural language query about treatment
pathogen_filter: Optional pathogen type filter
n_results: Number of results to return
Returns:
list of relevant guideline excerpts with metadata
Used by: Agent 1 (Empirical), Agent 4 (Justification)
"""
```
**ChromaDB Query:**
```python
results = collection.query(
query_texts=[query],
n_results=n_results,
where={"pathogen_type": pathogen_filter} if pathogen_filter else None,
include=["documents", "metadatas", "distances"]
)
```
---
### Tool 6: `calculate_mic_trend`
**Purpose:** Analyze MIC creep over time
```python
def calculate_mic_trend(
patient_id: str,
pathogen: str,
antibiotic: str,
historical_mics: list[dict] # [{date, mic_value}, ...]
) -> dict:
"""
Calculate resistance velocity and MIC trend.
Args:
patient_id: Patient identifier
pathogen: Identified pathogen
antibiotic: Target antibiotic
historical_mics: List of historical MIC readings
Returns:
dict with trend analysis, resistance_velocity, risk_level
Used by: Agent 3 (Trend Analyst)
"""
```
**Logic:**
```python
# Calculate resistance velocity
if len(historical_mics) >= 2:
baseline_mic = historical_mics[0]["mic_value"]
current_mic = historical_mics[-1]["mic_value"]
ratio = current_mic / baseline_mic
if ratio >= 4: # Two-step dilution increase
risk_level = "HIGH"
alert = "MIC Creep Detected - Risk of Treatment Failure"
elif ratio >= 2:
risk_level = "MODERATE"
alert = "MIC Trending Upward - Monitor Closely"
else:
risk_level = "LOW"
alert = None
```
---
## Part 4: Workflow Integration
### Stage 1: Empirical Phase (Before Lab Results)
```
Input: Patient history, symptoms, infection site
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent 1: Intake Historian (MedGemma 1.5) │
│ ├── Tool: search_clinical_guidelines() │
│ │ └── ChromaDB: idsa_treatment_guidelines │
│ ├── Tool: query_resistance_pattern() │
│ │ └── SQLite: atlas_susceptibility_percent │
│ └── Tool: query_antibiotic_info() │
│ └── SQLite: eml_antibiotics │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent 4: Clinical Pharmacologist (TxGemma) │
│ ├── Tool: check_drug_interactions() │
│ │ └── SQLite: drug_interactions │
│ └── Tool: query_antibiotic_info() [dosing] │
│ └── SQLite: eml_antibiotics + dosage_guidance │
└─────────────────────────────────────────────────────────┘
│
▼
Output: Empirical therapy recommendation with safety check
```
### Stage 2: Targeted Phase (After Lab Results)
```
Input: Lab report (antibiogram image/PDF)
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent 2: Vision Specialist (MedGemma 4B) │
│ ├── Extract: Pathogen name, MIC values │
│ └── Tool: interpret_mic_value() │
│ └── SQLite: mic_breakpoints │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent 3: Trend Analyst (MedGemma 27B) │
│ ├── Tool: calculate_mic_trend() │
│ │ └── Patient historical data + current MIC │
│ └── Tool: query_resistance_pattern() │
│ └── SQLite: atlas_susceptibility (population data) │
└─────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent 4: Clinical Pharmacologist (TxGemma) │
│ ├── Tool: search_clinical_guidelines() │
│ │ └── ChromaDB: idsa_treatment_guidelines │
│ ├── Tool: check_drug_interactions() │
│ │ └── SQLite: drug_interactions │
│ └── Generate: Final prescription with justification │
└─────────────────────────────────────────────────────────┘
│
▼
Output: Targeted therapy with MIC trend analysis & safety alerts
```
---
## Part 5: Implementation Checklist
### SQLite Setup
- [ ] Create database schema with all tables
- [ ] Import EML Excel files (ACCESS, RESERVE, WATCH)
- [ ] Import ATLAS susceptibility data (both sheets)
- [ ] Import MIC breakpoint tables (41 sheets)
- [ ] Import drug interactions CSV
- [ ] Add severity classification to interactions
- [ ] Create indexes for efficient queries
### ChromaDB Setup
- [ ] Initialize ChromaDB persistent storage
- [ ] Process ciae403.pdf with chunking strategy
- [ ] Process MIC breakpoint PDF
- [ ] Add metadata to all chunks
- [ ] Test semantic search queries
### Tool Implementation
- [ ] Implement `query_antibiotic_info()`
- [ ] Implement `query_resistance_pattern()`
- [ ] Implement `interpret_mic_value()`
- [ ] Implement `check_drug_interactions()`
- [ ] Implement `search_clinical_guidelines()`
- [ ] Implement `calculate_mic_trend()`
- [ ] Create unified tool interface for LangGraph
---
## File Structure
```
AMR-Guard/
├── docs/ # Source documents
├── data/
│ ├── medic.db # SQLite database
│ └── chroma/ # ChromaDB persistent storage
├── src/
│ ├── db/
│ │ ├── schema.sql # Database schema
│ │ └── import_data.py # Data import scripts
│ ├── tools/
│ │ ├── antibiotic_tools.py # query_antibiotic_info, interpret_mic
│ │ ├── resistance_tools.py # query_resistance_pattern, calculate_mic_trend
│ │ ├── safety_tools.py # check_drug_interactions
│ │ └── rag_tools.py # search_clinical_guidelines
│ └── agents/
│ ├── intake_historian.py # Agent 1
│ ├── vision_specialist.py # Agent 2
│ ├── trend_analyst.py # Agent 3
│ └── clinical_pharmacologist.py # Agent 4
└── KNOWLEDGE_STORAGE_STRATEGY.md # This document
```
|