Last Updated at 2:28 p.m. ET

After more than four months, Congress passed a spending deal on Friday morning that provides long-term funding for several major health programs. It's at a cost, however, to a significant funding source for the Centers for Disease Control and Prevention.

The House vote occurred just before dawn, after a government shutdown that lasted roughly six hours.

The Community Health Center Fund, which serves more than 27 million mostly low-income Americans, was reauthorized for four years.

“This is a huge relief. I can’t tell you the number of people from these centers who called or even came into the offices of their representatives to talk about the difficulties they faced,” says Dan Hawkins, senior vice president of public policy and research at the National Association of Community Health Centers.

The federal government foots around 70 percent of the bill for community health centers, which have expanded across the country thanks to increased funding from the Affordable Care Act (ACA). According to a survey by the Kaiser Family Foundation, if the budget standoff continued, 53 percent of centers said they might have started laying off staff and roughly a third of respondents said they would have started closing their doors or reducing their services.

Two programs that work hand-in-hand with community health centers were funded for two years: The National Health Service Corp, which sends recently graduated doctors to underserved areas in exchange for paying off their medical school debts, and the Teaching Health Centers program, which places medical residents in community health centers with the agreement that they’ll become a primary care physician there once their residency is complete.

Also included in the spending deal is four more years of funding for the Children’s Health Insurance Program (CHIP). It covers 9 million low-income children and pregnant women who don’t have employer-based insurance but make too much money to qualify for Medicaid. The program was reauthorized last month for six years; the four additional years is likely due to a report from the Congressional Budget Office that found funding CHIP for a decade would actually save the federal government $6 billion.

A lesser-known program that helps vulnerable new moms is also safe now. The Maternal, Infant and Early Childhood Home Visiting Program helps at-risk parents, such as teens or those with a history of substance abuse. Nurses and social workers provide them with pre- and post-natal care, parenting skills and counseling on education and job opportunities. It serves around 160,000 families across the country and is now funded for five years.

Advocates say a multi-year deal was a necessity.

“We are finally at a place where our programs have the assurance they need to continue serving families in poverty. We serve families for more than two years, so we can’t just rely on funding from month to month,” says Fran Benton, a spokesperson with Nurse-Family Partnership, one of the largest organizations that contracts with states to administer the program.

Unlike the other two, the home visiting program did not receive any stopgap funding the past four months. As Governing previously reported, Illinois ended two home visiting services, and Colorado had to cut off service to 100 families because it couldn't rehire a handful of home-visiting staffers.

The four months of uncertainty also proved detrimental for some community health centers: According to the Kaiser survey, 3 percent have already closed their doors, and 4 percent have already laid off staff.

An additional $6 billion is set aside to bolster funding for opioid and mental health treatment.

But the spending deal isn't a total victory for public health advocates.

The first fund dedicated to public health programs and efforts to prevent epidemics will be cut by $1.35 billion over 10 years to offset the cost of renewing the other health programs. The Prevention and Public Health Fund has been a frequent target of Republicans, likely because it was created by the ACA.

Earlier this week, Georges Benjamin, executive director of the American Public Health Association said in a statement:

"The Prevention Fund makes up 12 percent of the Centers for Disease Control and Prevention’s budget and supports key public health activities like childhood lead poisoning prevention, vaccination, smoking cessation and other programs in all 50 states. Slashing the fund will put these critical public health programs and the people they serve at risk."

As gridlock becomes more common on Capitol Hill, and programs as bipartisan as CHIP and the Community Health Center Fund are taken hostage, some patient advocates worry that the past few months are a sign of worse things to come.

Hawkins, of the National Association of Community Health Centers, is more optimistic: "I see hope in this agreement, and my hope is that the future is not as crazy as the immediate past."