Enrich a hospice provider portfolio in Python

Add ownership, a care-assessment measure and family caregiver experience to a provider research list using CMS identifiers.

A hospice provider research list

You have CMS identifiers for hospice providers and want to add ownership, care-quality measures and caregiver experience to a research brief. This example joins a short provider list to the Hospice Provider & Quality Reference, selecting a comprehensive-assessment measure, timely-help survey result and family caregiver star rating.

The optional example input CSV contains two genuine CMS identifiers with fictional research labels, “Durham review” and “Greensboro review.” The labels stand in for your own project names. The identical records appear in the portfolio list in the Python code below.

The three files below are small excerpts from the paid dataset, using the same filenames and fields: two provider records, all 136 quality/activity observations and all 44 caregiver-survey observations for those providers. The full reference covers 6,669 providers. Save these three CSVs in one folder; you do not need the optional input CSV to run the inline code.

Code example

Run this code in a notebook cell or Python script with the sample folder as your working directory. It uses Python’s standard library. Selecting a particular measure code preserves one result per input provider; joining the entire measure table would multiply those rows.

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

# These research labels are fictional; the CMS provider IDs are real.
portfolio = [
    {"research_label": "Durham review", "provider_id": "341507"},
    {"research_label": "Greensboro review", "provider_id": "341503"},
]
folder = Path(".")  # Folder containing the three downloaded CSV files.

def read_rows(filename):
    with (folder / filename).open(newline="", encoding="utf-8-sig") as stream:
        return list(csv.DictReader(stream))

def unique_index(rows, fields):
    result = {}
    for row in rows:
        key = tuple(row[field] for field in fields)
        if key in result:
            raise ValueError(f"Repeated reference key: {key}")
        result[key] = row
    return result

providers = unique_index(read_rows("providers.csv"), ["provider_id"])
quality = unique_index(read_rows("quality_measures.csv"), ["provider_id", "measure_code"])
survey = unique_index(read_rows("caregiver_experience.csv"), ["provider_id", "measure_code"])
results = []
for item in portfolio:
    key = item["provider_id"]
    provider = providers.get((key,))
    if provider is None:
        raise ValueError(f"Provider {key} is absent from this source edition")
    assessment = quality[(key, "H_008_01_OBSERVED")]
    timely_help = survey[(key, "TIMELY_CARE_TBV")]
    stars = survey[(key, "SUMMARY_STAR_RATING")]
    results.append({
        **item,
        "provider_name": provider["provider_name"],
        "ownership": provider["ownership_type"],
        "assessment_pct": assessment["value"],
        "assessment_status": assessment["value_status"],
        "assessment_period": assessment["period_start"] + " to " + assessment["period_end"],
        "timely_help_pct": timely_help["value"],
        "timely_help_status": timely_help["value_status"],
        "survey_stars": stars["value"],
        "survey_stars_status": stars["value_status"],
        "survey_period": timely_help["period_start"] + " to " + timely_help["period_end"],
        "assessment_note": assessment["footnote_text"],
        "timely_help_note": timely_help["footnote_text"],
        "stars_note": stars["footnote_text"],
    })

def display(row, value, status, suffix=""):
    return row[value] + suffix if row[status] == "published" else row[status]

for row in results:
    print(f"{row['research_label']} | {row['provider_id']} | {row['provider_name']} | {row['ownership']}")
    print("  Comprehensive assessment: " + display(row, "assessment_pct", "assessment_status", "%") + " | " + row["assessment_period"])
    print("  Always received timely help: " + display(row, "timely_help_pct", "timely_help_status", "%") + " | " + row["survey_period"])
    print("  Family caregiver survey rating: " + display(row, "survey_stars", "survey_stars_status", " / 5"))
    for field in ("assessment_note", "timely_help_note", "stars_note"):
        if row[field]:
            print("  CMS note: " + row[field])

Analysis of the output

Durham review | 341507 | DUKE HOSPICE | Non-Profit
  Comprehensive assessment: 95.54% | 2024-10-01 to 2025-09-30
  Always received timely help: 78% | 2023-10-01 to 2025-09-30
  Family caregiver survey rating: 4 / 5
Greensboro review | 341503 | AUTHORACARE COLLECTIVE | Non-Profit
  Comprehensive assessment: 99.67% | 2024-10-01 to 2025-09-30
  Always received timely help: 82% | 2023-10-01 to 2025-09-30
  Family caregiver survey rating: 4 / 5

The Durham record resolves to Duke Hospice and the Greensboro record to AuthoraCare Collective. The reference adds each provider’s ownership and the selected measures without matching on names or addresses.

The comprehensive-assessment percentages are 95.54% and 99.67%. This CMS measure describes assessment of the required care processes at admission, covering October 2024–September 2025. The timely-help results, 78% and 82%, summarize caregivers reporting that they always received timely help. Their reporting period covers patients who died from October 2023–September 2025.

Both providers have a 4-star family caregiver survey rating. That rating summarizes caregiver experience; it is not the same measure as the clinical assessment percentage. These records support a provider research brief, but the different methods and periods do not support combining them into a single score or treating these small differences as statistically established.

The example keeps publication status and CMS notes with every selected result. Other providers may have unavailable results because of small samples or other reporting conditions. Those values remain blank with an explanation rather than becoming zero.

Using the full dataset

After purchase, extract the ZIP and point folder at its CSVs. Replace portfolio with your own list, or load a CSV containing research_label and provider_id. Keep provider identifiers as text: some contain letters and others start with zero.

The seven tables include provider details, quality/activity observations, caregiver experience, reported served ZIPs, measure definitions, footnotes and complete source-row accounting. Use measures.csv to choose other measures and check their units. The Hospice Care Index is out of ten, spending is dollars per beneficiary, and nursing-care minutes are not percentages.

served_zips.csv supports a separate geographic research task. It retains 7,329 relationships for 242 provider IDs absent from the general-information file and flags 4,625 source-state disagreements. The collection period is unspecified. These are reported historical relationships, not a guarantee of current service availability, and postal ZIPs must not be treated as Census ZCTAs.

The complete reference costs $29 once for this source edition, including its documentation and future ACD processing improvements.

Sources and versions

The four CMS hospice source files were released August 26, 2026. ACD captured and prepared them October 19, 2026 UTC. Individual observations retain their own reporting periods; the August release date is not the date care was delivered. This edition does not contain the newer HOPE symptom follow-up measures.

The source and preparation record describes the retained files, coverage and checks. Original CMS data are freely available; ACD supplies prepared tables, documented joins, validation and delivery. No CMS endorsement or individual care recommendation is implied.

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