first-icu-stay

Identify first ICU stays and hospital admissions using MIMIC-IV derived fields.

40|17|Updated Oct 27, 2025
One-click install
npx skills add https://github.com/hannesill/m4 --skill first-icu-stay
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: first-icu-stay
Source: https://github.com/hannesill/m4/tree/main/src/m4/skills/clinical/first-icu-stay
Command: npx skills add https://github.com/hannesill/m4 --skill first-icu-stay

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Identify first ICU stays and first hospital admissions to support cohort construction and prevent correlated observations.

Core Features & Use Cases

  • Identify the first ICU stay within each hospitalization and the first hospital admission for a patient to enable independent observations.
  • Select incident ICU patients and apply readmission exclusion to build clean adult cohorts across ICU and inpatient data.
  • Use across analyses requiring patient-level independence and simple cohort reproducibility across datasets.

Quick Start

Identify the first ICU stay and the first hospital admission for each patient to generate independent observations for cohort construction.

Frequently Asked Questions about first-icu-stay

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I identify the first ICU stay for each patient in MIMIC-IV to build an independent cohort?

To identify the first ICU stay in MIMIC-IV, you derive sequence fields like icustay_seq and first_icu_stay to isolate incident admissions. This prevents correlated observations by ensuring only the initial ICU stay is included per patient.

What is readmission exclusion and why is it needed for ICU cohort construction?

Readmission exclusion removes subsequent hospital and ICU visits to maintain patient-level independence in cohort construction. By isolating the first hospital admission using first_hosp_stay, you prevent correlated data points from skewing your analysis.

How do I exclude readmissions across both hospital and ICU levels using SQL?

You exclude readmissions by applying sequential ranking to hospital and ICU stays, then filtering for first_hosp_stay and first_icu_stay. This removes repeat visits from mimiciv_hosp and mimiciv_icu to ensure independent observations.

Can I apply age and duration filters when selecting incident ICU patients?

Yes, you can apply age shifting and duration-based filters alongside first_icu_stay flags to select incident ICU patients. This allows you to build clean adult cohorts while handling mortality flags within the MIMIC-IV dataset.

What MIMIC-IV tables are required to extract the first hospital admission for a patient?

Extracting the first hospital admission requires the mimiciv_hosp and mimiciv_hosp.patients tables. These tables provide the necessary data to generate hospstay_seq and first_hosp_stay fields for isolating incident hospitalizations.

Why does my cohort analysis show correlated observations after selecting ICU stays?

Correlated observations occur when multiple ICU stays per patient are included. You resolve this by applying readmission exclusion logic to retain only the first_icu_stay, ensuring each patient contributes a single independent event to the cohort.