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

```{r, include = FALSE}
knitr::opts_chunk$set(
  comment = "#>",
  collapse = TRUE,
  out.width = "100%",
  dpi = 150
)
```

```{r setup, message=FALSE}
library(metalite.sl)
library(metalite.ae)
library(metalite)
library(dplyr)
```


## Build a metadata


```{r}
adsl <- metalite_sl_adsl
metadata_ae <- metalite.ae::meta_ae_example()
metadata_ae$data_observation <- metalite_sl_adae
head(adsl)
```

```{r}
plan <- plan(
  analysis = "disp", population = "apat",
  observation = "apat", parameter = "disposition;medical-disposition"
)
```

```{r}
meta <- meta_adam(
  population = adsl,
  observation = adsl
) |>
  define_plan(plan = plan) |>
  define_population(
    name = "apat",
    group = "TRTA",
    subset = quote(SAFFL == "Y")
  ) |>
  define_parameter(
    name = "disposition",
    var = "EOSSTT",
    label = "Trial Disposition",
    var_lower = "DCSREAS"
  ) |>
  define_parameter(
    name = "medical-disposition",
    var = "EOTSTT",
    label = "Participant Study Medication Disposition",
    var_lower = "DCTREAS"
  ) |>
  define_analysis(
    name = "disp",
    title = "Disposition of Participant",
    label = "disposition table"
  ) |>
  meta_build()
```

## Interactive Disposition
```{r}
react_disposition(
  metadata_sl = meta,
  metadata_ae = metadata_ae,
  width = 1200
)
```
