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: Meningitis B Doses for 16-21 Year Olds

About

This report shows list of active patients ages 16-21 and the total number of meningitis B vaccines that they have received.

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

Caveats

“Meningitis B” vaccines are any vaccines listed in the patient’s vaccine chart with CVX codes 162-164.  They could have been given by the practice or recorded as legacy vaccines from elsewhere.

Code

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

select a.*, total_menb from 
(
select patno, fname,lname, birthdat, floor(datediff(month, dateadd(day,-extract(day from birthdat)+1,birthdat),  dateadd(day,-extract (day from birthdat)+1,cast('today' as date)) )/12) as age

from register

where status_pat ='ACTIVE'  and patno >99 
and lname <> 'TESTPATIENT'
) a

left outer join
(select patno, count(vacname) as total_menb from vaccine1 where cvxcode in (163,162,164) group by patno) v
on a.patno = v.patno
where age between 16 and 21