SQL: Invalid Appointment Types on Scheduled Appointments

About

This SQL identifies Appointment Types on scheduled appointments that do not match an Appointment Type in your system.

Caveats

  • If the SQL returns no results, then there is no action necessary. 
  • If results are returned, the appointment needs to be edited so that it includes a valid Appointment Type.

Code

To highlight and copy the code below to your clipboard, simply click the Copy button.

select s.appt_date as appointment_date, s.create_datetime as appointment_scheduled_on, s.patno as patient_id, s.code1 as appt_reason from schedule s where s.appt_date > current_timestamp and s.patno > 0 and s.code1  not in (select code1 from appt_type where code_type = 0) order by s.appt_date