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

#' Plot comparison QMRA calculation with initial vs supplementary processes
#' 
#' Compare the result of the QMRA simulation with reduction_log from initial vs supplementary processes
#' @param scenario data.frame, scenario obtained with create_scenario function
#' @param pathogen character, Name of the pathogen to simulate
#' @param regulationLog data.frame regulation value of the log reduction to compare with simulation result
#' @param regulationConcentration data.frame regulation value of the log reduction to compare with simulation result
#' @import cowplot
#' @import ggplot2
#' @importFrom purrr map2
#' @return combine_plots
#' 
#' @export
#' @examples
#' \donttest{
#' library(dplyr)
#' scenario_example <- create_scenario(
#'   filepath = system.file("input_1culture_2pop.xlsx", package = "ambre")
#' )
#'
#'
#' regulation_reduction <- config_ambre$regulation$regulation_value |> 
#'   dplyr::filter(Country == "France") |>
#'   dplyr::select(-c(Concentration, Country, RegulationID))
#' regulation_concentration <- config_ambre$regulation$regulation_value |> 
#'   dplyr::filter(Country == "France") |>
#'   dplyr::select(-c(Country, RegulationID, Reduction))
#'
#' plot_comparison_qmra_initial_vs_supplementary_processes(
#'   scenario = scenario_example,
#'   pathogen = c("Campylobacter jejuni", "Norovirus"),
#'   regulationLog = regulation_reduction,
#'   regulationConcentration = regulation_concentration
#' )
#' }
plot_comparison_qmra_initial_vs_supplementary_processes <- function(scenario, pathogen, regulationLog, regulationConcentration){

  qmra_initial <- run_qmra_initial_situation(scenario = scenario, 
                       pathogen = pathogen,
                       regulationLog = regulationLog,
                       regulationConcentration = regulationConcentration)
  qmra_supplementary <- run_qmra_supplementary_process(scenario = scenario, 
                               pathogen = pathogen,
                               regulationLog = regulationLog,
                               regulationConcentration = regulationConcentration )

  combine_log_reduction <- map2(
              qmra_initial$logreduction,
              qmra_supplementary$logreduction,
              ~ plot_grid(
      .x +
        labs(subtitle = "Initial Situation") +
        theme(plot.subtitle = element_text(hjust = 0.5)),
      .y +
        labs(subtitle = "Supplementary Process") +
        theme(plot.subtitle = element_text(hjust = 0.5)),
      ncol = 2,
      align = "h"
    )
)
  combine_dalys <- map2(
  qmra_initial$dalys,
  qmra_supplementary$dalys,
  ~ plot_grid(
      .x +
        labs(subtitle = "Initial Situation") +
        theme(plot.subtitle = element_text(hjust = 0.5)),
      .y +
        labs(subtitle = "Supplementary Process") +
        theme(plot.subtitle = element_text(hjust = 0.5)),
      ncol = 2,
      align = "h"
    )
)
    
  combine_plots <- list(
    log_reduction = combine_log_reduction,
    dalys = combine_dalys)
  
  return(combine_plots)
}
