Compare health-center costs and finances in Python

Compare real reporting groups using visits, allocated cost per visit and net income including other income.

Compare health-center reporting groups

You have a roster of health-center CMS Certification Numbers (CCNs) and want to compare visits, costs and financial results. This example adds each reporting group’s allocated cost per visit and calculates a net income margin including other income. It also shows how many additional centers each report says it covers.

The optional input.csv contains three real North Carolina reporting CCNs. The same selections appear in the roster list in the Python code below; the purchased package names this file example_input.csv. Names and financial observations come from CMS. None are invented.

Download reports.csv into your working folder. This genuine subset of the paid file contains every report for these three CCNs and all 268 columns. The full $29 reference retains 3,531 reports for 3,354 reporting CCNs across six CSV tables, including identification-only filings and separately listed consolidated participants. Review the full product and field coverage.

Code example

Run the code in a notebook cell, IPython or a script beside reports.csv. It uses Python’s standard library and keeps 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 real reporting CCNs also appear in example_input.csv.
roster = [{'reporting_ccn': '341105'}, {'reporting_ccn': '341813'}, {'reporting_ccn': '341838'}]
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['reporting_ccn']].append(row)

results = []
for item in roster:
    matches = reports.get(item['reporting_ccn'], [])
    if not matches:
        print(item['reporting_ccn'], 'has no report in this source edition')
    for report in matches:  # Report ID, not CCN alone, identifies an observation.
        margin = ''
        fields = ['net_patient_revenue', 'other_income', 'net_income']
        if all(report[name + '_status'] == 'reported' for name in fields):
            total_income = Decimal(report['net_patient_revenue']) + Decimal(report['other_income'])
            if total_income > 0:
                margin = str((Decimal(report['net_income']) / total_income * 100).quantize(
                    Decimal('0.01'), rounding=ROUND_HALF_UP))
        results.append({
            'reporting_ccn': report['reporting_ccn'],
            'facility_name': report['facility_name'],
            'report_id': report['report_id'],
            'period_start': report['period_start'],
            'period_end': report['period_end'],
            'consolidated_report_indicator': report['consolidated_report_indicator'],
            'additional_fqhcs_reported': report['additional_fqhcs_reported'],
            'practitioner_visits': report['practitioner_visits'],
            'average_cost_per_visit': report['average_cost_per_visit'],
            'net_income_margin_percent': margin,
        })

for row in results:
    print(f"{row['reporting_ccn']} | {row['facility_name']} | report {row['report_id']}")
    print(f"  {row['period_start']} to {row['period_end']} | consolidated: {row['consolidated_report_indicator'] or 'not supplied'} | additional FQHCs: {row['additional_fqhcs_reported'] or 'not supplied'}")
    print(f"  Visits: {row['practitioner_visits'] or 'not supplied'} | reported cost/visit: ${row['average_cost_per_visit'] or 'not supplied'} | net income margin including other income: {row['net_income_margin_percent'] + '%' if row['net_income_margin_percent'] else 'not calculated'}")

Replace roster with your own selections or rows read from a CSV. Keep CCNs as strings and change data_directory if your files are in another folder.

Analysis of the output

341105 | NEIGHBORHEALTH CENTER  INC. | report 51371
  2024-01-01 to 2024-12-31 | consolidated: Y | additional FQHCs: 1
  Visits: 20509 | reported cost/visit: $311.67 | net income margin including other income: -24.07%
341813 | PIEDMONT HEALTH SERVICES  INC. | report 52668
  2024-01-01 to 2024-12-31 | consolidated: Y | additional FQHCs: 9
  Visits: 106575 | reported cost/visit: $269.82 | net income margin including other income: 6.23%
341838 | GOSHEN MEDICAL CENTER INC | report 52103
  2024-01-01 to 2024-12-31 | consolidated: Y | additional FQHCs: 35
  Visits: 137665 | reported cost/visit: $223.65 | net income margin including other income: 11.49%

NeighborHealth reports 20,509 practitioner visits at an allocated cost of $311.67 per visit; Piedmont reports $269.82 and Goshen $223.65. These are the source-reported Worksheet B values, not Medicare payment rates or prices paid by patients.

These reports have different organizational scopes. NeighborHealth lists one additional FQHC, Piedmont nine and Goshen 35, beyond each primary reporting center. The figures describe consolidated reporting groups. Assigning a group’s total visits or income to each participant would duplicate those amounts.

The financial comparison includes other income. NeighborHealth reports $5,993,258 in net patient revenue, $1,283,283 in other income and −$1,751,270 in net income. Dividing net income by the sum of net patient revenue and other income gives −24.07%. The corresponding margins are 6.23% for Piedmont and 11.49% for Goshen. Other income can include donations, investment returns and government appropriations; it is not a measure of grants alone.

All three reports cover January–December 2024. Before interpreting differences, check period length, consolidation scope, services and cost allocation. Neither cost per visit nor net income margin establishes clinical quality or explains why one group differs from another.

The code calculates a margin only when all three financial values are reported and the denominator is positive. The full file supplies net patient revenue in 1,837 reports and net income in 1,934. An absent source cell stays source_cell_absent; an existing empty cell is source_blank. Neither becomes zero. Unmatched CCNs receive an explicit message.

Using the full dataset

Replace the sample reports.csv with the purchased file. The code runs unchanged. Keep report_id as the unique observation key: 177 reporting CCNs have two retained reports. facility_coverage.csv exposes report counts and actual fiscal dates.

Join consolidated_participants.csv to reports.csv on report_id to inspect additional centers listed in a filing. It contains 8,074 relationships from 1,118 reports. These rows are reported relationships, not an allocation of group finances or a current ownership directory. The additional-center count agrees with nonempty participant CCNs in 1,081 reports and differs in 29; missing counts remain unavailable.

source_fields.csv supplies the 120 selected worksheet coordinates, meanings, units and availability counts. S-3 medical, mental-health and intensive-outpatient visits have separate definitions. Intern/resident visits are already included in other totals and should not be added again. FTEs measure hours/2080, not headcount.

Use the hospital and care-facility selection page to compare financial, quality and Medicare-activity products for other provider settings. Each is a separate purchase with its own population and periods.

Sources and versions

CMS FQHC14 all-years archive, FY2024 RPT, ALPHA and NMRC members. The cohort selects fiscal starts between October 1, 2023 and September 30, 2024; actual periods extend through September 30, 2025. These are freestanding CMS-224-14 reports, not every health-center location or hospital-based FQHC department.

The archive was modified October 5, 2026 and captured October 31, 2026 UTC. Exact HCRIS extraction is not supplied. ACD processing revision 1 prepares selected worksheet values and listed participants, with independent source reconciliation and reproducible retained inputs. It is not an audit of the underlying accounts.

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

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