We are currently updating the OP Help Center content for the release of OP 14.19 or OP 19. OP 19 is a member of the certified OP 14 family of products (official version is 14.19.1), which you may see in your software (such as in Help > About) and in the Help Center tabs labeled 14.19. You may also notice that the version number in content and videos may not match the version of your software, and some procedural content may not match the workflow in your software. We appreciate your patience and understanding as we make these enhancements.

SQL: Newborns Without Followups

About

This report looks for active patients under the age of 60 days old (at the time the report is run) who do not have a future appointment (of any kind) scheduled. It also lists if patients have had a recent visit in the office. This can be used as a transition of care tracking report for PCMH.

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

Caveats

This report runs off the office Schedule.  It only counts visits in the Recent Visit category if the date is in the past and the status of the appointment is marked Completed. 
Future scheduled appointments don’t show if the status of the appointment is Cancelled.

Code

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

select register.patno,fname,lname,birthdat, recent_visit, sched_next from register 
left outer join
(select patno scpat, max(appt_date) recent_visit from schedule where schedule.visit_status = 'Completed' and patno >= 99 group by patno order by patno) s1 
on s1.scpat = register.patno
left outer join
(select patno, min(appt_date) sched_next, visit_status svs from schedule where appt_date >= cast('now' as date) and (schedule.visit_status not in ('Completed','Cancelled') or schedule.visit_status is null) and  patno >= 101 group by patno, svs order by patno) f on f.patno = register.patno
where status_pat = 'ACTIVE' and cast('now' as date)-birthdat < 60 
and sched_next is null