Skip to main content

EHR Integration

One of ChartChat's core features is the ability for patients to connect their existing hospital/EHR accounts and pull their health records directly into the portal. This page explains how that works end-to-end.

Supported EHR providers​

ProviderDisplay NameID
EpicEpic MyChartepic
eClinicalWorkseClinicalWorks (Healow)healow
MEDITECHMEDITECH Greenfieldmeditech

Hospitals can also be connected individually — see the Settings page docs.

How EHR connection works (high level)​

Patient clicks "Connect" in Settings
→ App starts OAuth2 flow with the EHR
→ Patient logs in to their EHR patient portal
→ EHR redirects back to ChartChat with an authorization code
→ Server exchanges the code for an access token
→ Server creates a PatientEHRConnection FHIR resource
→ Server syncs the patient's records from the EHR into ChartChat

PatientEHRConnection resource​

This is a custom FHIR resource (defined in the ChartChat FHIR profile) that records the link between a ChartChat patient and their EHR account.

Key fields:

FieldDescription
patientReference to the Patient resource
ehrProviderName of the EHR (e.g., "Epic MyChart")
statusactive, token_expired, or inactive
lastSyncISO timestamp of the last successful data sync

How the app knows which EHR a record came from​

Each FHIR resource synced from an EHR gets an identifier entry with a system prefix that identifies the source:

EHRIdentifier system prefix
Epicurn:epic:
Healow / eClinicalWorksurn:healow:
MEDITECHurn:meditech:

For example, a lab result from Epic might have:

"identifier": [{ "system": "urn:epic:observation", "value": "abc123" }]

The getProviderFromResource() function in ehrUtils.ts reads these prefixes to determine the source.

EhrContext — tracking connected providers in the UI​

When the app loads after login, App.tsx fetches all active PatientEHRConnection resources and syncs them into EhrContext:

  • Providers with an active connection are added to context.
  • Providers no longer active are removed from context.

EhrContext persists the connected providers list in localStorage so that the sidebar badges and EHR badges on health records remain visible even between page refreshes without re-fetching.

EHR sync — manual refresh​

From the Dashboard, the patient can click Refresh to trigger a new sync:

  1. POST /fhir/referesh/all-ehrs — starts a background sync job on the server.
  2. The app polls GET /fhir/referesh/status every 3 seconds.
  3. The server returns { status: 'syncing' } while the job runs, then a result object when done.
  4. The result tells the app which providers synced successfully, which had expired tokens, and which errored.

Token expiry​

EHR access tokens expire (typically after 1 hour or when the patient logs out of their EHR portal). When this happens:

  • The PatientEHRConnection status is updated to token_expired.
  • In Settings, the provider shows a warning with a Reconnect button.
  • The patient must go through the OAuth flow again to get a new token.

EhrSourceBadge component​

Every health record page shows a small badge next to each row indicating which EHR the record came from. This is rendered by the EhrSourceBadge component using the provider information from getProviderFromResource().


Test Patient Credentials​

These are sandbox patient accounts provided by Epic and Healow for testing the EHR connect flow. When a patient clicks Connect in Settings and the MyChart or Healow login screen appears, use these credentials to simulate a real patient login.

Epic (MyChart sandbox)​

UsernamePassword
fhircamilaepicepic1
fhirderrickepicepic1
fhirdesireeepicepic1

Healow (eClinicalWorks sandbox)​

UsernamePassword
AdultFemaleFHIRe@CWFHIR1
AdultMaleFHIRe@CWFHIR1
ChildFemaleFHIRe@CWFHIR1
ChildMaleFHIRe@CWFHIR1
note

These credentials are for the EHR's own patient-facing login screen (MyChart / Healow portal), not for ChartChat itself. They are sandbox/test accounts only — no real patient data.