Calculate Hospital Frailty Risk Score (HFRS) for ICU patients using ICD diagnosis codes. Use for frailty assessment, risk stratification, or outcome prediction in older patients. Supports both ICD-9-CM and ICD-10-CM codes for MIMIC-IV compatibility.
Calculate HFRS from ICD diagnosis codes. Based on Gilbert et al. (2018) Lancet methodology with 109 weighted ICD-10 codes.
Per the original publication, HFRS is calculated using diagnoses from:
Each unique ICD code is counted only once, even if it appears in multiple admissions.
| Score |
|---|
| Category |
|---|
| 30-day Mortality OR |
|---|
| < 5 | Low | Reference |
| 5-15 | Intermediate | 1.65 (1.62-1.68) |
| > 15 | High | 1.71 (1.68-1.75) |
ICD-9 mappings are NOT part of the original publication. They have been added for MIMIC-IV compatibility, which contains both ICD-9 and ICD-10 coded admissions. Use ICD-9 mappings with appropriate caution.
Emergency admission types in MIMIC-IV: The SQL implementation considers EMERGENCY, URGENT, and EW EMER. as emergency admissions.
Code matching uses 3-character prefix for ICD-10 (e.g., F05 matches F05.0, F05.1). ICD-9 uses variable-length matching.
| ICD-10 | Points | Description |
|---|---|---|
| F00 | 7.1 | Dementia in Alzheimer's |
| G81 | 4.4 | Hemiplegia |
| G30 | 4.0 | Alzheimer's disease |
| I69 | 3.7 | Sequelae of CVD |
| R29 | 3.6 | Tendency to fall |
| F05 | 3.2 | Delirium |
| N39 | 3.2 | UTI/incontinence |
| W19 | 3.2 | Unspecified fall |
Full 109-code list: references/hfrs_icd_codes.csv
-- See scripts/calculate_hfrs.sql for the complete query
-- Key tables used:
-- - mimiciv_hosp.admissions (admission dates and types)
-- - mimiciv_hosp.diagnoses_icd (ICD codes)
-- Simplified example: score a single admission
SELECT
a.subject_id,
a.hadm_id,
SUM(w.points) AS hfrs_score
FROM mimiciv_hosp.diagnoses_icd d
JOIN mimiciv_hosp.admissions a ON d.hadm_id = a.hadm_id
JOIN hfrs_weights w ON d.icd_code LIKE w.icd_prefix || '%'
AND d.icd_version = w.icd_version
GROUP BY a.subject_id, a.hadm_id;
from scripts.calculate_hfrs import calculate_hfrs
diagnoses = [
{'icd_code': 'F05', 'icd_version': 10}, # Delirium
{'icd_code': '2900', 'icd_version': 9}, # Dementia (ICD-9)
{'icd_code': 'R29', 'icd_version': 10}, # Falls
]
result = calculate_hfrs(diagnoses)
print(f"HFRS: {result['score']} ({result['risk_category']} risk)")