SQL: Total E&M Productivity by Month

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 looks for the total number of sick and well E&M done by rendering providers per month based on a date range you specify.

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

Caveats

  • You must use OP’s billing module for this SQL to work.
  • Codes in the 99201-99215 and 99381-99395 series count.  So 99211 counts as an E&M for this purpose.

SQL Code: Firebird

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

select yr, mo, staffinit, count(cptcode) from
(
select eXTRACT(YEAR FROM date1) as yr, extract(month from date1) as mo,   cptcode,staffinit from archive_transactions 
inner join staff1 on staff1.staffid = rend_addr_id
where date1 between :start_date and :end_date
and cptcode not in ('1','2','3','4','99999','113')
and ((cptcode between '99201' and '99215') or (cptcode between '99381' and '99395'))
and archive_flag = 1
order by yr, mo, staffid
) 
group by yr, mo, staffinit


SQL Code: MySQL

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

select yr, mo, staffinit, count(cptcode) from
(
select eXTRACT(YEAR FROM date1) as yr, extract(month from date1) as mo,   cptcode,staff1.staffinit from archive_transactions 
inner join staff1 on staff1.staffid = rend_addr_id
where date1 between :start_date and :end_date
and cptcode not in ('1','2','3','4','99999','113')
and ((cptcode between '99201' and '99215') or (cptcode between '99381' and '99395'))
and archive_flag = 1
order by yr, mo, staffid
) t1
group by yr, mo, staffinit