Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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.

Import the ATHENA library into your project and use the built in help to review how to use each function. On import, 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:

 ATHENAclient - sets up the adapter framework

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.

 ATHENAauth - authenticates with the Athenahealth server

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 - stores and encrypts the API token and token expiry

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 - makes API requests and returns the response

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

 methods/ATHENAcreatePatient - prepares arguments for ATHENAcustom to create a patient

ATHENAcreatePatient prepares the arguments, including populating the path parameters (ex. practice ID) in the API string and loading the required header. It then calls ATHENAcustom to create a patient in Athenahealth via HTTP POST request.

 methods/ATHENAsearchPatients - prepares arguments for ATHENAcustom to search for a patient based on the provided query parameters

ATHENAsearchPatients prepares the arguments, including populating the path parameters (ex. practice ID) in the API string. It then calls ATHENAcustom to search for a patient in Athenahealth.

 methods/ATHENAsearchPatientsFhir - prepares arguments for ATHENAcustom to search for a FHIR patient based on the provided query parameters

ATHENAsearchPatientsFhir prepares the arguments, including the FHIR-specific API string, and calls ATHENAcustom to search for a FHIR patient in Athenahealth.

  • No labels