SQL: Unbilled Encounter Notes

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 shows all encounter notes and whether something was billed on those dates of service for a date of service range you specify.

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

Caveats

An encounter note will show with a blank row under "CODES" if no CPT codes of any kind were billed on that date of service.

SQL Code: Firebird

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

select enc_note.patno, fname, lname, enc_note.date1, cast(mdm_plan as char(30000)) as mdm_plan, codes from enc_note
inner join register on register.patno = enc_note.patno
left outer join (select patno, date1, cast(list(cptcode,',') as char(200)) as codes from archive_transactions where date1 between :start_Date and :end_date and archive_Flag = 1 and cptcode not in ('1','2','3','4') group by patno, date1) a on a.patno = enc_note.patno and a.date1 = enc_note.date1
where enc_note.date1 between :start_Date and :end_date


SQL Code: MySQL

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

select enc_note.patno, fname, lname, enc_note.date1, mdm_plan, codes from enc_note
inner join register on register.patno = enc_note.patno
left outer join (select patno, date1,group_concat(cptcode separator ',') as codes  from archive_transactions where date1 between :start_date and :end_date and archive_Flag = 1 and cptcode not in ('1','2','3','4') group by patno, date1) a on a.patno = enc_note.patno and a.date1 = enc_note.date1
where enc_note.date1 between :start_date and :end_date