At the June meeting of the University of Michigan regents, U-M Health System president Dave Spahlinger projected a $129 million surplus for the 2016 fiscal year. With annual revenues of more than $3 billion and roughly 16,000 full-time-equivalent employees, the UMHS is by far Washtenaw County’s biggest business, and its financial health is critical to the university and to the region as a whole.

The number–since revised upward–continued a welcome financial turnaround. The health system reported a surplus of $87 million in 2015, up from just $17 million the year before. This despite debt service on the new women’s and children’s hospitals (combined cost $754 million) and a planned $175 million health center in Brighton, which broke ground in September.

In a press release, Spahlinger credited strong patient volume and improved patient access along with faculty and staff engagement. Demand for outpatient services in particular has steadily increased, with new patient appointments growing 38 percent over the previous five years.

But Republican plans to repeal Obamacare threaten to undo that progress. “The Affordable Care Act [ACA] has been a significant positive” for the bottom line, Spahlinger told the Observer in September. That’s because the number of uninsured patients treated at the UMHS fell dramatically as the Medicaid rolls expanded under Obamacare and more low-income people acquired private insurance. “We probably have one of the most generous charity care policies in the state,” Spahlinger noted. “Anybody under 200 percent of federal poverty [guidelines] who didn’t have insurance … and lives in the state could get free care here.”

The UMHS once wrote off many millions each month for such care–$8 million in December 2013 alone. Two Decembers later, charity care came in under $4 million. Bad debt from unpaid bills–an even bigger liability–also declined under Obamacare.

President-elect Donald Trump plans to appoint Tom Price, Obamacare’s most rabid enemy in Congress, to head the Department of Health and Human Services, and Republican congressional leaders say that repeal will be one of their first acts in January. Implementing it, and coming up with a replacement plan, will take longer, but the ACA will probably collapse within a year as insurers flee the marketplace. And current plans call for the national rollback of the ACA’s Medicaid expansion.

If that happens, the UMHS will be much worse off than before the ACA took effect. That’s a legacy of Obamacare’s little-known deal-making history. Because the UMHS treats many low-income patients, it’s classified a “disproportionate share hospital” (DSH). Collectively, DSH hospitals used to get tens of billions of dollars a year in Medicare “buffer” funds and other subsidies–but agreed to give them up to help finance the ACA. In exchange, the hospitals were promised a windfall from Obamacare’s newly insured patients.

Now those insurance payments are likely to disappear–but the funding cuts will probably remain. A December report by the American Hospital Association (AHA) calculates that DSH hospitals will lose $289 billion over eight years if the ACA is repealed and the Medicare cuts are not reversed. “Losses of this magnitude cannot be sustained” and will result in “massive job losses,” AHA president Richard Pollack wrote in December letters to Trump and to Congress.

Though the UMHS will suffer if Obamacare collapses, it also has a hidden lifeline. Crucially, one surviving DSH program is providing spectacular returns that are likely to grow, not disappear.

That lifeline runs through the hospital’s outpatient pharmacies. A federal program called 340B, after the section of the Veterans Health Care Act of 1992 that created it, requires manufacturers to sell DSH providers outpatient drugs for 20 to 50 percent less than they charge others. The extra profits aren’t passed on to patients or their insurers but go to the hospitals’ bottom line.

Between fiscal 2013 and 2016, outpatient pharmacy revenue at the UMHS exploded from $193 million to $447 million a year. Its share of the health system’s revenue also doubled, from 7 percent to 14 percent. With gross margins of about 43 percent, the outpatient pharmacy alone probably turned a loss to a profit in 2014–and had a much bigger impact last year.

The U-M has been a DSH since 2004. In fiscal 2009, it established a specialty pharmacy to provide injectable drugs and other medications that require close physician supervision. Together, those changes have proved enormously profitable. “This year we saw record financial performance,” chief pharmacy officer Stan Kent wrote in his 2016 annual report, “largely due to our specialty pharmacy business and 340B participation.”

The specialty pharmacy started out dispensing immunosuppressive drugs to organ transplant patients, who must take the drugs for the rest of their lives to prevent rejection–a niche previously served by outside pharmacies under contract with the hospital. “There’s a margin to be made off of these drugs; that’s why these outside companies do that,” says Jim Stevenson, chief pharmacy officer from 1999 to 2014. By establishing its own specialty pharmacy, “we kept that within the University of Michigan system.”

But there are relatively few transplant patients. So, over time, U-M’s pharmacies added cancer chemotherapy and rheumatology drugs (for rheumatoid arthritis and other autoimmune diseases), which usually must be infused intravenously in a clinical setting. These became major profit drivers. “As our cancer infusions and non-cancer infusions grew, as our programs grew, that 340B pricing became more and more valuable year over year,” says Stevenson.

What really drove the revenue explosion, though, were new oral treatments for cancer and hepatitis C. The cancer pills are more convenient and less toxic than conventional chemotherapy, but they’re also very expensive: Pfizer’s Ibrance, a breast cancer drug discovered in Ann Arbor, came to market last year at a list price of more than $118,000 a year.

Even more important, three years ago, the FDA approved Olysio and Sovaldi, the first so-called direct-acting antivirals (DAAs) for hepatitis C. Other DAAs quickly followed. Before then, patients with hepatitis C, who are at risk for cirrhosis, liver failure, and liver cancer, took a combination of two old drugs, interferon beta and ribavirin. They cured the disease less than half the time, and their extreme side effects–anemia, fatigue, flu-like symptoms, and severe depression–led many patients to forgo or abandon treatment and some to commit suicide. The new pills, which precisely target viral proteins, are largely free of side effects and cure about 95 percent of hepatitis C cases, usually after just twelve weeks of treatment.

