Over the objections of many doctors and their powerful advocacy groups, states are moving to force physicians to check on patients’ narcotic-purchasing habits, one of the more effective ways of curbing opioid abuse as the deadly drug epidemic continues.

Eighteen states have adopted comprehensive mandates in the past four years requiring doctors who prescribe opioids and other controlled substances to check databases that show whether their patients are getting drugs elsewhere. About 13 other states have weaker mandates that cover more limited circumstances, according to a recent review by the Pew Charitable Trusts and Brandeis University.

“I felt it was important to make sure it was mandatory,” said Ricardo Lara (D), a California state senator who last year led a successful drive to replace the voluntary system there. “The systems that are mandatory are the ones that are having an impact and saving people’s lives. . . . The data speaks for itself.”

But the result of the state-by-state approach is a patchwork of rules that vary considerably, despite evidence that opioid abusers will cross state lines and travel great distances to illegally obtain prescription drugs. Voluntary systems remain in the remainder of states, where research shows many drug prescribers do not use the databases — known as prescription drug monitoring programs, or PDMPs.

In Congress last summer, an effort to encourage development of uniform databases was ultimately left out of the Comprehensive Addiction and Recovery Act.In some places, prescribers can check only the narcotics purchases in their own states.

Even the mandatory programs have different requirements for prescribers’ use and the drugs that must be covered.

In Kentucky, for example, which has one of the toughest approaches, prescribers must check a PDMP before issuing a first prescription for opioids, benzodiazepines and other controlled substances. They then must recheck it at least every 90 days thereafter.

Neighboring Missouri remains the only state without a PDMP, which critics say encourages substance abusers from bordering states to buy drugs there. Republican state Sen. Rob Schaaf, a physician, has led efforts to block PDMP legislation for years out of concern for patient privacy, according to his chief of staff, Jim Lembke.

“I think the senator’s argument would be that PDMPs don’t work. They divert people to heroin. They’re not lowering the amount of people that get addicted,” Lembke said.

To curb “doctor shopping,” the databases generally make information on controlled-substance purchases recorded by pharmacists and other drug dispensers quickly available to prescribers. The drugs include oxycodone, hydrocodone, Xanax and others, though the list varies from state to state. Prescribers — mainly physicians — can see which drugs their patients are obtaining and whether they are going to other prescribers to do so.

Research shows that mandatory systems are much more effective at getting doctors to use PDMPs. A 2014 survey of primary-care doctors by the Bloomberg School of Public Health at Johns Hopkins University showed that 53 percent across the country reported ever using a PDMP. But when Kentucky, New York and other states instituted strong requirements, use of the databases soared, doctor shopping declined, and overall prescribing of narcotics and other drugs fell.

New York was averaging 11,000 monthly requests for PDMP reports in the 3 1/2  years before mandated use in 2013. Six months later, requests had risen to 1.2 million per month, according to the Pew report. Doctor shopping, defined as a person obtaining controlled-substance prescriptions from five prescribers in one month, fell 76.4 percent in a year. Opioid prescribing dropped by 8.7 percent, and prescriptions for buprenorphine, a drug used to treat opioid dependence, rose 12.8 percent.

Kentucky and Ohio saw similar results.

Multiple provider episodes are defined as patients using five or more prescribers and five or more dispensers within the month. (New York PDMP/Pew Charitable Trusts)

“States with strong requirements for prescribers to use the PDMP tend to have higher rates of enrollment and utilization and, as a result, have seen greater improvements in opioid prescribing and faster declines in doctor shopping,” Thomas Clark, a research associate at the Institute for Behavioral Health at Brandeis University, who helped prepare the Pew report, said in an email. Ultimately, that “means less addiction and diversion, as well as fewer overdoses and deaths related to prescription drugs.”

For the most part, doctors have vigorously fought mandatory PDMP checks. Their two largest associations — the American Medical Association and the American College of Physicians — support voluntary plans, arguing that doctors should be free to make decisions about how to manage their patients and practices.

“When you pass a mandate, you create other consequences that you sometimes don’t want,” said Steven Stack, immediate past president of the AMA and an emergency-room physician in Lexington, Ky. Stack and others note that pressure on doctors in the late 1990s and early 2000s to more aggressively treat pain led to overprescribing of narcotics and fueled the current opioid epidemic. About 180,000 Americans have died from prescription-opioid overdoses since 2000.

In hospital emergency rooms, Stack added, the mandate imposes another time-consuming burden on already overworked physicians and staffs that takes them away from their patients.

During a busy 12-hour shift, he said, perhaps 10 of the 30 emergency patients he sees receive a narcotic for pain. Each time, he or a nurse must log into the Kentucky database to review the patient’s purchasing habits — which can take 30 seconds to two minutes and sometimes much more if there are problems with the information or the technology.

“We have taken doctors and turned them into clerical staff and typists,” Stack said. “We are locked down at a computer, playing the equivalent of a very boring video game on very bad technology.”

The study defined multiple provider episodes as individuals receiving multiple controlled-substance prescriptions from four or more prescribers and filled at four or more pharmacies within a three-month period. (University of Kentucky Institute for Pharmaceutical Outcomes and Policy/Pew Charitable Trusts)

Primary-care physician Daniel Alford, director of the Clinical Addiction Research and Education unit at the Boston University School of Medicine, said it is extremely rare for him to find a doctor shopper among his patients. But he still must check for each person under Massachusetts’s mandated system.

“Is this a good use of my time, to be looking up patients on the PDMP, when, frankly, in a ­primary-care practice the yield is incredibly low?” he asked.

Most states have responded by allowing nurses and other staff to check a database on behalf of a doctor, nurse practitioner or other prescriber, although the ultimate responsibility remains the prescriber’s. According to the Pew study, allowing “delegates” to check for a prescriber still increases PDMP use.

That is the ultimate goal of the continuing effort. In light of the epidemic, doctors need to shed their old habits, said Gary Mendell of Shatterproof, a group that advocates strict, mandatory ­PDMPs.

“Fifteen years ago, there was no need to squeeze into your time with a patient the need to check a database to see what other medications they’re taking,” he said. The opioid crisis has changed that situation, he said, and “they haven’t caught up with that.”