Randy Davis, a 53-year-old laborer, was taking various painkillers for a shoulder injury that didn’t get better after surgery. As the pain worsened, the Castro Valley resident began crushing the pills, then snorting them to get instant relief.

In May 2013, his sister found him slumped over on his bed after he overdosed on the pills. By the time the ambulance arrived, Davis was dead.

Over the past 10 years, the number of Bay Area residents who had opiates — including commonly used prescription painkillers such as OxyContin, Percocet and Vicodin — in their bodies when they died has grown steadily, doubling and in some areas tripling, according to a Bay Area News Group investigation. Last year, 220 people died as a result of opiate overdoses in Alameda, Contra Costa Santa Clara and San Mateo counties, nearly twice as many as a decade ago, according to numbers compiled from coroner reports.

Opiate overdoses have also resulted in sharply rising emergency room visits and hospital stays, which doubled in Alameda and Santa Clara counties in 2013 and grew by nearly 60 percent in Contra Costa.

The spike is driven by a number of factors, but a primary one is the shockingly easy access to pills, readily available after dental work, for back pain or many other ailments that cause discomfort, doctors and public health officials say.

“You have a tooth pulled at the dentist and you get 30 pills,” said Alice Gleghorn, who oversees addiction services at the San Francisco Department of Public Health. “You take it for two days and you have the rest left over, just sitting in your medicine cabinet.”

It wasn’t always this way.

For decades, long-term opiate use was reserved for cancer patients and those needing end-of-life care. Patients prescribed painkillers for chronic pain received small quantities and were carefully monitored, said Andrew Kolodny, chief medical officer for Phoenix House, a national addiction treatment program.

But 20 years ago that began to change, in part due to a push from the pharmaceutical industry to prescribe painkillers more widely, Kolodny said.

The passage of the Prescription Drug User Fee Act in 1992 accelerated the speed at which new drugs were brought to market in exchange for fees from pharmaceutical companies. Just four years after it was passed, the number of new prescriptions for all drugs had more than doubled, with opiate use surging after the 1995 approval of OxyContin.

Today, an estimated 14 million people in the United States abuse painkillers and more than 17,000 die each year after overdosing on them, according to the Substance Abuse and Mental Health Services Administration.

In the Bay Area last year, doctors wrote out an estimated 2.2 million prescriptions for opiate painkillers — nearly one for every three people who live in the region, according to the California Department of Justice.

The problem is so severe that in May, Santa Clara County officials sued five pharmaceutical companies, accusing them of a decades-long false advertising campaign officials say resulted in millions of addictions and numerous deaths from opiates. The lawsuit alleges that companies recruited “key opinion leaders,” including doctors and pain specialists they considered sympathetic to prescription painkiller use, then poured millions into marketing opiates as a safe and humane way of dealing with pain.

The pharmaceutical companies, which include Purdue Pharma, Janssen and Actavis, declined to comment on the pending litigation.

This newspaper compiled data on local opiate overdose deaths from statistics kept in county medical examiner’s offices. The biggest increase has been in Santa Clara County, where the number of people who died with opiates in their bodies more than tripled.

In some cases, the data specified the opiate involved, including legal pills such as OxyContin, hydrocodone (initially marketed as Vicodin), and diazepam as well as — in a smaller number of cases — the illegal opiate heroin. But in other cases medical examiners were unable to determine if someone died from legal painkillers or heroin, because the drugs metabolize quickly in the body.

‘I would do anything’

For many, the drugs hold a powerful lure.

Vicki, who didn’t want her last name used, is a 56-year-old San Jose resident and a grandmother of five who turned to a doctor about 12 years ago with complaints of rheumatoid arthritis pain. She was given Vicodin, the muscle relaxant Soma, and fentanyl. But as a former user of illegal drugs, Vicki was at a higher risk for addiction, something her doctor failed to mention.

“Once I started using drugs again, my body just wanted more and more, and I would do anything I could to get them,” Vicki said. When she ran out of pills, Vicki lied to her doctor, saying she had forgotten hers while visiting relatives. She went to the emergency room for a pain shot and shopped at online pharmacies.

