attr_names <- EpiModelWHAMPDX::attr_names
suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(magrittr))
suppressPackageStartupMessages(library(cowplot))
suppressPackageStartupMessages(library(ggrepel))
library(EpiModelWHAMPDX)
sim_dat <- readRDS("../../EpiModel/AE/sim_epimodel3/sim_on_2021-04-02_at_2033.rds")
options(dplyr.summarise.inform = FALSE)
knitr::opts_chunk$set(echo = TRUE, message = FALSE,
                      warning = FALSE, fig.width = 8)

print_many_plots <- function(testing_plots, num_hash = 3, 
                             targ_df = EpiModelWHAMPDX::WHAMP.targs){
  big_temp <- paste0(c(rep("#", num_hash),
  " %s {.tabset .tabset-fade .tabset-pills} ", "
", " 
 "), collapse = "")
  sml_temp <- paste0(c("\n\n", rep("#", num_hash + 1), " %s ", "
", " 
 "), collapse = "")
  for (ms_idx in 1:length(testing_plots)) {
    sub_plot_info <- testing_plots[[ms_idx]]
    if (is.null(sub_plot_info$plt_type)) {
      plt_type <- "line" 
      }else{plt_type <- sub_plot_info$plt_type}
    meas_data <- make_epi_plot_data(sim_dat, sub_plot_info)
    if (!is.null(sub_plot_info$sec_title)) {
      this_meas_name <- sub_plot_info$sec_title
    }else{
      this_meas_name <- sub_plot_info$plot_name
    }
    cat(sprintf(big_temp, this_meas_name))
    this_targ <- targ_df %>%
      filter(sub_plot_info$name == measure)
    attrs_present <- unique(meas_data$epi_data$cat_name)
    for (ct_idx in seq(attrs_present)) {
      this_cat <- attrs_present[ct_idx]
      cat(sprintf(sml_temp, this_cat))
      print(EpiModelWHAMPDX::plot_epi(
        meas_data, this_cat, this_targ,
        plot_type = plt_type, year_range = c(1980, 2030)))
      cat("\n\n")
    }
  }
}
cur_targs <- readRDS("../../Data/EpiModelSims/WHAMP.dx.targs.rds")

1 Model Validation

2 Data Validation

2.1 Participation in PrEP Drug Assitance Program (PDAP)

num.on.pdap <- list(
  pdap.num = list(name = "num.pdap",
                  sec_title = "Number",
                  plot_name = "Number in PDAP",
                  plot_cap = "Among individuals taking PrEP",
                  plot_ylab = "Count",
                  plt_type = "line",
                  vars = c("num.pdap."),
                  sum_fun = function(x) { x }
  ),
  pdap.prop = list(name = "prop.pdap",
                   sec_title = "Proportion of those on PrEP",
                   plot_name = "Proportion on PDAP",
                   plot_cap = "Among individuals taking PrEP",
                   plot_ylab = "Proportion",
                   plt_type = "line",
                   vars = c("num.pdap.", "neg.prep.num."),
                   sum_fun = function(x, y) { x / y }
  ),
  pdap.prop = list(name = "prop.neg.pdap",
                   sec_title = "Proportion of HIV negatives",
                   plot_name = "Proportion on PDAP",
                   plot_cap = "Among HIV - individuals",
                   plot_ylab = "Proportion",
                   plt_type = "line",
                   vars = c("num.pdap.", "num.", "i.num."),
                   sum_fun = function(x, y, z) { x / (y - z) }
  )
)

print_many_plots(num.on.pdap, targ_df = cur_targs, num_hash = 3)

2.1.1 Number

2.1.1.1 ovr

2.1.1.2 race

2.1.1.3 region

2.1.1.4 age.grp

2.1.1.5 snap5

2.1.1.6 insurance

2.1.2 Proportion of those on PrEP

2.1.2.1 ovr

2.1.2.2 race

2.1.2.3 region

2.1.2.4 age.grp

2.1.2.5 snap5

2.1.2.6 insurance

2.1.3 Proportion of HIV negatives

2.1.3.1 ovr

2.1.3.2 race

2.1.3.3 region

2.1.3.4 age.grp

2.1.3.5 snap5

2.2 Participation in ART Drug Assitance Program (ADAP)

num.on.adap <- list(
  adap.num = list(name = "num.adap",
                   sec_title = "Number",
                   plot_name = "Number in ADAP",
                   plot_cap = "Among individuals taking PrEP",
                   plot_ylab = "Count",
                   plt_type = "line",
                   vars = c("num.adap."),
                   sum_fun = function(x) { x }
  ),
  adap.prop = list(name = "prop.adap",
                   sec_title = "Proportion of ART users in ADAP",
                   plot_name = "Proportion in ADAP",
                   plot_cap = "Among ART users",
                   plot_ylab = "Proportion",
                   plt_type = "line",
                   vars = c("num.adap.", "tx.i.num."),
                   sum_fun = function(x, y) { x / y }
  )#,
  # adap.prop = list(name = "prop.adap.pos",
  #                  sec_title = "Proportion of diagnosed in ADAP",
  #                  plot_name = "Proportion in ADAP",
  #                  plot_cap = "Among diagnosed individuals",
  #                  plot_ylab = "Proportion",
  #                  plt_type = "line",
  #                  vars = c("num.adap.", "diag.i.num."),
  #                  sum_fun = function(x, y) { x / y }
  # )
)

print_many_plots(num.on.adap, targ_df = cur_targs, num_hash = 3)

2.2.1 Number

2.2.1.1 ovr

2.2.1.2 race

2.2.1.3 region

2.2.1.4 age.grp

2.2.1.5 snap5

2.2.1.6 insurance

2.2.2 Proportion of ART users in ADAP

2.2.2.1 ovr

2.2.2.2 race

2.2.2.3 region

2.2.2.4 age.grp

2.2.2.5 snap5

2.2.2.6 insurance