Payerbox Docs

Common queries

All queries run against sof.pdex_prior_authorization_item, the materialized view built from a ViewDefinition. Scope is PDex prior-auth EOBs.

1. EOBs per month, last 12 months

SELECT date_trunc('month', created::date)::date AS month,
       COUNT(DISTINCT eob_id)                   AS eob_count
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
GROUP  BY 1
ORDER  BY 1 DESC;
montheob_count
2026-05-01138 421
2026-04-01142 008
2026-03-01151 776
2026-02-01129 442
2026-01-01134 905
2025-12-01118 614

2. EOBs by business identifier system

WITH per_eob AS (
  SELECT eob_id, MAX(business_identifier_system) AS bis
  FROM   sof.pdex_prior_authorization_item
  GROUP  BY eob_id
)
SELECT COALESCE(bis, 'no-business-identifier') AS business_identifier_system,
       COUNT(*) AS eob_count
FROM   per_eob
GROUP  BY 1
ORDER  BY 2 DESC;
business_identifier_systemeob_count
https://example.org/system-11 842 117
urn:oid:1.2.3.4612 008
https://example.org/system-2387 540
no-business-identifier12 411

3. Top 20 members by PA count, last 12 months

High utilizers.

SELECT patient_ref,
       COUNT(DISTINCT eob_id) AS eob_count,
       COUNT(*)               AS pa_item_rows
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
  AND  patient_ref IS NOT NULL
GROUP  BY 1
ORDER  BY 2 DESC
LIMIT  20;

pa_item_rows counts materialized view rows (one per item × adjudication); eob_count is distinct authorizations.

patient_refeob_countpa_item_rows
Patient/XXXX-XXXX-XXXX-XXXX-00014121 803
Patient/XXXX-XXXX-XXXX-XXXX-00023871 645
Patient/XXXX-XXXX-XXXX-XXXX-00033611 528
Patient/XXXX-XXXX-XXXX-XXXX-00043481 472
Patient/XXXX-XXXX-XXXX-XXXX-00053311 391

4. Top 20 service codes, last 12 months

Which services get authorized most.

SELECT item_product_or_service_code,
       COUNT(*)               AS item_count,
       COUNT(DISTINCT eob_id) AS eob_count
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
GROUP  BY 1
ORDER  BY 2 DESC
LIMIT  20;
item_product_or_service_codeitem_counteob_count
99214982 145318 077
99213271 882152 410
J3490188 03792 615
90837142 90478 220
E0601121 76865 419

5. Top 20 primary diagnoses, last 12 months

SELECT primary_diagnosis_code, primary_diagnosis_display,
       COUNT(DISTINCT eob_id) AS eob_count
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
  AND  primary_diagnosis_code IS NOT NULL
GROUP  BY 1, 2
ORDER  BY 3 DESC
LIMIT  20;
primary_diagnosis_codeprimary_diagnosis_displayeob_count
I10Essential (primary) hypertension184 412
E11.9Type 2 diabetes mellitus without complications141 028
J45.909Unspecified asthma, uncomplicated97 614
M54.50Low back pain, unspecified82 305
I50.9Heart failure, unspecified73 184

6. EOBs by outcome × status, last 12 months

The basic adjudication mix.

SELECT outcome, status, COUNT(DISTINCT eob_id) AS eob_count
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
GROUP  BY 1, 2
ORDER  BY 3 DESC;
outcomestatuseob_count
completeactive1 384 022
partialactive312 818
erroractive148 405
completecancelled21 094
completeentered-in-error1 612

7. EOBs by denial reason code

Why authorizations get denied.

WITH per_eob AS (
  SELECT eob_id,
         array_agg(DISTINCT code) FILTER (WHERE code IS NOT NULL) AS codes
  FROM   sof.pdex_prior_authorization_item,
         LATERAL unnest(item_denial_reason_codes) AS code
  GROUP  BY eob_id
)
SELECT COALESCE(c, 'no-denial-reason') AS denial_reason_code,
       COUNT(*) AS eob_count
FROM   per_eob
LEFT  JOIN LATERAL unnest(COALESCE(codes, ARRAY[NULL::text])) AS c ON true
GROUP  BY 1
ORDER  BY 2 DESC;
denial_reason_codeeob_count
no-denial-reason1 723 882
5062 491
1648 207
2219 805
1978 612
966 233

The denial codes come from CARC (Claim Adjustment Reason Codes, maintained by X12). A separate set, RARC (Remittance Advice Remark Codes, M-/N- prefixed), gives supplementary detail. Resolve specific codes against the X12 lists.

8. Denial rate by month

SELECT date_trunc('month', created::date)::date AS month,
       round(100.0 * count(*) FILTER (WHERE outcome = 'error')
                  / nullif(count(*), 0), 1) AS denial_pct,
       count(*) AS eob_count
FROM   sof.pdex_prior_authorization_item
WHERE  created::date >= current_date - INTERVAL '12 months'
GROUP  BY 1
ORDER  BY 1 DESC;
monthdenial_pcteob_count
2026-05-018.4138 421
2026-04-018.2142 008
2026-03-018.7151 776
2026-02-018.1129 442
2026-01-018.0134 905
2025-12-017.6118 614

Last updated: