% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/reporter.R
\name{build_reports}
\alias{build_reports}
\title{Consolidate findings and write role-based Excel reports}
\usage{
build_reports(cfg, state)
}
\arguments{
\item{cfg}{A named list of paths from \code{project_config.R}.}

\item{state}{The state object returned by \code{\link{run_checks}}.}
}
\value{
Invisibly \code{NULL}. Reports are written to \code{cfg$reports}.
}
\description{
Merges new findings with previously saved issues, incorporates reviewer
feedback from role-separated feedback folders, and writes four
role-specific reports plus \code{all_open.xlsx} and
\code{all_closed.xlsx} to \code{cfg$reports}.
}
\details{
\strong{Feedback loop:}
After distributing reports to reviewers, they place updated files in
the appropriate subfolder under \code{cfg$feedback}:
\itemize{
\item \code{feedback/DM/}   - Data Management reviewer
\item \code{feedback/MW/}   - Medical Writing reviewer
\item \code{feedback/SDTM/} - SDTM programmer
\item \code{feedback/ADAM/} - ADaM programmer
}
On the next run, \code{build_reports()} reads the most recent file
from each feedback folder, merges \code{analyst_note},
\code{review_note} and status updates back into the findings, and
overwrites the reports with the merged version.
}
\examples{
\donttest{
tmp_rep <- tempdir()
cfg <- list(
  rule_registry = system.file("extdata", "rule_registry.xlsx",
                              package = "rCoreGage"),
  trial_checks  = tmp_rep,
  study_checks  = tmp_rep,
  inputs        = tmp_rep,
  reports       = tmp_rep,
  feedback      = tmp_rep
)
state         <- setup_coregage(cfg)
state$domains <- load_inputs(cfg)
state         <- run_checks(cfg, state)
build_reports(cfg, state)
}
}
