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 »

Need help? Contact us:

 

 

The Epic FHIR adapter is designed to provide a template for getting started with Epic FHIR integrations, including:

  1. Authenticating with the Epic FHIR Server via OAuth2.0 (JWT)

  2. Performing various interactions against the Epic FHIR Server including create, read, search, and extended $operations.

This component can be customized and adapted according to your workflow needs.

How to use it:

 STEP 1: Login or sign up for Epic On FHIR to access the Testing Sandbox and create a Client App called "Iguana"

Refer to Set up your Epic FHIR Sandbox for the sign up process, creating and client and gathering the authentication details needed for the Epic FHIR Adapter.

 STEP 2: Import the Epic FHIR Adapter component in Iguana

See Create a Component if this is your first time!

 STEP 3: Configure the ClientId and PrivateKey custom fields and click Edit to open the Translator

Enter the ClientId and PrivateKey certificate path.

Using the information provided, the component will run through the authentication workflow and store the returned access token and expiry time in an encrypted file for use on subsequent API requests.

image-20240422-202132.png

 STEP 4: View and modify the examples for creating and searching for a patient on the Epic FHIR Server

Use the provided SamplePatient.json to load a FHIR patient resource. Alternatively, you can explore the FHIR Profiling Tool to generate a template resource you can use to populate with data of your own.

-- Load a sample patient
local F = io.open(iguana.projectRoot()..'SamplePatient.json','rb')
local RawPatient = F:read("*a")
F:close()
local NewPatient = json.parse{data=RawPatient}

Set live=true to invoke the creation interaction.

-- Create the new patient
E:create{resource="Patient",parameters=NewPatient,live=true}
   
-- Search for our patient
local Search = {
   family = 'Lufhir',  
   given = 'Sakiko',
   birthdate = '1994-07-22'
   }
local Status, R = E:search{resource="Patient",parameters=Search,live=true}     

View the resultant patient search in the Annotations:

Screen Shot 2024-02-20 at 4.38.22 PM.png

How the EPICFHIR Library works:

 EPICFHIRclient - sets up the adapter framework

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

 EPICFHIRcustom - makes API requests and returns the response

EPICcustom 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 is still valid (based on the key_expiry). If not, it calls EPICFHIRauth to perform 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. Patient) and parameters for the call (ex. the patient resource to be created) - to build and carry out the appropriate HTTP request.

 auth/EPICFHIRauth - authenticates with the Epic FHIR Server

The EPICFHIRauth function builds and makes the HTTP POST token request to obtain the access token required for any resource requests against the FHIR Server.

A separate EPICFHIRcreateJWT function creates the JSON Header and Payload components of the JWT and calls EPICFHIRjwt to sign and return the JWT required for the token request.

If the token requests 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 EPICFHIRencrypt.

 auth/EPICFHIRencrypt - stores and encrypts the API token and token expiry

EPICFHIRencrypt provides localized https://interfaceware.atlassian.net/wiki/x/EQCeqg functionality via save and load functions that 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.

 auth/EPICFHIRjwt - takes the provided parameters and private key to generate and sign the JWT token

EPICFHIRjwt provides localized OAUTH Library functionality. It takes the provided JWT header, JWT payload, signing algorithm, and private key to generate and sign the JWT token.

 method/EPICFHIRcreate - prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Create request

EPICFHIRcreate prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Create HTTP POST request.

 method/EPICFHIRsearch - prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Search request

EPICFHIRsearch prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Search HTTP GET request.

 method/EPICFHIRreadResource - prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Read request

EPICFHIRreadResource prepares the API endpoint and arguments to call EPICFHIRcustom for an FHIR Resource Read HTTP GET request.

 method/EPICFHIRoperation - prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Extended Operation request

EPICFHIRoperation prepares the arguments and calls EPICFHIRcustom for an FHIR Resource Create HTTP GET or POST request.

A FHIR operation is extended functionality unique across FHIR Servers. Extended operations on a resource use a $ in front of the operation. For example, when calling EPICFHIRcustom, the passed api argument may be “Patient/$match“ to perform a more detailed patient matching search.

  • No labels