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: Unbilled After Hours Codes

About

This report shows all encounter notes reflecting dates of Saturday or Sunday where neither 99050 or 99051 was billed for a date of service range that you specify.

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

Caveats

Inpatient services (POS 21 and 22) are excluded.

Code

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

select distinct * from
(
select a.patno, a.date1,  cptcode, a.ins_carrier_code from 
(
SELECT at1.PATNO,
      at1.DATE1, at1.ins_carrier_code, lname,
      EXTRACT(WEEKDAY FROM at1.DATE1) as weekday
FROM ARCHIVE_TRANSACTIONS at1
inner join register on register.patno = at1.patno

WHERE
      ( at1.DATE1 BETWEEN :start_date and :end_date)
      AND ( at1.CPTCODE NOT IN ('1', '2', '26', 'PLA')
      and at1.archive_flag = 1 )
      AND ( at1.POS NOT IN ('21','22') ) 
and EXTRACT(WEEKDAY FROM at1.DATE1) in (6,7)
ORDER BY at1.DATE1,
             at1.PATNO
) a
left outer join
(select patno, date1, cptcode from archive_transactions where date1 between :start_date and :end_date and cptcode in ('99051','99050') and archive_flag = 1) ah on (ah.patno = a.patno) and (ah.date1 = a.date1)
) where cptcode is null