% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/collector.R
\name{collect_findings}
\alias{collect_findings}
\title{Collect findings from a single check into the master issues table}
\usage{
collect_findings(
  state,
  df,
  id,
  desc_col = "description",
  sobs = TRUE,
  unblind_codes = character(0)
)
}
\arguments{
\item{state}{The current state object.}

\item{df}{A data frame produced by the check. Must contain columns:
\code{subj_id} (character), \code{vis_id} (numeric),
\code{description} (character, max 200 chars).}

\item{id}{Character. The check ID matching the ID column in
\code{rule_registry.xlsx}.}

\item{desc_col}{Character. Name of the description column in \code{df}.
Defaults to \code{"description"}.}

\item{sobs}{Logical. Whether to limit output to 20 observations.
Defaults to \code{TRUE}.}

\item{unblind_codes}{Character vector. Topic codes that could unblind
the study. Rows with negative subject IDs where these codes are
absent from the description are excluded. Defaults to \code{character(0)}.}
}
\value{
Updated \code{state} object.
}
\description{
Called at the end of every individual check block. Validates the
findings data frame, counts valid observations via
\code{\link{count_valid}}, and appends to \code{state$issues} and
\code{state$summary_log}.
}
\examples{
\donttest{
# Build a minimal state object
state <- list(
  issues = data.frame(id = character(0), subj_id = character(0),
                      vis_id = numeric(0), description = character(0),
                      review = character(0), stringsAsFactors = FALSE),
  summary_log = data.frame(headlink = character(0), nu = integer(0),
                           rule_set = character(0), sobs = character(0),
                           stringsAsFactors = FALSE)
)

# A findings data frame produced by a check
MY_CHECK <- data.frame(
  subj_id     = c("SUBJ-001", "SUBJ-002"),
  vis_id      = NA_real_,
  description = c("AESEV missing for RASH", "AESEV missing for HEADACHE"),
  stringsAsFactors = FALSE
)

state <- collect_findings(state, MY_CHECK, id = "AECHK001")
}
}
