Write a SQL query to calculate 30-day readmission rates by hospital unit from patient encounter data.
Use completed inpatient encounters as the denominator. A readmission occurs when the same patient has another inpatient admission after discharge and within 30 days of the index discharge date.
unit_id, unit_name, eligible_discharges, readmissions_within_30_days, and readmission_rate_pctunit_id ascending| Column | Type | Description |
|---|---|---|
| encounter_idPK | INT | Unique patient encounter identifier |
| patient_id | INT | Patient identifier |
| unit_id | INT | Hospital unit associated with the encounter |
| admission_date | DATE | Date the patient was admitted |
| discharge_date | DATE | Date the patient was discharged |
| encounter_type | VARCHAR(30) | Type of encounter, such as Inpatient or Observation |
| discharge_status | VARCHAR(30) | Disposition recorded at discharge |
| Column | Type | Description |
|---|---|---|
| unit_idPK | INT | Unique hospital unit identifier |
| unit_name | VARCHAR(100) | Hospital unit name |