GenerateCodeForDataEntryValidation: Autogenerate code for data validation

generate_data_validation_codeR Documentation

Autogenerate code for data validation

Description

This is a utility function that employs code generation to produce R code that validates data entry workflow for errors of omission and commision.

Usage

generate_data_validation_code(metadata, date_var, hosp_var, surrogate_id_var,
  custom_code = NA, updates = NULL, updates_envir_depth = 1,
  negative_char = "_")

Arguments

metadata

REDCap metadata with a formatted branching logic variable f.branching_logic. See ExpandBranchingLogic

date_var

Name of variable that captures the date of entry

hosp_var

Name of variable that holds the hospital code

surrogate_id_var

Name of variable that holds a surrogate identifier that is easier to reference

custom_code

Any code that is appended for custom plugin of special validation checks.

updates

Name of a list of RedcapUpdate(s) to be used for plugging functionality that abstracts the introduction of new variables during the projects lifecycle. See RedcapUpdate

updates_envir_depth

Integer of what parent frame contains updates. Default is immediate parent of calling environment (1) ie one level deep.

negative_char

checkbox expansion character for a negative checkbox level

Details

Using the redcap metadata, code is generated that validates data entry during the data capture process.

This code is then evaluated into a function that is then iterated through the records to check for errors during data capture.

The result is a dataset containing the resultant errors.

Value

A function that can be evaluated to validate data entry workflow for a single record.

See Also

Other Code Generators: generate_date_conversion_code, generate_formatting_code, generate_remove_missing_code, generate_remove_outliers_code


smockin/RedcapData documentation built on Feb. 2, 2023, 3:19 a.m.