SQL: Confirm Medicaid Designation of Plans in OP is Correct

About

The OP software will automatically determine which encounters are ascribed to Medicaid and which encounters ones are not. This determination is based upon how you have set up insurance carriers. Run this SQL: Medicaid Plans SQL.  You will be prompted to enter your attestation period start date. This query provides an estimated total number of encounters during the selected period for all active Medicaid plans (and only active Medicaid plans).  Your results should look like the image below

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

Caveats

This should be used when determining Meaningful Use Volume Counts using the OP Software. See Introduction: Determining Medicaid Volume using the OP Software.

Code

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

select ins_carrier.ins_carrier_code, ins_carrier_name, encounters from ins_carrier
left outer join
(
select count(uniqid) as encounters, ins_carrier_code from
(
select distinct uniqid, ins_carrier_code from (

  select patno, date1, (patno || ' ' || date1) as uniqid, cptcode, ins_carrier_code from archive_transactions at1
 where at1.cptcode not in ('1','2','3','4') and pos not in (21,23)  and
  at1.date1 between :attestation_start and ( :attestation_start + 89) and at1.archive_flag = 1
  union
  select patno, date1, (patno || ' ' || date1) as uniqid, cptcode, ins_carrier_code_other as ins_carrier_code from    archive_transactions at2
 where at2.cptcode not in ('1','2','3','4') and pos not in (21,23) and
  at2.date1 between :attestation_start and ( :attestation_start + 89)  and at2.archive_flag = 1
      ) ata1

) 
group by ins_carrier_code    ) ata2

on ata2.ins_carrier_code = ins_carrier.ins_carrier_code
 where claim_filing_code = 'MC' and ins_carrier.archive_flag in (0,2)