% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/scores_su_tlfb_sui_sdsu.R
\name{prepare_data_sdsu}
\alias{prepare_data_sdsu}
\title{Prepare data for applying mid-year strategy}
\usage{
prepare_data_sdsu(data)
}
\arguments{
\item{data}{tibble. Dataset with columns from several tables (e.g. \code{su_y_lowuse}, \code{su_y_sui}, \code{su_y_mypi}, \code{su_y_mysu}, \code{su_y_tlfb}) and
containing at minimum \code{participant_id}, \code{session_id}, \code{ab_g_dyn__visit_dtt}, \code{ab_g_dyn__visit_age}, and \code{su_y_mypi_dtt}.}
}
\value{
tibble. Input tibble with added/modified columns:
\code{session_type}, \code{session_date}, \code{session_date_filled}, \code{session_id_mapped},
\code{last_session_id}, \code{forecast_next_annual}, and \code{session_id_mapped_forecast}.
}
\description{
Clean and prepare data for Static and Dynamic Substance Use (SDSU)
scoring:
\itemize{
\item derive \code{session_type} ("A" for annual, "M" for mid-year),
\item compute \code{session_date} and \code{session_age},
\item fill missing session dates within each participant and sort by filled date,
\item map mid-year sessions to the next observed annual session (\code{session_id_mapped}),
\item compute \code{last_session_id}, \code{forecast_next_annual}, and \code{session_id_mapped_forecast}.
}
}
\examples{
\dontrun{
prepare_data_sdsu(dplyr::tibble(
  participant_id = "sub-1",
  session_id = "ses-01A",
  ab_g_dyn__visit_dtt = as.Date("2020-01-01"),
  su_y_mypi_dtt = as.Date(NA)
))
}
}
\keyword{internal}
