13  Forms/Instruments

13.1 Instrument Names and Labels

You can export a list of instrument names and their corresponding instrument labels.

redcap_instruments()

%%capture
%%R
instruments <- redcap_instruments(
    redcap_uri = url, 
    token = token, 
    verbose = TRUE, 
    config_options = NULL
)$data

export_instruments()

project.export_instruments(format_type = "df")
instrument_name instrument_label
0 demographics Demographics
1 symptoms Symptoms
2 test_information Test Information
3 close_contacts Close Contacts
4 work_information Work Information

Note: Use the value under instrument_name (not instrument_label) when specifying specific instruments as arguments in the REDCapR and PyCap API functions.

13.2 Download PDF of Instruments

These functions will download the instrument specified and all of the fields as a cleanly formatted questionnaire pdf file.

redcap_instrument_download()

%%capture
%%R
redcap_instrument_download(
    instrument = "symptoms",
    directory = "./files/instruments/",
    file_name = "symptoms_instrument.pdf",
    redcap_uri = url,
    overwrite = TRUE,
    token = token
)

export_pdf()

close_contact = project.export_pdf(instrument = 'close_contacts')
with open("files/instruments/close_contacts.pdf","wb") as binary_file:
    binary_file.write(close_contact[0])
from IPython.display import IFrame
IFrame("files/instruments/close_contacts.pdf", width=750, height=500)