Your description of the in-patient problem sadly reflects the state of affairs up in Canada too, where most, but not all, healthcare is free (eyes and teeth are strange exceptions).
I’ve got an older friend who did a lot of drugs back in the day, but got his life mostly figured out until a few years ago when he had to get shoulder surgery. Prescribed Oxy for recovery, even after telling the surgeon about his past addiction struggles. As expected, they become less effective over time, he likes getting high, so he starts taking larger doses. Gets to the end of his prescription and can’t get a refill.
Did he make bad choices here? Definitely. But then the health care system screws up:
“I want to detox and get clean again.”
“Sorry, you’ve never overdosed, so you can’t detox in the hospital. Maybe you can get on a waiting list for a private (out of pocket) facility. Oh, and no refills, you’re an addict”
“Maybe I can be a short-term patient at a mental health facility?”
“Sorry, you’ve never tried committing suicide because of your drug use. Maybe you can get on a wait list at a private facility? Oh, and no refills, you’re an addict!”
So... what does an opioid addict who is in withdrawal and can’t get support from the health care system do? Goes and scores some heroin...
Today he’s mostly clean again. I think he pops a pill here and there but isn’t high all day. But... this could have all been avoided. The health care system had many opportunities to help out here, but didn’t.
Edit: one last note: the private facilities are quite expensive and have massive waiting lists. Even if he had had the cash to go, he would have still been in limbo for weeks-to-months with no access to clean drugs nor support to get clean.