query_cohort
Query cohort counts from clinical datasets by filtering on patient demographics, diagnoses, ICU stay, and mortality. Returns patient and admission counts with demographics.
Instructions
Query cohort counts based on filtering criteria.
Used by the cohort builder UI for live updates as users adjust filters. Can also be called directly to get cohort statistics.
Args: dataset: Dataset name, e.g. 'mimic-iv'. age_min: Minimum patient age (0-130, inclusive). age_max: Maximum patient age (0-130, inclusive). gender: Patient gender ('M' or 'F'). icd_codes: List of ICD diagnosis code prefixes to filter by. icd_match_all: If True, patient must have ALL ICD codes (AND); default is ANY (OR). has_icu_stay: If True, require ICU stay; if False, exclude ICU patients. in_hospital_mortality: If True, require in-hospital death; if False, exclude deaths.
Returns: JSON with patient_count, admission_count, demographics, and SQL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| age_min | No | ||
| age_max | No | ||
| gender | No | ||
| icd_codes | No | ||
| icd_match_all | No | ||
| has_icu_stay | No | ||
| in_hospital_mortality | No | ||
| dataset | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |