We are currently updating the OP Help Center content for the release of OP 19, which is a member of the certified OP 14 family of products. OP 19’s 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: Bright Futures Past Due Recall

About

This SQL was used to create the data for the Extreme Practice Makeover presentation at OPUC 2019.

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

Caveats

None

Code

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

select d.* from
(
select c.*, appt_date, code1  from
(
select b.* from
(
select a.*, 
case when months_ago_checkup is null then 'due' 
when months_ago_checkup >=12 then 'due' 
when months_ago_checkup >=6 and months_old >= 20.75 and months_old <35.5 then 'due'  
when months_ago_checkup >=3 and months_old >= 8.75  and months_old <20.75 then 'due' 
when months_ago_checkup >=3 and months_old >= 7.75 and months_old <8.75 then 'due'
when months_ago_checkup >=2 and months_old >=1.75  and months_old <7.75 then 'due'
when months_ago_checkup >=1 and months_old <1.75 then 'due'
else 'ok'  end as due
from (
select register.patno, fname, lname, register.birthdat, (datediff(month, dateadd(day,-extract(day from birthdat)+1,birthdat), dateadd(day,-extract (day from birthdat)+1,cast('today' as date)))) as months_old,  last_pe, floor(datediff(month, dateadd(day,-extract(day from last_pe)+1,last_pe), dateadd(day,-extract (day from last_pe)+1,cast('today' as date)))) as months_ago_checkup from register
left outer join (select patno, max(date1) as last_pe from physical group by patno) p on p.patno = register.patno
where status_pat = 'ACTIVE' and register.patno >99 and lname <> 'TESTPATIENT') a
) b 
) c
left outer join (select * from schedule where appt_date >= cast('today' as date) and ((visit_status <> 'Cancelled' and visit_status not like 'No Show%') or visit_status is null)) s on s.patno = c.patno
) d