SQL: HEDIS-like W34

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 is similar to HEDIS W34. It takes all currently-active patients who were 3-6 years old as of a reference date you specify, and determines whether they had a checkup in the previous 365 days of the reference date.

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

Caveats

  • The report looks for patients who are CURRENTLY active (who may or may not have been active on the reference date).
  • “Recent checkup” only shows if the checkup has been done in the previous 365 days from the reference date.  For example, a patient who had a checkup done 400 days before the reference date will show a blank. It will not the most recent reference date.
  • Status date shows when patients’ status was last changed with your practice. This allows you to exclude patients who have, for example, only been active one month with your practice.
  • By changing the age limits to read “Between 11 and 21,” you can make this into a AWC (Adolescent Well Checkup) HEDIS measure.

SQL Code: Firebird

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

select b.*, case when recent_checkup is not null then 'pass' else 'fail' end as metric from
(
select a.*, recent_checkup from 
(
select patno, birthdat, status_date, staffname, ins_carrier_code, floor(datediff(month, dateadd(day,-extract(day from birthdat)+1,birthdat), dateadd(day,-extract (day from birthdat)+1,cast(:ref_date as date)))/12)  as age from register
inner join staff1 on staff1.staffid=register.addr_id
where status_pat = 'ACTIVE' 
) a 
left outer join
(select max(date1) as recent_checkup, patno from physical where date1 between :ref_date - 365 and :ref_date group by patno) p on p.patno = a.patno
where age between 3 and 6
) b


SQL Code: MySQL

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

select b.*, case when recent_checkup is not null then 'pass' else 'fail' end as metric from
(
select a.*, recent_checkup from 
(
select patno, birthdat, status_date, staffname, ins_carrier_code, floor(timestampdiff(month,birthdat,cast(:ref_date as date))) as age from register
inner join staff1 on staff1.staffid=register.addr_id
where status_pat = 'ACTIVE' 
) a 
left outer join
(select max(date1) as recent_checkup, patno from physical where date1 between :ref_date - 365 and :ref_date group by patno) p on p.patno = a.patno
where age between 3 and 6
) b