Write a SQL query to calculate each office's monthly treatment acceptance rate and average revenue per patient from appointment, treatment, and payment tables. Use completed appointments, attribute payments to the appointment month, and exclude cancelled appointments. Treat only accepted and declined treatments as treatment opportunities.
Output
- One row per office and calendar month, ordered by
office_id, then month_start.
- Columns:
office_id, month_start, treatment_acceptance_rate, and average_revenue_per_patient.
- Return zero for missing treatment or revenue values.