Abstract
Aims
This study aims to introduce the OralOpioids R package, a novel research tool for the in-depth study and analysis of opioid prescriptions in Canada, which reports a significant per-capita pharmaceutical opioid consumption.
Methods
The OralOpioids R package employs data from Health Canada's Drug Product Database (DPD), focusing on authorized oral opioids. It systematically filters drug identification numbers (DINs) by narcotic schedules and administration routes. Moreover, it calculates the morphine equivalent dose (MED) for each DIN using the CDC table. Core functions include MED calculation for specific drugs, brand name retrieval, opioid content extraction, and unit computations based on Canadian MED guidelines.
Results
When juxtaposed against renowned opioid calculators such as MDCalc, Oregon Pain, and Ohio Pain, the OralOpioids package exhibited a near-perfect correlation, with R-squared values consistently at 0.99.
Conclusions
The OralOpioids package, distinctively tailored for research, marks a significant stride in understanding and monitoring Canada's opioid milieu. By encompassing data on discontinued opioids, it fosters a nuanced comprehension of the opioid panorama, enabling historical insight and post-marketing watchfulness. Primarily targeting researchers, its scope extends to healthcare providers, insurers, and administrative boards, all of whom can leverage its potent capabilities for informed decision-making. Although currently centered on Canadian opioids, its flexible design is primed for future expansion, potentially capturing a global audience and catalyzing efforts against the opioid crisis.
Introduction
The opioid crisis in Canada has become a significant public health concern, with a sharp rise in the number of opioid-related deaths and hospitalizations. According to the Canadian Institute for Health Information (CIHI), in Canada alone, there were over 34,455 opioid-related deaths in 2019 between January 2016 and September 2022. 1 One possible factor that contributed to the crisis is the high rate of opioid prescribing in Canada. In 2016, physicians and nurse practitioners provided one prescription for every two Canadians, making the country the world's second-biggest per-capita consumer of pharmaceutical opioids after the United States. 2 The rate of opioid prescription is decreasing in Canada, but the epidemic remains a public health crisis. 2 In 2017, the Canadian government released a national guideline for the use of opioids in chronic noncancer pain, which aimed to provide healthcare providers with evidence-based recommendations for prescribing opioids. 3 In addition, Health Canada has introduced regulations around the promotion of opioids, including restrictions on advertising and promotional activities aimed at healthcare professionals and patients. 4 One of the tools that have been introduced to address this crisis is the morphine equivalent dose (MED) monitoring. 5 The MED is a measure of the potency of opioids that is based on the amount of morphine that would provide equivalent pain relief. It is important to note that not all opioids are the same, and their potency varies. For example, fentanyl is much more potent than morphine, and as such, smaller doses of fentanyl can provide equivalent pain relief to larger doses of morphine. By converting all opioids to an equivalent dose of morphine, healthcare providers can compare dosages across different opioids and ensure that patients are receiving appropriate doses of opioids (Table 1). 5
MED for Commonly Prescribed Opioids. 6
Canadian provinces, including British Columbia and Ontario, have implemented MED monitoring programs using databases like PharmaNet and the Narcotics Monitoring System (NMS) to track opioid prescriptions and identify patients at risk of opioid misuse.7,8 PharmaNet, a province-wide network in British Columbia, collects all prescriptions dispensed in community pharmacies, providing a comprehensive medication history for each patient and helping to prevent prescription errors and fraud. 8 Prescription monitoring programs (PMPs) form part of a pan-Canadian strategy to manage prescription drug use, aiming to enhance patient care, promote safe use of controlled drugs, and reduce harm and diversion. 9 These programs offer a range of features, including real-time patient profiles and unique identifiers, to ensure effective monitoring and intervention. The NMS in Ontario is another example of a system where pharmacies are required to submit dispensing information about all monitored drugs. 7
Details of all drugs sold in Canada, including opioids, are available in the Drug Product Database (DPD). The DPD is a comprehensive database of all drug products sold in Canada and is updated nightly. The key identifier for each drug product in the DPD is the Drug Identification Number (DIN), which is a computer-generated eight-digit number. It is mandatory to indicate the DIN on the prescription label and on over-the-counter drugs that are evaluated for sale in Canada. 10 The DIN if entered on the DPD contains important information about the drug product, including the manufacturer, product name, active ingredient, strength of active ingredient, pharmaceutical form, route of administration, and status. The status field is generally limited to approved, canceled post-market, canceled pre-market, canceled, dormant, and marketed. 10
The Canadian Guideline for Safe and Effective Use of Opioids for chronic noncancer pain 3 provides a valuable framework for healthcare providers in this context. For patients who are new to opioid therapy, the initial daily MED should not surpass 50 mg. Additionally, for those already undergoing opioid therapy, any increase in MED should be limited to no more than 50% of their current dose. Although the maximum daily MED recommended by guidelines is 90 mg, it is recognized that individual patient needs may necessitate higher or lower doses in specific cases. MED calculators are valuable online tools that help healthcare providers determine the equivalent dose of opioids based on their potency, simplifying the process of comparing dosages across different opioids. Examples of such calculators include the morphine milligram equivalents (MME) calculator by MDCalc which is based on the CDC guideline for prescribing opioids for chronic pain (2016). 11 The Oregon pain guidance calculator offers information about methadone conversion factors and co-prescription of benzodiazepines, also based on the CDC guideline (2016). 12 The Ohio Automated Rx Reporting System employs conversion factors created by the US Centers for Disease Control and Prevention. 13 All these opioid calculators require the user to input the opioid content to calculate the MED. This is the gap that the authors intend to close. To our knowledge, there is no open source software that allows the user to input a Drug Identifier (DIN in Canada) and outputs the MED. The aim of this R package is to provide information on oral opioids that are authorized for sale in various countries. While several clinical tools and calculators aim at providing immediate assistance to healthcare providers in their decision-making process, a deeper dive into opioid prescription analysis, and long-term trends is crucial for research endeavors. The ability to automate MED calculations through drug identification can streamline large-scale studies, retrospective analyses, and observational research, which in turn can lead to better clinical guidelines and improved patient outcomes. As opioid use remains a primary concern in Canada, a comprehensive research tool like the OralOpioids R package promises not only to simplify data extraction but also to provide an enhanced understanding for researchers delving into patterns, implications, and possible interventions related to opioid prescriptions. At present, the authors have decided to focus only on opioids authorized for sale by Health Canada. 14 The package is available for download from CRAN. https://cran.r-project.org/web/packages/OralOpioids/index.html.
Methods
Processing of the Database Information
Health Canada updates the DPD’s data every month. This data dump can be obtained from the Health Canada website at the following link: https://www.canada.ca/en/health-canada/services/drugs-health-products/drug-products/drug-product-database/what-data-extract-drug-product-database.html. Our R package analyzes the most recent DPD data dump to identify all oral opioids that are authorized for sale in Canada. Our analysis is restricted to DINs with a Schedule of Narcotic and a route of administration oral, transdermal, rectal, buccal, and sublingual. 15 Synthetic cannabinoids, although included in the narcotics class per Health Canada, are excluded from the analysis. The R package identifies and deletes nonopioid ingredients, such as ibuprofen and acetaminophen, retaining only opioid ingredients for further analysis. For example, DIN 621463 contains 300 mg of acetaminophen and 60 mg of codeine. Just the codeine would be retained for analysis to calculate the MED.
Usage of the R Package
Download the most recent DPD data dump.
If the user chooses to download the most recent data dump, proceed to step 2. Otherwise, terminate the process.
Restrict DINs to those with oral, transdermal, rectal, buccal, or sublingual routes, and schedule is denoted as “narcotic.”
Deleted synthetic cannabinoids (e.g., products containing nabilone).
Identify and delete nonopioid ingredients (e.g., ibuprofen, acetaminophen), retaining only the opioid ingredients.
Retain the most recent three changes in status for each DIN.
If a DIN has fewer than three changes in status, retain all of them.
Identify the opioid content in each DIN.
For buprenorphine/naloxone combinations, identify the opioid content for both ingredients.
Calculate the MED for each DIN, using the opioid content identified in step 5. The CDC conversion table was used (Figure 1).
Results
A shiny app that analyzes the April 2023 download is available at <http://ankonacanada.shinyapps.io/Opioidpaper> . One of the key functions of the package is the load_HealthCanada_Opioid_Table function, which allows users to download the most recent spreadsheet containing details of oral opioids authorized by Health Canada. For May 2023, there were 741 opioids listed in the spreadsheet. For suboxone DINs, buprenorphine and naloxone were listed in separate rows. 80% of DINs identified were oral and 10% were transdermal (predominantly suboxone, fentanyl, and buprenorphine). Close to 30% of DINs were codeine. Anileridine, meperidine, and pentazocine were the least frequently used, with only one DIN (Figure 2).

