There are two versions of this SQL: Firebird and MySQL. The MySQL version only applies to clients who are have migrated to MySQL.. All other Practices should continue to use the Firebird version of this code. Click to expand and copy the code you need. If you are unsure which code to use, please check with your Practice Administrator. |
About
This report shows the patient name, DOB, patient phone number, and schedule information (scheduled provider, date/time, and location) for cancelled appointments in a date range that you specify.
A sample image of this SQL report run in the Database Viewer is shown below:
Report Usage Ideas
You can sort by TOTAL_CANCELLED to see the total number of appointments cancelled during the period. This may be useful for following up with patients who cancel more than is typical.
SQL Code: Firebird
To highlight and copy the code below to your clipboard, simply click the Copy button.
with s as ( select uniqkey, patno, ( fname || ' ' || lname) as patient_name, birthdat, code1 as appt_type, hphone, loc_name, staffname as scheduled_provider, dateadd(minute,start_time,appt_date) as appt_time from schedule inner join register on register.patno = schedule.patno inner join staff1 on staff1.staffid = schedule.addr_id inner join location on location.id = schedule.loc_id where appt_date between :start_date and :end_date and visit_status in ( 'Cancelled','Cancelled Same Day') order by patno ) select s.*, total_cancelled from s inner join (select patno, count(uniqkey) as total_cancelled from s group by 1) t on t.patno = s.patno
SQL Code: MySQL
To highlight and copy the code below to your clipboard, simply click the Copy button.
with s as ( select uniqkey, schedule.patno, ( fname || ' ' || lname) as patient_name, birthdat, code1 as appt_type, hphone, loc_name, staffname as scheduled_provider, date_add(appt_date, interval start_time minute) as appt_time from schedule inner join register on register.patno = schedule.patno inner join staff1 on staff1.staffid = schedule.addr_id inner join location on location.id = schedule.loc_id where appt_date between :start_date and :end_date and visit_status in ( 'Cancelled','Cancelled Same Day') order by schedule.patno ) select s.*, total_cancelled from s inner join (select patno, count(uniqkey) as total_cancelled from s group by 1) t on t.patno = s.patno