As lawmakers grapple with how best to combat the nation’s prescription painkiller abuse crisis, a recent survey is shedding light on how patients who get these medications — drugs such as OxyContin, methadone or Vicodin — sometimes share or mishandle them.

According to findings detailed in a research letter published Monday in JAMA Internal Medicine, about 1 in 5 people who were prescribed the highly addictive drugs reported having shared their meds with a friend, often to help the other person manage pain. Most people with a prescription either had or expected to have extra pills left after finishing treatment. And almost 50 percent didn’t know how to safely get rid of the drugs left over after their treatment was complete, or how to store them while going through treatment.

The study’s authors suggested that the results point to changes doctors could make in prescribing practices and counseling to help alleviate the problems.

“We’ve all been saying leftover medications are an issue,” said Wilson Compton, deputy director of the federal National Institute on Drug Abuse, who wasn’t involved with the study. “Now I have a number that is concerning.”

The survey was sent to a random sample of almost 5,000 people in 2015. Of the recipients, about 1,000 had used prescription painkillers in the past year. Almost all of the people in this group responded to the survey.

“There’s a growing awareness among medical advisers, policymakers and even members of the general public that these are medications that can do serious harm,” said Colleen Barry, one of the study’s authors. She is a professor of health policy at Johns Hopkins University and co-director of the university’s Center for Mental Health and Addiction Policy Research.

And it is not news that most people who use prescription painkillers for nonmedical reasons often get them through social channels rather than a physician. In 2013 — the most recent year for which this data is available — the National Survey on Drug Use and Health estimated that number to be more than 80 percent.

But this paper’s findings illustrate some of the forces behind drug-sharing, Barry said, and in turn indicate how to stop it. For instance, the authors recommend that doctors prescribe smaller amounts of drugs, to minimize leftovers that could be shared or stolen. That tracks with new opioid prescribing guidelines issued by the Centers for Disease Control and Prevention.

And the prevalence of sharing medications suggests consumers need to be better educated about how addictive prescription opioids are, Barry said.

Doctors, added NIDA’s Compton, also need to understand the risk that, when they prescribe pills, they could end up used by someone else.

“One out of five people that I write a prescription to for opioids may share those with someone else. That’s a lot of people,” he said.