The first prescription that patients get for opioid painkillers has a large influence on their risk of long-term use, according to a new report published Friday.

Prescribing fewer opioids to be taken over a period shorter than three days in the initial prescription decreases the likelihood of chronic use, researchers wrote in the Morbidity and Mortality Weekly Report, published by the Centers for Disease Control and Prevention.

There is a sharp increase in the probability of patients using opioids long term if they are prescribed these pain pills for more than five days, their study found, and a further increase for patients who got a 30-day supply of drugs. Refills or second prescriptions also play a role in determining whether people are able to stop using opioids or continue to take the drugs.

Approximately one in seven people who were given a second opioid prescription or a refill were still on opioids one year later, according to the study, which analyzed patient records from 2006 to 2015.

The study excluded patients with prior substance use disorders as well as those who had cancer (with the exception of non-melanoma skin cancer), said Bradley Martin, who heads the pharmaceutical evaluation and policy division at the University of Arkansas for Medical Sciences. The data his team analyzed didn’t include the cause or intensity of the patients’ pain, which might have influenced the results.

The type of drug prescribed also make a difference in how likely people were to stay on opioids. Patients who were initially prescribed a long-acting opioid were at a higher risk of chronic opioid use. About 1 in 4 patients continue opioid use one year after being initially prescribed a long-acting opioid, and 1 in 5 were still on opioids three years later.

Opioid overdoses have resulted in the deaths of hundreds of thousands of people in the United States. In 2014, drug overdoses killed 47,055. Over-prescription of these drugs in the United States exacerbates the problem, according to another Morbidity and Mortality Weekly Report.