Flow chart depicting how the OralOpioid package works. Each month the latest version of Health Canada's drug database would be downloaded in the package library and available for analysis.

Distribution of opioid types and their routes of administration, illustrating the predominance of oral administration and frequent use of Codeine when the May 2023 download from OralOpioids was analyzed.
The Excel spreadsheet downloaded in the R library contains information about opioids that have been authorized for sale in Canada. The Excel spreadsheet is also available as Supplemental material. Table 2 includes the following columns.
Details of the Data Frame that the Package Outputs
Table 2 shows the contents of the downloaded Excel spreadsheet containing the dispensing limits and market status of opioid medications authorized for sale by health Canada (as per information current in May 2023).
This spreadsheet is downloaded in the package library. Each time the function load_HealthCanada_opioid_table is run, it will be checked if this spreadsheet contains the latest data from Health Canada. If the spreadsheet is outdated, upon the user's confirmation (Selection: Y), the system attempts to download the necessary data. After successful data download and update, the system generates a confirmation message regarding the successful update of the HealthCanada_Opioid_Table to the most recent date.
The package also contains functions that extract information from the Health Canada opioid dataset to extract specific information about prescribed drugs based on their DIN. A package vignette is included as Supplemental material. These functions include:
MED: This function calculates the MED for a particular drug using its DIN. The MED standardizes opioid potency across different medications, allowing for meaningful comparisons and informed prescribing decisions. Brand: This function retrieves the brand name associated with a specific oral opioid using its DIN. Providing the brand name simplifies communication between healthcare providers and patients when discussing and prescribing medications. Opioid: This function extracts the opioid content for a given drug using its DIN. Knowledge of the opioid content is crucial for understanding the potency of the prescribed medication and adjusting dosages accordingly. MED_50 and MED_90: These functions compute the number of units (tables or ml for liquids) corresponding to the 50 and 90 MED thresholds, respectively, as outlined in the Canadian guideline for safe and effective use of opioids for chronic noncancer pain. These threshold values aid healthcare providers in making well-informed decisions about dosage adjustments and addressing potential safety concerns.
Validation
Scatter plots were employed to evaluate the degree of agreement and reliability between our package and online MED calculators. The scatter plots demonstrate the perfect correlation between MED values from OralOpiods and other well-known online opioid calculators available including MDCalc, Oregon Pain, and Ohio Pain. In each plot, the x-axis represents the MED values from the OralOpioids package, while the y-axis corresponds to the respective MED values from the online calculators. Dashed red lines with slopes and intercepts close to 1 and 0, respectively, demonstrate near-perfect agreement between the OralOpioids package and each calculator. The points in all plots exhibit strong linear relationships, closely adhering to the lines of near-perfect agreement. This observation is further supported by the high R-squared values for each comparison: 0.99 for MDCalc, 0.99 for Oregon Pain, and 0.99 for Ohio Pain. These values highlight the excellent agreement between the OralOpioids R package and the online opioid calculators in terms of MED values. Additionally, the small deviations in slope and intercept values across all comparisons suggest minimal discrepancies between the methods, indicating the reliability and accuracy of the OralOpioids R package in calculating MED values. Thus the MED values in our package are accurate and reliable when compared to online oral opioid calculators (Figure 3).