Ironically, her pain didn’t get better — a common effect when users develop a tolerance for the drugs, Kolodny and others say. As Vicki’s addiction took over, she left her house less and less, slurred her speech and nodded off during dinner.

“People don’t think it (addiction) can happen to them, but that’s not true,” Vicki said. “It can happen to anyone.”

Vicki eventually quit and checked herself into rehab. She has been clean for six years and now manages her pain through exercise, a good diet and a short-term steroid for when her pain flares up.

Yet for many who experience debilitating, all-encompassing pain, opiates are necessary for a functional lifestyle.

“We don’t want to be inhumane to our patients who are suffering and just walk away from them,” said Phillip Coffin, director of substance abuse research at the San Francisco Department of Public Health. “That’s not what we do in medicine.”

Zeroing in on ‘dirty’ doctors

While acknowledging that some opiate use is legitimate, officials are cracking down on doctors who prescribe to addicts with little regard for symptoms or treatment.

Los Gatos doctor Jasna Mrdjen was arrested in 2012 for prescribing oxycodone to drug addicts and charging as much as $100 for a bottle, according to the Santa Clara County District Attorney’s Office. Mrdjen instructed patients about how to avoid being arrested and even conducted drug sales in the parking lot of her clinic, prosecutors say; she is still awaiting trial.

One of her patients was 29-year-old Steven English, a San Jose resident who began taking pills after suffering a hand injury in jiujitsu. English, who graduated from Santa Clara University and had worked as an investment broker at Morgan Stanley, received as many as 300 pills at a time from Mrdjen, said his mother, Pam English.

One morning in 2012, he and his parents were planning to go to yoga together near their home in Truckee. When Pam English checked on her son, he was snoring contentedly in bed. She decided to let him rest. When she returned, her son was silent. She shook him to wake him up, but he was dead.

“We were ignorant and just didn’t have experience with these pills,” English said. “Now we know they are so powerfully addictive that we have to be wary.”

While many more people still die from prescription pills, there is evidence that increasing legal opiate use is pushing more people to try heroin, local public health officials say. That’s because as pharmaceutical companies change formulas to make pills harder to abuse and police departments crack down on illicit doctors, the shortage of pills is pushing addicts to find other ways of getting a high. Heroin remains relatively cheap.

“It’s purely price,” said an undercover detective at the Livermore Police Department, who spoke on the condition of anonymity. “Kids would rather be doing pills because they’re considered clean, but because they’re so expensive, they are turning to heroin.”

But for others, legal painkillers remain the drug of choice. They’re socially acceptable, and the dangers are easy to overlook.

April Rovero, whose son, Joey, died in 2009 after overdosing on pills he bought from a “dirty doctor” in Los Angeles, said that needs to change.

Rovero now heads the National Coalition Against Prescription Drug Abuse and frequently speaks to schools and parents about the dangers of addiction. She’s also pushing for tougher action by the Medical Board of California in going after doctors who overprescribe, meting out not just fines but also jail time.

What “everyone needs to understand,” Rovero said, “is that these drugs are not safer because a doctor prescribes them, but (they) can be just as deadly, addictive and illegal as street drugs.”

Parents can play an important role in keeping their children from abusing prescription drugs.

Ensure your home is safe from prescription drug abuse. Lock up your drugs and discard unused and expired drugs at a drop-off site close to you.

Talk to your child about the dangers of “pharm” or “Skittles” parties as early as middle school. At these parties, bowls of prescription drugs are passed around containing mixtures of all of the medications the partygoers were able to “score” from whatever medicine cabinets they have access to.

Get to know your child’s friends and their parents and be on the alert for those who allow underage drinking and the use of other substances in their homes.

Watch for changes in mood, attitude and sleeping habits.

Other signs may include missing work or school, lack of personal grooming and slurred speech.

Karina Ioffee covers the city of Richmond and West Contra Costa County. She has been a reporter for 15 years and has won numerous awards for her work, including from the Overseas Press Club. She speaks Spanish and Russian and is a former competitive gymnast. When not working, she likes to do yoga, cycle and dance.