These are incredible drugs, and they’re incredibly costly. A typical twelve-week course of treatment with Harvoni, the most widely prescribed DAA, has a list price of $94,500–or $1,125 for a single pill. Institutions don’t pay list price, but it’s still extremely expensive: according to a recent report by the IMS Institute for Healthcare Informatics, insurers reimburse hospitals an average of $50,400 for treating a patient with Harvoni. According to Aaron Vandervelde, a Washington, D.C.-based health care consultant (and U-M business school grad), reimbursement for such expensive drugs includes a markup of 6-10 percent to cover the hospital’s costs to dispense it. So an average hospital might pay $46,000-$47,500 for a course of Harvoni and keep roughly $2,800 to $4,500.

A hospital that gets the drug at the 340B rate can make a lot more. The 340B discount typically starts at 23 percent off the average selling price. At that rate, a disproportionate share hospital like UMHS would pay about $32,000 to $35,000 for a course of Harvoni–and earn somewhere between $15,000 and $18,000. That’s just from the drug–payments to the hospital facility and the treating doctor would be on top of that. And it could be more: Vandervelde, who consults mainly for drug companies but also for insurers and hospitals, says 340B discounts can be as much 30 percent below the average selling price. At that rate, a 340B hospital would earn $17,000-$18,000 for each insured patient.

As a major liver referral center, UMHS has “one of the largest hepatology programs in this country and perhaps the world,” says U-M hepatologist Anna Lok in a U-M promotional video. UMHS spokesperson Mary Masson won’t give the actual number of hepatitis C patients it treats but emails that it is in the “thousands,” most of them eligible for 340B pricing.

“Last year hepatitis C contributed a lot to our pharmaceutical performance,” Spahlinger says. “We had been following patients for years with hep C, and we had what I would call a backlog of patients.” Beginning in 2009 the UMHS counseled many patients to hold off on treatment and wait for the DAAs. Once the drugs arrived, treating the backlog gave the hospital a one-time financial windfall.

How much might the U-M be earning from hep C treatments? Our $15,000 to $18,000 range per eligible patient is just a guess; Gilead Sciences, maker of Harvoni, won’t disclose how much it charges UMHS for the drug, and the UMHS won’t say either. But Spahlinger doesn’t rule out a gain in the range of $10,000 to $20,000 for every insured 340B patient. “Not sure that’s what we make,” he says. “That may be related to the savings we get–I don’t know.”

Masson writes that the health system’s hepatitis C drug revenue totaled $54 million in fiscal year 2016. With the drug alone billing at $50,400, it could collect that much by treating fewer than 1,100 insured patients. Depending on the size of its 340B discount, and its markup on non-discounted drugs, UMHS may have turned a gross profit of $9 million to $12 million. And that’s just from hep C–it enjoys similar markups on the oncology, rheumatology, and other outpatient drugs it also buys at 340B prices.

The imminent loss of Obamacare is even more dangerous because it comes at a time when health systems face enormous pressure to grow. Most American outpatient care is still “fee for service,” with providers billing insurers for each treatment and diagnostic procedure they perform. But now Medicare and private insurers are moving inexorably towards a future of “bundled” payments: providers will get a fixed amount per patient per year, or a flat rate per “episode” of specialty care, regardless of the actual services provided. To spread that risk across the largest possible pool of patients, providers are competing to buy physician practices and even entire health systems.

Investing when revenue is uncertain is a risky business–but to survive in the bundled payment era, UMHS leaders have concluded that they must aggressively expand their outstate network. That’s partly to head off other health systems already doing this and partly because UMHS can’t compete for most patients on price.

But here, too, the U-M’s outpatient pharmacy provides a lifeline: each expansion is a chance to acquire more 340B patients. In December, the UMHS completed its acquisition of Metro Health, a Grand Rapids-area osteopathic hospital. Though the arrangement was described as an “affiliation,” Crain’s Detroit Business reported that it will “make 208-bed Metro Health a wholly owned subsidiary of UMHS.” Masson writes that 340B wasn’t a consideration in the deal, but Metro Health’s hospital and clinics will bring more 340B-qualifying cancer, arthritis, and hepatitis C patients into the UMHS system.

Though the 340B program has become critical to the UMHS, it won’t reveal the precise impact. Its 2015 financial reports show the University of Michigan Medical Group (UMMG), the faculty group practice that collects doctors’ payments and distributes them, to be the fastest growing unit in the health system. “A lot of that I would attribute to the hep C growth,” says Spahlinger. But the U-M rejected an Observer Freedom of Information Act request for the UMMG budget because “the UMMG does not have a separate budget,” wrote U-M chief freedom of information officer Patricia Sellinger. This despite the existence of a permanent UMMG budget and finance committee that “reviews the UMMG budget annually,” according to the UMHS website. Last summer, the UMHS removed several detailed financial statements from the website. Questions about why they were removed went unanswered, although the UMHS did provide the Observer a four-page financial summary for fiscal 2016.

The hepatitis C money, wherever it goes, is already falling off, because the patient backlog has been treated. “We anticipate actually for next year that the revenue from hep C drugs will drop about $22 million,” says Spahlinger. It won’t disappear completely, because new patients continue to be diagnosed. Most people infected with hep C are baby boomers who acquired the disease through blood transfusions before blood supplies were first tested in 1991, and many are still unaware they have it. (Hepatitis C can be asymptomatic for decades.) Most will eventually need treatment. Another large group consists of young adults infected by shared injection needles during the current heroin and opioid drug epidemics.

In all, an estimated four million people are infected with hep C nationwide. Cancer and autoimmune diseases are not disappearing either, nor their expensive drugs.

That’s fortunate for UMHS. If Obamacare’s demise brings a fresh flood of uninsured or underinsured patients, it will need every dollar its outpatient pharmacies can earn, and more.