-- What pharma actually buys: food, travel, consulting and royalties
-- Fonteum reproducible query — https://fonteum.com/research/open-payments-types-of-payments-2024
-- Data as of: 2026-01-23  ·  methodology: open-payments/v1
-- Source datasets: CMS Open Payments
-- Run against the frozen federal snapshot to reproduce the published figures.
-- License: U.S. Government Works (federal sources; 17 U.S.C. §105).

-- What pharma actually buys: payment-type breakdown — reproducible query.
--
-- Source:   CMS Open Payments, program year 2024 (PGYR2024, published 2026-01-23).
-- Table:    public.cms_open_payments (16,146,544 records, public, read-only).
-- Scope:    General (non-research) payments only  (record_type = 'general').
-- Grain:    nature_of_payment (16 categories). No recipient named.
--
-- Reads open_payments_by_nature_mv; definition reproduced for audit.

-- All payment-nature categories, by total dollars (open_payments_by_nature_mv):
SELECT
  nature_of_payment                                AS nature,
  count(*)                                         AS payments,
  round(sum(total_amount_usd))::bigint             AS total_usd,
  round(sum(total_amount_usd) / count(*), 0)       AS avg_per_payment
FROM public.cms_open_payments
WHERE record_type = 'general' AND program_year = 2024 AND nature_of_payment IS NOT NULL
GROUP BY nature_of_payment
ORDER BY total_usd DESC;
--  Royalty or License                              846,848,447     15,053   56,258
--  Compensation for services other than consulting 694,537,282    238,656    2,911   (speaking, non-CME)
--  Consulting Fee                                  556,511,013    185,882    2,994
--  Food and Beverage                               411,750,206 14,101,484       29   <- 91.7% of payment count
--  Acquisitions                                    213,455,947        413  516,842   <- highest avg
--  Travel and Lodging                              202,500,154    588,784      344
--  Grant                                           123,006,051      7,263   16,937
--  Education                                        67,045,121    151,641      442
--  Honoraria                                        43,422,896     16,448    2,640
--  Debt forgiveness                                 40,810,437      7,687    5,309
--  Long term medical supply or device loan          37,760,405     17,141    2,203
--  Space rental or facility fees (teaching hosp.)   33,805,521      7,511    4,500
--  Compensation for faculty/speaker (CME program)   32,855,300     14,013    2,345
--  Gift                                              4,477,576     25,972      172
--  Charitable Contribution                           4,404,912        696    6,329
--  Entertainment                                       610,469      6,403       95

-- The two economies — share of count vs share of dollars:
WITH g AS (
  SELECT count(*) AS recs, sum(total_amount_usd) AS val
  FROM public.cms_open_payments
  WHERE record_type = 'general' AND program_year = 2024
)
SELECT
  -- food = 91.7% of payments, 12.4% of dollars
  round(100.0 * (SELECT count(*) FROM public.cms_open_payments
                 WHERE record_type='general' AND program_year=2024
                   AND nature_of_payment='Food and Beverage') / g.recs, 1)   AS food_count_pct,   -- 91.7
  -- royalty + speaking + consulting = 2.9% of payments, 63.3% of dollars
  round(100.0 * (SELECT sum(total_amount_usd) FROM public.cms_open_payments
                 WHERE record_type='general' AND program_year=2024
                   AND nature_of_payment IN (
                     'Royalty or License',
                     'Consulting Fee',
                     'Compensation for services other than consulting, including serving as faculty or as a speaker at a venue other than a continuing education program'
                   )) / g.val, 1)                                            AS top3_dollar_pct   -- 63.3
FROM g;
