EPIC Integration In Mule 4

Author: Abhijeet Devani

What is EPIC?

EPIC is a cloud-based Electronic health record solution catering to several specialties. EPIC is in use across a broad range of practices, from community hospitals and independent practices to multi-specialty hospital groups and hospice care providers.

EPIC is a strong supporter of the HL7® FHIR® standard as the future of REST-based interoperability.

What is FHIR?

The Fast Healthcare Interoperability Resource is a draft data standard developed and nurtured by HL7 International.

Note: DSTU is an old FHIR standard and R4 is the latest FHIR standard.

Read more about EPIC from here Epic on FHIR.

Before Jumping to EPIC click here to understand briefly about Oauth 2.0.

Use Case: In this use case, we will be fetching patient data from EPIC using OAuth 2.0-based EHR Launch (SMART on FHIR) method.

Step 1: Sign Up and Login

  • Go to the official EPIC website (https://fhir.epic.com/) and sign up. Set a username and password for your account.

Note: If you sign up using your organization’s email address, your organization EPIC admin needs to approve the request for you to access EPIC. Once the admin approves it, you will receive a mail to set the username and password for your account.

Sign Up Page:

  • Once your account is created, login into your account. 

Click on Login → EPIC on FHIR → Enter Credentials and Sign in.

Login Page:

Step 2: Create an App

  •  Click on Create Button.
  • Enter details below.
  • Give a name to your application.
  • Client Id and Non-Production Client Id will be populated automatically.
  • Select Application audience (ie. app consumer type).
  • Select the API’s which you want to use and move them to the selected tab.
  • Provide the Redirect URL. In this case, we are going to run our Mule application locally, for that reason we used localhost as our Redirect URL. In case you are deploying the application to CloudHub please don’t forget to change the Redirect URL.
  • Generate the Client’s secret and save it with you. We will be using it in the upcoming steps.
  • Select FHIR Version in this case we select R4.
  • Accept the terms and conditions and then Click on Save and Ready for Sandbox button.
  • Now you are ready with the App.

Step 3: Implementation in Mule

  • Before you start developing Mule code, you can also test or try to access patient data from EPIC, using Postman, Click here to know. 
  • We will be using the EHR Launch (SMART on FHIR) method to connect our Mule application to EPIC.
  • In this POC, I will be accessing patient data from EPIC by using the FHIR Id of that patient.
  • Take an HTTP Listener and provide a path name.
  • Create an object store configuration and add a persistent object store.
  • Drag an HTTP Request and do the following configurations.

HTTP Request Configuration:

  • Host: fhir.epic.com/interconnect-fhir-oauth/api/FHIR/R4
  • aud: https%3A%2F%2Ffhir.epic.com%2Finterconnect-fhir-oauth%2Fapi%2Ffhir%2Fdstu2

(Resource server the application intends to access, which is typically the FHIR server)

  • Client Id: Provide the client id which we got while creating the app in EPIC.
  • Client Secret: The URL encodes the client secret which we got while creating the app in EPIC.
  • Scopes: openid profile offline_access

(This parameter describes the information for which the web application is requesting access)

  • Token URL: https://fhir.epic.com/interconnect-fhir-oauth/oauth2/token

Step 4: Execute the application (One time process if an application is being executed in CloudHub)

  • Now, run your application and once it is deployed take the Local authorization URL: https://localhost:8082/authorize and hit it from the browser. (Note: It should be replaced with CloudHub URL if you are planning to deploy it on CloudHub).
  • Enter username and password for any patient you can get test username and password from Sandbox Test Data and allow access to your app. Click here to get the Sandbox Test Data page.
  • You will see the Successfully retrieved access token Message.

Step 5: Fetch Patient Data

  • Then hit https://localhost:8082/byid/eq081-VQEgP8drUUqCWzHfw3 (Endpoint which you configured for your Mule applications HTTP Listener) from Postman or Arc.
  • eq081-VQEgP8drUUqCWzHfw3 → This is the FHIR Id for the patient. You will get it from the Sandbox Test data of EPIC. Click here to get the Sandbox Test Data page.
  • Done. You will get patient data.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.