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

#' Pathogen Query
#' 
#' Query to return pathogen ID from pathogen Name using the database
#' @param config list configuration file default value is config_ambre dataset
#' @param pathogenName character Name of the pathogen for which you want to find the ID
#' @importFrom dplyr filter pull
#' @return pathogenID integer ID of the pathogen define
#' 
#' @export
#' @examples
#' query_pathogen(pathogenName = "Campylobacter jejuni")
#'
#' query_pathogen(pathogenName = c("Campylobacter jejuni", "Rotavirus"))
#'
query_pathogen <- function(config = config_ambre, pathogenName) {
  allowed_pathogen <- c(
      "Campylobacter jejuni",
      "Escherichia coli enterohemorrhagic (EHEC)",
      "Escherichia coli",
      "Legionella pneumophila",
      "Listeria monocytogenes (Death as response)",
      "Listeria monocytogenes (Infection)",
      "Listeria monocytogenes (Stillbirths)",
      "Pseudomonas aeruginosa (Contact lens)",
      "Pseudomonas aeruginosa (bacterimia)",
      "Salmonella Typhi",
      "Salmonella anatum",
      "Salmonella meleagridis",
      "Salmonella nontyphoid",
      "Salmonella serotype newport",
      "Shigella",
      "Staphylococcus aureus",
      "Vibrio cholerae",
      "Yersinia pestis",
      "Bacillus anthracis",
      "Burkholderia pseudomallei",
      "Coxiella burnetii",
      "Francisella tularensis",
      "Mycobacterium avium",
      "Rickettsia rickettsi",
      "Norovirus",
      "Rotavirus",
      "Adenovirus",
      "Echovirus",
      "Enteroviruses",
      "SARS",
      "Influenza",
      "Lassa virus",
      "Poliovirus",
      "Rhinovirus",
      "Cryptosporidium parvum",
      "Giardia duodenalis",
      "Endamoeba coli",
      "Naegleria fowleri" )
  
  if (any(!pathogenName %in% allowed_pathogen)) {
    stop("Pathogen name doesn't exist")
  }
  
  pathogenID <- config_ambre$inflow |> filter(PathogenName %in% pathogenName) |> 
                                          pull(PathogenID)
  return(pathogenID)
    
}
