athenahealth uses encounter and outcome data to monitor operational performance across providers. Write a PostgreSQL query to identify the providers with the highest rate of negative encounter outcomes during the last completed calendar quarter.
Treat DENIED and DELAYED outcomes as negative. The rate is negative outcomes divided by all qualifying encounters, including encounters with no recorded outcome.
Requirements
- Filter encounters to the last completed calendar quarter based on the current date.
- Calculate total encounters, negative outcomes, and the negative outcome rate for each provider.
- Return the top five providers, ordered by negative outcome rate descending. Break ties with total encounters descending, then
provider_id ascending.
- Exclude providers with no qualifying encounters.