⛑ REDCap API interface in Python

Overview

Logo for The Center for Data Driven Discovery

REDCap API in Python

Description

Supports structured data extraction for REDCap projects. The API module d3b_redcap_api.redcap.REDCapStudy can be logically divided into three parts...

Part 1: The low level interface

These are generic request/response handlers implemented here because there's no "official" Python SDK from Vanderbilt for the REDCap API, and the closest thing there is (https://github.com/redcap-tools/PyCap) wasn't being actively maintained when I wanted it.

(If someone wants to replace this part using PyCap at some point, go ahead. Just don't break any of Part 3 in the process.)

Functions: _get_response, _get_json, _get_text, _act_file

Part 2: API functions

With the exception of get_records, which semi-intelligently retrieves records in batches instead of all at once to evade server errors from response timeouts, these all mirror the same/similarly named commands described in the REDCap API documentation at https://<your_redcap_server>/api/help/. For CHOP users that would be https://redcap.chop.edu/api/help.

(If someone wants to replace this part using PyCap at some point, go ahead. Just don't break any of Part 3 in the process.)

Functions:

Getters Setters Deleters
get_arm_names (Export Arms) set_arm_names (Import Arms)) NA
get_event_metadata (Export Events) set_event_metadata (Import Events) NA
get_instrument_labels (Export Instruments) NA NA
get_field_export_names (Export List of Export Field Names) NA NA
get_file (Export a File) set_file (Import a File) delete_file (Delete a File)
get_redcap_version (Export REDCap Version) NA NA
get_project_info (Export Project Info) set_project_info (Import Project Info) NA
get_project_xml (Export Project XML) NA NA
get_users (Export Users) set_users (Import Users) NA
get_data_dictionary (Export Metadata (Data Dictionary)) set_data_dictionary (Import Metadata (Data Dictionary)) NA
get_instrument_event_mappings (Export Instrument-Event Mappings) set_instrument_event_mappings (Import Instrument-Event Mappings) NA
get_records (Export Records) set_records (Import Records) delete_records (Delete Records)
get_repeating_forms_events (Export Repeating Instruments and Events) set_repeating_forms_events (Import Repeating Instruments and Events) NA
get_report_records (Export Reports) NA NA

Part 3: Whole project retrieval and structuring

Functions:

Name Purpose

get_selector_choice_map

Returns a map for every field that needs translation from a numeric index to a label value:

{
  <field_name>: {
    <index>: <value>,
    ...indexes
  },
  ...fields
}

get_records_tree

Returns all data from the project in the nested form:
{
  <event>: {                   # event data
    <instrument>: {            # event instrument data
      <record_id>: {           # subject data for this event instrument
        <instance>: {          # subject event instrument instance
          <field>: {<values>}, # set of field values
          ...fields
        },
        ...instances
      },
      ...records
    },
    ...instruments
  },
  ...events
}

There are also some extra utility functions for converting the records tree into one or more Pandas DataFrames...

Name Purpose

d3b_redcap_api.df_utils.to_df

Converts one get_records_tree()[event][instrument] to a pandas DataFrame

d3b_redcap_api.df_utils.all_dfs

Calls to_df on every instrument found in the records tree and returns a dict keyed by the instrument name if the instrument name is unique or by event_instrument if not.

Example Usage:

from d3b_redcap_api.redcap import REDCapStudy
from d3b_redcap_api.df_utils import all_dfs

r = REDCapStudy("https://redcap.chop.edu/api/", PROJECT_API_TOKEN)
study_data, errors = r.get_records_tree(raw_selectors=False)

as_dataframes = all_dfs(study_data)
Owner
D3b
Center for Data Driven Discovery in Biomedicine at the Children's Hospital of Philadelphia
D3b
Tools ini hanya bisa digunakan untuk menyerang website atau http/s

☢️ Tawkun DoS ☢️ Tools ini hanya bisa digunakan untuk menyerang website atau http/s FITUR: [ ☯️ ] Proxy Mode [ 🔥 ] SOCKS Mode | Kadang Eror [ ☢️ ] Ht

Bandhitawkunthi 9 Jul 19, 2022
A telegram bot script for generating session string using pyrogram and telethon on Telegram bot

String-session-Bot Telegram Bot to generate Pyrogram and Telethon String Session. A star ⭐ from you means a lot to us! Usage Deploy to Heroku Tap on a

Wahyusaputra 8 Oct 28, 2022
칼만 필터는 어렵지 않아(저자 김성필) 파이썬 코드(Unofficial)

KalmanFilter_Python 칼만 필터는 어렵지 않아(저자 김성필) 책을 공부하면서, Matlab 코드를 Python으로 변환한 것입니다. Contents Part01. Recursive Filter Chapter01. Average Filter Chapter0

Donghun Park 20 Oct 28, 2022
A stock information collector and parser for Taiwan and US market. Automatically send LINE message if the pre-defined rules are triggered.

agastock 開發動機 就在海運飆漲的2021年7月,差點跪在地上喜迎財富自由的當下,EPS超高好消息不斷的長榮竟然套在202元一去不回,有圖有真相(哭) 忽然體會到追高殺低不是辦法,魯蛇我得靠邏輯分析也能出頭天,經過三個月無數個不出門的周末,產出簡單的爬蟲和分析工具。 上過金融研訓院的量化交易

Gavin Lee 12 Nov 16, 2022
Search stock images (e.g. via Unsplash) and save them to your Wagtail image library.

Wagtail Stock Images Search stock images (e.g. via Unsplash) and save them to your Wagtail image library. Requirements Python 3 Django = 2 Wagtail =

Vicktor 12 Oct 12, 2022
SEBUAH TOOLS CRACK FACEBOOK & INSTAGRAM DENGAN FITUR YANGMENDUKUNG

SEBUAH TOOLS CRACK FACEBOOK & INSTAGRAM DENGAN FITUR YANGMENDUKUNG

Jeeck X Nano 1 Dec 27, 2021
An example of matrix addition, demonstrating the basic method of Python calling C library functions

Example for Python call C functions An example of matrix addition, demonstrating the basic method of Python calling C library functions. How to run Bu

Quantum LIu 2 Dec 21, 2021
twtxt is a decentralised, minimalist microblogging service for hackers.

twtxt twtxt is a decentralised, minimalist microblogging service for hackers. So you want to get some thoughts out on the internet in a convenient and

buckket 1.8k Jan 09, 2023
Upload comma-delimited files to biglocalnews.org in your GitHub Action

Upload comma-delimited files to biglocalnews.org in your GitHub Action Inputs api-key: Your biglocalnews.org API token. project-id: The identifier of

biglocalnews 1 Apr 20, 2022
Multi-purpose bot made with discord.py

PizzaHat Discord Bot A multi-purpose bot for your server! ℹ️ • Info PizzaHat is a multi-purpose bot, made to satisfy your needs, as well as your serve

DTS 28 Dec 16, 2022
It was increasingly cumbersome to eye-grep CF output in the AWS console.

cfplot Overview It was increasingly cumbersome to eye-grep CF output in the AWS console. I couldn't find another tool out there to provide individual

46 Dec 26, 2022
❝𝐓𝐡𝐞 𝐌𝐨𝐬𝐭 𝐏𝐨𝐰𝐞𝐫𝐟𝐮𝐥𝐥 𝐆𝐫𝐨𝐮𝐩 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐁𝐨𝐭❞

❝𝐓𝐡𝐞 𝐌𝐨𝐬𝐭 𝐏𝐨𝐰𝐞𝐫𝐟𝐮𝐥𝐥 𝐆𝐫𝐨𝐮𝐩 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐁𝐨𝐭❞

Abdisamad Omar Mohamed 5 Jun 24, 2022
Apex lets you build, deploy, and manage AWS Lambda functions with ease.

No longer maintained This software is no longer being maintainted and should not be chosen for new projects. See this issue for more information Apex

Apex 25 Dec 23, 2022
Bitcoin-chance-wheel - Try your luck at getting bitcoins

Program Features - ✍️ Why did we name this tool the Lucky Wheel? - ✍️ This tool

hack4lx 20 Dec 22, 2022
Cogs for Red-DiscordBot

matcha-cogs Cogs for Red-DiscordBot. Installation [p]repo add matcha-cogs

MatchaTeaLeaf 2 Aug 27, 2022
A BOT TO FIND ID OF A STICKER.

sticker id A BOT TO FIND ID OF A STICKER. THIS REPOSITORY HAVE TWO BRANCHES FOR DEPLOY WITH COMMAND & WITHOUT COMMAND. Mandatory variables API_ID - Ge

Ashik Muhammed 3 Dec 29, 2022
ignorant allows you to check if a phone number is used on different sites like snapchat, instagram.

Ignorant For BTC Donations : 1FHDM49QfZX6pJmhjLE5tB2K6CaTLMZpXZ ignorant does not alert the target phone number ignorant allows you to check if a phon

Palenath 513 Dec 31, 2022
This discord bot preview user 42intra login picture.

42intra_Pic BOT This discord bot preview user 42intra login picture. created by: @YOPI#8626 Using: Python 3.9 (64-bit) (You don't need 3.9 but some fu

Zakaria Yacoubi 7 Mar 22, 2022
A method to check whether a Discord user is using the client or not.

Discord Captcha Method This is an example, of a verification trough a check, if the user loads the picture send with the verification-message. This ma

Julien 2 Jan 19, 2022
Assassination API for getting random quotes from Assassination Classroom.

Assassination API Take advantage of what you have, while you have it. Quotes from Assassination Classroom Assassination classroom is one of best anime

Swanand Mulay 3 Jul 15, 2022