MIMIC-IV Patient Analysis: Comprehensive QA Generation
Goal
Systematically explore a patient's complete clinical record and submit diverse, high-quality QA pairs covering all meaningful clinical domains. Target 20–30 QA pairs for complex patients with multiple admissions; 10–15 for simple cases.
Database Overview
27 tables with two prefixes:
hosp_ — hospital-level data (diagnoses, procedures, medications, admissions, labs)
icu_ — ICU-specific data (stays, inputs/outputs, procedures, events)
Three metadata tables: table_comments, column_comments, column_documentation
Start with get_database_info to confirm available tables.
Key Column Names (Common Pitfalls)
Incorrect column names are the #1 cause of failed queries.
| Table |
Use This |
NOT This |
hosp_prescriptions |
drug, starttime, doses_per_24_hrs |
medication, start_date, frequency |
hosp_pharmacy |
medication, route, frequency |
drug |
hosp_emar |
medication, event_txt, charttime |
route, dose_val_rx |
hosp_d_icd_diagnoses |
long_title |
description, title |
hosp_d_icd_procedures |
long_title |
description |
icu_icustays |
los |
length, length_of_stay |
hosp_omr |
subject_id, chartdate, result_name, result_value |
hadm_id, charttime, result_unit |
hosp_drgcodes |
description (own column, no JOIN needed) |
joining a separate dictionary |
hosp_hcpcsevents |
hcpcs_cd, short_description |
joining hosp_d_hcpcs on hcpcs_cd |
hosp_poe |
order_type, order_subtype, ordertime |
order_name |
hosp_transfers |
careunit, intime, outtime, eventtype |
unit, transfer_type |
hosp_services |
transfertime, curr_service, prev_service |
starttime |
hosp_microbiologyevents |
spec_type_desc, org_name, ab_name, interpretation |
specimen_type, organism_name |
Critical drug column distinction: hosp_prescriptions uses drug (orders). hosp_pharmacy and hosp_emar use medication (dispensed/administered). Using medication in hosp_prescriptions will always fail.
Critical: hosp_labevents does NOT exist. Use hosp_omr for outpatient measurements. Use icu_inputevents/icu_outputevents for ICU lab-like data.
Core JOIN Patterns
-- hosp_prescriptions: drug frequency across all admissions
SELECT drug, COUNT(*) as cnt FROM hosp_prescriptions
WHERE hadm_id IN (SELECT hadm_id FROM hosp_admissions WHERE subject_id = <sid>)
GROUP BY drug ORDER BY cnt DESC LIMIT 20
-- hosp_pharmacy: dispensed medications (uses medication, not drug; no subject_id column)
SELECT medication, route, frequency, COUNT(*) as cnt
FROM hosp_pharmacy
WHERE hadm_id IN (SELECT hadm_id FROM hosp_admissions WHERE subject_id = <sid>)
GROUP BY medication ORDER BY cnt DESC LIMIT 20
-- hosp_omr: query directly by subject_id (outpatient measurements)
SELECT chartdate, result_name, result_value
FROM hosp_omr WHERE subject_id = <sid> ORDER BY chartdate
-- ICD diagnosis with readable title
SELECT d.hadm_id, d.seq_num, d.icd_code, d.icd_version, dt.long_title
FROM hosp_diagnoses_icd d
JOIN hosp_d_icd_diagnoses dt ON d.icd_code = dt.icd_code AND d.icd_version = dt.icd_version
WHERE d.subject_id = <sid>
-- Tables with hadm_id only (no subject_id): JOIN through hosp_admissions
SELECT ... FROM hosp_services s
JOIN hosp_admissions ha ON s.hadm_id = ha.hadm_id
WHERE ha.subject_id = <sid>
-- ICU stays: JOIN through hosp_admissions
SELECT ic.stay_id, ic.hadm_id, ic.intime, ic.outtime, ic.los, ic.first_careunit
FROM icu_icustays ic
JOIN hosp_admissions ha ON ic.hadm_id = ha.hadm_id
WHERE ha.subject_id = <sid>
-- ICU inputs aggregated (total per medication)
SELECT di.label, SUM(ie.amount) as total, ie.amountuom
FROM icu_inputevents ie JOIN icu_d_items di ON ie.itemid = di.itemid
WHERE ie.stay_id = <stay_id> GROUP BY di.label, ie.amountuom ORDER BY total DESC
-- ICU outputs (urine, drainage)
SELECT di.label, SUM(oe.value) as total, oe.valueuom
FROM icu_outputevents oe JOIN icu_d_items di ON oe.itemid = di.itemid
WHERE oe.stay_id = <stay_id> GROUP BY di.label, oe.valueuom
-- ICU procedures (ventilation, dialysis): duration in minutes
SELECT di.label, SUM(pe.value) as total_minutes, pe.valueuom
FROM icu_procedureevents pe JOIN icu_d_items di ON pe.itemid = di.itemid
WHERE pe.stay_id = <stay_id> GROUP BY di.label, pe.valueuom
When a query fails with "no such column", check column_comments:
SELECT column_name, comment FROM column_comments WHERE table_name = '<table>'
Systematic Exploration Order
Phase 1 — Foundation (always first)
- Patient demographics:
hosp_patients → age, gender, date of death
- Admissions overview:
hosp_admissions → count, dates, admission types, insurance, discharge locations, in-hospital deaths. For many admissions, query total count first, then fetch in batches.
- Diagnoses:
hosp_diagnoses_icd JOIN hosp_d_icd_diagnoses → primary and comorbid conditions. Use OFFSET to paginate if results are capped.
- Procedures:
hosp_procedures_icd JOIN hosp_d_icd_procedures → surgical and clinical interventions
- ICU stays:
icu_icustays (JOIN through hosp_admissions) → LOS, care units, timing
Phase 2 — Care Context
- Clinical services:
hosp_services → service transitions per admission
- Prescriptions (ordered):
hosp_prescriptions → GROUP BY drug ORDER BY COUNT(*) DESC for most-ordered drugs. Use drug column, not medication.
- Pharmacy (dispensed):
hosp_pharmacy → GROUP BY medication ORDER BY COUNT(*) DESC for most-dispensed drugs with route/frequency detail. This complements prescriptions and is often more clinically specific.
- DRG classifications:
hosp_drgcodes → billing severity and mortality risk (description is inline, no JOIN needed)
- Transfers:
hosp_transfers → intra-hospital care unit movement sequences
- Microbiology:
hosp_microbiologyevents → organisms, antibiotic sensitivities (always include ab_name and interpretation columns for resistance patterns)
Phase 3 — Clinical Depth (when ICU stays exist, do steps 12–13; otherwise pursue as relevant)
- ICU inputs/outputs: For each ICU stay, query
icu_inputevents and icu_outputevents by stay_id → aggregate (GROUP BY di.label, SUM(amount)) to identify key medications, vasopressors, fluid totals, and urine output. For extended stays (>5 days), also check icu_ingredientevents for nutritional formula totals.
- ICU procedures:
icu_procedureevents → ventilation duration (sum of minutes), dialysis
- Outpatient measurements:
hosp_omr → weight, BMI, blood pressure trends over time
- eMAR:
hosp_emar → actual medication administrations with GROUP BY medication, event_txt ORDER BY COUNT(*) DESC
- Provider orders:
hosp_poe → COUNT(*) GROUP BY order_type for order distribution
- HCPCS events:
hosp_hcpcsevents → billed services/procedures
Phase 4 — Synthesis
- Identify clinically interesting patterns: readmission intervals (days between discharge and next admission), disease progression, care escalation over time, discharge destination evolution, per-admission diagnosis complexity (diagnoses count per hadm_id)
- Look for cross-cutting themes: recurrent infections with same/different organisms, resistance evolution, DRG severity trajectory, ICU readmissions
Aggregation tip: When a table returns truncated results, use COUNT(*) first, then GROUP BY for summary, and OFFSET to paginate. Prefer compact aggregate queries over many sequential offset queries.
QA Generation Strategy
Coverage Targets
Generate QA pairs across these domains — focus on what's clinically rich for this patient.
| Domain |
Example question angles |
| Primary diagnoses & admission drivers |
What condition drove each admission? Sequence of complications? |
| Comorbid conditions |
Which chronic diseases appear across all/most admissions? |
| Surgical/procedural interventions |
What procedures were performed, when, and for what indication? |
| Medication regimen |
Most prescribed drugs across all admissions? Dosing details for critical medications? |
| Pharmacy dispensing |
Most frequently dispensed medications with route/frequency details? |
| Care trajectory |
How did admission frequency, sources, and discharge destinations change over time? |
| Clinical service assignments |
Which services managed the patient and when did they transition? |
| ICU care |
What infusions (vasopressors, sedation, antibiotics) were used with total amounts? What was fluid balance? |
| Infectious complications |
What organisms were cultured? Full resistance/sensitivity pattern per organism? |
| DRG severity |
How did DRG classifications and severity scores change over admissions? |
| Discharge & outcomes |
Where was the patient discharged across admissions? In-hospital deaths? DNR documentation? |
| Longitudinal trends |
How did weight, BMI, blood pressure change over the observation period? |
| Transfer & care unit patterns |
What was the intra-hospital care unit sequence during complex admissions? |
| Readmission patterns |
What were the intervals between discharge and readmission? Which periods had rapid readmissions? |
| Admission complexity |
How many diagnoses per admission? Which admissions were most diagnostically complex? |
| Nutritional support |
What were the volumes and types of enteral/parenteral nutrition during prolonged ICU stays? |
| Advance care planning |
When was DNR status first documented and how consistently maintained? |
QA Quality Standards
Strong QA pairs include:
- Concrete values: Exact dates, drug names with doses/totals (e.g., "Heparin 69,193 units"), organism names with full resistance patterns, LOS in days, procedure names with laterality
- Clinical context: Not just the fact but why it matters (e.g., "discharged to rehab, indicating functional impairment")
- Completeness: Full enumeration when there are only a few items (e.g., list all 4 ICU stays with dates and durations); summaries with top items when there are many
- Cross-cutting synthesis: Connecting data from multiple tables or admissions into a coherent narrative
Anti-patterns to avoid:
- Vague counts without specifics: "19 prescription orders were placed" → instead name the top drugs with counts
- Trivial single-fact answers: "The patient is a 76-year-old male on Medicare" → embed demographics into richer clinical context
- Redundant pairs covering the same information in slightly different wording
- Schema questions ("What columns does this table have?")
Example: weak vs. strong
- Weak: "What were the prescriptions for this patient?" → "19 prescription orders were placed, including both MAIN and BASE drug types."
- Strong: "What were the most frequently prescribed medications?" → "Insulin (65 prescriptions), Furosemide (34), Warfarin (16), Aspirin (15), Levothyroxine (13) — reflecting diabetes, heart failure, and thyroid management."
High-Value QA Types
These patterns tend to produce rich, specific QA pairs:
- ICU medication details: "What vasopressors/sedatives/antibiotics were used during [ICU stay] and in what total amounts?" (requires
icu_inputevents aggregation)
- Antibiotic resistance patterns: "What organisms were identified and what was the resistance/sensitivity pattern per organism?" (requires
hosp_microbiologyevents with ab_name + interpretation)
- Longitudinal trajectory: "How did discharge destinations change over [N] years?" or "What was the pattern of care escalation?"
- Readmission intervals: "What were the shortest intervals between discharge and subsequent readmission, and what were the associated conditions?"
- Specific procedural detail: "What specific approach was used for [procedure] and what was the clinical indication?"
- Drug frequency across all admissions: "What were the top 10 most prescribed/dispensed medications across all admissions?" (requires both
hosp_prescriptions + hosp_pharmacy)
- DRG severity evolution: "How did DRG severity and mortality scores change over successive admissions?"
- Care unit progression during complex admission: "What care units did the patient transit through during their longest hospitalization and in what order?"
- Fluid balance during ICU: "What were the total inputs and outputs during [ICU stay]?" (requires
icu_inputevents + icu_outputevents)
- Advance care planning: "When was DNR status first documented and how consistently was it recorded?"
- Admission pattern analysis: "What was the distribution of admission types, sources, and frequency over the observation period?"
- Per-admission complexity: "Which admissions had the most diagnoses and what conditions drove their complexity?"
Submission Pattern
Submit QA pairs in thematic batches after completing each exploration phase — don't submit one at a time. Interleave: explore a domain → verify data quality → submit 3–6 related QA pairs → continue. This ensures progress is saved and helps maintain thematic coherence in QA pairs.
Handling Query Failures
When a query fails:
- Read the error — it often lists the available columns for that table
- Correct the column name using the table above and retry once
- If still failing, check
column_comments for the correct schema
- If a table doesn't exist, use the alternatives listed above
Do not spend more than 2 retries on any single query — move on if data isn't available.
1---2name: mimic-iv-patient-analysis-23description: Comprehensive strategy for analyzing individual patient records in MIMIC-IV EHR database and generating high-quality, diverse QA pairs. Use this skill whenever the task involves analyzing a specific patient's clinical data from MIMIC-IV (or similar EHR databases), querying across hospital and ICU tables, and submitting QA pairs that cover the patient's full clinical story — diagnoses, procedures, medications, care trajectory, and outcomes. Trigger when you see tasks like "Analyze patient <ID>", "Generate QA pairs for patient", or any patient-centric EHR exploration task.4---56# MIMIC-IV Patient Analysis: Comprehensive QA Generation78## Goal910Systematically explore a patient's complete clinical record and submit diverse, high-quality QA pairs covering all meaningful clinical domains. Target 20–30 QA pairs for complex patients with multiple admissions; 10–15 for simple cases.1112## Database Overview131427 tables with two prefixes:15- **`hosp_`** — hospital-level data (diagnoses, procedures, medications, admissions, labs)16- **`icu_`** — ICU-specific data (stays, inputs/outputs, procedures, events)1718Three metadata tables: `table_comments`, `column_comments`, `column_documentation`1920Start with `get_database_info` to confirm available tables.2122## Key Column Names (Common Pitfalls)2324Incorrect column names are the #1 cause of failed queries.2526| Table | Use This | NOT This |27|---|---|---|28| `hosp_prescriptions` | `drug`, `starttime`, `doses_per_24_hrs` | `medication`, `start_date`, `frequency` |29| `hosp_pharmacy` | `medication`, `route`, `frequency` | `drug` |30| `hosp_emar` | `medication`, `event_txt`, `charttime` | `route`, `dose_val_rx` |31| `hosp_d_icd_diagnoses` | `long_title` | `description`, `title` |32| `hosp_d_icd_procedures` | `long_title` | `description` |33| `icu_icustays` | `los` | `length`, `length_of_stay` |34| `hosp_omr` | `subject_id`, `chartdate`, `result_name`, `result_value` | `hadm_id`, `charttime`, `result_unit` |35| `hosp_drgcodes` | `description` (own column, no JOIN needed) | joining a separate dictionary |36| `hosp_hcpcsevents` | `hcpcs_cd`, `short_description` | joining `hosp_d_hcpcs` on `hcpcs_cd` |37| `hosp_poe` | `order_type`, `order_subtype`, `ordertime` | `order_name` |38| `hosp_transfers` | `careunit`, `intime`, `outtime`, `eventtype` | `unit`, `transfer_type` |39| `hosp_services` | `transfertime`, `curr_service`, `prev_service` | `starttime` |40| `hosp_microbiologyevents` | `spec_type_desc`, `org_name`, `ab_name`, `interpretation` | `specimen_type`, `organism_name` |4142**Critical drug column distinction**: `hosp_prescriptions` uses `drug` (orders). `hosp_pharmacy` and `hosp_emar` use `medication` (dispensed/administered). Using `medication` in `hosp_prescriptions` will always fail.4344**Critical**: `hosp_labevents` does NOT exist. Use `hosp_omr` for outpatient measurements. Use `icu_inputevents`/`icu_outputevents` for ICU lab-like data.4546## Core JOIN Patterns4748```sql49-- hosp_prescriptions: drug frequency across all admissions50SELECT drug, COUNT(*) as cnt FROM hosp_prescriptions51WHERE hadm_id IN (SELECT hadm_id FROM hosp_admissions WHERE subject_id = <sid>)52GROUP BY drug ORDER BY cnt DESC LIMIT 205354-- hosp_pharmacy: dispensed medications (uses medication, not drug; no subject_id column)55SELECT medication, route, frequency, COUNT(*) as cnt56FROM hosp_pharmacy57WHERE hadm_id IN (SELECT hadm_id FROM hosp_admissions WHERE subject_id = <sid>)58GROUP BY medication ORDER BY cnt DESC LIMIT 205960-- hosp_omr: query directly by subject_id (outpatient measurements)61SELECT chartdate, result_name, result_value62FROM hosp_omr WHERE subject_id = <sid> ORDER BY chartdate6364-- ICD diagnosis with readable title65SELECT d.hadm_id, d.seq_num, d.icd_code, d.icd_version, dt.long_title66FROM hosp_diagnoses_icd d67JOIN hosp_d_icd_diagnoses dt ON d.icd_code = dt.icd_code AND d.icd_version = dt.icd_version68WHERE d.subject_id = <sid>6970-- Tables with hadm_id only (no subject_id): JOIN through hosp_admissions71SELECT ... FROM hosp_services s72JOIN hosp_admissions ha ON s.hadm_id = ha.hadm_id73WHERE ha.subject_id = <sid>7475-- ICU stays: JOIN through hosp_admissions76SELECT ic.stay_id, ic.hadm_id, ic.intime, ic.outtime, ic.los, ic.first_careunit77FROM icu_icustays ic78JOIN hosp_admissions ha ON ic.hadm_id = ha.hadm_id79WHERE ha.subject_id = <sid>8081-- ICU inputs aggregated (total per medication)82SELECT di.label, SUM(ie.amount) as total, ie.amountuom83FROM icu_inputevents ie JOIN icu_d_items di ON ie.itemid = di.itemid84WHERE ie.stay_id = <stay_id> GROUP BY di.label, ie.amountuom ORDER BY total DESC8586-- ICU outputs (urine, drainage)87SELECT di.label, SUM(oe.value) as total, oe.valueuom88FROM icu_outputevents oe JOIN icu_d_items di ON oe.itemid = di.itemid89WHERE oe.stay_id = <stay_id> GROUP BY di.label, oe.valueuom9091-- ICU procedures (ventilation, dialysis): duration in minutes92SELECT di.label, SUM(pe.value) as total_minutes, pe.valueuom93FROM icu_procedureevents pe JOIN icu_d_items di ON pe.itemid = di.itemid94WHERE pe.stay_id = <stay_id> GROUP BY di.label, pe.valueuom95```9697When a query fails with "no such column", check `column_comments`:98```sql99SELECT column_name, comment FROM column_comments WHERE table_name = '<table>'100```101102## Systematic Exploration Order103104### Phase 1 — Foundation (always first)1051. **Patient demographics**: `hosp_patients` → age, gender, date of death1062. **Admissions overview**: `hosp_admissions` → count, dates, admission types, insurance, discharge locations, in-hospital deaths. For many admissions, query total count first, then fetch in batches.1073. **Diagnoses**: `hosp_diagnoses_icd` JOIN `hosp_d_icd_diagnoses` → primary and comorbid conditions. Use `OFFSET` to paginate if results are capped.1084. **Procedures**: `hosp_procedures_icd` JOIN `hosp_d_icd_procedures` → surgical and clinical interventions1095. **ICU stays**: `icu_icustays` (JOIN through `hosp_admissions`) → LOS, care units, timing110111### Phase 2 — Care Context1126. **Clinical services**: `hosp_services` → service transitions per admission1137. **Prescriptions (ordered)**: `hosp_prescriptions` → `GROUP BY drug ORDER BY COUNT(*) DESC` for most-ordered drugs. Use `drug` column, not `medication`.1148. **Pharmacy (dispensed)**: `hosp_pharmacy` → `GROUP BY medication ORDER BY COUNT(*) DESC` for most-dispensed drugs with route/frequency detail. This complements prescriptions and is often more clinically specific.1159. **DRG classifications**: `hosp_drgcodes` → billing severity and mortality risk (description is inline, no JOIN needed)11610. **Transfers**: `hosp_transfers` → intra-hospital care unit movement sequences11711. **Microbiology**: `hosp_microbiologyevents` → organisms, antibiotic sensitivities (always include `ab_name` and `interpretation` columns for resistance patterns)118119### Phase 3 — Clinical Depth (when ICU stays exist, do steps 12–13; otherwise pursue as relevant)12012. **ICU inputs/outputs**: For each ICU stay, query `icu_inputevents` and `icu_outputevents` by `stay_id` → aggregate (`GROUP BY di.label, SUM(amount)`) to identify key medications, vasopressors, fluid totals, and urine output. For extended stays (>5 days), also check `icu_ingredientevents` for nutritional formula totals.12113. **ICU procedures**: `icu_procedureevents` → ventilation duration (sum of minutes), dialysis12214. **Outpatient measurements**: `hosp_omr` → weight, BMI, blood pressure trends over time12315. **eMAR**: `hosp_emar` → actual medication administrations with `GROUP BY medication, event_txt ORDER BY COUNT(*) DESC`12416. **Provider orders**: `hosp_poe` → `COUNT(*) GROUP BY order_type` for order distribution12517. **HCPCS events**: `hosp_hcpcsevents` → billed services/procedures126127### Phase 4 — Synthesis12818. Identify clinically interesting patterns: readmission intervals (days between discharge and next admission), disease progression, care escalation over time, discharge destination evolution, per-admission diagnosis complexity (diagnoses count per hadm_id)12919. Look for cross-cutting themes: recurrent infections with same/different organisms, resistance evolution, DRG severity trajectory, ICU readmissions130131**Aggregation tip**: When a table returns truncated results, use `COUNT(*)` first, then `GROUP BY` for summary, and `OFFSET` to paginate. Prefer compact aggregate queries over many sequential offset queries.132133## QA Generation Strategy134135### Coverage Targets136137Generate QA pairs across these domains — focus on what's clinically rich for this patient.138139| Domain | Example question angles |140|---|---|141| Primary diagnoses & admission drivers | What condition drove each admission? Sequence of complications? |142| Comorbid conditions | Which chronic diseases appear across all/most admissions? |143| Surgical/procedural interventions | What procedures were performed, when, and for what indication? |144| Medication regimen | Most prescribed drugs across all admissions? Dosing details for critical medications? |145| Pharmacy dispensing | Most frequently dispensed medications with route/frequency details? |146| Care trajectory | How did admission frequency, sources, and discharge destinations change over time? |147| Clinical service assignments | Which services managed the patient and when did they transition? |148| ICU care | What infusions (vasopressors, sedation, antibiotics) were used with total amounts? What was fluid balance? |149| Infectious complications | What organisms were cultured? Full resistance/sensitivity pattern per organism? |150| DRG severity | How did DRG classifications and severity scores change over admissions? |151| Discharge & outcomes | Where was the patient discharged across admissions? In-hospital deaths? DNR documentation? |152| Longitudinal trends | How did weight, BMI, blood pressure change over the observation period? |153| Transfer & care unit patterns | What was the intra-hospital care unit sequence during complex admissions? |154| Readmission patterns | What were the intervals between discharge and readmission? Which periods had rapid readmissions? |155| Admission complexity | How many diagnoses per admission? Which admissions were most diagnostically complex? |156| Nutritional support | What were the volumes and types of enteral/parenteral nutrition during prolonged ICU stays? |157| Advance care planning | When was DNR status first documented and how consistently maintained? |158159### QA Quality Standards160161**Strong QA pairs include:**162- **Concrete values**: Exact dates, drug names with doses/totals (e.g., "Heparin 69,193 units"), organism names with full resistance patterns, LOS in days, procedure names with laterality163- **Clinical context**: Not just the fact but why it matters (e.g., "discharged to rehab, indicating functional impairment")164- **Completeness**: Full enumeration when there are only a few items (e.g., list all 4 ICU stays with dates and durations); summaries with top items when there are many165- **Cross-cutting synthesis**: Connecting data from multiple tables or admissions into a coherent narrative166167**Anti-patterns to avoid:**168- Vague counts without specifics: "19 prescription orders were placed" → instead name the top drugs with counts169- Trivial single-fact answers: "The patient is a 76-year-old male on Medicare" → embed demographics into richer clinical context170- Redundant pairs covering the same information in slightly different wording171- Schema questions ("What columns does this table have?")172173**Example: weak vs. strong**174- Weak: "What were the prescriptions for this patient?" → "19 prescription orders were placed, including both MAIN and BASE drug types."175- Strong: "What were the most frequently prescribed medications?" → "Insulin (65 prescriptions), Furosemide (34), Warfarin (16), Aspirin (15), Levothyroxine (13) — reflecting diabetes, heart failure, and thyroid management."176177### High-Value QA Types178179These patterns tend to produce rich, specific QA pairs:1801811. **ICU medication details**: "What vasopressors/sedatives/antibiotics were used during [ICU stay] and in what total amounts?" (requires `icu_inputevents` aggregation)1822. **Antibiotic resistance patterns**: "What organisms were identified and what was the resistance/sensitivity pattern per organism?" (requires `hosp_microbiologyevents` with `ab_name` + `interpretation`)1833. **Longitudinal trajectory**: "How did discharge destinations change over [N] years?" or "What was the pattern of care escalation?"1844. **Readmission intervals**: "What were the shortest intervals between discharge and subsequent readmission, and what were the associated conditions?"1855. **Specific procedural detail**: "What specific approach was used for [procedure] and what was the clinical indication?"1866. **Drug frequency across all admissions**: "What were the top 10 most prescribed/dispensed medications across all admissions?" (requires both `hosp_prescriptions` + `hosp_pharmacy`)1877. **DRG severity evolution**: "How did DRG severity and mortality scores change over successive admissions?"1888. **Care unit progression during complex admission**: "What care units did the patient transit through during their longest hospitalization and in what order?"1899. **Fluid balance during ICU**: "What were the total inputs and outputs during [ICU stay]?" (requires `icu_inputevents` + `icu_outputevents`)19010. **Advance care planning**: "When was DNR status first documented and how consistently was it recorded?"19111. **Admission pattern analysis**: "What was the distribution of admission types, sources, and frequency over the observation period?"19212. **Per-admission complexity**: "Which admissions had the most diagnoses and what conditions drove their complexity?"193194### Submission Pattern195196Submit QA pairs in thematic batches after completing each exploration phase — don't submit one at a time. Interleave: explore a domain → verify data quality → submit 3–6 related QA pairs → continue. This ensures progress is saved and helps maintain thematic coherence in QA pairs.197198## Handling Query Failures199200When a query fails:2011. Read the error — it often lists the available columns for that table2022. Correct the column name using the table above and retry once2033. If still failing, check `column_comments` for the correct schema2044. If a table doesn't exist, use the alternatives listed above205206Do not spend more than 2 retries on any single query — move on if data isn't available.