In what Sen. Lamar Alexander dubbed a “Christmas miracle,” the Senate gave final approval Wednesday to a $4.8 billion medical cures bill, the first major piece of healthcare legislation since passage of the Affordable Care Act.

The 21st Century Cures Act, which President Barack Obama could sign as early as Thursday, provides $2 billion for Vice President Joe Biden’s cancer “moonshot” and funds to address the nation’s growing opioid epidemic, as well as makes the first changes to the mental health system in a decade.

Alexander, R-Tenn., who steered the bipartisan measure through the upper chamber, said the passage was a “Christmas miracle.” Biden called lawmakers personally to push the measure, originally written by Republicans in 2015.

“It still wasn’t easy to pass, because we’re dealing with a lot of life and death issues,” Alexander said on the Senate floor Wednesday.

The bill reforms government rules on clinical trials and gives drug companies incentives to pursue cures for rare diseases. It also speeds approval of “breakthrough” medical devices and puts greater focus on personalized medicine. The Food and Drug Administration gets $500 million to help defray the expense of new responsibilities.

About $1.6 billion is allocated for brain studies that will focus on such diseases as Alheimer’s, and $1.4 billion is allocated for the precision medicine initiative, an attempt to revolutionize how health and disease are treated.

It also instructs the Department of Health and Human Services to clarify patient confidentiality rules so information can be shared with family caregivers.

More than 1,400 lobbyists from 40 companies pushed for passage of the measure, with pharmaceutical and medical device companies the big winners after spending $192 million, Kaiser Health News reported. Researchers at universities and medical centers, mental health groups, patient advocacy groups and information technology firms also will reap benefits from the legislation, NPR reported.

But the measure also created losers, among them public health, which loses about 30 percent of its funding,  and consumer and patient safety groups.

Mental health advocates hailed passage of the measure.

“I’d heard too many devastating stories of people struggling with serious mental illness and addiction whose lives were forever changed because they couldn’t get the care they need,” Sen. Chris Murphy, D-Conn., said. “I’d seen up close the heartbreak and frustration that families suffered trying to find care for a loved one — care that seemed impossible to find and even harder to pay for.”

Ronald Honberg, national director of policy and legal affairs at the National Alliance on Mental Illness, told USA Today he appreciates the bill’s focus on “preventing the most horrific consequences of untreated mental illness.”

The GOP had been working quietly behind the scenes to tackle gun violence by those with mental issues since the 2012 massacre at Sandy Hook Elementary School in Newtown, Connecticut, the Hill reported, but the mental health provisions were scaled back significantly as the measure worked its way through Congress.