Inpatient treatment programs for heroin and opioid dependence can be so difficult to get into in some parts of the country that drug users who want to quit are voluntarily asking judges to lock them up — just to guarantee they'll get help.

In Massachusetts, that's happening via a 46-year-old law that was designed for family members to commit their loved ones to a locked facility when they are deemed "a danger to themselves or others" because of drug or alcohol abuse. But as more people struggling with addiction are actually requesting this sort of lock-up, some are questioning whether "voluntary" court-ordered commitment for treatment of substance abuse is a good idea.

On a bench outside a Springfield, Mass., courtroom recently, a 33-year old man looked more alert than you might expect for someone coming off a heroin binge. He'd previously been clean for two months, he said, but couldn't maintain it.

"Now I'm probably doing two bags," he said, "and it's getting me high as a kite." He still very much wants to quit, he said. NPR agreed not to disclose his name.

The man said he's been spending $1,000 a week on heroin, scaring his family and scaring himself. They're all worried he'll overdose. That's why, even though it would mean giving up his liberty for up to 90 days, he was in court that day to ask the judge to lock him away — inside a treatment program that he wouldn't be allowed to leave, far away from his dealers.

"If I don't do this, I'm going to lose my freedom eventually anyway," he explained. "Eventually, I'm going to get enough charges to the point where I go to jail anyway."

Massachusetts is one of 38 that allow civil commitment for substance abuse.

"Basically, it's a good way to get clean," the heroin user in Springfield explained. "Because, if you try getting into these five- or six-day [detoxification programs], it takes forever. It takes a month to get into the place, and if you don't have the right insurance, they don't want you."

Officially, under the law, you're not allowed to ask for your own commitment. Someone else — a close relative, a probation officer or emergency room doctor, for example — must petition the court on your behalf. But if you agree not to oppose that sort of petition, the judge is likely to approve it.

In the Springfield courtroom of Judge Michele Ouimet-Rooke, that day, the man requesting to be committed stood tall, respectful of the judge.

His sister was the official petitioner. A forensic psychologist testified that the man was, indeed, a danger to himself and others because of his heroin use. Then his attorney spoke.

"My client is in agreement to go to the treatment program in Brockton," Maria Puppolo, told the judge. That facility is the Men's Addiction Treatment Center in Brockton, Mass., a locked-down, privately run intervention program, exclusively for men who have been mandated to go there by the civil courts.

"He understands the seriousness of his addiction and he wants to get the help," the attorney added.

The judge agreed.

"Very good, sir," Ouimet-Rooke said. "I do find there is a basis for the commitment."

As a court officer led the man away in handcuffs, the man smiled at his family and looked relieved. That same afternoon, the judge committed three other heroin users to detox programs, all of them willing.

In most such cases, these drug users hope to be assigned to a privately run treatment center like the one in Brockton. But if there's no room there, some men will end up at a more bare-bones program at the state prison. (Women who are committed to mandatory treatment in these civil proceedings in Massachusetts go exclusively to privately run treatment centers.)

This year, about 8,000 people will be committed to substance abuse treatment in Massachusetts, officials estimate — that's up 40 percent from five years ago. It's not clear how many of those commitments are voluntary.

Jennifer Flanagan, a Democrat and Massachusetts state senator representing Worcester and Middlesex, led an investigation in 2014 into this trend — partly to understand why people addicted to drugs were trying to get committed. She says she found that many just couldn't find or afford treatment outside the courts.

"If you're an addict and you finally decide, 'Today is the day I want to go,' you may not necessarily go through the hassle of calling every place and trying to get a bed, and calling your insurance company," Flanagan says. It some ways it's easier just to ask a judge for voluntary commitment, she says, "because you're mandated a bed."

That's a bed in an inpatient program that the state has to pay for if insurance doesn't — and the length of treatment is often longer than most insurance policies would cover. While Flanagan calls that a "misuse of the system," others say that's what the system is for.

Judge William Mazanec III presides over the Greenfield District Court in Greenfield, Mass. He considers it part of his job to help some people who have become physically and emotionally dependent on opioids — people who see the courts as their last resort in being able to quit the drugs.

"They're asking for me to use that process to force them into a situation where they can't just walk out of treatment," Mazanec said. "You have a window of opportunity where they're recognizing this. You have to act quickly."

Still, the process doesn't always run smoothly. Sometimes drug users want to find out where they're likely to be sent — a private treatment center or a prison program — before agreeing to go. If it's prison, because there aren't enough beds open at the private center, some try to stop the commitment process after it starts.

That puts court officials in a bind — and frustrates some state officials, including Flanagan.

The law was designed, Flanagan said, "to get someone out of imminent danger. If you're in danger, you're in danger."

Copyright 2016 WFCR-FM. To see more, visit WFCR-FM.