Adjustment Analysis by Month and Payor

We are trying to nail down the source of unusually high adjustments for a period. We want to know the amount billed, amount paid, amount adjusted, portion (%) adjusted for each month and payor, grouped by adjustment code.

This query illustrates the aggregate function SUM, as well as imbedded IF expressions and COALESCE expressions to eliminate NULLs. This is the kind of result set that you might want examine in different orders, so just shuffle the columns in the SELECT list, and in the GROUP BY and ORDER BY clauses as you wish. The GROUP BY and ORDER BY lists should match to prevent confusion when examining the results.

 

SELECT
   (IF a.payortype = 'I' THEN 'INS' ELSE 'PRIVATE' END IF) AS "Payor Type",
   a.adjcode AS "AdjCode", 
   YEAR(a.srv_date) AS "Year",
   MONTH(a.srv_date) AS "Month",
   (UPPER(a.payorname) + ' ' + a.payorfname) AS "Payor",
   SUM (b.chgsplamt) AS "Total Billed",
   SUM((IF a.credtype <> 'Adjustment' THEN COALESCE(a.crsplamt,0) ELSE 0 END IF)) AS "Payments",
   SUM((IF a.credtype = 'Adjustment' THEN a.crsplamt ELSE 0 END IF)) AS "Adjustments" ,
   (IF "Adjustments" IS NOT NULL AND "Total Billed" IS NOT NULL AND "Total Billed" <> 0 
      THEN CAST(("Adjustments"/"Total Billed" * 100)AS DECIMAL(6,2))
   ELSE 0
   END IF)  AS "% Adjusted" 
FROM 
   sos.rv_creditsplits a
   JOIN sos.jchgsplits b ON a.chgsplnum = b.chgsplnum
WHERE
   a.crsplamt IS NOT NULL 
   AND "AdjCode" IS NOT NULL
   AND a.srv_date BETWEEN '2001-01-01' AND '2001-12-31'
GROUP BY 
   "PayorType","AdjCode","Year","Month","Payor"
ORDER BY
   "PayorType","AdjCode","Year","Month","Payor"

Service Count, Total Charges, and Applied Payments by Provider and Patient Category

We would like to know the income generated for services based on provider and patient category.

The following query shows these results in a “ROLLUP” grid, displaying both detail down to the service code level as well as subtotals and grand totals. When you run the query and examine the results, you should interpret “NULL” in the Provider, PtCategory, and Service columns as meaning “ALL”. For example, the row that shows NULL in all three of these columns is showing the totals for ALL providers, ALL ptcategories, and ALL service codes — in other words, the grand totals. A row that shows a specific provider and a specific category, but NULL in the Service column provides the subtotal of all service codes for the indicated provider and category. You could limit the result set by replacing the wildcard percent sign in the WHERE clause with a specific provider code and/or patient category code if you like.

SELECT
   (a.provfname + ' '+a.provlname) AS "Provider",
   c.categcode AS "PtCategory",
   a.srvcode AS "Service",
   COUNT(DISTINCT jnum) AS "Srv Count",
   SUM(a.chgsplamt) AS "TotalCharges",
   SUM(COALESCE((SELECT SUM(COALESCE(crsplamt,0)) FROM sos.rv_creditsplits
   WHERE  chgsplnum = a.chgsplnum AND credtype IN ('CASH','CHECK','CHARGE')),0)) AS "TotalPayments"
FROM
   sos.rv_charges a
   JOIN sos.patients b ON a.ptnum = b.ptnum
   LEFT OUTER JOIN sos.ptcategs c ON b.ptcategnum = c.ptcategnum
WHERE
   a.trandate BETWEEN '1980-01-01' AND '2008-12-31'
   AND a.provcode LIKE '%'
   AND "PtCategory" LIKE '%'
GROUP BY
  ROLLUP ("Provider","PtCategory","Service")

Balance Breakdown By Patient On Specified Date

 Our auditors have requested a report of outstanding balances per client, as of Dec 31, 2011, separated by liability (Medicare, Medicaid, private insurance and self-pay). Insurance type is specified by “Coverage Type” on the Additional tab of the Insurance Carrie/Plan. We want to report patients in either the Active or Inactive lists, as long as they have a balance of some kind at the end of 2011.

Because we are looking for balances on a previous date, we have to tally up all the charges and payments on or before that date, then subtract the latter from the former to find the balance. To do that will require a bunch of embedded subqueries as you can see in the query below. If you want to run the query for a different date, be sure to replace ALL the instances of ‘2011-12-31’!

The output specified in this example will go to an HTML format file called AUDIT2011.HTML located in the C:\SOS folder. You can output the results to screen for inspection before outputting to file by inserting two dashes or slashes at the beginning of the last line. Just remove those characters when you are ready to generate the file. The benefit of outputting in HTML format is that you can view the results in a web browser, or open the file with Excel for additional massaging.

