calculate_mme_df {mmequiv}R Documentation

Calculate MME for medication data in long format

Description

[Deprecated]

This function takes medication data in long format (multiple rows per patient ID), calculates MME using the local calculation method (calculate_mme_local()), and adds prescription-level values as new columns. It also returns two additional data frames with patient-level MME summaries (one with buprenorphine included and one without).

Usage

calculate_mme_df(
  data,
  id_col = "patient_id",
  medication_col = "medication_name",
  dose_col = "dose",
  doses_per_day_col = "doses_per_24_hours",
  days_col = "days_of_medication",
  therapy_days_col = "therapy_days",
  observation_days_col = "observation_window_days",
  therapy_days_without_col = NULL,
  observation_days_without_col = NULL
)

Arguments

data

A data.frame or tibble in long format with one row per medication per patient or participant (id_col)

id_col

Name of the column containing patient identifier; default is "patient_id"

medication_col

Name of the column containing medication names; default is "medication_name"

dose_col

Name of the column containing dose values; default is "dose"

doses_per_day_col

Name of the column containing doses per 24 hours; "doses_per_24_hours"

days_col

Name of the column containing days of medication; default is "days_of_medication"

therapy_days_col

Name of the column containing therapy days with buprenorphine (up to one unique value per patient); default is "therapy_days"

observation_days_col

Name of the column containing observation window days with buprenorphine (up to one unique value per patient); default is "observation_window_days"

therapy_days_without_col

Name of the column containing therapy days without buprenorphine (up to one unique value per patient). If NULL (default), uses the value from therapy_days_col.

observation_days_without_col

Name of the column containing observation window days without buprenorphine (up to one unique value per patient). If NULL (default), uses the value from observation_days_col.

Value

A list containing three elements:

See Also

calculate_mme_local()

Examples

library(dplyr)
# Calculate MME using long-format data
# Subset of opioid_trial data used for speedier example
mme <- calculate_mme_df(
  data = opioid_trial |> dplyr::filter(patient_id %in% sprintf("P%03d", 1:100)),
  therapy_days_without_col = "therapy_days_without",
  observation_days_without_col = "observation_window_days_without"
  )
# ->
mme <- calculate_mme(
  x = opioid_trial |> dplyr::filter(patient_id %in% sprintf("P%03d", 1:100)),
  therapy_days_without_col = "therapy_days_without",
  observation_days_without_col = "observation_window_days_without"
  )

head(mme$medications)

head(mme$patient_summary_with_buprenorphine)

head(mme$patient_summary_without_buprenorphine)

# Cleanup
rm(mme)


[Package mmequiv version 1.0.0 Index]