---
title: "banffIT-vignette"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{banffIT-vignette}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

This package is designed to assign standardized diagnoses using the
Banff Classification (Category 1 to 6 diagnoses, including Acute and Chronic
active T-cell mediated rejection as well as Active, Chronic active, and Chronic
antibody mediated rejection).

The following steps will guide you in this process of diagnosis assignment with
the package. To get your dataset ready and in a correct format, you must
refer to the data dictionary provided with the package
<a href="https://PersonalizedTransplantCare.github.io/banffIT-documentation/templates/banff_dictionary.xlsx">here</a>
(or using the function `get_banff_dictionary()` in R). This data dictionary
contains metadata specifying how your input dataset should be formatted and what
information it must contain.

# 1. Having your dataset ready

A template (available 
<a href="https://PersonalizedTransplantCare.github.io/banffIT-documentation/templates/banff_template.xlsx" download class="external-link">here</a>
or `get_banff_template()` in R) as well as an example dataset (available
<a href="https://PersonalizedTransplantCare.github.io/banffIT-documentation/templates/banff_example.xlsx" download class="external-link">here</a>
or `get_banff_example()` in R) are also available with the package to help you
construct and prepare your dataset.

# 2. Run the process with the main function 

The main function `banff_launcher()` will go through 3 steps. It will:

a) Evaluate your input dataset (using `banff_dataset_evaluate()` internally).
If your input dataset is not in the correct format or is missing information,
a report will be saved in your output folder and will flag variables and
rows that are not formatted properly. The next step will not run if the input
dataset is not in the correct format.

b) Assign diagnosis to each observation (using `calculate_adequacy()` and
`add_diagnoses()` internally).

c) Save the output dataset containing diagnoses,a summary report with
descriptive statistics of your output dataset, and the data dictionary.


# 3. Use the example file

This command example runs the diagnosis assignment process on the dataset
specified in the input_file path. The output files will be saved in
path_folder/example. The diagnoses will be displayed in English and only
observation with adequacy == 1 will be taken into consideration due to the
option_filter argument. Finally, the output dataset will contain variables
generated in the process due to the argument "detail" set to TRUE.

```{r, eval=FALSE}

# To install banffIT
install.packages('banffIT')

library(banffIT)
# If you need help with the package, please use:
banffIT_website()

# use example
version <- 2022
input_file <- system.file("extdata", paste0(version,"/banff_example.xlsx"), 
                          package = "banffIT")
banff_launcher(
  input_file = input_file,
  output_folder = tempdir(), # 'folder_path/example'
  version = version,
  language = 'label:en',
  option_filter = adequacy == 1,
  detail = TRUE)

```
