File size: 2,827 Bytes
4cb96fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
---
license: other
license_name: public-domain-with-cpt
license_link: LICENSE
task_categories:
  - tabular-classification
  - tabular-regression
tags:
  - medicare
  - cms
  - healthcare
  - physician
  - duckdb
  - government-data
  - medical-billing
pretty_name: CMS Medicare Physician & Other Supplier Database
size_categories:
  - 100M<n<1B
---

# CMS Medicare Physician & Other Supplier Database

A clean, queryable DuckDB database built from the [CMS Medicare Physician & Other Practitioners Public Use Files](https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners) -- provider-level Medicare Part B claims data from CY2012 through CY2023.

**121,707,609 rows** across **3 tables** covering what every physician billed, what Medicare paid, and how many services and beneficiaries per NPI per HCPCS code.

Built with [cms-medicare-database](https://github.com/ian-nason/cms-medicare-database).

## Quick Start

### DuckDB CLI

```sql
INSTALL httpfs;
LOAD httpfs;
ATTACH 'https://huggingface.co/datasets/Nason/cms-medicare-database/resolve/main/cms_medicare.duckdb' AS cms (READ_ONLY);

-- Total Medicare spending by year
SELECT year, ROUND(SUM(line_srvc_cnt * avg_medicare_payment_amt) / 1e9, 2) AS total_spending_billions
FROM cms.physician_services
GROUP BY year ORDER BY year;
```

### Python

```python
import duckdb
con = duckdb.connect()
con.sql("INSTALL httpfs; LOAD httpfs;")
con.sql("""
    ATTACH 'https://huggingface.co/datasets/Nason/cms-medicare-database/resolve/main/cms_medicare.duckdb'
    AS cms (READ_ONLY)
""")
con.sql("SELECT * FROM cms.physician_services LIMIT 5").show()
```

DuckDB uses HTTP range requests, so only the pages needed for your query are downloaded.

## Tables

| Table | Description | Rows |
|-------|-------------|------|
| `physician_services` | Provider-level Medicare Part B claims: one row per NPI per HCPCS code per place  | 106,515,734 |
| `physician_summary` | Provider-level aggregate summary: one row per NPI per year with total services,  | 12,232,194 |
| `geography_service` | Geographic aggregate: Medicare utilization and payment by state/national level,  | 2,959,681 |

## Data Source

[CMS Medicare Physician & Other Practitioners PUF](https://data.cms.gov/provider-summary-by-type-of-service/medicare-physician-other-practitioners) -- maintained by CMS. Updated annually. Public domain U.S. government data. HCPCS descriptions include AMA CPT content used under CMS license.

## License

Database build code: MIT. Underlying data: public domain (U.S. government work). Note: HCPCS descriptions contain AMA CPT content included as provided by CMS in the PUF.

## GitHub

Full source code, build instructions, and data dictionary: [github.com/ian-nason/cms-medicare-database](https://github.com/ian-nason/cms-medicare-database)