23  Metadata

Metadata refers to the project’s set up characteristics, including field attributes grouped by instrument assignment. Metadata can be thought of as the project’s data dictionary.

In these examples, we will export the project metadata and re-import it so that no changes are made to the project.

redcap_metadata_write()

%%R
metadata <- redcap_metadata_read(redcap_uri=url, token=token)$data
R[write to console]: The data dictionary describing 30 fields was read from REDCap in 0.7 seconds.  The http status code was 200.
%%capture --no-stdout 
%%R
redcap_metadata_write(metadata, redcap_uri=url, token=token)
$success
[1] TRUE

$status_code
[1] 200

$outcome_message
[1] "30 fields were written to the REDCap dictionary in 0.7 seconds."

$field_count
[1] 30

$elapsed_seconds
[1] 0.688035

$raw_text
[1] ""

import_metadata()

metadata = project.metadata
metadata[0]
{'field_name': 'record_id',
 'form_name': 'demographics',
 'section_header': '',
 'field_type': 'text',
 'field_label': 'Study ID',
 'select_choices_or_calculations': '',
 'field_note': '',
 'text_validation_type_or_show_slider_number': '',
 'text_validation_min': '',
 'text_validation_max': '',
 'identifier': '',
 'branching_logic': '',
 'required_field': '',
 'custom_alignment': '',
 'question_number': '',
 'matrix_group_name': '',
 'matrix_ranking': '',
 'field_annotation': ''}
project.import_metadata(to_import=metadata)
30