(CNN) How large a role do doctors play in the opioid crisis? Nearly 30% of all opioids prescribed in US clinics or doctors' offices lack a documented reason -- such as severe back pain -- to justify a script for these addictive drugs, new research finds.

In total, opioids were prescribed in almost 809 million outpatient visits over a 10-year period, with 66.4% of these prescriptions intended to treat non-cancer pain and 5.1% for cancer-related pain, according to a study published Monday in the journal Annals of Internal Medicine.

However, for the remaining 28.5% of prescriptions -- about three out of every 10 patients -- there was no record of either pain symptoms or a pain-related condition, the Harvard Medical School and RAND Corp. researchers say.

'Inappropriate prescribing'

"For these visits, it is unclear why a physician chose to prescribe an opioid or whether opioid therapy is justified," said Dr. Tisamarie B. Sherry , lead author of the study and an associate physician policy researcher at RAND. "The reasons for this could be truly inappropriate prescribing of opioids or merely lax documentation."

Sherry and her colleagues, who analyzed data from the National Ambulatory Medical Care Survey for 2006 through 2015, say the most common diagnoses at doctor visits that lacked medical justification were high blood pressure, high cholesterol, opioid dependence and "other follow-up examination."

Opioid dependence, which accounted for only 2.2% of these diagnoses, cannot explain why a doctor failed to give an adequate reason for prescribing addictive painkillers.

"If a doctor does not document a medical reason for prescribing an opioid, it could mean that the prescription is not clinically appropriate," Sherry said. "But it could also mean that the doctor simply missed recording the medical justification for an opioid, perhaps due to time constraints, clinic workflows or complicated documentation systems."

We cannot assume that poor record-keeping "indicates a nefarious purpose on the part of the doctor," she added.

Social media's contribution

Tim K. Mackey, an associate professor at the University of California, San Diego School of Medicine and director of the Global Health Policy Institute, described the new study as "an important analysis," with the findings highlighting "gaps in our understanding of why clinicians prescribed opioids."

Mackey, who did not participate in the research, believes that the study could lead to stricter prescribing guidelines, which in turn could give rise to "unforeseen consequences." For example, if new guidelines and initiatives make it harder for people to access opioids from hospitals and clinics, "this could shift demand to more accessible platforms, including the internet," he wrote in an email.

"The public health danger of sales of opioids online has been well recognized by the US government, with a US General Accounting Office report from as early as 2004 warning about pain medications available online without a prescription," he said.

Mackey's own research highlights how online pharmacies use social media to sell controlled substances while drug dealers use Twitter to sell opioids by including their phone or email information.

Someone may start by getting medication for a legitimate "pain" diagnosis, but once they become addicted, their health provider may no longer be willing to write scripts, Mackey said.

"After exhausting friends, relatives and other personal contacts, many may go to illicit channels, including street buys no longer confined to the 'street' but digitized on social media," he said. Some turn to internet pharmacies despite concerns about fraud and identify theft.

"Either way, this dangerous progression of different access points that continues to enable the opioid epidemic is not well understood," Mackey said.

With more data needed to make sense of this public health crisis, technology companies, regulators, law enforcement and researchers need to come together to share ideas, innovations and research, he said.

"Unfortunately, some of this needed collaboration may be elusive," he said. He explained that researchers who use machine-learning and Twitter's public application programming interface to detect illicit online activity are prevented from sharing their findings with law enforcement due to Twitter's terms of use

"This leaves regulators like the US Food and Drug Administration and the US Department of Justice in the dark about how they can cut off this dangerous channel of access that may continue to fuel the opioid crisis even after we make strides in other areas, such as physician prescribing," Mackey said.

Get CNN Health's weekly newsletter Sign up here to get The Results Are In with Dr. Sanjay Gupta every Tuesday from the CNN Health team.

Sherry said another key finding of her study was that "physicians were especially lax at documenting their medical reasons for continuing chronic opioid prescriptions" despite government guidelines from 2016 recommending "periodic formal re-evaluation" in cases of long-term opioid treatment.

"It is now more important than ever for physicians to transparently and accurately document their justification for using an opioid so that we can identify and rectify problematic prescribing behavior," Sherry said. "Our findings indicate that we still have a long way to go to reach this goal."