This repository contains sample scripts using Ruby and Python to interact with the Beneficiary Claims Data API (BCDA) Version 2.
These scripts are for demonstration purposes and are NOT intended to be used in production. Organizations most implement robust security practices to protect their secrets and tokens. Error handling, token validation/refresh and logging must also be implemented when integrating with a production environment.
The following steps are performed by these sample scripts:
- Create access token
- Submit a data
$export
request - Retrieve Job ID and URL
- Check Job status
For additional details, please refer to the BCDA documentation.
It is expected that the job processing a given data export request is completed before the token expires. Please refer to the Try the API section in the BCDA documentation to obtain sandbox credentials corresponding to an extra-small Accountable Care Organization (ACO).
The bcda.rb
script contains simple logic to interact with the BCDA v2 API using the Ruby programming language.
Ruby 3.1.0+
Note: Please refer to the Ruby Documentation for instructions on how to download and install Ruby in your system.
Execute the following command to install dependencies:
$ gem install http
First you must modify the script to include the BCDA sandbox (testing) credentials:
# Credentials
# Visit the following link for sandbox credentials: https://bcda.cms.gov/guide.html#try-the-api
CLIENT_ID = "REPLACE-WITH-SANDBOX-CLIENT-ID"
CLIENT_SECRET = "REPLACE-WITH-SANDBOX-CLIENT-SECRET"
Note: Please refer to the Try the API section in the BCDA documentation to obtain sandbox credentials corresponding to an extra-small Accountable Care Organization (ACO).
You can then execute the script by running the following command:
$ ruby bcda.rb
The bcda.py
script contains simple logic to interact with the BCDA v2 API using the Python programming language.
Python 3.10.0+
Note: Please refer to the Python Beginners Guide for instructions on how to download and install Python in your system.
Execute the following command to install dependencies:
$ pip3 install httpx
First you must modify the script to include the BCDA sandbox (testing) credentials:
# Credentials
# Visit the following link for sandbox credentials: https://bcda.cms.gov/guide.html#try-the-api
CLIENT_ID = "REPLACE-WITH-SANDBOX-CLIENT-ID"
CLIENT_SECRET = "REPLACE-WITH-SANDBOX-CLIENT-SECRET"
Note: Please refer to the Try the API section in the BCDA documentation to obtain sandbox credentials corresponding to an extra-small Accountable Care Organization (ACO).
You can then execute the script by running the following command:
$ python3 bcda.py
Developed by Alberto Colón Viera.
This software is licensed under the MIT License. See LICENSE.