Skip to main content

MODMED Library

The MODMED Library is an importable library containing functions to connect, authenticate, and interact with ModMed's FHIR API. This library is used in the ModMed FHIR Adapter.

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

require "MODMED.MODMEDclient"   

How it works:

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

MODMEDclient - sets up the adapter framework

Sets up the MODMED FHIR adapter framework, adding the various method modules to a metatable and storing the configurations added to the custom fields.

methods/MODMEDcustom - makes API requests and returns the response

MODMEDcustom 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. If not, it calls MODMEDauth to perform the OAuth2.0 authentication workflow to obtain the token to be used in subsequent requests. It also retries any authentication issues by retrieving a different token.

  • Uses the passed configurations API request parameters - the method (ex. post), API (ex. Patient) and parameters for the call (ex. the patient resource to be created) - to build and carry out the appropriate HTTP request.

methods/MODMEDsearch - prepares the parameters and calls MODMEDcustom for a FHIR Resource search request

MODMEDsearch prepares the parameters and calls MODMEDcustom for an FHIR Resource Search HTTP GET request.

methods/MODMEDreadResource - prepares the parameters and calls MODMEDcustom for a FHIR resource read request

MODMEDreadResource prepares the API endpoint and parameters to call MODMEDcustom for a FHIR resource read HTTP GET request.

methods/MODMEDcreate - prepares the parameters and calls MODMEDcustom for a FHIR resource create request

MODMEDcreate prepares the API endpoint and parameters to call MODMEDcustom for a FHIR resource create HTTP POST request.