ATHENA Library

The ATHENA Library is an importable library containing functions to connect, authenticate, and interact with the Athenahealth API. This library is used in the Athenahealth Adapter.

When imported, typically only the ATHENAclient module needs to be required in order to create the client and access the API methods.

require "ATHENA.ATHENAclient"

How it works:

Use the Translator’s built in help to review how to use each function:

 

Sets up the ATHENA adapter framework, adding the various method modules to a metatable and storing the configurations added to the custom fields. It also loads the key and key_expiry configurations from the encrypted file via ATHENAencrypt if available.

The ATHENAauth function builds and makes the HTTP POST token request to obtain the access token required for interacting with the AthenaHealth API.

If the token request is successful (HTTP 200 response), the token and token expiry returned are stored in the adapter object (key and key_expiry) and saved in an encrypted file via ATHENAencrypt.

ATHENAencrypt provides save and load functions to encrypt and decrypt the provided API token and expiry time in an external file. This allows the token to be reused for subsequent API calls.

ATHENAcustom takes in any API requests and parameters to make the API call and return the response.

  • First the function checks if the token key exists or if the key_expiry time has passed and performs the OAuth2.0 authentication workflow to obtain the token to be used in subsequent requests.

  • Uses the passed configurations API request parameters - the method (ex. post), API (ex. v1/1128700/patients), headers (ex. Content-Type), and parameters for the call (ex. the patient details to be created) - to build and carry out the appropriate HTTP request.

This function is used as the fundamental API operation function in the provided wrapper methods and can also be independently called for a custom operation. An example of how ATHENAcustom can be used to directly query the same endpoint as ATHENAsearchPatients is shown below:

image-20240412-201701.png

Related pages