HAI Detection - Demo & Help
Back to DashboardOverview
The NHSN HAI Reporting module assists Infection Preventionists in identifying and classifying Healthcare-Associated Infections (HAIs) for NHSN reporting. Currently supported:
- CLABSI - Central Line-Associated Bloodstream Infections
- CAUTI - Catheter-Associated Urinary Tract Infections
- SSI - Surgical Site Infections (Superficial, Deep, Organ/Space)
- VAE - Ventilator-Associated Events (VAC, IVAC, Possible/Probable VAP)
- CDI - Clostridioides difficile Infections (HO-CDI, CO-CDI, CO-HCFA)
The system uses a four-stage workflow:
- Rule-based screening - Identifies candidates (BSI + line for CLABSI; catheter + positive urine for CAUTI; procedure + infection signals for SSI; ventilator worsening for VAE; positive C. diff test for CDI)
- LLM fact extraction - Extracts clinical facts from notes (symptoms, alternate sources, wound assessments)
- Rules engine - Applies deterministic NHSN criteria to extracted facts
- IP Review - ALL candidates go to IP for final decision
Key principle: The LLM extracts facts and provides a preliminary classification with confidence score, but the Infection Preventionist always makes the final determination. This ensures human oversight on all HAI decisions.
Quick Start - Generate Demo Data
Create CLABSI Candidates
Generate demo patients with CLABSI scenarios for testing:
# Create one CLABSI + one Not CLABSI (random type)
cd /home/david/projects/aegis
python scripts/demo_clabsi.py
# Create all scenario types
python scripts/demo_clabsi.py --all
# Create a specific scenario
python scripts/demo_clabsi.py --scenario clabsi
python scripts/demo_clabsi.py --scenario mbi
python scripts/demo_clabsi.py --scenario secondary-uti
python scripts/demo_clabsi.py --scenario secondary-pneumonia
Create CAUTI Candidates
Generate demo patients with CAUTI (Catheter-Associated UTI) scenarios:
# Create one CAUTI + one Not CAUTI (random type)
cd /home/david/projects/aegis
python scripts/demo_cauti.py
# Create all scenario types
python scripts/demo_cauti.py --all
# Create a specific scenario
python scripts/demo_cauti.py --scenario cauti
python scripts/demo_cauti.py --scenario asymptomatic-bacteriuria
python scripts/demo_cauti.py --scenario not-cauti
Create SSI Candidates
Generate demo patients with SSI (Surgical Site Infection) scenarios:
# Create one SSI + one Not SSI (random type)
cd /home/david/projects/aegis
python scripts/demo_ssi.py
# Create all scenario types
python scripts/demo_ssi.py --all
# Create a specific scenario
python scripts/demo_ssi.py --scenario superficial
python scripts/demo_ssi.py --scenario deep
python scripts/demo_ssi.py --scenario organ-space
python scripts/demo_ssi.py --scenario not-ssi
Create CDI Candidates
Generate demo patients with CDI (C. difficile Infection) scenarios:
# Create one CDI + one Not CDI (random type)
cd /home/david/projects/aegis
python scripts/demo_cdi.py
# Create all scenario types
python scripts/demo_cdi.py --all
# Create a specific scenario
python scripts/demo_cdi.py --scenario ho-cdi
python scripts/demo_cdi.py --scenario co-cdi
python scripts/demo_cdi.py --scenario co-hcfa
python scripts/demo_cdi.py --scenario recurrent
python scripts/demo_cdi.py --scenario not-cdi
Run the Full Pipeline
After creating demo data, run the HAI monitor to detect and classify candidates:
cd /home/david/projects/aegis/hai-detection
python -m src.runner --full
This will:
- Detect new CLABSI candidates from FHIR
- Run LLM extraction and rules engine classification
- Create review entries in the IP Review Queue
Then go to the Dashboard to review and make final decisions on the new cases.
CLABSI Demo Scenarios
| Scenario | Command | Organism | Key Evidence | Classification |
|---|---|---|---|---|
| Clear CLABSI | --scenario clabsi |
S. aureus | Line site infection, negative UA, clear CXR | CLABSI |
| MBI-LCBI | --scenario mbi |
E. coli | BMT patient, ANC 0, Grade 3 mucositis | Not CLABSI - MBI |
| Secondary (UTI) | --scenario secondary-uti |
E. coli | Same organism in blood + urine, pyelonephritis on CT | Not CLABSI - Secondary |
| Secondary (PNA) | --scenario secondary-pneumonia |
Pseudomonas | Same organism in blood + respiratory, VAP on CXR | Not CLABSI - Secondary |
CAUTI Demo Scenarios
CAUTI (Catheter-Associated Urinary Tract Infection) detection follows NHSN criteria requiring catheter >2 days, positive culture, and qualifying symptoms:
| Scenario | Command | Catheter Days | Key Evidence | Classification |
|---|---|---|---|---|
| Clear CAUTI | --scenario cauti |
5 days | E. coli 10^5 CFU/mL, fever 38.5°C, dysuria | CAUTI |
| CAUTI (Fever Only, Young) | --scenario cauti-fever |
4 days | Klebsiella 10^5 CFU/mL, fever 38.8°C (patient age 50) | CAUTI |
| Asymptomatic Bacteriuria | --scenario asb |
5 days | Positive culture, no symptoms documented | Asymptomatic Bacteriuria |
| Fever Only (Elderly) | --scenario fever-elderly |
2 days | Fever 38.5°C, patient age 75, catheter ≤2 days | Not CAUTI (Age Rule) |
| Not Eligible (Mixed Flora) | --scenario mixed-flora |
5 days | >2 organisms (mixed flora culture) | Not Eligible |
| Not Eligible (Candida) | --scenario candida |
5 days | Candida albicans only (yeast excluded) | Not Eligible |
Note: The age-based fever rule requires patients >65 years to have catheter >2 days for fever alone to qualify as a CAUTI symptom.
SSI Demo Scenarios
| Scenario | Command | Procedure | Key Evidence | Classification |
|---|---|---|---|---|
| Superficial SSI | --scenario superficial |
Cholecystectomy | Purulent drainage, erythema, positive wound culture | Superficial SSI |
| Deep SSI | --scenario deep |
Colectomy | Fascial dehiscence, fever >38C, deep tissue involved | Deep SSI |
| Organ/Space SSI | --scenario organ-space |
Colectomy | Pelvic abscess on CT, positive drain culture | Organ/Space SSI |
| Not SSI | --scenario not-ssi |
Total Knee | Wound healing well, no infection signs | Not SSI |
VAE Demo Scenarios
VAE (Ventilator-Associated Event) detection follows the NHSN tiered classification hierarchy:
| Scenario | Command | Ventilator Days | Key Evidence | Classification |
|---|---|---|---|---|
| VAC Only | --scenario vac |
Day 5 | FiO2 +25%, no fever, no antibiotics | VAC (Tier 1) |
| IVAC | --scenario ivac |
Day 7 | PEEP +4 cmH2O, fever 38.8°C, vancomycin x5 days | IVAC (Tier 2) |
| Possible VAP | --scenario possible-vap |
Day 8 | IVAC criteria + positive sputum culture | Possible VAP (Tier 3) |
| Probable VAP | --scenario probable-vap |
Day 10 | IVAC criteria + purulent secretions + BAL 10^5 CFU/mL | Probable VAP (Tier 3) |
| Not VAE | --scenario not-vae |
Day 3 | Stable ventilator settings, no worsening | Not VAE |
Note: VAE detection requires access to ventilator parameter data (FiO2/PEEP) from the EHR.
CDI Demo Scenarios
CDI (Clostridioides difficile Infection) detection follows NHSN LabID Event criteria with time-based onset classification:
| Scenario | Command | Specimen Day | Key Evidence | Classification |
|---|---|---|---|---|
| HO-CDI | --scenario ho-cdi |
Day 5 | Positive toxin A/B, unformed stool, >3 days after admission | HO-CDI |
| CO-CDI | --scenario co-cdi |
Day 2 | Positive toxin A/B, unformed stool, ≤3 days after admission | CO-CDI |
| CO-HCFA | --scenario co-hcfa |
Day 2 | CO-CDI + discharged from facility within prior 4 weeks | CO-HCFA |
| Recurrent CDI | --scenario recurrent |
Day 5 | Positive test 30 days after prior CDI episode | Recurrent HO-CDI |
| Duplicate (Not Reported) | --scenario duplicate |
Day 3 | Positive test 10 days after prior CDI (within 14-day window) | Duplicate |
| Not CDI (GDH Only) | --scenario gdh-only |
Day 4 | GDH antigen positive, toxin negative (does not qualify) | Not CDI |
Note: CDI classification is time-based. Day 1 = admission date. HO-CDI = specimen day >3. CO-CDI = specimen day ≤3.
IP Review Decisions
When reviewing a CLABSI candidate, you (the Infection Preventionist) make the final determination. The LLM classification and confidence score are shown as decision support, but you always have the final say.
Confirmed HAI (CLABSI)
Confirmed central line-associated bloodstream infection. Use when:
- Central line in place >2 calendar days
- No alternative source for the BSI
- Pathogenic organism OR 2+ positive cultures for skin contaminant
Will be counted as CLABSI and available for NHSN submission.
Confirmed Not HAI
The BSI is not a CLABSI. Use when:
- Clear alternative source identified (UTI, pneumonia, etc.)
- Single culture for skin contaminant (likely contamination)
- Does not meet NHSN CLABSI criteria
Case will be closed and not reported to NHSN.
MBI-LCBI
Mucosal Barrier Injury Laboratory-Confirmed Bloodstream Infection. Use when ALL criteria met:
- Neutropenia (ANC <500) OR allogeneic HSCT with Grade 3-4 GI GVHD
- Eligible MBI organism (gut flora: E. coli, Klebsiella, Enterococcus, Candida, etc.)
- Mucosal barrier injury present (mucositis, GVHD)
MBI-LCBI is counted separately from CLABSI for NHSN reporting.
Secondary
BSI is secondary to another primary infection. Use when:
- Same organism isolated from another site (urine, respiratory, wound)
- Clinical presentation consistent with primary infection at other site
- BSI developed after or concurrent with other site infection
Common sources: UTI, pneumonia, intra-abdominal infection, skin/soft tissue
Needs More Info
Additional review or information needed. Use when:
- Clinical notes are incomplete
- Need to review additional cultures or imaging
- Want to discuss with ID or primary team
Candidate stays in the review queue for follow-up. When you later submit a final decision (Confirmed or Not HAI), any prior "Needs More Info" reviews are automatically superseded.
NHSN CLABSI Criteria Quick Reference
Inclusion Criteria
- Patient has a central line at time of BSI OR within 1 calendar day of line removal
- Central line was in place for >2 calendar days on the date of event
- Patient has a laboratory-confirmed bloodstream infection (LCBI)
- BSI is not secondary to an infection at another site
LCBI Criteria
Criterion 1 (Pathogen): Recognized pathogen identified from blood culture not related to infection at another site
Criterion 2 (Contaminant): Common skin contaminant (e.g., CoNS, Corynebacterium) identified from 2+ blood cultures drawn on separate occasions, PLUS patient has fever (>38.0°C), chills, or hypotension
Exclusion: Secondary BSI
A BSI is considered secondary if the same organism is isolated from another site AND:
- The other site infection meets NHSN site-specific criteria, OR
- The clinical presentation is consistent with infection at the other site
NHSN SSI Criteria Quick Reference
Surveillance Window
- 30 days - Standard for most procedures
- 90 days - Procedures with implants (prosthetics, hardware)
Wound Classification
- Class 1 (Clean) - No inflammation, no break in technique, respiratory/GI/GU not entered
- Class 2 (Clean-Contaminated) - Controlled entry into GI/GU/respiratory tract
- Class 3 (Contaminated) - Acute inflammation, gross spillage from GI tract
- Class 4 (Dirty-Infected) - Old traumatic wound, existing infection
Superficial Incisional SSI (any one)
- Purulent drainage from superficial incision
- Organisms from aseptically-obtained culture from superficial incision
- Signs (pain, swelling, erythema, heat) + incision opened by surgeon (unless culture-negative)
- Physician diagnosis of superficial incisional SSI
Deep Incisional SSI (any one)
- Purulent drainage from deep incision (but not organ/space)
- Deep incision spontaneously dehisces OR deliberately opened AND fever (>38°C) or pain
- Abscess in deep incision found on exam, reoperation, imaging, or histopath
- Physician diagnosis of deep incisional SSI
Organ/Space SSI (any one)
- Purulent drainage from drain placed in organ/space
- Organisms from culture of fluid/tissue from organ/space
- Abscess in organ/space found on exam, reoperation, imaging, or histopath
- Physician diagnosis of organ/space SSI
Common Organ/Space Sites
NHSN codes: IAB (intra-abdominal), MED (mediastinitis), BONE (osteomyelitis), DISC (disc space), JNT (joint), MEN (meningitis)
NHSN CAUTI Criteria Quick Reference
Inclusion Criteria
- Indwelling urinary catheter (IUC) in place for >2 calendar days on date of event
- IUC was in place on the date of event OR removed the day before
- Patient has a positive urine culture meeting criteria
- Patient has at least one qualifying symptom (not asymptomatic bacteriuria)
Culture Criteria
- CFU/mL: ≥10⁵ CFU/mL (100,000 colony-forming units per mL)
- Organism count: ≤2 organisms identified (no mixed flora)
- Excluded organisms: Candida species, yeast, and other fungi
Qualifying Symptoms (at least one)
- Fever: Temperature >38.0°C (100.4°F)
- Suprapubic tenderness: Pain/tenderness over the bladder
- CVA pain/tenderness: Costovertebral angle (flank) tenderness
- Urinary urgency: Sudden compelling need to urinate
- Urinary frequency: Increased frequency of urination
- Dysuria: Pain or burning with urination
Age-Based Fever Rule
Special consideration for fever as the only symptom:
- Patient ≤65 years: Fever alone qualifies as a CAUTI symptom
- Patient >65 years: Fever alone requires catheter >2 days; otherwise, another symptom must be present
This rule helps distinguish CAUTI from other causes of fever in elderly catheterized patients.
Asymptomatic Bacteriuria
If catheter and culture criteria are met but NO symptoms are documented, the case is classified as:
- Asymptomatic bacteriuria (ASB) - Not reported as CAUTI
- ASB cases require IP review to confirm no symptoms were missed in documentation
- ASB is common in catheterized patients and should not be treated unless symptomatic
Common Uropathogens
Organisms typically associated with CAUTI:
- Escherichia coli (most common)
- Klebsiella pneumoniae
- Enterococcus faecalis
- Pseudomonas aeruginosa
- Proteus mirabilis
- Enterobacter species
NHSN VAE Criteria Quick Reference
VAE Hierarchy (NHSN Tiers)
VAE classifications are hierarchical - higher tiers include all criteria from lower tiers:
| Classification | Tier | Requires |
|---|---|---|
| VAC (Ventilator-Associated Condition) | 1 | Baseline period + sustained worsening |
| IVAC (Infection-related VAC) | 2 | VAC + temperature/WBC + antimicrobials |
| Possible VAP | 3 | IVAC + purulent secretions OR positive culture |
| Probable VAP | 3 | IVAC + purulent secretions + quantitative culture |
VAC Criteria
Baseline Period (≥2 calendar days):
- Patient on mechanical ventilation
- Stable or decreasing daily minimum FiO2 or PEEP
Worsening Period (≥2 calendar days after baseline):
- Daily minimum FiO2 increased ≥20 percentage points over baseline minimum, OR
- Daily minimum PEEP increased ≥3 cmH2O over baseline minimum
VAC onset date = first day of the worsening period
IVAC Criteria (VAC + all of the following)
- Temperature: >38°C or <36°C
- WBC: ≥12,000 cells/mm³ or ≤4,000 cells/mm³
- Antimicrobials: New qualifying antimicrobial started within ±2 calendar days of VAC onset AND continued for ≥4 calendar days
Possible VAP Criteria (IVAC + one of the following)
- Purulent secretions: ≥25 neutrophils and ≤10 squamous epithelial cells per low power field
- Positive culture: Positive respiratory culture (any growth)
Probable VAP Criteria (IVAC + both of the following)
- Purulent secretions: As defined above
- Quantitative culture meeting threshold:
- BAL (bronchoalveolar lavage): ≥10⁴ CFU/mL
- Lung tissue: ≥10⁴ CFU/g
- PSB (protected specimen brush): ≥10³ CFU/mL
- ETA (endotracheal aspirate): ≥10⁶ CFU/mL
Qualifying Antimicrobials for IVAC
Includes most IV/PO antibiotics used for respiratory infections:
- Beta-lactams (piperacillin-tazobactam, ceftriaxone, cefepime, meropenem, etc.)
- Fluoroquinolones (ciprofloxacin, levofloxacin, moxifloxacin)
- Aminoglycosides (gentamicin, tobramycin, amikacin)
- Glycopeptides (vancomycin)
- Oxazolidinones (linezolid)
Excludes: Topical agents, antifungals, antivirals
NHSN CDI Criteria Quick Reference
CDI LabID Event Definition
A positive laboratory test result for:
- C. difficile toxin A and/or B, OR
- Toxin-producing C. difficile by culture or PCR/NAAT
On an unformed stool specimen (including ostomy collections).
Important: GDH (glutamate dehydrogenase) antigen-only results do NOT qualify as a LabID event.
Onset Classification
| Classification | Specimen Day | Description |
|---|---|---|
| HO-CDI | Day 4+ (>3 days) | Healthcare-Facility-Onset: Specimen collected >3 days after admission |
| CO-CDI | Days 1-3 (≤3 days) | Community-Onset: Specimen collected ≤3 days after admission |
| CO-HCFA | Days 1-3 | Community-Onset Healthcare Facility-Associated: CO-CDI with discharge from any facility within prior 4 weeks |
Day 1 = facility admission date
Recurrence Classification
| Days Since Last CDI Event | Classification | Reporting |
|---|---|---|
| ≤14 days | Duplicate | Not reported (same episode) |
| 15-56 days | Recurrent | Reported as recurrent CDI |
| >56 days | New Incident | Reported as new CDI event |
Test Type Eligibility
For multi-step testing algorithms, the last test performed determines eligibility:
| Test Type | Qualifies for LabID Event |
|---|---|
| Toxin A/B EIA | Yes (if positive) |
| PCR/NAAT | Yes (if positive) |
| Toxigenic culture | Yes (if positive) |
| GDH antigen only | No |
Specimen Requirements
- Unformed stool only: Specimen must conform to container shape (Bristol stool types 5-7)
- Formed stool excluded: Solid stool specimens do not qualify
- Ostomy specimens: Acceptable if stool is unformed
- Rectal swabs: Generally not acceptable for CDI surveillance
Common LOINC Codes for C. diff Testing
- 34713-8: C. difficile toxin A
- 34714-6: C. difficile toxin B
- 34712-0: C. difficile toxin A+B
- 82197-9: C. difficile toxin B gene (PCR)
- 80685-5: C. difficile toxin genes (NAAT)
LLM-Assisted Classification
The system uses a two-stage approach: LLM extraction followed by rules engine.
Stage 1: LLM Fact Extraction
A local LLM (Ollama llama3.1) reads clinical notes and extracts structured facts:
- Alternate infection sources - Pneumonia, UTI, SSTI, intra-abdominal
- Symptoms - Fever, WBC changes, hypotension
- MBI factors - Neutropenia, mucositis, HSCT status, GVHD
- Line assessment - Exit site findings, clinical suspicion
- Contamination signals - Team treating as contaminant
The LLM answers factual questions about documentation - it does NOT make classification decisions.
Stage 2: Rules Engine
Deterministic NHSN criteria are applied to the extracted facts:
- Basic eligibility check (line days, timing)
- MBI-LCBI criteria evaluation
- Secondary BSI check (same organism at other site)
- Contamination check (single commensal culture)
- Default to CLABSI if no exclusions apply
IP Makes Final Decision
ALL candidates are routed to IP review regardless of confidence score. The LLM classification and confidence are displayed as decision support, but IP always makes the final determination.
This approach ensures:
- Human oversight on all HAI determinations
- Transparency - Every decision can be traced to specific criteria
- Override tracking - When IP disagrees with LLM, it's logged for quality assessment
Privacy: All PHI stays on-premise. The Ollama LLM runs locally and no data is sent to external services.
Troubleshooting
FHIR server not responding
# Check if container is running
docker ps | grep hapi
# Restart if needed
cd asp-bacteremia-alerts
docker-compose down && docker-compose up -d
Clear HAI data and start fresh
# Clear HAI/NHSN database (shared database)
rm -f ~/.aegis/nhsn.db
# Clear FHIR server data
cd asp-bacteremia-alerts
docker-compose down && docker-compose up -d
LLM classification not running
# Check if Ollama is running
curl http://localhost:11434/api/tags
# If not running, start Ollama
ollama serve
Check available Ollama models
ollama list
Architecture
+-------------------+ +-------------------+
| Demo Scripts |---->| HAPI FHIR |
| demo_clabsi.py | | Server :8081 |
| demo_ssi.py | | |
| demo_vae.py | | |
| demo_cdi.py | | |
+-------------------+ +---------+---------+
|
v
+-------------------+
| HAI Monitor |
| (Rule-based |
| Screening) |
+---------+---------+
|
+----------+----------+----------+----------+----------+
| | | | | |
+----------+ +----------+ +----------+ +----------+ +----------+
|CLABSI | |CAUTI | |SSI | |VAE | |CDI |
|Detector | |Detector | |Detector | |Detector | |Detector |
|(BSI+Line)| |(Cath+UCx)| |(Procedure| |(Vent | |(C.diff |
+----------+ +----------+ +----------+ +----------+ +----------+
| | | | |
+----------+----------+----------+----------+
|
+--------------------+--------------------+
v v
+-------------------+ +-------------------+
| LLM Extraction | | Rules Engine |
| (Ollama llama3.1)|---> Facts ------->| (NHSN Criteria) |
+-------------------+ +---------+---------+
|
v
+-------------------+
| IP Review |
| (Final Decision) |
+---------+---------+
|
+-----------------------------+
v v
+-------------------+ +-------------------+
| Confirmed HAI | | Confirmed Not HAI |
| (NHSN Events) | | (Rejected) |
+-------------------+ +-------------------+
Links
- Dashboard - Active cases awaiting IP review
- History - Completed reviews (confirmed HAI and confirmed not HAI)
- Reports & Analytics - LLM quality metrics and override tracking
- NHSN Submission - Export or submit confirmed events to NHSN
- ASP Alerts Help - Help for bacteremia and antimicrobial usage alerts