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 indicates the elapsed time spent in all statuses for all appointments between the two dates that you specify.
A sample image of this SQL report run in the Database Viewer is shown below:
Caveats
- This report can be modified so that you can determine your average wait time by provider, by appointment type, by phase, etc. Alternatively you can export the raw data to Excel and manipulate it that way.
- This report takes a long time to run. Do not run it for more than a 2-week period (unless your practice is very small).
SQL Code: Firebird
To highlight and copy the code below to your clipboard, simply click the Copy button.
select patno, appt_date,schedule.code1,schedule.uniqkey as appointment_number,description, activity_starttime, activity_endtime, (activity_endtime - activity_starttime)*24*60 as nettime, appt_type.description, staffinit as provider_seen from schedule inner join schedule_pat_trak on (schedule.uniqkey = schedule_pat_trak.schedule_pk_uniqkey ) inner join appt_type on (appt_type.appt_type_id = schedule_pat_trak.activity_status) inner join staff1 on (schedule.addr_id = staff1.staffid ) where schedule.visit_status='Completed' and activity_starttime between :start_date and :enddate
SQL Code: MySQL
To highlight and copy the code below to your clipboard, simply click the Copy button.
select patno, appt_date,schedule.code1,schedule.uniqkey as appointment_number,description, schedule_pat_trak.activity_starttime, schedule_pat_trak.activity_endtime, timestampdiff(minute,schedule_pat_trak.activity_starttime,schedule_pat_trak.activity_endtime) as nettime, appt_type.description, staffinit as provider_seen from schedule inner join schedule_pat_trak on (schedule.uniqkey = schedule_pat_trak.schedule_pk_uniqkey ) inner join appt_type on (appt_type.appt_type_id = schedule_pat_trak.activity_status) inner join staff1 on (schedule.addr_id = staff1.staffid ) where schedule.visit_status='Completed' and schedule_pat_trak.activity_starttime between :start_date and :end_date