---
title: "Tuberculosis Report"
output: html_document
params: 
  country: "United Kingdom"
  interactive: FALSE
---

```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = FALSE,
                      warnings = FALSE,
                      eval = TRUE)
```

```{r report-setup, include = FALSE, results = "hide"}
## Load the package
library(getTBinR)

## Load additional packages
library(ggplot2)

## Get the data
tb <- get_tb_burden(verbose = FALSE)

## Get the data dictionary
dict <- get_data_dict(verbose = FALSE)

##Assign parameters
country <- params$country
interactive <- params$interactive
```

## TB incidence rates

```{r get country-stats, include = FALSE, results = "hide"}
inc_sum <- summarise_metric(tb, "e_inc_100k", country)
```

In `r inc_sum$year` `r country` had an estimated Tuberculosis incidence rate of `r inc_sum$metric` per 100,000 people making it number `r inc_sum$world_rank` in the world and number `r inc_sum$region_rank` regionally. In the last 10 years this has changed by `r inc_sum$avg_change` on average each year. 

### Regional and Global Trends Comparision

```{r}
plot_tb_burden_summary(countries = country,
                       metric_label = "e_inc_100k",
                       compare_to_world = TRUE, 
                       compare_to_region = TRUE,
                       compare_all_regions = FALSE,
                       annual_change = FALSE,
                       facet = "Area",
                       scales = "free_y",
                       legend = "none",
                       interactive = interactive,
                       verbose = FALSE)
```

## Rates Regional Breakdown

```{r, fig.height = 8, fig.width = 8 }
plot_tb_burden_overview(countries = country,
                        compare_to_region = TRUE,
                        interactive = interactive,
                        verbose = FALSE)
```

## Case Detection Rates (CDR)

```{r, include = FALSE, results = "hide"}
cdr_sum <- summarise_metric(tb, "c_cdr", country)
```

`r country` had an estimated case detection rate of `r cdr_sum$metric`% in `r cdr_sum$year` making it number `r cdr_sum$world_rank` in the world (with number 1 having the highest CDR) and number `r cdr_sum$region_rank` regionally. In the last 10 years this has changed by `r cdr_sum$avg_change` on average each year. 

### Regional Breakdown

```{r, fig.height = 8, fig.width = 8}
plot_tb_burden_overview(metric = "c_cdr",
                        countries = country,
                        compare_to_region = TRUE,
                        interactive = interactive,
                        verbose = FALSE)
```

## TB mortality rates - excluding HIV


```{r, include = FALSE, results = "hide"}
mort_exc_hiv_sum <- summarise_metric(tb, "e_mort_exc_tbhiv_100k", country)
```

In `r mort_exc_hiv_sum$year` `r country` had an estimated Tuberculosis mortality rate (excluding HIV) of `r mort_exc_hiv_sum$metric`  per 100,000 people making it number `r mort_exc_hiv_sum$world_rank` in the world and number `r mort_exc_hiv_sum$region_rank` regionally. In the last 10 years this has changed by `r mort_exc_hiv_sum$avg_change` on average each year. 

### Proportion of TB Cases that Died (excluding HIV) - Regional and Global Comparision

```{r, fig.height = 8, fig.width = 12}
plot_tb_burden_summary(metric = "e_mort_exc_tbhiv_num",
                       denom = "e_inc_num",
                       rate_scale = 100,
                       countries = country,
                       compare_to_region = TRUE,
                       compare_all_regions = FALSE,
                       interactive = interactive,
                       verbose = FALSE,
                       facet = "Area",
                       scales = "free_y",
                       legend = "none") +
  labs(y = "Proportion (%) of TB cases that died (excluding HIV)")
```

### Rates Regional Breakdown

```{r, fig.height = 8, fig.width = 8}
plot_tb_burden_overview(metric = "e_mort_exc_tbhiv_100k",
                        countries = country,
                        compare_to_region = TRUE,
                        interactive = interactive,
                        verbose = FALSE)
```

## TB HIV related mortality rates

```{r, include = FALSE, results = "hide"}
mort_inc_hiv_sum <- summarise_metric(tb, "e_mort_tbhiv_100k", country)
```

In `r mort_inc_hiv_sum$year` `r country` had an estimated Tuberculosis mortality rate (related to HIV) of `r mort_inc_hiv_sum$metric`  per 100,000 people making it number `r mort_inc_hiv_sum$world_rank` in the world and number `r mort_inc_hiv_sum$region_rank` regionally. In the last 10 years this has changed by `r mort_inc_hiv_sum$avg_change` on average each year. 

### Proportion of TB Cases that Died (related to HIV) - Regional and Global Comparision

```{r, fig.height = 8, fig.width = 12}
plot_tb_burden_summary(metric = "e_mort_tbhiv_num",
                       denom = "e_inc_num",
                       rate_scale = 100,
                       countries = country,
                       compare_to_region = TRUE,
                       compare_all_regions = FALSE,
                       interactive = interactive,
                       verbose = FALSE,
                       facet = "Area",
                       scales = "free_y",
                       legend = "none") +
  labs(y = "Proportion (%) of TB cases that died (related to HIV)")
```

### Rates Regional Breakdown

```{r, fig.height = 8, fig.width = 8}
plot_tb_burden_overview(metric = "e_mort_tbhiv_100k",
                        countries = country,
                        compare_to_region = TRUE,
                        interactive = interactive,
                        verbose = FALSE)

```
