Ms. Whitefield, 28, had developed endocarditis, an infection of the heart valves caused by bacteria that entered her blood when she injected methamphetamine one morning in 2016. Doctors saved her life with open-heart surgery, but before operating, they gave her a jolting warning: If she continued shooting up and got reinfected, they would not operate again

With meth resurgent and the opioid crisis showing no sign of abating, a growing number of people are getting endocarditis from injecting the drugs — sometimes repeatedly if they continue shooting up. Many are uninsured, and the care they need is expensive, intensive and often lasts months. All of this has doctors grappling with an ethically fraught question: Is a heart ever not worth fixing?

“We’ve literally had some continue using drugs while in the hospital,” said Dr. Thomas Pollard, a veteran cardiothoracic surgeon in Knoxville, Tenn. “That’s like trying to do a liver transplant on someone who’s drinking a fifth of vodka on the stretcher.”