Skip to contents

This function processes and validates a user's specimen CSV file to ensure it meets the requirements for a specific action. The process includes reading the file, preprocessing, validation, and formatting of the specimens. If the file doesn't meet the specified requirements for specimens, an error is thrown.

Usage

process_specimen_csv(
  user_csv,
  user_action,
  sample_type,
  file_type = "na",
  bind_data = NULL,
  database = Sys.getenv("SDB_PATH"),
  config_yml = Sys.getenv("SDB_CONFIG")
)

Arguments

user_csv

The path to the user's specimen CSV file. This will be read into a data frame.

user_action

A character string indicating the action the user is taking with the specimen data (e.g., 'upload').

sample_type

A character string specifying the type of specimens in the user CSV.

file_type

A character string indicating the type of file (default is "na").

bind_data

A named list of data to be added to the user file. The list names will be the new columns and the values to their respective column. Default is NULL, which means that no data will be binded.

database

A character string indicating the path to the SQLite database used for specimen validation checks. Defaults to the system environment variable 'SDB_PATH'.

config_yml

A character string indicating the path to a configuration YAML file for specimens. Defaults to the system environment variable 'SDB_CONFIG'.

Value

A processed and validated user specimen CSV as a data frame.

See also

Examples

if (FALSE) { # \dontrun{
# Provide the path to the user specimen CSV file and action details
user_file_path <- "path/to/user/specimen/file.csv"
action <- "upload"
type <- "blood_sample"

# Process and validate the user specimen CSV
processed_csv <- process_specimen_csv(user_file_path, action, type)
} # }