# SMART on FHIR with Epic and Oracle Health

> A generic guide to reading patient data from Epic and Oracle Health with SMART App Launch: registration, discovery, EHR and standalone launch, PKCE, scopes and the differences you meet.

Source: https://developers.anpheros.com/guides/smart-on-fhir-epic-oracle-health

**Epic and Oracle Health (formerly Cerner) both expose SMART on FHIR APIs, so one app can read patient data from either with the same flow: register the app in each vendor's developer program, discover the endpoints from `.well-known/smart-configuration`, launch with OAuth 2.0 and PKCE, and read US Core resources. This is a generic technical guide; Anpheros has no partnership with either vendor.**

## The flow is the same everywhere

1. **Register the app** in the vendor's developer program (Epic's developer site and Oracle Health's code console). You get a client ID per environment and choose the scopes and launch types.
2. **Discover** the authorization and token endpoints at `https://<fhir-base>/.well-known/smart-configuration`.
3. **Launch.**
   - *EHR launch*: a clinician opens your app inside the EHR; you receive `iss` and `launch` and ask for the `launch` scope.
   - *Standalone launch*: a patient (or clinician) starts from your app; ask for `launch/patient` to get the patient picked at sign-in.
4. **Authorize** with the authorization code flow and PKCE (`code_challenge_method=S256`). Public apps (mobile, browser) have no client secret; confidential apps authenticate with a secret or, preferably, a signed JWT (`private_key_jwt`).
5. **Exchange the code** for an access token. The response carries the launch context: `patient`, sometimes `encounter`, and `id_token` when you asked for `openid fhirUser`.
6. **Read US Core resources** with the token: `Patient`, `Condition`, `Observation` (labs, vital signs), `MedicationRequest`, `AllergyIntolerance`, `Immunization`, `DocumentReference`.

## Scopes

SMART v1 scopes look like `patient/Observation.read`; SMART v2 uses `patient/Observation.rs` and allows granular filters such as `patient/Observation.rs?category=laboratory`. Many servers support both; read the `scopes_supported` list in the SMART configuration and ask only for what your feature needs. Add `offline_access` only if the person expects the connection to keep working.

## Differences you will meet

| Topic | What to check |
|---|---|
| Environments | Each vendor has a sandbox with test patients and separate production endpoints per health system |
| Endpoint directory | Production FHIR base URLs differ per organization; use the vendor's published endpoint lists |
| Scope versions | Whether SMART v1, v2 or both are accepted |
| Refresh tokens | Lifetime and whether `offline_access` is granted to patient apps |
| Writes | Read access is broad; writing back is limited and often needs a separate review |
| Rate limits and paging | Follow `Bundle.link` `next`; do not assume one page holds everything |

## Keep what the patient brings, with consent

After the read, most apps need somewhere to keep the data, combine it with other sources and share it later. Anpheros Platform stores one FHIR R4 record per person:

- write each resource with its source system and author as `Provenance`;
- keep versions instead of overwriting, so corrections stay traceable;
- let other apps or clinicians read only what the person approves, by scope and for a set time.

Anpheros is hosted in the EU. A US data region and a HIPAA business associate agreement (BAA) are available on request for production customers; production for US patient data starts only after the BAA is signed. Try the flow on the free sandbox with synthetic patients.

## Frequently asked questions

### Do I need a separate integration for Epic and Oracle Health?
The protocol is the same (SMART App Launch, OAuth 2.0, FHIR R4, US Core), so most code is shared. You register separately with each vendor and each health system's production endpoint, and you handle small differences in scopes, refresh tokens and paging.

### What is the difference between an EHR launch and a standalone launch?
In an EHR launch the app is opened from inside the EHR and receives the launch context; in a standalone launch the user starts in your app and picks or signs in as the patient at the authorization server.

### Should my app use SMART v1 or v2 scopes?
Use what the server lists in `scopes_supported`. SMART v2 scopes (`.rs`, `.cruds`) are more precise and allow query filters; many servers still accept v1 scopes for compatibility.

### Does Anpheros connect to Epic or Oracle Health for me?
No. Your app connects to each EHR with the patient's or clinician's authorization. Anpheros is where you can keep and share that data afterwards, with the person's consent.

## Related

- [CMS Patient Access API and FHIR](https://developers.anpheros.com/guides/cms-patient-access-api)
- [Cures Act and information blocking for health apps](https://developers.anpheros.com/guides/cures-act-information-blocking)
- [TEFCA and QHINs for developers](https://developers.anpheros.com/guides/tefca-qhin-developers)
- [HIPAA for health app backends](https://developers.anpheros.com/guides/hipaa-health-app-backend)