SELECT
   a.lastname, a.firstname, a.id AS "Account ID",
   -- Medicare
   COALESCE((SELECT SUM(chgsplamt) 
   FROM sos.jchgsplits chs JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum JOIN sos.carriers car ON ptp.payornum = car.payornum
   WHERE chs.ptnum = a.ptnum AND car.coverage = 'C' AND chs.chgspldate <= '2011-12-31'),0) AS "Medicare Charges",
   COALESCE((SELECT SUM(crsplamt) 
   FROM sos.jcrsplits crs 
     JOIN sos.jchgsplits chs ON crs.chgsplnum = chs.chgsplnum 
     JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum 
     JOIN sos.carriers car ON ptp.payornum = car.payornum 
     JOIN sos.jcredits cre ON crs.jnum = cre.jnum 
     JOIN sos.journal jou ON cre.jnum = jou.jnum
   WHERE chs.ptnum = a.ptnum 
     AND car.coverage = 'C' 
     AND chs.chgspldate <= '2011-12-31' 
     AND jou.trandate <= '2011-12-31') ,0) AS "Medicare Credits",
   ("Medicare Charges" - "Medicare Credits") AS "Medicare Balance",
  -- Medicaid
   COALESCE((SELECT SUM(chgsplamt) 
   FROM sos.jchgsplits chs JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum JOIN sos.carriers car ON ptp.payornum = car.payornum
   WHERE chs.ptnum = a.ptnum AND car.coverage = 'D' AND chs.chgspldate <= '2011-12-31'),0) AS "Medicaid Charges",
   COALESCE((SELECT SUM(crsplamt) 
   FROM sos.jcrsplits crs 
     JOIN sos.jchgsplits chs ON crs.chgsplnum = chs.chgsplnum 
     JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum 
     JOIN sos.carriers car ON ptp.payornum = car.payornum 
     JOIN sos.jcredits cre ON crs.jnum = cre.jnum 
     JOIN sos.journal jou ON cre.jnum = jou.jnum
   WHERE chs.ptnum = a.ptnum 
     AND car.coverage = 'D' 
     AND chs.chgspldate <= '2011-12-31' 
     AND jou.trandate <= '2011-12-31' ) ,0) AS "Medicaid Credits",
   ("Medicaid Charges" - "Medicaid Credits") AS "Medicaid Balance",
   -- Private Ins 
   COALESCE((SELECT SUM(chgsplamt) 
   FROM sos.jchgsplits chs JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum JOIN sos.carriers car ON ptp.payornum = car.payornum
   WHERE chs.ptnum = a.ptnum AND car.coverage NOT IN ('C','D') AND chs.chgspldate <= '2011-12-31'),0) AS "Private Ins Charges",
   COALESCE((SELECT SUM(crsplamt) 
   FROM sos.jcrsplits crs 
     JOIN sos.jchgsplits chs ON crs.chgsplnum = chs.chgsplnum 
     JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum 
     JOIN sos.carriers car ON ptp.payornum = car.payornum 
     JOIN sos.jcredits cre ON crs.jnum = cre.jnum 
     JOIN sos.journal jou ON cre.jnum = jou.jnum
   WHERE chs.ptnum = a.ptnum 
     AND car.coverage NOT IN ('C','D') 
     AND chs.chgspldate <= '2011-12-31' 
     AND jou.trandate <= '2011-12-31' ) ,0) AS "Private Ins Credits",
   ("Private Ins Charges" - "Private Ins Credits") AS "Private Ins Balance",
   -- Self-Pay
   COALESCE((SELECT SUM(chgsplamt) 
   FROM sos.jchgsplits chs JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum JOIN sos.payors pay ON ptp.payornum = pay.payornum
   WHERE chs.ptnum = a.ptnum AND pay.payortype IN ('P','O') AND chs.chgspldate <= '2011-12-31'),0) AS "Self-Pay Charges",
   COALESCE((SELECT SUM(crsplamt) 
   FROM sos.jcrsplits crs 
     JOIN sos.jchgsplits chs ON crs.chgsplnum = chs.chgsplnum 
     JOIN sos.ptpayors ptp ON chs.ptpayornum = ptp.ptpayornum 
     JOIN sos.payors pay ON ptp.payornum = pay.payornum
     JOIN sos.jcredits cre ON crs.jnum = cre.jnum 
     JOIN sos.journal jou ON cre.jnum = jou.jnum
   WHERE chs.ptnum = a.ptnum 
     AND pay.payortype IN ('P','O') 
     AND chs.chgspldate <= '2011-12-31' 
     AND jou.trandate <= '2011-12-31' ) ,0) AS "Self-Pay Credits",
   ("Self-Pay Charges" - "Self-Pay Credits") AS "Self-Pay Balance"

