suspicion-of-infection
Identify suspected infection events in MIMIC-IV using antibiotic administration plus culture timing. Use as a component of Sepsis-3 definition or for infection research.
Packaged view
This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.
Install command
npx @skill-hub/cli install hannesill-m4-suspicion-of-infection
Repository
Skill path: src/m4/skills/suspicion-of-infection
Identify suspected infection events in MIMIC-IV using antibiotic administration plus culture timing. Use as a component of Sepsis-3 definition or for infection research.
Open repositoryBest for
Primary workflow: Research & Ops.
Technical facets: Full Stack.
Target audience: everyone.
License: Apache-2.0.
Original source
Catalog source: SkillHub Club.
Repository owner: hannesill.
This is still a mirrored public skill entry. Review the repository before installing into production workflows.
What it helps with
- Install suspicion-of-infection into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
- Review https://github.com/hannesill/m4 before adding suspicion-of-infection to shared team environments
- Use suspicion-of-infection for development workflows
Works across
Favorites: 0.
Sub-skills: 0.
Aggregator: No.
Original source / Raw SKILL.md
---
name: suspicion-of-infection
description: Identify suspected infection events in MIMIC-IV using antibiotic administration plus culture timing. Use as a component of Sepsis-3 definition or for infection research.
license: Apache-2.0
metadata:
author: m4-clinical-extraction
version: "1.0"
database: mimic-iv
category: derived-concepts
source: https://github.com/MIT-LCP/mimic-code/tree/main/mimic-iv/concepts/sepsis
validated: true
---
# Suspicion of Infection
This concept identifies when clinicians suspected infection based on clinical actions: antibiotic administration combined with culture collection within a defined time window.
## When to Use This Skill
- Building Sepsis-3 cohorts (infection component)
- Antibiotic stewardship research
- Time-to-treatment studies
- Infection onset timing
- Culture yield research
## Pre-computed Table
```sql
SELECT
subject_id,
stay_id,
hadm_id,
ab_id, -- Unique antibiotic ID per patient
antibiotic, -- Antibiotic name
antibiotic_time, -- When antibiotic started
suspected_infection, -- 1 if meets criteria, 0 otherwise
suspected_infection_time, -- Onset time of suspected infection
culture_time, -- When culture was obtained
specimen, -- Culture specimen type
positive_culture -- 1 if culture positive, 0 if negative
FROM mimiciv_derived.suspicion_of_infection;
```
## Definition Logic
**Suspected infection** requires BOTH:
1. **Antibiotic administration** (systemic, not topical)
2. **Culture collection** within time window:
- Culture obtained up to 72h BEFORE antibiotic, OR
- Culture obtained up to 24h AFTER antibiotic
### Suspected Infection Time
The `suspected_infection_time` is defined as:
- The **culture time** if culture was obtained BEFORE antibiotic
- The **antibiotic time** if antibiotic was given BEFORE culture
This represents when infection was first clinically suspected.
## Antibiotic Filtering
The query includes systemic antibiotics only:
- **Included routes**: IV, PO, NG, etc.
- **Excluded routes**: Topical (OU, OS, OD, AU, AS, AD, TP), eye drops, ear drops
- **Excluded formulations**: Creams, gels, ophthalmic ointments, desensitization
## Culture Matching Logic
Each antibiotic is matched to cultures in two directions:
### Culture Before Antibiotic (Primary)
- Culture obtained within 72 hours before antibiotic start
- If multiple cultures, uses the EARLIEST culture before the antibiotic
### Culture After Antibiotic (Secondary)
- Culture obtained within 24 hours after antibiotic start
- If multiple cultures, uses the EARLIEST culture after the antibiotic
Priority: Culture-before-antibiotic takes precedence when both exist.
## Critical Implementation Notes
1. **One Row Per Antibiotic**: Each antibiotic prescription gets its own row, potentially matched to one culture.
2. **Duplicate Handling**: A single culture may be matched to multiple antibiotics. A single antibiotic is matched to at most one culture (the earliest relevant one).
3. **ICU Association**: The `stay_id` is populated when antibiotic timing overlaps with an ICU stay. May be NULL for floor patients.
4. **Chart Dates vs Times**: Microbiology cultures sometimes only have dates (not times). When charttime is null, the query uses chartdate for matching.
5. **Positive Culture Flag**: Indicates whether organisms grew. Negative cultures still count as suspected infection (clinical suspicion existed).
6. **Specimen Types**: Include all culture types (blood, urine, sputum, etc.). The `specimen` column identifies the type.
## Example: Infection Events Per Patient
```sql
SELECT
subject_id,
COUNT(*) AS n_suspected_infections,
SUM(positive_culture) AS n_positive_cultures
FROM mimiciv_derived.suspicion_of_infection
WHERE suspected_infection = 1
GROUP BY subject_id
ORDER BY n_suspected_infections DESC;
```
## Example: Time from Culture to Antibiotic
```sql
SELECT
ROUND(
TIMESTAMP_DIFF(antibiotic_time, culture_time, HOUR), 0
) AS culture_to_abx_hours,
COUNT(*) AS n_events
FROM mimiciv_derived.suspicion_of_infection
WHERE suspected_infection = 1
AND culture_time < antibiotic_time -- culture first
GROUP BY 1
ORDER BY 1;
```
## Example: Most Common Antibiotics in Suspected Infection
```sql
SELECT
antibiotic,
COUNT(*) AS n_prescriptions,
SUM(positive_culture) AS n_positive,
ROUND(AVG(positive_culture), 2) AS positive_rate
FROM mimiciv_derived.suspicion_of_infection
WHERE suspected_infection = 1
GROUP BY antibiotic
ORDER BY n_prescriptions DESC
LIMIT 20;
```
## Example: Culture Specimen Distribution
```sql
SELECT
specimen,
COUNT(*) AS n_cultures,
SUM(positive_culture) AS n_positive,
ROUND(AVG(positive_culture), 2) AS positive_rate
FROM mimiciv_derived.suspicion_of_infection
WHERE suspected_infection = 1
GROUP BY specimen
ORDER BY n_cultures DESC;
```
## Related Skills
- [sepsis-3-cohort](../sepsis-3-cohort/SKILL.md) - Complete Sepsis-3 definition
- [sofa-score](../sofa-score/SKILL.md) - Organ dysfunction component
## References
- Singer M et al. "The Third International Consensus Definitions for Sepsis and Septic Shock (Sepsis-3)." JAMA. 2016;315(8):801-810.
---
## Referenced Files
> The following files are referenced in this skill and included for context.
### ../sepsis-3-cohort/SKILL.md
```markdown
---
name: sepsis-3-cohort
description: Identify Sepsis-3 patients in MIMIC-IV using the consensus definition (SOFA >= 2 + suspected infection). Use for sepsis cohort studies, outcome research, or quality metrics.
license: Apache-2.0
metadata:
author: m4-clinical-extraction
version: "1.0"
database: mimic-iv
category: cohort-definitions
source: https://github.com/MIT-LCP/mimic-code/tree/main/mimic-iv/concepts/sepsis
validated: true
---
# Sepsis-3 Cohort Identification
The Sepsis-3 definition (2016) identifies sepsis as life-threatening organ dysfunction caused by a dysregulated host response to infection. Operationalized as:
- **Suspected infection** (antibiotics + culture within time window) AND
- **SOFA score >= 2** (within 48h before to 24h after suspected infection)
## When to Use This Skill
- Creating sepsis patient cohorts for research
- Sepsis outcome studies
- Quality improvement and benchmarking
- Comparing sepsis populations across studies
- Validating machine learning models on sepsis data
## Pre-computed Table
```sql
SELECT
subject_id,
stay_id,
-- Infection details
antibiotic_time,
culture_time,
suspected_infection_time,
-- SOFA details
sofa_time,
sofa_score,
respiration,
coagulation,
liver,
cardiovascular,
cns,
renal,
-- Sepsis flag
sepsis3
FROM mimiciv_derived.sepsis3;
```
## Sepsis-3 Definition Details
### Suspected Infection Criteria
A patient has suspected infection when:
1. **Antibiotics are administered** (IV or oral routes, excluding topical) AND
2. **Cultures are obtained** within a time window:
- Culture within 72h BEFORE antibiotic, OR
- Culture within 24h AFTER antibiotic
### SOFA Criteria
SOFA >= 2 points, where SOFA is calculated using the 24-hour worst values:
- Must occur within 48h before to 24h after suspected infection time
### Important Assumption
**Baseline SOFA is assumed to be 0** for all patients. The true Sepsis-3 definition requires acute change of >= 2 points from baseline, but pre-hospital baseline is rarely available.
## Critical Implementation Notes
1. **ICU-Only Definition**: This query identifies sepsis onset WITHIN the ICU. It cannot detect sepsis present at ICU admission or ED sepsis.
2. **Time of Sepsis Onset**: Defined as the earliest of:
- `suspected_infection_time` (when infection was suspected)
- This is typically the culture time if culture preceded antibiotics
3. **Multiple Antibiotics**: A patient may have multiple antibiotic-culture pairs. The query returns the first (earliest) suspected infection event.
4. **Culture Types**: All culture types are included (blood, urine, respiratory, etc.). Each culture specimen is identified.
5. **Positive vs Negative Cultures**: The `positive_culture` flag indicates whether the culture grew organisms. Sepsis-3 does not require positive cultures.
6. **SOFA Time Window**: SOFA must be >= 2 within:
- 48 hours BEFORE suspected_infection_time, OR
- 24 hours AFTER suspected_infection_time
## Example: Identify Sepsis Cohort
```sql
SELECT
s.stay_id,
ie.subject_id,
ie.hadm_id,
s.suspected_infection_time AS sepsis_onset,
s.sofa_score,
adm.hospital_expire_flag AS mortality
FROM mimiciv_derived.sepsis3 s
INNER JOIN mimiciv_icu.icustays ie ON s.stay_id = ie.stay_id
INNER JOIN mimiciv_hosp.admissions adm ON ie.hadm_id = adm.hadm_id
WHERE s.sepsis3 = TRUE;
```
## Example: Sepsis Severity Distribution
```sql
SELECT
CASE
WHEN sofa_score < 5 THEN 'Mild (SOFA 2-4)'
WHEN sofa_score < 10 THEN 'Moderate (SOFA 5-9)'
WHEN sofa_score < 15 THEN 'Severe (SOFA 10-14)'
ELSE 'Very Severe (SOFA 15+)'
END AS severity,
COUNT(*) AS n_patients,
ROUND(AVG(adm.hospital_expire_flag), 3) AS mortality_rate
FROM mimiciv_derived.sepsis3 s
INNER JOIN mimiciv_icu.icustays ie ON s.stay_id = ie.stay_id
INNER JOIN mimiciv_hosp.admissions adm ON ie.hadm_id = adm.hadm_id
WHERE s.sepsis3 = TRUE
GROUP BY 1
ORDER BY 1;
```
## Example: Time from ICU Admit to Sepsis Onset
```sql
SELECT
ROUND(
TIMESTAMP_DIFF(s.suspected_infection_time, ie.intime, HOUR), 0
) AS hours_to_sepsis,
COUNT(*) AS n_patients
FROM mimiciv_derived.sepsis3 s
INNER JOIN mimiciv_icu.icustays ie ON s.stay_id = ie.stay_id
WHERE s.sepsis3 = TRUE
GROUP BY 1
ORDER BY 1;
```
## Limitations
1. **Baseline SOFA Unknown**: Assumes baseline SOFA = 0, may over-classify chronic organ dysfunction as sepsis
2. **ICU-Only**: Cannot identify ED sepsis or sepsis present on admission
3. **Antibiotic-Dependent**: Requires antibiotic administration - may miss untreated infections
4. **Culture-Dependent**: Requires cultures obtained - may miss clinically diagnosed infections
## Related Skills
- [suspicion-of-infection](../suspicion-of-infection/SKILL.md) - Detailed infection timing
- [sofa-score](../sofa-score/SKILL.md) - SOFA calculation details
## References
- Singer M et al. "The Third International Consensus Definitions for Sepsis and Septic Shock (Sepsis-3)." JAMA. 2016;315(8):801-810.
- Seymour CW et al. "Assessment of Clinical Criteria for Sepsis." JAMA. 2016;315(8):762-774.
```
### ../sofa-score/SKILL.md
```markdown
---
name: sofa-score
description: Calculate SOFA (Sequential Organ Failure Assessment) score for ICU patients in MIMIC-IV. Use for sepsis severity assessment, organ dysfunction quantification, mortality prediction, or Sepsis-3 criteria evaluation.
license: Apache-2.0
metadata:
author: m4-clinical-extraction
version: "1.0"
database: mimic-iv
category: severity-scores
source: https://github.com/MIT-LCP/mimic-code/tree/main/mimic-iv/concepts/score
validated: true
---
# SOFA Score Calculation
The Sequential Organ Failure Assessment (SOFA) score quantifies organ dysfunction across 6 systems. Each component scores 0-4, with a total range of 0-24. Higher scores indicate greater organ dysfunction.
## When to Use This Skill
- User asks about SOFA score calculation
- Sepsis-3 criteria assessment (SOFA >= 2 indicates organ dysfunction)
- Mortality prediction or severity stratification
- Comparing organ dysfunction between cohorts
- Calculating delta-SOFA (change from baseline)
## Components and Scoring
| System | 0 | 1 | 2 | 3 | 4 |
|--------|---|---|---|---|---|
| **Respiration** (PaO2/FiO2 mmHg) | >= 400 | < 400 | < 300 | < 200 + respiratory support | < 100 + respiratory support |
| **Coagulation** (Platelets x10^3/uL) | >= 150 | < 150 | < 100 | < 50 | < 20 |
| **Liver** (Bilirubin mg/dL) | < 1.2 | 1.2-1.9 | 2.0-5.9 | 6.0-11.9 | >= 12.0 |
| **Cardiovascular** | No hypotension | MAP < 70 | Dopa <= 5 or Dob | Dopa > 5 or Epi <= 0.1 or Norepi <= 0.1 | Dopa > 15 or Epi > 0.1 or Norepi > 0.1 |
| **CNS** (GCS) | 15 | 13-14 | 10-12 | 6-9 | < 6 |
| **Renal** (Creatinine mg/dL or UO) | < 1.2 | 1.2-1.9 | 2.0-3.4 | 3.5-4.9 or UO < 500 | >= 5.0 or UO < 200 |
Note: Vasopressor doses are in mcg/kg/min. UO is urine output in mL/day.
## Pre-computed Table
MIMIC-IV provides a pre-computed SOFA table with hourly values:
```sql
SELECT
stay_id,
hr,
starttime,
endtime,
respiration_24hours,
coagulation_24hours,
liver_24hours,
cardiovascular_24hours,
cns_24hours,
renal_24hours,
sofa_24hours
FROM mimiciv_derived.sofa
WHERE hr = 24; -- 24 hours after ICU admission
```
## Required Tables for Custom Calculation
- `mimiciv_icu.icustays` - ICU stay identifiers
- `mimiciv_derived.bg` - Blood gas for PaO2/FiO2 (specimen = 'ART.')
- `mimiciv_derived.chemistry` - Creatinine
- `mimiciv_derived.enzyme` - Bilirubin
- `mimiciv_derived.complete_blood_count` - Platelets
- `mimiciv_derived.gcs` - Glasgow Coma Scale
- `mimiciv_derived.urine_output_rate` - Daily urine output
- `mimiciv_derived.ventilation` - Ventilation status
- `mimiciv_derived.norepinephrine`, `epinephrine`, `dopamine`, `dobutamine` - Vasopressors
## Critical Implementation Notes
1. **Time Window**: The score uses the worst value in a 24-hour rolling window. SOFA calculated at hour 24 uses data from hours 0-24.
2. **Respiratory Score**: Requires interaction between PaO2/FiO2 ratio AND ventilation status:
- Scores of 3 or 4 require mechanical ventilation
- The lowest PaO2/FiO2 is tracked separately for ventilated vs non-ventilated periods
- Important: The original SOFA publication does not explicitly define "respiratory support." In our SQL implementation, we define it as invasive mechanical ventilation only (vd.ventilation_status = 'InvasiveVent'). If you wish to include non-invasive ventilation (e.g., CPAP, BiPAP), modify the filter to: vd.ventilation_status IN ('InvasiveVent', 'NonInvasiveVent').
3. **FiO2 Sources**: FiO2 can come from blood gas measurement OR charted FiO2. When not documented, estimate from supplemental O2 device.
4. **Vasopressor Units**: All vasopressor doses must be in mcg/kg/min. Weight is often estimated (check `mimiciv_derived.weight_durations`).
5. **GCS in Sedated Patients**: For sedated/intubated patients, use pre-sedation GCS or assume normal (GCS=15). The verbal component may be 0 for intubated patients - this is handled specially.
6. **Arterial Blood Gas**: Use only arterial specimens (`specimen = 'ART.'`) for PaO2/FiO2.
7. **Missing Components**: Missing data is imputed as 0 (normal) in the final score. Document which components are missing; do not claim complete scores when data is absent. If you prefer to treat missing data as NA rather than 0, you will need to modify the SQL (remove the COALESCE(..., 0) wrapper). Statistically, it is more appropriate to treat missing values as missing and calculate SOFA scores after proper imputation.
8. **Urine Output Calculation**: Uses `uo_tm_24hr` to verify 24 hours of data available before calculating rate.
## Example: Get SOFA at 24h for All ICU Stays
```sql
SELECT
ie.stay_id,
ie.subject_id,
ie.hadm_id,
s.sofa_24hours,
s.respiration_24hours,
s.coagulation_24hours,
s.liver_24hours,
s.cardiovascular_24hours,
s.cns_24hours,
s.renal_24hours
FROM mimiciv_icu.icustays ie
LEFT JOIN mimiciv_derived.sofa s
ON ie.stay_id = s.stay_id
AND s.hr = 24
ORDER BY s.sofa_24hours DESC NULLS LAST;
```
## Example: Delta-SOFA (Change Over Time)
```sql
WITH sofa_change AS (
SELECT
stay_id,
sofa_24hours AS sofa_day1,
LEAD(sofa_24hours, 24) OVER (
PARTITION BY stay_id ORDER BY hr
) AS sofa_day2
FROM mimiciv_derived.sofa
WHERE hr = 24 OR hr = 48
)
SELECT
stay_id,
sofa_day1,
sofa_day2,
sofa_day2 - sofa_day1 AS delta_sofa
FROM sofa_change
WHERE sofa_day2 IS NOT NULL;
```
## References
- Vincent JL et al. "The SOFA (Sepsis-related Organ Failure Assessment) score to describe organ dysfunction/failure." Intensive Care Medicine. 1996;24(7):707-710.
- Vincent JL et al. Use of the SOFA score to assess the incidence of organ dysfunction/failure in intensive care units: results of a multicenter, prospective study. Working group on "sepsis-related problems" of the European Society of Intensive Care Medicine. Crit Care Med. 1998 Nov;26(11):1793-800.
- Singer M et al. "The Third International Consensus Definitions for Sepsis and Septic Shock (Sepsis-3)." JAMA. 2016;315(8):801-810.
```