SQL: Invalid Appointment Types Associated to Visit Templates

About

This SQL identifies Appointment Types attached to Visit Templates that do not match an Appointment Type in your system.

A sample image of this SQL report run in the Database Viewer is shown below:

Caveats

  • If the SQL returns no results, then there is no action necessary. 
  • If results are returned, the Visit Templates need to be edited to either remove the Default Appointment Type or select a valid Appointment Type.
  • The query does display archived Visit Templates.

Code

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

select e.enc_form_template as template_name, e.appt_as_scheduled as appointment_type, 'ENCOUNTER' as template_type from enc_note e where e.patno = -100 and e.appt_as_scheduled is not null and e.appt_as_scheduled <> '' and e.appt_as_scheduled  not in ( select code1 from appt_type where code_type = 0) union select p.frm_nm as template_name, p.appt_as_scheduled as appointment_tpye, 'WELL' as template_type from phystmpl p where p.appt_as_scheduled is not null and p.appt_as_scheduled <> '' and p.appt_as_scheduled  not in (select code1 from appt_type where code_type = 0)