In Baltimore, the health commissioner, Dr. Leana Wen, uses a need-based algorithm to decide which emergency rooms, needle-exchange vans, E.M.T.s and opioid outreach workers receive the city’s limited supply of naloxone — and which don’t. The drug, which reverses overdoses, has saved some 14,000 Baltimore residents since 2015. But its price has increased in recent years, by between 95 and 500 percent, depending on which version of the medication is being considered. Even with donations and discounts from drug makers, Dr. Wen says the city can’t afford all the naloxone it needs.

In Louisiana, the state secretary of health, Dr. Rebekah Gee, says that officials must weigh the number of hepatitis C patients they could cure with new medications against a host of other priorities, like infrastructure and universal preschool. The drugs’ list prices run from $26,400 to $96,000 per person. Roughly 2.7 million Americans suffer from hepatitis C, a painful, often deadly infection spread mainly through injection drug use; roughly 20,000 of them are Louisiana residents who receive health care through state-funded programs. Even with various discounts, Dr. Gee says she cannot treat everyone on the state’s rosters.

Such calculations are being made everywhere, and not just because of the opioid crisis. Twenty-somethings fresh off their parents’ health insurance are rationing insulin; seniors are choosing between heart medications and groceries. Lives are laid to waste as cures stand at the ready.

One possible solution involves an obscure part of federal law known as Section 1498. The provision acts as a sort of eminent domain for patented inventions, allowing the government to circumvent patent protections as long as the patent holder is fairly compensated. In the case of a pharmaceutical, the Department of Health and Human Services can authorize a drug maker to produce a low-cost generic version, which it could then buy in bulk. Both Dr. Gee and Dr. Wen have asked the government to consider invoking the law to address the twin epidemics of opioid overdoses and hepatitis C.