Learn R Programming

wizaRdry (version 0.6.4)

NdaDataStructure: NdaDataStructure R6 Class

Description

Represents a single field (data element) in an NDA data structure. This is a typed struct (similar to Go structs) that enforces schema consistency and provides validation for NDA field definitions.

Arguments

Public fields

element_name

ElementName object - field name (ElementName in Excel)

data_type

DataType object - data type (String, Integer, Float, Date, GUID, Boolean)

size

Size object - size for String types

required

RequirementLevel object - requirement level (Required, Recommended, Conditional, No)

element_description

Description object - field description

value_range

ValueRange object - allowed values or range

notes

Notes object - field notes

aliases

Aliases object - field aliases

selection_order

Integer - order in which field was selected

selected_for_submission

Logical - whether field is selected for NDA submission

source_metadata

SourceMetadata object - field source tracking

missing_info

MissingInfo object - missing data information

validation_rules

ValidationRules object - validation rules

Methods


Method new()

Create a new NdaDataStructure instance

Usage

NdaDataStructure$new(
  element_name,
  data_type = "String",
  size = NULL,
  required = "No",
  element_description = "",
  value_range = "",
  notes = "",
  aliases = "",
  selection_order = NULL,
  source = NULL,
  source_metadata = NULL,
  missing_info = NULL,
  validation_rules = NULL,
  ...
)

Arguments

element_name

Field name (required) - accepts string or ElementName object

data_type

Data type (default: "String") - accepts string or DataType object

size

Size for String types - accepts numeric or Size object

required

Requirement level (default: "No") - accepts string or RequirementLevel object

element_description

Field description - accepts string or Description object

value_range

Allowed values or range - accepts string or ValueRange object

notes

Field notes - accepts string or Notes object

aliases

Field aliases - accepts string, list, or Aliases object

selection_order

Selection order

source

Field source (legacy - use source_metadata instead)

source_metadata

SourceMetadata object

missing_info

MissingInfo object or list

validation_rules

ValidationRules object or list

...

Additional fields

Returns

A new NdaDataStructure object


Method to_excel_row()

Convert to Excel row (returns named list for data.frame row)

Usage

NdaDataStructure$to_excel_row()

Returns

Named list with Excel column names and values


Method to_list()

Convert to legacy list format for backward compatibility

Usage

NdaDataStructure$to_list()

Returns

List with field definition


Method is_super_required()

Check if field is a super required field

Usage

NdaDataStructure$is_super_required()

Returns

Logical


Method is_from_ndar_subject()

Check if field came from ndar_subject01

Usage

NdaDataStructure$is_from_ndar_subject()

Returns

Logical


Method is_dcc_required()

Check if field is a DCC required field

Usage

NdaDataStructure$is_dcc_required()

Returns

Logical


Returns

Logical


Method modify()

Create a modified copy of this field

Usage

NdaDataStructure$modify(
  value_range = NULL,
  notes = NULL,
  modification_note = NULL,
  ...
)

Arguments

value_range

New value range (string or ValueRange object)

notes

New notes (string or Notes object)

modification_note

Description of modification

...

Other fields to modify

Returns

New NdaDataStructure object


Method print()

Print method for NdaDataStructure

Usage

NdaDataStructure$print()

Returns

Self (invisibly)


Method merge_value_ranges()

Merge value ranges from multiple sources

Usage

NdaDataStructure$merge_value_ranges(
  nda_range = NULL,
  redcap_range = NULL,
  data_range = NULL,
  missing_codes = character(0)
)

Arguments

nda_range

ValueRange from NDA (may be NULL)

redcap_range

ValueRange from REDCap (may be NULL)

data_range

ValueRange from data (may be NULL)

missing_codes

Character vector of missing data codes

Returns

Self (invisibly) with merged value_range


Method get_merge_warnings()

Get any warnings from merge operations

Usage

NdaDataStructure$get_merge_warnings()

Returns

Character vector of warnings


Method clear_merge_warnings()

Clear merge warnings

Usage

NdaDataStructure$clear_merge_warnings()

Returns

Self (invisibly)


Method clone()

The objects of this class are cloneable with this method.

Usage

NdaDataStructure$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

This class replaces ad-hoc list construction for NDA field definitions. It provides:

  • Type safety and validation for field definitions

  • Consistent structure across all code paths

  • Factory methods for creating fields from different sources

  • Helper methods for common operations

  • Direct mapping to Excel export columns

The field structure matches the NDA data dictionary schema: ElementName, DataType, Size, Required, ElementDescription, ValueRange, Notes, Aliases

Uses typed R6 classes from NdaClasses.R for all fields (ElementName, DataType, Size, RequirementLevel, Description, ValueRange, Notes, Aliases, etc.)