Compare hospice service use and payments in Python
Add covered days, nursing visits and Medicare payments to a provider roster, then calculate payment per covered day.
Add Medicare activity to a hospice provider roster
You have a list of hospice providers and want to compare their service volume and Medicare payments. This example adds covered days, nursing visits and payments, then calculates payment per covered day for fiscal 2024: October 2023–September 2024.
The optional input.csv contains three genuine North Carolina provider CMS Certification Numbers (CCNs). The same selections appear in the roster list in the Python code below. No provider observations are invented.
Download providers.csv into your working folder. It is a genuine subset of the purchased file: three selected providers with all 90 columns retained. The full $29 reference contains 6,134 providers, separate state/national benchmarks and source documentation across five CSV tables. Review the complete product and coverage.
Code example
Run the code in a notebook cell, IPython or a script beside providers.csv. It uses Python’s standard library and joins on fiscal year and CCN. The payment-per-day calculation runs only when both inputs are reported and covered days are positive.
Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.
import csv
from decimal import Decimal
from pathlib import Path
# Three real provider selections, also supplied in input.csv.
roster = [
{'provider_ccn': '341500'},
{'provider_ccn': '341507'},
{'provider_ccn': '341531'},
]
def compare_providers(roster, directory='.', fiscal_year='2024'):
with (Path(directory) / 'providers.csv').open(encoding='utf-8', newline='') as file:
providers = {}
for row in csv.DictReader(file):
key = (row['fiscal_year'], row['provider_ccn'])
if row['summary_level'] != 'PROVIDER' or key in providers:
raise ValueError('Expected one provider row per fiscal year and CCN')
providers[key] = row
results = []
for selection in roster:
ccn = selection['provider_ccn']
provider = providers.get((fiscal_year, ccn))
result = dict(provider_ccn=ccn, provider_name='', covered_days='',
medicare_payment='', nursing_visits='', payment_per_covered_day='',
ratio_status='not_in_file')
if provider:
for field in ['provider_name', 'covered_days', 'medicare_payment', 'nursing_visits']:
result[field] = provider[field]
numerator_status = provider['medicare_payment_status']
denominator_status = provider['covered_days_status']
result['ratio_status'] = 'unavailable: ' + numerator_status + '/' + denominator_status
if numerator_status == denominator_status == 'reported':
days = Decimal(provider['covered_days'])
result['ratio_status'] = 'zero_denominator'
if days > 0:
ratio = Decimal(provider['medicare_payment']) / days
result.update(payment_per_covered_day=f'{ratio:.2f}', ratio_status='calculated')
days = provider['covered_days'] if denominator_status == 'reported' else denominator_status
visits = provider['nursing_visits'] if provider['nursing_visits_status'] == 'reported' else provider['nursing_visits_status']
paid = f"${Decimal(provider['medicare_payment']):,.0f}" if numerator_status == 'reported' else numerator_status
per_day = '$' + result['payment_per_covered_day'] if result['ratio_status'] == 'calculated' else result['ratio_status']
print(f"{ccn} | {provider['provider_name']} | {days} covered days | {visits} nursing visits | {paid} Medicare paid | {per_day} per covered day")
else:
print(f'{ccn} | not in this file; no zero activity inferred')
results.append(result)
return results
results = compare_providers(roster)
Replace roster with your own selections or rows read from a CSV. Keep CCNs as strings: leading zeros and letters are meaningful. Set directory when calling compare_providers if the data are in a different folder.
Analysis of the output
341500 | Hospice & Palliative Care Charlotte Region | 344459 covered days | 85254 nursing visits | $67,100,731 Medicare paid | $194.80 per covered day
341507 | Duke Hospice | 61188 covered days | 13044 nursing visits | $14,019,006 Medicare paid | $229.11 per covered day
341531 | Unc Hospice | 25010 covered days | 6278 nursing visits | $5,745,336 Medicare paid | $229.72 per covered day
Duke Hospice reports 61,188 covered days, 13,044 nursing visits and $14,019,006 in Medicare payments. Dividing those payments by covered days gives $229.11 per covered day. The result gives a provider roster useful historical scale and payment context without requiring you to interpret the original CMS field names first.
The ratio is calculated from annual totals. It is not a reimbursement schedule, current patient quote or measure of care quality. Providers differ in their patients and care settings; these figures are not adjusted for those differences. Covered days fall inside the fiscal-year window and do not describe complete lifetime stays or average length of service.
A reported zero remains zero. An unavailable input retains its status instead of becoming a zero or a ratio. suppressed preserves CMS’s asterisk; source_limitation preserves its Puerto Rico dual-eligibility plus marker. A CCN absent from the file is labeled not_in_file; no activity level is inferred.
Using the full dataset
Extract the purchased ZIP and replace the sample providers.csv with the full file. The code runs unchanged. There is one record per fiscal_year + provider_ccn, with 49 source fields, 40 numeric-availability columns and an original row number.
The other four CSVs provide 53 geographic benchmarks, accounting for every original row, source-field definitions and the source edition. Use a published benchmark when comparing against a state or the nation. Keep it separate from provider records: beneficiaries can overlap across providers and source suppression varies, so summing providers need not reproduce the benchmark.
The full provider file also includes stays, beneficiary characteristics, primary-diagnosis shares, nursing minutes, social-work/aide visits, standardized payments and the routine-home-care share of days. Diagnosis categories may overlap across a stay’s claims. Only the routine-home-care share is supplied; separate shares for the other hospice care levels are absent.
For caregiver experience, quality measures and reported served ZIPs, see the separately sold Hospice Provider & Quality Reference. Check historical CCN identity, names and reporting periods before joining. The hospital and care-facility selection page compares the available settings and tasks.
Sources and versions
Source: CMS Medicare Post-Acute Care Utilization, Hospice by Geography and Provider, FY2024. CMS modified the distribution August 11, 2026; ACD retained it October 28, 2026 UTC. The source CSV and methodology establish fiscal dates, despite the catalog’s generic calendar-year range.
These are paid Medicare fee-for-service hospice claims. Represented beneficiaries can include Medicare Advantage enrollees; this is not a complete MA encounter dataset, all-payer activity or patient-level claims. The original source is free. ACD sells preparation, validation, documentation and delivery.
The download preserves both allowed and Medicare-paid amounts, which agree in this file, while documenting a conflict between the generic dictionary and hospice-specific methodology. Geographic payment standardization is not adjustment for patient severity. Read the source and preparation record. Same-source processing improvements are included; no automatic refresh is promised.
Example checked October 28, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.