MIMIC-IV Patient Analysis
Perform a comprehensive, systematic analysis of a patient's complete clinical record from the MIMIC-IV database by querying the SQLite database directly and efficiently.
Database Structure
The database has 27 tables. Key tables and their primary columns:
Core patient tables:
hosp_patients — demographics: subject_id, gender, anchor_age, anchor_year, anchor_year_group, dod
hosp_admissions — hospital stays: subject_id, hadm_id, admittime, dischtime, deathtime, admission_type, admission_location, discharge_location, insurance, language, marital_status, race, edregtime, edouttime, hospital_expire_flag
Clinical data (per admission):
hosp_diagnoses_icd — ICD diagnoses: subject_id, hadm_id, seq_num, icd_code, icd_version
hosp_d_icd_diagnoses — diagnosis dictionary: icd_code, icd_version, long_title
hosp_procedures_icd — ICD procedures: subject_id, hadm_id, seq_num, chartdate, icd_code, icd_version
hosp_d_icd_procedures — procedure dictionary: icd_code, icd_version, long_title
hosp_drgcodes — DRG billing: subject_id, hadm_id, drg_type, drg_code, description, drg_severity, drg_mortality
hosp_services — clinical service: subject_id, hadm_id, transfertime, prev_service, curr_service
hosp_transfers — unit movements: subject_id, hadm_id, transfer_id, eventtype, careunit, intime, outtime
Medications:
hosp_prescriptions — prescribed drugs: subject_id, hadm_id, starttime, stoptime, drug, drug_type, dose_val_rx, dose_unit_rx, route
hosp_emar — administration record: subject_id, hadm_id, emar_id, charttime, medication, event_txt, scheduletime
hosp_pharmacy — pharmacy fills: subject_id, hadm_id, pharmacy_id, drug, starttime, stoptime
Diagnostics:
hosp_microbiologyevents — cultures: subject_id, hadm_id, charttime, spec_type_desc, test_name, org_name, interpretation, comments
hosp_omr — vitals/anthropometrics: subject_id, chartdate, seq_num, result_name, result_value
hosp_hcpcsevents — billing codes: subject_id, hadm_id, chartdate, hcpcs_cd, short_description
hosp_d_hcpcs — HCPCS dictionary: code, category, long_description, short_description
Orders:
hosp_poe — provider orders: subject_id, hadm_id, poe_id, ordertime, order_type, order_subtype, transaction_type, order_status
ICU tables (only present if patient had ICU stay):
icu_icustays — ICU episodes: subject_id, hadm_id, stay_id, first_careunit, last_careunit, intime, outtime, los
icu_inputevents — IV fluids/medications: stay_id, starttime, endtime, itemid, amount, amountuom, ordercategoryname
icu_outputevents — urine/drainage: stay_id, charttime, itemid, value, valueuom
icu_procedureevents — ICU procedures: stay_id, starttime, endtime, itemid, value, valueuom, ordercategoryname
icu_d_items — ICU item dictionary: itemid, label, category
Critical Column Name Pitfalls
Avoid these common errors that cause query failures:
| Table |
WRONG |
CORRECT |
hosp_transfers |
transfertime |
intime (sort by intime) |
hosp_poe |
order_time |
ordertime |
hosp_omr |
charttime |
chartdate |
hosp_hcpcsevents JOIN hosp_d_hcpcs |
ON h.hcpcs_cd = d.hcpcs_cd |
ON h.hcpcs_cd = d.code |
hosp_procedures_icd JOIN hosp_d_icd_procedures |
alias mismatch |
ensure alias used in JOIN matches the one defined |
Analysis Workflow
Start with get_database_info to confirm table availability, then query directly — do not call describe_table before each query; use the column names listed above.
Step 1 — Patient demographics
SELECT * FROM hosp_patients WHERE subject_id = <patient_id>
Note: anchor_age is age in anchor_year (dates are shifted for privacy). If dod is not null, the patient died.
Step 2 — All hospital admissions
SELECT * FROM hosp_admissions WHERE subject_id = <patient_id> ORDER BY admittime
For each hadm_id, note: admission/discharge times, type, source, destination, insurance, hospital_expire_flag.
Track discharge destination progression across admissions (HOME → HOME HEALTH CARE → SNF → LTACH → died in hospital) as it signals functional decline trajectory.
Step 3 — ICU stays
SELECT * FROM icu_icustays WHERE subject_id = <patient_id> ORDER BY intime
Empty result = no ICU. If ICU present, note care units and length of stay (los).
Step 3.5 — ICU deep dive (when ICU stays exist)
For each stay_id, query ICU event tables for critical clinical detail:
-- Procedures (ventilation, dialysis, arterial lines, etc.)
SELECT pe.starttime, pe.endtime, d.label, d.category, pe.value, pe.valueuom
FROM icu_procedureevents pe
JOIN icu_d_items d ON pe.itemid = d.itemid
WHERE pe.stay_id = <stay_id>
ORDER BY pe.starttime
-- Key inputs (fluids, vasopressors, medications)
SELECT ie.starttime, d.label, d.category, ie.amount, ie.amountuom, ie.ordercategoryname
FROM icu_inputevents ie
JOIN icu_d_items d ON ie.itemid = d.itemid
WHERE ie.stay_id = <stay_id>
ORDER BY ie.starttime LIMIT 50
-- Outputs (urine, drainage)
SELECT oe.charttime, d.label, oe.value, oe.valueuom
FROM icu_outputevents oe
JOIN icu_d_items d ON oe.itemid = d.itemid
WHERE oe.stay_id = <stay_id>
ORDER BY oe.charttime LIMIT 30
From ICU events, capture: mechanical ventilation duration, vasopressor use, fluid balance (total inputs vs outputs), dialysis/CRRT, invasive monitoring (arterial line, central line).
Step 4 — Diagnoses (with human-readable names)
SELECT d.icd_code, d.icd_version, d.long_title, diag.hadm_id, diag.seq_num
FROM hosp_diagnoses_icd diag
JOIN hosp_d_icd_diagnoses d ON diag.icd_code = d.icd_code AND diag.icd_version = d.icd_version
WHERE diag.subject_id = <patient_id>
ORDER BY diag.hadm_id, diag.seq_num
seq_num=1 is the primary diagnosis. Note special ICD codes:
- Z88x = drug allergy documentation (e.g., Z880 = penicillin allergy)
- Z66 = do not resuscitate (DNR) order
- Z515 = encounter for palliative care
- Z79x = long-term medication use (e.g., Z7901 = anticoagulants)
For patients with 4+ admissions, also run an aggregate query to identify recurring diagnoses:
SELECT d.long_title, COUNT(*) as admission_count
FROM hosp_diagnoses_icd diag
JOIN hosp_d_icd_diagnoses d ON diag.icd_code = d.icd_code AND diag.icd_version = d.icd_version
WHERE diag.subject_id = <patient_id> AND diag.seq_num <= 5
GROUP BY d.long_title
ORDER BY admission_count DESC
LIMIT 20
Step 5 — Procedures
SELECT p.hadm_id, p.seq_num, p.chartdate, p.icd_code, proc.long_title
FROM hosp_procedures_icd p
JOIN hosp_d_icd_procedures proc ON p.icd_code = proc.icd_code AND p.icd_version = proc.icd_version
WHERE p.subject_id = <patient_id>
ORDER BY p.hadm_id, p.seq_num
Step 6 — Medications prescribed
SELECT hadm_id, drug, starttime, stoptime, dose_val_rx, dose_unit_rx, route
FROM hosp_prescriptions
WHERE subject_id = <patient_id>
ORDER BY hadm_id, starttime
For patients with 4+ admissions, rank medications by frequency:
SELECT drug, COUNT(*) as prescription_count
FROM hosp_prescriptions
WHERE subject_id = <patient_id>
GROUP BY drug
ORDER BY prescription_count DESC
LIMIT 20
Step 7 — Physical measurements (BMI, weight, height, BP)
SELECT chartdate, result_name, result_value
FROM hosp_omr
WHERE subject_id = <patient_id>
ORDER BY chartdate
For longitudinal patients, separately track weight and blood pressure trends:
SELECT chartdate, result_value FROM hosp_omr
WHERE subject_id = <patient_id> AND result_name = 'Weight (Lbs)'
ORDER BY chartdate
SELECT chartdate, result_value FROM hosp_omr
WHERE subject_id = <patient_id> AND result_name = 'Blood Pressure'
ORDER BY chartdate
Weight loss ≥5% from baseline is clinically significant; ≥10% suggests disease-related cachexia or malnutrition.
Step 8 — Microbiology cultures
SELECT chartdate, spec_type_desc, test_name, org_name, interpretation, comments
FROM hosp_microbiologyevents
WHERE subject_id = <patient_id>
ORDER BY chartdate
org_name null with a comment like "< 10,000 CFU/mL" = negative culture. For positive cultures, record the organism name, specimen type, and interpretation.
Step 9 — Clinical service and transfers
-- Service
SELECT * FROM hosp_services WHERE subject_id = <patient_id> ORDER BY transfertime
-- Physical location movements (per hadm_id)
SELECT * FROM hosp_transfers WHERE hadm_id = <hadm_id> ORDER BY intime
Step 10 — DRG billing codes
SELECT * FROM hosp_drgcodes WHERE subject_id = <patient_id>
APR-DRG has severity (1-4) and mortality (1-4) scores. Severity 3-4 or mortality 3-4 indicates a high-complexity/high-risk admission.
Step 11 — Provider orders and eMAR (targeted)
-- Provider orders overview
SELECT ordertime, order_type, order_subtype, transaction_type, order_status
FROM hosp_poe WHERE subject_id = <patient_id> AND hadm_id = <hadm_id>
ORDER BY ordertime LIMIT 30
-- Medication administration (check "Not Given" vs "Administered")
SELECT charttime, medication, event_txt, scheduletime
FROM hosp_emar WHERE subject_id = <patient_id> AND hadm_id = <hadm_id>
ORDER BY charttime LIMIT 50
The hosp_emar event_txt field distinguishes "Administered" from "Not Given" — this reveals medication compliance and route changes (PO/NG route = nasogastric feeding, suggesting dysphagia).
Synthesizing the Analysis
After gathering data, produce a structured summary covering:
- Demographics — age, sex, race, insurance, vital status (alive/deceased + date if known)
- Admission summary — number of admissions, date range, types, sources, discharge destinations; explicitly note trajectory (e.g., progressive shift to institutional discharge = functional decline)
- ICU course — whether ICU was needed, which units, total duration, key interventions (ventilation, vasopressors, fluid balance if queried)
- Primary diagnoses by admission — primary condition per hadm_id; use a table format for multi-admission patients
- Comorbidities — significant secondary diagnoses across admissions; for multi-admission patients, note which conditions appear across how many admissions
- Procedures — surgical and therapeutic interventions with dates
- Medications — key drug classes, notable transitions or polypharmacy; for multi-admission patients, list top prescriptions by frequency
- Diagnostics — positive culture results (organism + specimen), physical measurement trends (weight trajectory, BP range)
- Clinical service trajectory — services and care unit progression across admissions
- Key clinical insights — clinically meaningful patterns with explanations:
- Discharge to rehab/SNF → functional impairment
- Multiple laxatives (Senna + Bisacodyl + Docusate) → immobility or opioid use
- PO/NG drug routes → nasogastric feeding (likely dysphagia)
- Sequential anticoagulant changes → treatment optimization
- Z88x codes → drug allergies
- Z66/Z515 codes → DNR/palliative care goals
- Weight loss ≥10% → cachexia or disease progression
- Insurance transition Private→Medicare → age 65 crossed during observation period
- Discharge destinations: HOME → HOME HEALTH → SNF → LTACH → hospital death = functional decline
Include evidence anchors: specific ICD codes, exact dates, drug names with doses, organism names, DRG severity/mortality scores, and weight values. These factual anchors make the analysis verifiable and clinically useful.
End the analysis with FINISH: followed by the full summary.
Efficiency Tips
- Query all admissions first, then drill into individual
hadm_id values for detailed data
- For patients with multiple admissions, use
subject_id-level queries before hadm_id-level ones
- If a query fails with a column error, correct the column name immediately using the pitfalls table above — do not call
describe_table
- Use LIMIT when exploring eMAR/POE (large tables); paginate with OFFSET if needed
- For ICU patients, prioritize
icu_procedureevents (procedures are most clinically discriminating) over exhaustive input/output enumeration
- Skip ICU event tables entirely when
icu_icustays returns empty
1---2name: mimic-patient-analysis-33description: Comprehensive patient analysis using the MIMIC-IV clinical database. Use this skill whenever asked to analyze, summarize, or investigate a patient's medical history, hospital admissions, diagnoses, medications, procedures, or clinical course from a MIMIC-IV SQLite database. Triggers on prompts like "Analyze patient [ID]", "summarize patient history", "what happened to patient X", or any request to explore patient-level EHR data from MIMIC-IV tables.4---56# MIMIC-IV Patient Analysis78Perform a comprehensive, systematic analysis of a patient's complete clinical record from the MIMIC-IV database by querying the SQLite database directly and efficiently.910## Database Structure1112The database has 27 tables. Key tables and their primary columns:1314**Core patient tables:**15- `hosp_patients` — demographics: `subject_id, gender, anchor_age, anchor_year, anchor_year_group, dod`16- `hosp_admissions` — hospital stays: `subject_id, hadm_id, admittime, dischtime, deathtime, admission_type, admission_location, discharge_location, insurance, language, marital_status, race, edregtime, edouttime, hospital_expire_flag`1718**Clinical data (per admission):**19- `hosp_diagnoses_icd` — ICD diagnoses: `subject_id, hadm_id, seq_num, icd_code, icd_version`20- `hosp_d_icd_diagnoses` — diagnosis dictionary: `icd_code, icd_version, long_title`21- `hosp_procedures_icd` — ICD procedures: `subject_id, hadm_id, seq_num, chartdate, icd_code, icd_version`22- `hosp_d_icd_procedures` — procedure dictionary: `icd_code, icd_version, long_title`23- `hosp_drgcodes` — DRG billing: `subject_id, hadm_id, drg_type, drg_code, description, drg_severity, drg_mortality`24- `hosp_services` — clinical service: `subject_id, hadm_id, transfertime, prev_service, curr_service`25- `hosp_transfers` — unit movements: `subject_id, hadm_id, transfer_id, eventtype, careunit, intime, outtime`2627**Medications:**28- `hosp_prescriptions` — prescribed drugs: `subject_id, hadm_id, starttime, stoptime, drug, drug_type, dose_val_rx, dose_unit_rx, route`29- `hosp_emar` — administration record: `subject_id, hadm_id, emar_id, charttime, medication, event_txt, scheduletime`30- `hosp_pharmacy` — pharmacy fills: `subject_id, hadm_id, pharmacy_id, drug, starttime, stoptime`3132**Diagnostics:**33- `hosp_microbiologyevents` — cultures: `subject_id, hadm_id, charttime, spec_type_desc, test_name, org_name, interpretation, comments`34- `hosp_omr` — vitals/anthropometrics: `subject_id, chartdate, seq_num, result_name, result_value`35- `hosp_hcpcsevents` — billing codes: `subject_id, hadm_id, chartdate, hcpcs_cd, short_description`36- `hosp_d_hcpcs` — HCPCS dictionary: `code, category, long_description, short_description`3738**Orders:**39- `hosp_poe` — provider orders: `subject_id, hadm_id, poe_id, ordertime, order_type, order_subtype, transaction_type, order_status`4041**ICU tables (only present if patient had ICU stay):**42- `icu_icustays` — ICU episodes: `subject_id, hadm_id, stay_id, first_careunit, last_careunit, intime, outtime, los`43- `icu_inputevents` — IV fluids/medications: `stay_id, starttime, endtime, itemid, amount, amountuom, ordercategoryname`44- `icu_outputevents` — urine/drainage: `stay_id, charttime, itemid, value, valueuom`45- `icu_procedureevents` — ICU procedures: `stay_id, starttime, endtime, itemid, value, valueuom, ordercategoryname`46- `icu_d_items` — ICU item dictionary: `itemid, label, category`4748## Critical Column Name Pitfalls4950Avoid these common errors that cause query failures:5152| Table | WRONG | CORRECT |53|-------|-------|---------|54| `hosp_transfers` | `transfertime` | `intime` (sort by `intime`) |55| `hosp_poe` | `order_time` | `ordertime` |56| `hosp_omr` | `charttime` | `chartdate` |57| `hosp_hcpcsevents` JOIN `hosp_d_hcpcs` | `ON h.hcpcs_cd = d.hcpcs_cd` | `ON h.hcpcs_cd = d.code` |58| `hosp_procedures_icd` JOIN `hosp_d_icd_procedures` | alias mismatch | ensure alias used in JOIN matches the one defined |5960## Analysis Workflow6162Start with `get_database_info` to confirm table availability, then query directly — **do not call `describe_table` before each query**; use the column names listed above.6364### Step 1 — Patient demographics65```sql66SELECT * FROM hosp_patients WHERE subject_id = <patient_id>67```68Note: `anchor_age` is age in `anchor_year` (dates are shifted for privacy). If `dod` is not null, the patient died.6970### Step 2 — All hospital admissions71```sql72SELECT * FROM hosp_admissions WHERE subject_id = <patient_id> ORDER BY admittime73```74For each `hadm_id`, note: admission/discharge times, type, source, destination, insurance, hospital_expire_flag.7576**Track discharge destination progression across admissions** (HOME → HOME HEALTH CARE → SNF → LTACH → died in hospital) as it signals functional decline trajectory.7778### Step 3 — ICU stays79```sql80SELECT * FROM icu_icustays WHERE subject_id = <patient_id> ORDER BY intime81```82Empty result = no ICU. If ICU present, note care units and length of stay (`los`).8384#### Step 3.5 — ICU deep dive (when ICU stays exist)8586For each `stay_id`, query ICU event tables for critical clinical detail:8788```sql89-- Procedures (ventilation, dialysis, arterial lines, etc.)90SELECT pe.starttime, pe.endtime, d.label, d.category, pe.value, pe.valueuom91FROM icu_procedureevents pe92JOIN icu_d_items d ON pe.itemid = d.itemid93WHERE pe.stay_id = <stay_id>94ORDER BY pe.starttime9596-- Key inputs (fluids, vasopressors, medications)97SELECT ie.starttime, d.label, d.category, ie.amount, ie.amountuom, ie.ordercategoryname98FROM icu_inputevents ie99JOIN icu_d_items d ON ie.itemid = d.itemid100WHERE ie.stay_id = <stay_id>101ORDER BY ie.starttime LIMIT 50102103-- Outputs (urine, drainage)104SELECT oe.charttime, d.label, oe.value, oe.valueuom105FROM icu_outputevents oe106JOIN icu_d_items d ON oe.itemid = d.itemid107WHERE oe.stay_id = <stay_id>108ORDER BY oe.charttime LIMIT 30109```110111From ICU events, capture: mechanical ventilation duration, vasopressor use, fluid balance (total inputs vs outputs), dialysis/CRRT, invasive monitoring (arterial line, central line).112113### Step 4 — Diagnoses (with human-readable names)114```sql115SELECT d.icd_code, d.icd_version, d.long_title, diag.hadm_id, diag.seq_num116FROM hosp_diagnoses_icd diag117JOIN hosp_d_icd_diagnoses d ON diag.icd_code = d.icd_code AND diag.icd_version = d.icd_version118WHERE diag.subject_id = <patient_id>119ORDER BY diag.hadm_id, diag.seq_num120```121`seq_num=1` is the primary diagnosis. Note special ICD codes:122- **Z88x** = drug allergy documentation (e.g., Z880 = penicillin allergy)123- **Z66** = do not resuscitate (DNR) order124- **Z515** = encounter for palliative care125- **Z79x** = long-term medication use (e.g., Z7901 = anticoagulants)126127**For patients with 4+ admissions**, also run an aggregate query to identify recurring diagnoses:128```sql129SELECT d.long_title, COUNT(*) as admission_count130FROM hosp_diagnoses_icd diag131JOIN hosp_d_icd_diagnoses d ON diag.icd_code = d.icd_code AND diag.icd_version = d.icd_version132WHERE diag.subject_id = <patient_id> AND diag.seq_num <= 5133GROUP BY d.long_title134ORDER BY admission_count DESC135LIMIT 20136```137138### Step 5 — Procedures139```sql140SELECT p.hadm_id, p.seq_num, p.chartdate, p.icd_code, proc.long_title141FROM hosp_procedures_icd p142JOIN hosp_d_icd_procedures proc ON p.icd_code = proc.icd_code AND p.icd_version = proc.icd_version143WHERE p.subject_id = <patient_id>144ORDER BY p.hadm_id, p.seq_num145```146147### Step 6 — Medications prescribed148```sql149SELECT hadm_id, drug, starttime, stoptime, dose_val_rx, dose_unit_rx, route150FROM hosp_prescriptions151WHERE subject_id = <patient_id>152ORDER BY hadm_id, starttime153```154155**For patients with 4+ admissions**, rank medications by frequency:156```sql157SELECT drug, COUNT(*) as prescription_count158FROM hosp_prescriptions159WHERE subject_id = <patient_id>160GROUP BY drug161ORDER BY prescription_count DESC162LIMIT 20163```164165### Step 7 — Physical measurements (BMI, weight, height, BP)166```sql167SELECT chartdate, result_name, result_value168FROM hosp_omr169WHERE subject_id = <patient_id>170ORDER BY chartdate171```172173For longitudinal patients, separately track weight and blood pressure trends:174```sql175SELECT chartdate, result_value FROM hosp_omr176WHERE subject_id = <patient_id> AND result_name = 'Weight (Lbs)'177ORDER BY chartdate178179SELECT chartdate, result_value FROM hosp_omr180WHERE subject_id = <patient_id> AND result_name = 'Blood Pressure'181ORDER BY chartdate182```183184**Weight loss ≥5% from baseline is clinically significant**; ≥10% suggests disease-related cachexia or malnutrition.185186### Step 8 — Microbiology cultures187```sql188SELECT chartdate, spec_type_desc, test_name, org_name, interpretation, comments189FROM hosp_microbiologyevents190WHERE subject_id = <patient_id>191ORDER BY chartdate192```193`org_name` null with a comment like "< 10,000 CFU/mL" = negative culture. For positive cultures, record the organism name, specimen type, and interpretation.194195### Step 9 — Clinical service and transfers196```sql197-- Service198SELECT * FROM hosp_services WHERE subject_id = <patient_id> ORDER BY transfertime199200-- Physical location movements (per hadm_id)201SELECT * FROM hosp_transfers WHERE hadm_id = <hadm_id> ORDER BY intime202```203204### Step 10 — DRG billing codes205```sql206SELECT * FROM hosp_drgcodes WHERE subject_id = <patient_id>207```208APR-DRG has severity (1-4) and mortality (1-4) scores. Severity 3-4 or mortality 3-4 indicates a high-complexity/high-risk admission.209210### Step 11 — Provider orders and eMAR (targeted)211```sql212-- Provider orders overview213SELECT ordertime, order_type, order_subtype, transaction_type, order_status214FROM hosp_poe WHERE subject_id = <patient_id> AND hadm_id = <hadm_id>215ORDER BY ordertime LIMIT 30216217-- Medication administration (check "Not Given" vs "Administered")218SELECT charttime, medication, event_txt, scheduletime219FROM hosp_emar WHERE subject_id = <patient_id> AND hadm_id = <hadm_id>220ORDER BY charttime LIMIT 50221```222223The `hosp_emar` `event_txt` field distinguishes "Administered" from "Not Given" — this reveals medication compliance and route changes (PO/NG route = nasogastric feeding, suggesting dysphagia).224225## Synthesizing the Analysis226227After gathering data, produce a structured summary covering:2282291. **Demographics** — age, sex, race, insurance, vital status (alive/deceased + date if known)2302. **Admission summary** — number of admissions, date range, types, sources, discharge destinations; explicitly note trajectory (e.g., progressive shift to institutional discharge = functional decline)2313. **ICU course** — whether ICU was needed, which units, total duration, key interventions (ventilation, vasopressors, fluid balance if queried)2324. **Primary diagnoses by admission** — primary condition per hadm_id; use a table format for multi-admission patients2335. **Comorbidities** — significant secondary diagnoses across admissions; for multi-admission patients, note which conditions appear across how many admissions2346. **Procedures** — surgical and therapeutic interventions with dates2357. **Medications** — key drug classes, notable transitions or polypharmacy; for multi-admission patients, list top prescriptions by frequency2368. **Diagnostics** — positive culture results (organism + specimen), physical measurement trends (weight trajectory, BP range)2379. **Clinical service trajectory** — services and care unit progression across admissions23810. **Key clinical insights** — clinically meaningful patterns with explanations:239 - Discharge to rehab/SNF → functional impairment240 - Multiple laxatives (Senna + Bisacodyl + Docusate) → immobility or opioid use241 - PO/NG drug routes → nasogastric feeding (likely dysphagia)242 - Sequential anticoagulant changes → treatment optimization243 - Z88x codes → drug allergies244 - Z66/Z515 codes → DNR/palliative care goals245 - Weight loss ≥10% → cachexia or disease progression246 - Insurance transition Private→Medicare → age 65 crossed during observation period247 - Discharge destinations: HOME → HOME HEALTH → SNF → LTACH → hospital death = functional decline248249**Include evidence anchors**: specific ICD codes, exact dates, drug names with doses, organism names, DRG severity/mortality scores, and weight values. These factual anchors make the analysis verifiable and clinically useful.250251End the analysis with `FINISH:` followed by the full summary.252253## Efficiency Tips254255- Query all admissions first, then drill into individual `hadm_id` values for detailed data256- For patients with multiple admissions, use `subject_id`-level queries before `hadm_id`-level ones257- If a query fails with a column error, correct the column name immediately using the pitfalls table above — do not call `describe_table`258- Use LIMIT when exploring eMAR/POE (large tables); paginate with OFFSET if needed259- For ICU patients, prioritize `icu_procedureevents` (procedures are most clinically discriminating) over exhaustive input/output enumeration260- Skip ICU event tables entirely when `icu_icustays` returns empty