SQL: Vaccine Payments by VFC Status

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 the vaccines given in the office between two dates you specify. It also shows the VFC status, payments, and adjustments for each vaccine.

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

Caveats

This includes vaccine serum data, but it does not include vaccine administration codes.

SQL Code: Firebird

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

select date1, patno, staffname as rendering_provider, fname, lname, vfc1, vacname, cptcode, charge, ins_carrier_code, ins_carrier_code_other, round(p,2) as ins_paid, round(c,2) as patient_pd, round(a,2) as total_adjustment from vaccine1
inner join register on register.patno =vaccine1.patno
left outer join (Select trnsxno, date1, charge, rend_addr_id, ins_Carrier_code, ins_carrier_code_other, cptcode, patno from archive_transactions where cptcode between '90600' and '90745' and archive_Flag = 1) at1 on at1.patno = vaccine1.patno and at1.date1 = vaccine1.vacdate and at1.cptcode = vaccine1.offcode
left outer join (select sum(payment) as p, sum(copayrecd) as c, sum(adjustment + copayadjustment) as a, txnopaid from archive_transactions group by txnopaid) at2 on at2.txnopaid = at1.trnsxno
left outer join staff1 on staff1.staffid = at1.rend_addr_id
where vacdate between :Start_date and :end_Date and vfc1 <> 9


SQL Code: MySQL

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

select vaccine1.date1, register.patno, staffname as rendering_provider, fname, lname, vfc1, vacname, cptcode, charge, at1.ins_carrier_code, at1.ins_carrier_code_other, round(p,2) as ins_paid, round(c,2) as patient_pd, round(a,2) as total_adjustment from vaccine1
inner join register on register.patno =vaccine1.patno
left outer join (Select trnsxno, date1, charge, rend_addr_id, ins_Carrier_code, ins_carrier_code_other, cptcode, patno from archive_transactions where cptcode between '90600' and '90745' and archive_Flag = 1) at1 on at1.patno = vaccine1.patno and at1.date1 = vaccine1.vacdate and at1.cptcode = vaccine1.offcode
left outer join (select sum(payment) as p, sum(copayrecd) as c, sum(adjustment + copayadjustment) as a, txnopaid from archive_transactions group by txnopaid) at2 on at2.txnopaid = at1.trnsxno
left outer join staff1 on staff1.staffid = at1.rend_addr_id
where vacdate between :start_date and :end_date and vfc1 <> 9