% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_ph_meds.R
\name{compute_ph_meds_catg_all}
\alias{compute_ph_meds_catg_all}
\alias{compute_ph_p_meds_catg_all}
\alias{compute_ph_y_meds_catg_all}
\alias{compute_ph_p_dhx_catg_all}
\title{Compute all medication categories [Parent] [Youth]}
\usage{
compute_ph_meds_catg_all(
  data,
  rx_config = ABCDscores::rx_config,
  combine = TRUE
)

compute_ph_p_meds_catg_all(
  data,
  rx_config = ABCDscores::rx_config,
  combine = TRUE
)

compute_ph_y_meds_catg_all(
  data,
  rx_config = ABCDscores::rx_config,
  combine = TRUE
)

compute_ph_p_dhx_catg_all(
  data,
  rx_config = ABCDscores::rx_config,
  combine = TRUE
)
}
\arguments{
\item{data}{tbl, Dataframe containing the columns to be summarized.}

\item{rx_config}{tbl, Configuration tibble specifying the medication
category mappings to compute. Default is \code{ABCDscores::rx_config}.}

\item{combine}{logical, If \code{TRUE}, the computed summary scores are
appended to the original data frame. If \code{FALSE}, only the summary scores
are returned. Default is \code{TRUE}.}
}
\value{
tbl. see \code{combine} parameter.
}
\description{
This function computes all medication category mapping summary scores
based on the provided configuration in \code{rx_config} by mapping medication
RxCUI codes to their respective categories that are stored in
\code{ABCDscores::rx_map}.

It processes each row in \code{rx_config}. One row corresponds to one medication
category mapping score. For each row, it first checks \code{col_summary1}. If
\code{col_summary1} has data, that value is used. If \code{col_summary1} is \code{NA}, it
falls back to \code{col_summary2}.

It then applies \code{col_add} filtering only when both conditions are met:
\itemize{
\item the corresponding flag (\code{use_col_add1} or \code{use_col_add2}) is \code{TRUE}, and
\item \code{col_add} is provided (not \code{NA}).
}

When filtering is applied, only rows with \code{col_add == "1"} are retained;
otherwise, the selected RxCUI is set to \code{NA}.

After source selection and optional filtering, it maps the retained RxCUI
codes to their respective
categories using the appropriate mapping data frame from \code{ABCDscores::rx_map}
based on the \code{catg} specified in \code{rx_config}. The resulting category values
are then stored in a new column named as specified in the \code{name} column of
\code{rx_config}.
\itemize{
\item \emph{Summarized variables:} see \code{rx_config} for the list of variables.
}
}
\details{
\subsection{Disclaimer}{

"This product uses publicly available data from the U.S. National Library
of Medicine (NLM), National Institutes of Health, Department of Health and
Human Services; NLM is not responsible for the product and does not endorse
or recommend this or any other product."
}

\subsection{Functions for specific tables}{
\itemize{
\item \code{compute_ph_meds_catg_all()}: Computes all medication category
mappings across all tables.
\item \code{compute_ph_p_meds_catg_all()}: Computes all medication category
mappings for the \code{ph_p_meds} table.
\item \code{compute_ph_y_meds_catg_all()}: Computes all medication category
mappings for the \code{ph_y_meds} table.
\item \code{compute_ph_p_dhx_catg_all()}: Computes all medication category
mappings for the \code{ph_p_dhx} table.
}
}
}
\references{
The medical estimated use values and categories are generated
from: Lopez, D. A., Overholtzer, L. N., Rhee, K. E., Buchbinder, N.,
Ruiz-Orozco, G. E., Steinhilber, S., Tognoli, M., Lopez-Flores, A., &
Nagel, B. J. (2025). Classifying and visualizing medication use in the
Adolescent Brain Cognitive Development (ABCD) Study. \emph{medRxiv}.
}
\seealso{
\link{rx_map}
}
