SQL: Finalized Notes for Dates

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 notes that were finalized between two dates that you specify.

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

Caveats

  • The date range you specify is the date range when finalization occurred, not necessarily the date of service.
  • Only finalized notes (both encounter and well) are shown.
  • DAYS_TIL_FINALIZED represents the days elapsed between the date of service and the finalization date. For example, if 9/1 is the DOS but the note was not finalized until 9/4, the DAYS_TIL_FINALIZED would show 3.
  • COSIGNER is the user who cosigned the note, and COSIGN DATE is the timestamp when the note was cosigned. DAYS FROM COSIGN TO FINAL represents the days elapsed between the NP/PA finalizing the note and the supervising physician cosigning the note. If those last three fields are blank, the note has not been co-signed (including physician notes which do not need cosignature).

SQL Code: Firebird

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

select patno, date1 as dos, 'encounter note' as note_type, staff1.staffname as rendering, final_date, round(final_date - date1,1) as days_til_finalized, s2.staffname as cosigner, cosign_date, round( cosign_date - final_date,1) as days_from_cosign_to_final from enc_note
inner join staff1 on staff1.staffid = enc_note.p_addr_id
left outer join staff1 s2 on s2.staffid = enc_note.cosign_addr_id
where final_date between :Start_date and :end_date

union

select patno, date1 as dos, 'well note' as note_type, staff1.staffname as rendering, final_date, round(final_date - date1,1) as days_til_finalized, s2.staffname as cosigner,  cosign_date, round(cosign_date - final_date,1) as days_from_cosign_to_final from physical
inner join staff1 on staff1.staffid =physical.p_addr_id
left outer join staff1 s2 on s2.staffid = physical.cosign_addr_id
where final_date 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 patno, date1 as dos, 'encounter note' as note_type, staff1.staffname as rendering, final_date, round(timestampdiff(day,date1,final_date),1) as days_til_finalized, s2.staffname as cosigner, cosign_date, round(timestampdiff(day,final_date,cosign_date),1) as days_from_cosign_to_final from enc_note
inner join staff1 on staff1.staffid = enc_note.p_addr_id
left outer join staff1 s2 on s2.staffid = enc_note.cosign_addr_id
where final_date between :Start_date and :end_date

union

select patno, date1 as dos, 'well note' as note_type, staff1.staffname as rendering, final_date,round(timestampdiff(day,date1,final_date),1) as days_til_finalized, s2.staffname as cosigner, cosign_date, round(timestampdiff(day,final_date,cosign_date),1) as days_from_cosign_to_final from physical
inner join staff1 on staff1.staffid =physical.p_addr_id
left outer join staff1 s2 on s2.staffid = physical.cosign_addr_id
where final_date between :Start_date and :end_date