#' Check Combo Dropped Drugs
#'
#' Check_combo_dropped_drugs checks to see if we should advance to a new line if
#' a drug in a combo regimen is dropped and returns the line end date and
#' next line start date for the dropped combo drugs.
#' @param drug_summary a dataframe of drug summary table generated by \code{\link{get_drug_summary}}
#' @param line_end_reason a string phrase, explanation why the line ends
#' \itemize{
#' \item Last row hit
#' \item Passed discontinuation gap
#' \item New line started with new drugs
#' \item Entering continuation maintenance therapy
#' }
#' @return A list, line_name
#' @export
check_combo_dropped_drugs <-
function(drug_summary,
line_end_reason) {
# Get the list of dropped and undropped drugs
undropped_drugs <- drug_summary %>% filter(DROPPED == 0)
dropped_drugs <- drug_summary %>% filter(DROPPED == 1)
if (nrow(dropped_drugs) > 0) {
line_end_date <- min(dropped_drugs$LAST_SEEN)
line_next_start <- line_end_date + 1
line_end_reason <- "Combo drug dropped"
}
if (nrow(dropped_drugs) > 0) {
return(
list(
"line_end_date" = line_end_date,
"line_next_start" = line_next_start,
"line_end_reason" = line_end_reason
)
)
} else {
return(NA)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.