Join skilled nursing payments and therapy activity in Python

Connect fiscal-2024 covered days and Medicare payments to physical therapy profiles using facility CCNs.

Connect skilled nursing payments and therapy activity

You have a facility roster and want to add historical Medicare activity. This example joins skilled nursing covered days and payments to physical therapy minutes for three North Carolina facilities in fiscal 2024: October 1, 2023–September 30, 2024.

The optional input.csv contains three genuine facility CMS Certification Numbers (CCNs). The same selections appear in the roster list in the Python code below. No facility observations are invented.

Download facilities.csv and therapy_profiles.csv into your working folder. These genuine subsets of the purchased files retain all 130 and 70 columns for the selected facilities, including availability flags. The full $29 reference covers 13,784 facilities and separately supplies state/national benchmarks. Review the complete product and coverage.

Code example

Run this standard-library Python code in a notebook cell, IPython or a script beside the two CSV files. The join uses fiscal year and CCN, and checks that the facility names and locations agree.

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 pathlib import Path

# Three genuine facility selections; input.csv contains the same CCNs.
roster = [
    {'facility_ccn': '345000'},
    {'facility_ccn': '345001'},
    {'facility_ccn': '345002'},
]
data_dir = Path('.')  # Folder containing the two sample or full product CSVs.
fiscal_year = '2024'


def read_facilities(filename):
    with (data_dir / filename).open(encoding='utf-8', newline='') as file:
        rows = list(csv.DictReader(file))
    result = {}
    for row in rows:
        key = (row['fiscal_year'], row['facility_ccn'])
        if row['summary_level'] != 'PROVIDER' or key in result:
            raise ValueError('Expected one provider row per fiscal year and CCN')
        result[key] = row
    return result


facilities = read_facilities('facilities.csv')
therapy = read_facilities('therapy_profiles.csv')
results = []
for selection in roster:
    key = (fiscal_year, selection['facility_ccn'])
    facility, profile = facilities.get(key), therapy.get(key)
    result = dict(facility_ccn=selection['facility_ccn'], facility_name='',
                  covered_days='', medicare_payment='', physical_therapy_minutes='',
                  therapy_status='', status='not_in_file')
    if facility:
        result.update(facility_name=facility['facility_name'],
                      covered_days=facility['covered_days'],
                      medicare_payment=facility['medicare_payment'], status='in_file')
        if profile:
            for field in ['facility_name', 'city', 'state', 'zip5']:
                if facility[field] != profile[field]:
                    raise ValueError('Facility identity differs between files')
            result.update(physical_therapy_minutes=profile['physical_therapy_minutes'],
                          therapy_status=profile['physical_therapy_minutes_status'])
        else:
            result['therapy_status'] = 'not_in_file'
    results.append(result)
    if facility:
        days = facility['covered_days'] if facility['covered_days_status'] == 'reported' else facility['covered_days_status']
        payment = ('$' + format(int(facility['medicare_payment']), ',')) if facility['medicare_payment_status'] == 'reported' else facility['medicare_payment_status']
        minutes = result['physical_therapy_minutes'] if result['therapy_status'] == 'reported' else result['therapy_status']
        print(f"{result['facility_ccn']} | {result['facility_name']} | {days} covered days | {payment} Medicare paid | {minutes} PT minutes")
    else:
        print(f"{result['facility_ccn']} | not in this file; no zero activity inferred")

Replace roster with your own CCN strings or rows read from a CSV. Keep identifiers as text, including any leading zeros. Point data_dir at the folder containing your files.

Analysis of the output

345000 | Autumn Care Of Biscoe | 1621 covered days | $768,912 Medicare paid | 38249 PT minutes
345001 | Hillcrest Convalescent Center | 19431 covered days | $8,840,001 Medicare paid | 421403 PT minutes
345002 | Cypress Pointe Rehabilitation Center | 6098 covered days | $2,854,227 Medicare paid | 146423 PT minutes

The joined records give you historical activity for each facility. For example, Hillcrest reports 19,431 Medicare-covered days and $8,840,001 in Medicare payments, together with 421,403 physical therapy minutes from the linked assessment data. The payment is a fiscal-year total, not a daily price or a quote for a particular patient.

Covered days and therapy minutes come from different reporting processes. Therapy minutes depend on MDS Part A discharge assessments, which CMS does not always require. Dividing these totals does not establish complete therapy intensity, average length of stay or quality of care.

Each numeric measure has its own _status column. reported includes numeric zero. A blank with suppressed represents CMS’s asterisk; source_limitation represents the Puerto Rico dual-eligibility plus marker; source_marker_m preserves an M marker whose exact cause is not defined in the retained documents. None means zero. A CCN absent from the file likewise does not establish no activity.

The other payment columns distinguish billed charges, allowed amounts including cost sharing and third-party liability, and geographically standardized Medicare payments. Geographic standardization does not adjust for patient mix or make facilities comparable on quality.

Using the full dataset

Extract the purchased ZIP and replace both sample CSVs with their full counterparts. The code runs unchanged. Each provider table has one row per fiscal_year + facility_ccn.

Seven CSV tables provide facility utilization/payments, therapy and clinical profiles, two separate benchmark tables, complete source-record accounting, field mappings and source editions. Dictionaries, source-marker explanations, checksums and independent reconciliation accompany them.

The benchmark tables contain 50 states, DC, Puerto Rico and a national aggregate. Use the published aggregate appropriate to your question; do not append it to provider rows or expect provider sums to reproduce it. Distinct beneficiaries can appear at multiple facilities, and suppression differs across reporting levels. Clinical percentages use linked stays; PDPM percentages use days.

The Nursing Home Facility & Quality Reference supplies separately dated facility and quality information. Review historical CCN identity, names and reporting periods before joining it. The hospital and care-facility selection page explains the other care settings. These are independent purchases.

Sources and versions

Source: CMS Medicare Post-Acute Care Utilization, Skilled Nursing Facility summary and supplement, fiscal 2024. Both distributions were modified August 11, 2026 and captured by ACD October 27, 2026 UTC. Both official dictionaries and the August 2026 methodology are retained. Although the general catalog lists calendar dates, YEAR_TYPE=FY and the methodology establish the fiscal period used here.

This is Original Medicare fee-for-service skilled nursing activity, not all residents, payers or Medicare Advantage. Critical-access-hospital swing-bed claims are excluded; eligible other swing-bed providers can be included. Addresses and names are historical.

The original government sources are free. ACD sells preparation, validation, documentation and delivery. Same-source processing improvements are included; genuinely new source editions may be sold separately. No automatic refresh is promised. Read the source and preparation record.

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