Skip to main content
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

HHS OIG Toolkits for Calculating Opioid Levels and Identifying Patients At Risk of Misuse or Overdose

Issued on  | Posted on  | Report number: OEI-02-17-00561

Report Materials


OIG has developed two toolkits that provide detailed steps for using prescription drug claims data to analyze patients' opioid levels to identify certain patients at risk of opioid misuse or overdose. The first toolkit includes SAS programming code. The second toolkit includes R and SQL programming code. Both toolkits are based on the methodology that OIG developed for its extensive work on opioid use in Medicare Part D.

The toolkits provide highly technical information to assist our public and private sector partners—such as Medicare Part D plan sponsors, private health plans, and State Medicaid Fraud Control Units—with analyzing their own prescription drug claims data to help combat the opioid crisis.


The opioid crisis remains a public health emergency. As one of the lead Federal agencies fighting health care fraud, OIG is committed to supporting our public and private partners in their efforts to curb the opioid epidemic. These toolkits and the accompanying code can be used to analyze claims data for prescription drugs and identify patients who may be misusing or abusing prescription opioids and may be in need of additional case management or other followup. These toolkits and accompanying code can also be used to answer research questions about opioid utilization. These types of efforts are particularly important given the COVID-19 pandemic. The National Institutes of Health recently issued a warning that individuals with opioid use disorder could be particularly hard hit by COVID-19, as it is a disease that attacks the lungs. Respiratory disease is known to increase mortality risk among people taking opioids.

OIG has developed extensive work on opioid use in Medicare Part D. OIG most recently analyzed opioid levels in Medicare Part D in a data brief entitled (OEI-02-19-00390). The data brief identified almost 49,000 Part D beneficiaries who were at serious risk of misuse or overdose. Some of these beneficiaries received extreme amounts of opioids. Others appeared to be "doctor shopping"-i.e., receiving high amounts of opioids from multiple prescribers and multiple pharmacies. The analysis identified beneficiaries who are at risk by calculating their opioid levels using Part D prescription drug data.


These toolkits provide steps to calculate patients' average daily morphine equivalent dose (MED), which converts various prescription opioids and strengths into one standard value. This measure is also called morphine milligram equivalent (MME). The toolkits include a detailed description of the analysis and programming code in three different programming languages (SAS, R, and SQL) that can be applied to the user's own data. The SAS code, R code, and SQL code provide the same data. These data can be used to identify certain patients who are at risk of opioid misuse or overdose. Users can also modify the code to meet their needs, such as identifying patients at varying levels of risk.

There are two toolkits. For the SAS code, use this . For the R or SQL code, use this . The toolkits start with the same two chapters: (1) Analysis of Prescription Drug Claims Data; and (2) Explanation of the Programming Code To Conduct the Analysis. The remaining chapters contain the programming code.