chk
is a checkbox with a
coding 'a_b, A and B', the field name in the data export becomes chk___ab
. The loss of the
underscore causes fieldToVar
to fail as it can't match variable names to the meta data.
syncUnderscoreCodings
rectifies this problem by searching the suffixes and meta data for
underscores. If a discrepancy is found, the underscores are removed from the metadata codings, restoring
harmony to the universe. This bug was fixed in REDCap version 5.5.21 and this function does not apply to
that and later versions.syncUnderscoreCodings(records, meta_data, export)
fieldToVar
function.exportMetaData
syncUnderscoreCodings
performs a series of evaluations. First, it determines if any underscores are found
in the checkbox codings. If none are found, the function terminates without changing anything.
If the checkbox codings have underscores, the next evaluation is to determine if the variable names suffixes have
matching underscores. If they do, then the function terminates with no changes to the meta data.
For data exports, if the prior two checks find underscores in the meta data and no underscores in the suffixes, the underscores
are removed from the meta data and the new meta data returned.
For data imports, the meta data are not altered and the checkbox_field_name_map
attribute is used to
synchronize field names to the meta data and the expectations of REDCap (for import, REDCap expects the
underscore codings to be used.