This figure presents scatter plots comparing the MED values calculated by the OralOpioids package (x-axis) with those obtained from three online opioid calculators: MDCalc, Oregon Pain, and Ohio Pain (y-axis). The dashed red lines with slopes and intercepts close to 1 and 0, respectively, denote near-perfect agreement between the OralOpioids package and each calculator.
Discussion
The use of opioids for pain management has become increasingly prevalent over the past two decades, with a subsequent rise in opioid-related deaths and addiction. One approach to mitigating the risks associated with opioid use is to limit the daily dose of opioids to a specific MED, which is based on the potency of the opioid in relation to morphine. However, calculating MED can be a complex and time-consuming task, requiring knowledge of the opioid content and dosage form of a given medication.
The Oral Opioids package, which provides MED values for all oral opioids in Canada, including opioids no longer authorized for sale by Health Canada (which have the status of canceled-post market or discontinued), offers significant benefits to researchers working with administrative databases. The OralOpioids package offers several benefits to researchers seeking to study opioid prescribing patterns and trends. Firstly, the package contains comprehensive data on a wide range of opioids, including less common or discontinued opioids. This enables researchers to study prescribing patterns and trends comprehensively and gain a better understanding of the opioid landscape in Canada. Moreover, including canceled opioids in the package allows for a historical analysis of past prescribing patterns and trends. This is particularly useful in identifying changes in opioid prescribing behavior over time and the impact of policy interventions, guidelines, or educational initiatives on these changes. This allows researchers to investigate how the discontinuation of certain opioids may have influenced the prescribing of other opioids or alternative treatments. Additionally, including data on canceled opioids can help with post-marketing surveillance efforts, allowing researchers to monitor the ongoing use of these medications despite their cancelation. This can help identify potential sources of continued availability and inform strategies to curb the use of these medications. The inclusion of opioids no longer authorized for sale speaks to the forward-thinking design of the OralOpioids package. By acknowledging and accounting for the lifecycle of medications in the market, the package not only serves current requirements but also facilitates retrospective research. This ability to trace and understand historical prescribing data sets it apart from other existing tools.
The OralOpioids package importantly facilitates comprehensive research by including data on canceled opioids. It allows researchers to conduct comparative studies with the current opioid medications. Although the package itself does not evaluate safety or effectiveness given it does not possess any clinical data it offers a robust platform for researchers to analyze and draw insights from. This can assist in understanding the factors contributing to the cancelation of certain opioids. Such insights can, in turn, influence future drug development strategies and regulatory decision-making.
Finally, OralOpioids package can serve as a reminder to researchers and healthcare providers of the potential risks associated with these medications. This can help raise awareness of the importance of careful opioid prescribing and promote a culture of evidence-based decision-making. The vast database curated within the OralOpioids package aids in predictive analytics, helping stakeholders anticipate and respond to potential future challenges in opioid prescribing. The nature of this package caters to both a clinical and epidemiological audience, making it versatile and timely in addressing a multifaceted problem. Overall, the OralOpioids package offers a valuable resource for researchers seeking to gain insights into opioid prescribing in Canada and identify strategies for improving patient care and safety.
The authors note that while there are multiple opioid MED calculators available online, many require users to input the opioid content of a medication to estimate the MME. This can be a time-consuming and error-prone process, as opioid content can vary by dosage form and manufacturer. The MED function in the OralOpioids package streamlines this process by providing standardized estimates of opioid content and dosage forms. The comparison illustrates the OralOpioids package's distinctive approach and comprehensive coverage. It is not just a tool, but a repository of evolving knowledge. While the other calculators serve a purpose, the OralOpioids package adds depth by bridging gaps in existing MED calculator platforms.
Table 3 presents a comparison between the OralOpioids package and three online opioid calculators (MDCalc, Oregon, and Ohio) in terms of the availability of specific opioid drug information.
Comparison of the Three Online MED Calculators With Our Package.
In conclusion, the OralOpioids R package serves as a significant tool, capable of contributing to the broader, multipronged strategy required to combat the opioid crisis. Its utility in studying and improving opioid prescribing practices cannot be overstated, demonstrating the potential to significantly impact this ongoing public health issue. The package provides comprehensive information on oral opioids authorized for sale in Canada and includes functions to calculate MED and estimate opioid content, as well as functions to calculate the number of dosage units necessary to reach a MED of 50 or 90. The MED function is a particularly valuable tool as it eliminates the need for users to input opioid content and dosage forms for each medication to calculate MED. This can save time and ensure accurate calculations. The user-friendly nature of the package makes it accessible to both seasoned researchers and novice investigators, expanding its potential user base. The implications of this accessibility extend to fostering collaborative research projects across institutions, ultimately aiming to bring about a unified, informed response to the opioid crisis. The package has potential applications for healthcare providers, insurance companies, and workers’ compensation boards, as well as researchers studying opioid prescribing patterns and trends. While the package is currently focused on opioids authorized for sale in Canada, the authors suggest that it could potentially be expanded to include opioids authorized for sale in other countries in the future. The corresponding author of this manuscript employed the OralOpioids tool during their tenure at one of the Worker's Compensation Boards in Canada to identify individuals on dangerously high opioid doses, subsequently facilitating their treatment using Suboxone. This direct application also influenced the revision of the organization's medical aid policies, underscoring a more judicious approach to opioid prescriptions post-injury. This experience motivated the authors to devise an open-source package for the benefit of a larger community. Overall, the OralOpioids R package provides an important resource for those involved in pain management and opioid prescribing and has the potential to contribute to safer opioid use practices.
Supplemental Material
sj-xlsx-1-hme-10.1177_23333928231208251 - Supplemental material for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse
Supplemental material, sj-xlsx-1-hme-10.1177_23333928231208251 for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse by Ankona Banerjee and Erik Stricker in Health Services Research and Managerial Epidemiology
Supplemental Material
sj-html-2-hme-10.1177_23333928231208251 - Supplemental material for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse
Supplemental material, sj-html-2-hme-10.1177_23333928231208251 for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse by Ankona Banerjee and Erik Stricker in Health Services Research and Managerial Epidemiology
Supplemental Material
sj-pdf-3-hme-10.1177_23333928231208251 - Supplemental material for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse
Supplemental material, sj-pdf-3-hme-10.1177_23333928231208251 for OralOpioids: Harnessing R Programming and Data Science to Combat Opioid Misuse by Ankona Banerjee and Erik Stricker in Health Services Research and Managerial Epidemiology
Footnotes
Author's Note
Erik Stricker is also affiliated with Department for Molecular and Human Genetics.
Authorship Contribution
Ankona Banerjee contributed to conceptualization, methodology, software, validation, formal analysis, investigation, resources, data curation, writing–original draft, and writing–review and editing. Erik Stricker contributed to methodology, software, validation, and writing–review and editing.
Declaration of Conflicting Interests
The authors declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The authors received no financial support for the research, authorship, and/or publication of this article.
Data Availability
The Health Canada DPD metadata (Data Dump) is available for download from https://www.canada.ca/en/health-canada/services/drugs-health-products/drug-products/drug-product-database/what-data-extract-drug-product-database.html. The OralOpioids package is available for download from CRAN. The reference manual is attached as Supplemental material. https://cran.r-project.org/web/packages/OralOpioids/index.html. The Shiny app where a user can input a DIN for details is available at ![]()
Supplemental Material
Supplemental material for this article is available online.
Author Biographies
References
Supplementary Material
Please find the following supplemental material available below.
For Open Access articles published under a Creative Commons License, all supplemental material carries the same license as the article it is associated with.
For non-Open Access articles published, all supplemental material carries a non-exclusive license, and permission requests for re-use of supplemental material or any part of supplemental material shall be sent directly to the copyright owner as specified in the copyright notice associated with the article.