FROM 
  sos.patients a  
WHERE
  "Medicare Balance" <> 0
  OR "Medicaid Balance" <> 0
  OR "Private Ins Balance" <> 0
  OR "Self-Pay Balance" <> 0
ORDER BY
  a.lastname, a.firstname, a.id

 

Checking for Fields that Should Be Included in Encounter Import

The following query generates an HTML report that indicates the field elements that should be considered for inclusion if you are planning to import encounter data from a third-party product for billing by SOS Office Manager. The previous year of charge entries are analyzed.

Select 'Total Charge Count',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365)
UNION
Select 'CSU = U',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and csutype = 'u'
UNION
Select 'CSU = N',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and csutype = 'n'
UNION
Select 'Date Range',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(startdate,trandate) <> trandate
UNION
Select 'Units <> 1',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and units <> 1
UNION
Select 'Cost',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(cost,0) <> 0
UNION
Select 'CPT Modifiers',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(cptmod1,'')+coalesce(cptmod2,'')+coalesce(cptmod3,'')+coalesce(cptmod4,'') <> ''
UNION
Select 'Non-default POS',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and poscodenum <> (select lastpos from sos.ptvars where ptnum = journal.ptnum)
UNION
Select 'FP',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(fp,'') <> ''
UNION
Select 'EMG',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(emergency,'') <> ''
UNION
Select 'COB',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(cob,'') <> ''
UNION
Select 'Box 24K',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(box24k,'') <> ''
UNION
Select 'Lab Charge',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(labchg,0) <> 0
UNION
Select 'SortCode',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(sortcode,0) <> 0
UNION
Select 'Comment1',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(comment1,'') <> ''
UNION
Select 'Comment2',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(comment2,'') <> ''
UNION
Select 'Remark',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(remark,'') <> ''
UNION
Select 'Memo',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(memo,'') <> ''
UNION
Select 'MemoHA0',count(*) from sos.journal join sos.jcharges where trandate > (today() - 365) and coalesce(memoisha0,0) <> 0
;
OUTPUT TO 'c:\sos\ChargeImportCheck.html' format html

 

Aged Unapplied Credits

Is there a query out there that takes the unapplied (pre-pay) figure (obtained from an Aging Report) and breaks it down over a specified time period? I assume there is a date there is a date attached to the unapplied credit, probably the date that it was first entered in SOS?

Can a query give me the amount that remains unapplied and break down this total according to a range of times? E.g.,

Grand Total of unapplied               0-30                      31-60                    61-90                    91-120                 over 120

$63,852.72                      51,800.00            8050.50               3000                     1000.                    802.22

 

 

SELECT
  lastname,firstname,"id",
  SUM(crsplamt) AS "Total Unapplied",
  (SELECT SUM(crsplamt) FROM sos.jcrsplits crs join sos.journal jou on crs.jnum=jou.jnum  WHERE   jou.ptnum = a.ptnum AND crs.chgsplnum = 0  AND jou.trandate between (today() - 30) and today() ) as "CURRENT",
  (SELECT SUM(crsplamt) FROM sos.jcrsplits crs join sos.journal jou on crs.jnum=jou.jnum  WHERE jou.ptnum = a.ptnum AND crs.chgsplnum = 0 AND jou.trandate between (today() - 60) and(today()-31) ) as "31 - 60",
  (SELECT SUM(crsplamt) FROM sos.jcrsplits crs join sos.journal jou on crs.jnum=jou.jnum  WHERE jou.ptnum = a.ptnum AND crs.chgsplnum = 0 AND jou.trandate between (today() - 90) and (today()-61)  ) as "61 - 90",
  (SELECT SUM(crsplamt) FROM sos.jcrsplits crs join sos.journal jou on crs.jnum=jou.jnum  WHERE jou.ptnum = a.ptnum AND crs.chgsplnum = 0 AND jou.trandate between (today() - 120) and (today()-91) ) as "91 - 120",
  (SELECT SUM(crsplamt) FROM sos.jcrsplits crs join sos.journal jou on crs.jnum=jou.jnum  WHERE jou.ptnum = a.ptnum AND crs.chgsplnum = 0 AND jou.trandate < (today() - 120) ) as "Over 120"
FROM
  sos.jcrsplits a
  JOIN sos.patients b ON a.ptnum = b.ptnum
WHERE
  chgsplnum = 0
  AND flag = 0
  AND dischargedate IS NULL
GROUP BY
  lastname,firstname,"id","current","31 - 60","61 - 90","91 - 120", "Over 120"
ORDER BY
  lastname,firstname,"id"