Health advocates say a safe supply of opioids is critical to help prevent people from overdosing on tainted street drugs.

Now, a pilot project in Vancouver's Downtown Eastside provides some high-risk users with access to an automated machine that dispenses opioids prescribed by a doctor.

CBC takes a look at how it works.

How does the machine operate?

The machine, called MySafe, is stocked with hydromorphone tablets that are released on a pre-determined schedule to high-risk opioid users. A user must scan their palm on the machine to identify themselves. The machine recognizes each individual by verifying the vein pattern in their hand and then dispenses their prescription.

Made of steel and bolted to the floor, MySafe resembles an ATM or vending machine. It logs every package that is released and sends that information to a web feed that only program administrators can access.

Why is it needed?

Thousands of Canadians have lost their lives to the opioid crisis. In British Columbia, close to 5,000 people have died from overdoses since the province declared a public health emergency in 2016.

A toxic drug supply, often contaminated by a powerful opioid called fentanyl, is responsible for at least 80 per cent of overdose deaths in B.C. in the past three years, according to the province's coroners service.

"I think the only ethical response in this situation is to at least give people an alternative of a safe pharmaceutical drug that they will not overdose on," said MySafe founder and infectious disease doctor Mark Tyndall.

Tyndall says unlike methadone treatment, which is considered an abstinence-based program and helps addicts only with cravings and withdrawal symptoms, prescribed hydromorphone still gives users a high without the risk of death.

Derick Walker scans his hand on the MySafe machine to receive his dose of prescribed hydromorphone. (Ben Nelms/CBC)

Who can use it?

Participants are opioid users who have a history of overdosing. They must undergo a medical evaluation before being prescribed hydromorphone and agree to regular followups with a health professional. During the pre-screening, a prospective participant must have fentanyl detected in their urine to be eligible.

MySafe is located next to an overdose prevention site and participants can use the drugs there in the presence of health-care and front-line workers. The machine can supply enough pills for 48 users, holding five days worth of drugs for each participant, all of whom have their own specific prescriptions.

Participants can use the machine up to four times a day, but they must wait a few hours between each use. The machine can be programmed to make the window between doses as long or as short as administrators want.

Where do the drugs come from?

The drugs are prescribed by a doctor and pre-packaged by a pharmacy.

The pharmacy delivers the hydromorphone to designated health professionals who have been authorized by the participants to receive their prescriptions. Currently, Tyndall and a small group of volunteers run the pilot program and have this authorization. They load the machine.

The dose of pills is specific to each participant, who must agree to regular followup visits with a health professional. (Ben Nelms/CBC)

What about the law?

The sale, production and distribution of drugs is governed by the federal Controlled Drugs and Substances Act. People can apply for exemptions from Health Canada.

However, according to Health Canada, the machine does not require an exemption because it falls within the authority of health-care practitioners under provincial regulation, as the hydromorphone is prescribed to participants.

What is the response?

The B.C. Ministry of Mental Health and Addictions, which is not involved with MySafe, said it "will await the results" of the pilot and remains focused on its own work to scale up access to prescription alternatives to toxic street drugs.

Perry Kendall, interim co-executive director of the B.C. Centre on Substance Use, supports the pilot project.

"We very much hope that this can be expanded to reduce deaths and morbidity, get people into treatment and eventually move people into recovery," said Kendall.

The goal of MySafe is to reduce the risk of people dying from tainted street drugs. (Rafferty Baker/CBC)

Kendall, also a former provincial health officer, said the primary concern about the machine is the dispensed drugs will end up on the street, something Tyndall says is still a better alternative than having users take illegal drugs.

Derick Walker, a program participant, said the machine has given him his life back.

"I don't have to hustle all day to get money to support myself for street fentanyl, which is gambling with my life."