Compare hospice revenue, care days and net-income margins in Python

Add report dates, care days, revenue and expenses to a hospice roster, then calculate net-income margins.

Add financial context to a hospice roster

You have hospice CMS Certification Numbers (CCNs) and want to compare financial scale and care activity. This example adds reported revenue, operating expenses and enrollment days, then calculates net income as a percentage of total revenue.

The optional input.csv contains three real North Carolina hospice selections. The same CCNs appear in the roster list in the Python code below. The purchased package calls this file example_input.csv. Names, financial values and care days come from CMS; none are invented.

Download reports.csv into your working folder. It is a genuine subset of the purchased file: every report for these three CCNs, with all 232 columns. The full $29 reference contains 5,316 reports for 5,228 CCNs, coverage and source documentation across five CSV tables. Review the complete product and coverage.

Code example

Run this code in a notebook cell, IPython or a script beside reports.csv. It uses Python’s standard library and retains every matching report.

Paths are relative to your working folder; use from pathlib import Path; print(Path.cwd()) to check it, or supply full paths.

Python 3.10+ · Jupyter, IPython or a script
import csv
from collections import defaultdict
from decimal import Decimal, ROUND_HALF_UP
from pathlib import Path

# These three real hospice CCNs are also supplied in example_input.csv.
roster = [{'hospice_ccn': '341564'}, {'hospice_ccn': '341602'}, {'hospice_ccn': '341517'}]
data_directory = Path('.')

reports = defaultdict(list)
with (data_directory / 'reports.csv').open(encoding='utf-8', newline='') as source:
    for row in csv.DictReader(source):
        reports[row['hospice_ccn']].append(row)

results = []
for item in roster:
    matches = reports.get(item['hospice_ccn'], [])
    if not matches:
        print(item['hospice_ccn'], 'has no report in this source edition')
    for report in matches:  # Keep every report; CCN alone is not unique.
        revenue = report['total_revenue']
        income = report['net_income']
        margin = ''
        if (report['total_revenue_status'] == 'reported'
                and report['net_income_status'] == 'reported'
                and Decimal(revenue) > 0):
            margin = str((Decimal(income) / Decimal(revenue) * 100).quantize(
                Decimal('0.01'), rounding=ROUND_HALF_UP))
        results.append({
            'hospice_ccn': report['hospice_ccn'],
            'hospice_name': report['hospice_name'],
            'report_id': report['report_id'],
            'period_start': report['period_start'],
            'period_end': report['period_end'],
            'total_hospice_days': report['total_total_days'],
            'total_revenue': revenue,
            'operating_expenses': report['operating_expenses'],
            'net_income_margin_percent': margin,
        })

for row in results:
    print(f"{row['hospice_ccn']} | {row['hospice_name']} | report {row['report_id']}")
    print(f"  {row['period_start']} to {row['period_end']} | hospice days: {row['total_hospice_days'] or 'not supplied'}")
    print(f"  Revenue: ${row['total_revenue'] or 'not supplied'} | operating expenses: ${row['operating_expenses'] or 'not supplied'} | net-income margin: {row['net_income_margin_percent'] + '%' if row['net_income_margin_percent'] else 'not calculated'}")

Replace roster with your CCN selections or rows read from a CSV, preserving identifiers as strings. Change data_directory if reports.csv is in another folder.

Analysis of the output

341564 | HOSPICE OF YANCEY COUNTY | report 85135
  2023-10-01 to 2024-09-30 | hospice days: 29020
  Revenue: $6631453 | operating expenses: $5715699 | net-income margin: 13.81%
341602 | HOME HEALTH AND HOSPICE CARE  INC. | report 85142
  2023-10-01 to 2024-09-30 | hospice days: 10702
  Revenue: $1877731 | operating expenses: $1643159 | net-income margin: 12.49%
341517 | HOSPICE OF IREDELL COUNTY | report 85156
  2023-10-01 to 2024-09-30 | hospice days: 83241
  Revenue: $24043666 | operating expenses: $21783167 | net-income margin: 9.40%

Hospice of Yancey County reports $6,631,453 in total revenue and $5,715,699 in operating expenses for October 1, 2023 through September 30, 2024. Its reported net income is $915,754. Dividing net income by revenue gives 13.81%. The 29,020 hospice enrollment days provide activity context; they are not the denominator of that financial ratio.

All three selected reports cover the same 366-day period. Other reports in the full file have different fiscal dates. FY2024 identifies the CMS source-file cohort, not a common calendar year.

The ratio uses worksheet F-2 line 42 column 2 divided by line 26 column 4. Total revenue includes non-patient revenue, so this is a total net-income margin, not a patient-service margin, Medicare reimbursement rate or care-quality ranking. Review the underlying reporting scope and revenue mix before drawing conclusions from differences between hospices.

Enrollment days are days of care, not unique patients. The full file distinguishes continuous home care, routine home care, inpatient respite and general inpatient care, with separate payer fields. Contracted inpatient days are a subset of those inpatient totals. Worksheet C care costs and cost per day are also included; they are not the financial-statement operating expenses used here.

An omitted source coordinate stays source_cell_absent; an existing empty value is source_blank. Neither is silently converted to zero. The example calculates a margin only when both values are supplied and revenue is positive. A CCN absent from the edition gets an explicit message.

Using the full dataset

Extract the purchased ZIP and replace the sample reports.csv with the full file. The code runs unchanged. Its unique key is report_id. The relationship key hospice_ccn is not unique: 87 CCNs have multiple reports.

Use hospice_coverage.csv to identify repeated CCNs, varying report lengths and names. The edition contains no overlapping report pairs within a CCN. CMS labels 5,308 reports as submitted and eight amended; retain that status, but do not treat it as independent financial assurance or use a higher report ID as an automatic selection rule.

The reference prepares 103 explicitly documented worksheet cells per report. source_fields.csv supplies the exact worksheet, line, column, unit and form page. Other cells are counted in source_accounting.csv and retained in our raw archives for reproducibility; they are not additional prepared measures in this download. All 18 original report fields are retained, with original dates and identifier strings.

The hospital and care-facility selection page links to hospice quality, Medicare hospice utilization and home-health finances. These are separate purchases. Check historical CCN identity and each source’s period and scope before joining; quality observations, claims payments and cost-report finances answer different questions.

Sources and versions

Source: CMS HOSPC14 all-years archive, specifically the FY2024 RPT, ALPHA and NMRC files for freestanding hospices. CMS’s fiscal-year rule selects reports beginning October 1, 2023–September 30, 2024. Individual end dates extend to September 30, 2025.

The retained archive was last modified October 5, 2026 and captured October 30, 2026 UTC. The exact HCRIS extraction date is not supplied. ACD processing revision 1 joins report records to reviewed worksheet coordinates and checks them against the original files. This is a selected reference, not a complete HCRIS export or collection of independently audited statements.

CMS originals are free. ACD sells preparation, validation, documentation and delivery. Read the source and preparation record. Processing improvements for these retained inputs are included; genuinely new source editions may be sold separately.

Example checked October 30, 2026 against both these samples and the complete purchased files. Source and processing records, sample checksums · Expected result CSV. Independent preparation; no agency endorsement.