# WARNING - Generated by {fusen} from dev/flat_qmra.Rmd: do not edit by hand # nolint: line_length_linter.

#' Initial dose concentration
#'
#' This function calculates the initial dose that is a product of inflow concentration and volume for each exposure events.
#' @param scenario dataFrame scenario with volume and inflow_concentration columns
#' 
#' @importFrom purrr map2
#' @importFrom dplyr mutate
#' @return scenario_with_initial_dose
#' @export
#' @examples
#' library(dplyr)
#' library(purrr)
#' scenario_test <- create_scenario(system.file("input_1culture_2pop.xlsx", package = "ambre"))
#'
#' scenario_conc <- inflow_concentration(scenario = scenario_test,
#'  pathogenName = c("Campylobacter jejuni"))
#'
#' scenario_volume <-
#'   scenario_conc |>                     
#'   mutate(
#'     volume = map(
#'       .x = config,                                         
#'       .f = ~ simulate_exposure(config = .x)              
#'     )
#'   )
#'
#' initial_dose_calculation(scenario_volume)
initial_dose_calculation <- function(scenario){

  if (!"inflow_concentration" %in% names(scenario)) {
  stop("The inflow_concentration column is missing from the scenario object; run the inflow_concentration function to create it")
}
  
  if (!"volume" %in% names(scenario)) {
  stop("The volume column is missing from the scenario object; run the simulate_exposure function to create it")
}
  scenario_with_initial_dose<- scenario |>      
  mutate(
    initial_dose = map2(
      .x = inflow_concentration,   
      .y = volume,
      .f = ~ .x$events$inflow * .y$volumes$events$volume_perEvent              
    )
  )
  return(scenario_with_initial_dose)
}
