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

#' Inflow concentration custom
#' 
#' To calculate inflow concentration for specified pathogen
#' @param scenario list scenario created with create_scenario
#' @param concentration data.frame min, max and distribution law of pathogen concentration
#' @param monteCarlo integer number of simulation iterations for Monte Carlo
#' @importFrom purrr map
#' @importFrom dplyr mutate
#' 
#' @return scenario_with_concentration
#' 
#' @export
#' @examples
#' sc <- create_scenario(system.file("input_1culture_2pop.xlsx", package = "ambre"))
#' sc  <- update_volume_with_desired_value(sc, 
#'                                         volume = data.frame(min = c(0.5,1), 
#'                                                             max = c(1,2), 
#'                                                             type = c("triangle", "triangle")))
#'   
#' sc <- update_frequency_with_desired_value(scenario = sc, frequency = c(200L, 300L))
#'
#' concentration_custom <- data.frame(PathogenName = c("Campylobacter jejuni", "Norovirus"),
#'                                    min = c(1, 10),
#'                                    max = c(2,20),
#'                                    type = c("uniform", "uniform"))
#'   
#' inflow_concentration_custom(scenario = sc,
#'                             concentration = concentration_custom)
inflow_concentration_custom <- function(scenario, concentration, monteCarlo = 1000){
  if (isFALSE("PathogenName" %in% names(concentration))){
    stop("List of concentration must contain PathogenName")
  }
  scenario_updated_patho <- update_pathogen(scenario = scenario, 
                                            pathoName = concentration$PathogenName)
  scenario_updated_monte_carlo <- update_monte_carlo(scenario = scenario_updated_patho,
                                                     monte_carlo = monteCarlo)
  scenario_update_concentration <- update_concentration(scenario = scenario_updated_monte_carlo ,
                                                        concentration = concentration)
  
  concentration = map(.x = scenario_update_concentration$config,
                      .f= ~ simulate_inflow(.x))

  scenario_with_concentration <- scenario_update_concentration |>
     mutate(inflow_concentration = concentration)
  
  return(scenario_with_concentration)
    
}
