On paper, the average value of community benefits for all nonprofits about equals the value of the tax exemption, but there is tremendous variation among individual hospitals, with many falling short. There is also intense disagreement about how those community benefits are calculated and whether they actually serve the community in question.

Charity medical care is what most people think of when it comes to a community benefit, and before 1969 that was the legal requirement for hospitals to qualify for tax-exempt status. In that year, the tax code was changed to allow for a wide range of expenses to qualify as community benefits. Charitable care became optional and it was left up to the hospitals to decide how to pay back that debt. Hospitals could even declare that accepting Medicaid insurance was a community benefit and write off the difference between the Medicaid payment and their own calculations of cost.

An analysis by Politico found that since the full Affordable Care Act coverage expansion, which brought millions more paying customers into the field, revenue in the top seven nonprofit hospitals (as ranked by U.S. News & World Report) increased by 15 percent, while charity care — the most tangible aspect of community benefit — decreased by 35 percent.

Communities are often conflicted about the nonprofit hospitals in their midst. Many of these institutions are enormous employers — sometimes the largest employer in town — but the economic benefits do not always trickle down to the immediate neighborhoods. It is not unusual to see a stark contrast between these gleaming campuses and the disadvantaged neighborhoods that surround them.

In some communities, nonprofit hospitals are beloved institutions with a history of caring for generations of families. In other communities, the sums of money devoted to lavish expansions, aggressive advertising and eye-popping executive compensation are a source of irritation.

The average chief executive’s package at nonprofit hospitals is worth $3.5 million annually. (According to I.R.S. regulations, “No part of their net earnings is allowed to inure to the benefit of any private shareholder or individual.”) From 2005 to 2015, average chief executive compensation in nonprofit hospitals increased by 93 percent. Over that same period, pediatricians saw a 15 percent salary increase. Nurses got 3 percent.

A number of communities that think nonprofit hospitals take more than they give back have started to sue. The University of Pittsburgh Medical Center fought off one lawsuit from the city’s mayor to revoke its tax-exempt status. Last year it faced another from the Pennsylvania attorney general, alleging that the medical center, valued at $20 billion, did not fulfill “its obligation as a public charity” (the lawsuit was dismissed).