SQL: Nurse Vaccine Productivity

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 SQL is intended to indicate who the vaccinator was for all the shots given in your office during a selected date range.

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

Caveats

"Vaccinator" is defined as the staff member that appears in the S_ADDR_ID.  Most practices use this as "who actually poked the kid.”  If your practice enters “ordering doc” here instead, you’ll receive different results.

"Number of kids who got vaccinated" is different than  "number of separate sticks" because Bertha might give 4 flu shots, one to each of 4 kids, and Wanda might give 4 vaccines to 1 baby.

SQL Code: Firebird

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

select  date_given,count(patno) as kids, sum(shots) as sticks, vaccinator from
(

select patno, date_given, count(vaccine) as shots, vaccinator from
(
select patno, vacdate as date_given,vacname as vaccine,  staff2.staffname as vaccinator
from vaccine1
inner join staff1 staff2 on staff2.staffid = vaccine1.s_addr_id
inner join vac_inventory on vac_inventory.uniqkey = vaccine1.vac_lot_id
where vacdate between :start_date and :end_date and vaccine1.vfc1 <> 9
)
group by patno, date_given, vaccinator
order by date_given
) group by date_given, vaccinator


SQL Code: MySQL

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

select  date_given,count(patno) as kids, sum(shots) as sticks, vaccinator from
(

select patno, date_given, count(vaccine) as shots, vaccinator from
(
select patno, vacdate as date_given,vaccine1.vacname as vaccine,  staff2.staffname as vaccinator
from vaccine1
inner join staff1 staff2 on staff2.staffid = vaccine1.s_addr_id
inner join vac_inventory on vac_inventory.uniqkey = vaccine1.vac_lot_id
where vacdate between :start_date and :end_date and vaccine1.vfc1 <> 9
) t1
group by patno, date_given, vaccinator
order by date_given
) t2 group by date_given, vaccinator