SQL: Beyfortus Doses Given Overview

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 shows all Beyfortus doses your office has administered, whether they were first or second season doses, the total volume given documented, the number of Beyfortus product units billed on a claim, the admin code used, and the number of admin units billed on a claim.

Caveats

  • This only shows Beyfortus doses administered in your practice. Birthing hospital doses that you have recorded in OP, but not administered yourself from your own inventory, will not appear here.
  • "First season" and "second season" is by computing the age of the baby when the dose was given. Any infant under 8 months old on the day of administration is "first season." Any infant 8+ months on the day of administration is "second season."
  • Doses that you have given but not yet billed in a claim will have blank values in PRODUCT, PRODUCT_UNITS, ADMIN_CODE, and ADMIN_UNITS. Just being in the Superbill state is not enough to make them appear. They must have been converted to a claim.
  • DOSE_SIZE and DOSE_UNIT appear in the Complete List of the vaccine.
  • ADMIN_CODE might include any of 96372, 96380, or 96381.

Use Cases

  • Check to make sure all second season babies have had 2 ml dose sizes and 2 units of 90381 billed.
  • When reconciling your vaccine inventory, use the count of second season doses against the number of doses still in your fridge. This will make sure your staff have appropriately decremented both doses from your vaccine inventory.

SQL Code: Firebird

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

select a.patno, dob, dose_size, dose_unit, case when cutoff<=immdate then 'second season' else 'first season' end as season, product, product_units, admin_code, admin_units from (
select register.patno, birthdat as dob, vacdate as immdate, dose_size, dose_unit,
dateadd(month, 8, birthdat) as cutoff, product, product_units, d.cptcode as admin_code, d.admin_units
 from vaccine1
inner join register on register.patno = vaccine1.patno
left outer join (select patno, date1, cptcode as product, units as product_units from archive_transactions where cptcode in ('90380','90381') and archive_flag <=1 and date1 between :Start_date and :end_date ) c on c.patno=register.patno and c.date1 =vaccine1.vacdate
left outer join (select patno, date1, cptcode, units as admin_units from archive_transactions where cptcode in ('96372','96380','96381') and archive_flag <=1 and date1 between :Start_date and :end_date ) d on d.patno=register.patno and d.date1 =vaccine1.vacdate
where cvxcode  in ('306', '307') and vacdate between :Start_date and :end_date and vac_lot_id >=2
) a

SQL Code: MySQL

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

select a.patno, dob, dose_size, dose_unit, case when cutoff<=immdate then 'second season' else 'first season' end as season, product, product_units, admin_code, admin_units from (
select register.patno, birthdat as dob, vacdate as immdate, dose_size, dose_unit,
date_add(birthdat, interval 8 month) as cutoff, product, product_units, d.cptcode as admin_code, d.admin_units
 from vaccine1
inner join register on register.patno = vaccine1.patno
left outer join (select patno, date1, cptcode as product, units as product_units from archive_transactions where cptcode in ('90380','90381') and archive_flag <=1 and date1 between :Start_date and :end_date ) c on c.patno=register.patno and c.date1 =vaccine1.vacdate
left outer join (select patno, date1, cptcode, units as admin_units from archive_transactions where cptcode in ('96372','96380','96381') and archive_flag <=1 and date1 between :Start_date and :end_date ) d on d.patno=register.patno and d.date1 =vaccine1.vacdate
where cvxcode  in ('306', '307') and vacdate between :Start_date and :end_date and vac_lot_id >=2
) a