Dana-Farber wants to compare department readmission performance. Write a SQL query that identifies the departments with the highest 30-day readmission rates among completed admissions in the six-month period ending on the latest admission date in the data.
An admission is readmitted when the same patient has a subsequent admission after discharge and no later than 30 days after discharge. Count each eligible index admission at most once, even if it has multiple qualifying readmissions.
Output
- Return one row per department with at least one eligible admission.
- Include
department_name, eligible_admissions, readmitted_admissions, readmission_rate_pct, and department_rank.
- Return the top three departments, ordered by descending readmission rate. Break ties by department name alphabetically.
- Exclude admissions with a NULL discharge date from the eligible population.