Enable patient-authorized consumer health apps to read and contribute to an Epic record via SMART on FHIR patient access. This playbook fronts Epic's public patient FHIR endpoints with a MuleSoft Experience API that enforces OAuth2 scopes, brokers patient-mediated write-back, and manages app authorization lifecycle without a proxy ever holding patient credentials.
Tags: healthcare, epic, fhir, us-core, smart-on-fhir, patient-access, api-led, interoperability
Patient-Facing / Consumer Health Apps
Objective: Patients want to plug consumer apps into their Epic chart to both pull clinical data and push patient-generated data back. The friction is real: apps must complete Epic app-market registration, navigate the SMART launch and OAuth2 dance, request only US Core scopes the patient consents to, and write data clinicians will trust rather than silently discard. Done looks like a patient tapping Connect in a third-party app, authenticating against MyChart, granting a scoped consent, and the app reading Observations and Medications and contributing vitals and PROs as FHIR resources tagged with provenance and category so they never masquerade as clinician-entered data. This accelerator packages the Patient-Facing / Consumer Health Apps Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- Consumer Health Access (Experience API) — fronts Epic patient-access SMART on FHIR for consumer apps and enforces granted scopes ·
GET /.well-known/smart-configuration, GET /Observation, POST /Observation
- OAuth2 Proxy PKCE (OAuth2 broker flow) — brokers the Patient Standalone Launch redirect and code-for-token exchange without holding credentials ·
GET /authorize, POST /token, POST /token (refresh)
- Patient Access Orchestration (Process API) — orchestrates scoped US Core reads and patient write-back under one correlation ID ·
GET /patient-access/{resource}, POST /patient-access/observation
- Epic Patient FHIR (System API) — calls Epic's patient FHIR R4 endpoints for US Core reads and patient writes ·
GET /Patient/{id}, GET /MedicationRequest, POST /Observation, POST /QuestionnaireResponse
- Write Back Provenance (Write-back flow) — posts patient-reported Observations with Provenance and queues failures for replay ·
POST /Observation, POST /Provenance, DLQ enqueue
Prerequisites
- Registered patient-facing (public) client on the Epic App Orchard / open.epic vendor portal with a stable redirect URI and PKCE enabled
- Epic organization go-live with patient-access (Patient Standalone Launch) SMART on FHIR enabled and MyChart activated for the patient population
- US Core 3.1.1 or later capability confirmed in the target org SMART configuration statement
- Anypoint Platform environment with API Manager, a client-management strategy, and DataWeave 2.x
- TLS 1.2+ everywhere and a JWKS endpoint if using asymmetric client authentication for confidential backend services
- Patient consent and app-authorization records mapped to your data-governance and privacy policies
1. Epic interfaces and standards
This accelerator implements the Patient-Facing / Consumer Health Apps Epic Data Sharing Playbook. Register the connecting app on Epic on FHIR and confirm the customer has the relevant Epic modules licensed before building.
- MyChart patient authentication and consent
- SMART on FHIR Patient Standalone Launch with OAuth2 and PKCE
- FHIR R4 US Core resources: Patient, Observation, MedicationRequest, Condition, AllergyIntolerance, DocumentReference
- FHIR R4 patient-write via Observation and QuestionnaireResponse with Provenance
- SMART well-known configuration and CapabilityStatement discovery
- Patient-scoped .well-known/smart-configuration endpoint
Architecture
2. Business requirements
- Let patients connect any registered consumer app to their own chart without staff intervention or credential sharing.
- Read only the US Core resources the patient consented to, and prove which scopes were granted for every request.
- Accept patient-generated data as write-back that is unambiguously labeled patient-reported so clinicians can triage rather than trust blindly.
- Support instant de-authorization from the app or from MyChart, and stop honoring revoked tokens within one refresh cycle.
- Never let the integration layer see or store the patient's MyChart password.
3. Authorization brokering and launch
- Implement the Patient Standalone Launch: discover endpoints from .well-known/smart-configuration, then redirect the browser to Epic's authorize endpoint with PKCE code_challenge and the exact requested scopes.
- Keep the Experience API out of the credential path; it brokers the redirect and later exchanges the authorization code for tokens at Epic's token endpoint.
- Request granular scopes such as patient/Observation.rs and patient/MedicationRequest.r, never wildcard patient/. unless the app genuinely needs it.
- Store refresh tokens encrypted per app-authorization, keyed by a correlation ID that survives token rotation.
- Validate the aud parameter equals the Epic FHIR base URL to defeat token-phishing redirects.
4. Read mapping and normalization
- Map Epic US Core Observation, Condition, MedicationRequest, AllergyIntolerance, and Patient into a lean consumer-friendly Experience payload with DataWeave, dropping internal Epic extensions the app cannot use.
- Preserve LOINC and RxNorm codes on the way out so the app can reason about labs and meds rather than free text.
- Page transparently: follow FHIR Bundle next links server-side and return a single clean cursor to the app.
- Cache the CapabilityStatement and .well-known document per org, not per request, since they change rarely.
- Reject reads for any resource type outside the granted scope with a 403 and a scope-specific message, not a generic error.
5. Patient write-back and provenance
- Accept patient-generated vitals and PROs as FHIR Observation with category patient-reported and QuestionnaireResponse, then POST to Epic's patient-write endpoints.
- Attach a Provenance resource on every write recording the app as agent and the patient as author so the source is auditable in the chart.
- Set Observation.status appropriately and never assert a performer that implies a clinician measured the value.
- Validate write payloads against the US Core profile before submission and return the specific element that failed, not a 400 with no detail.
- Queue writes through a dead-letter queue so a transient Epic 5xx never silently loses patient-entered data.
6. Authorization lifecycle and operations
- Handle de-authorization initiated in MyChart or in the app by invalidating stored refresh tokens and purging cached PHI for that app-authorization.
- Detect revoked or expired grants when Epic returns invalid_grant on refresh, and surface a re-consent prompt rather than retrying blindly.
- Correlate every read, write, and token event with a single correlation ID spanning Experience, Process, and System APIs.
- Alert on the absence of expected token-refresh traffic for an active app, which is the failure mode dashboards miss most often.
- Rate-limit per app-authorization to protect Epic endpoints from a misbehaving consumer app polling in a tight loop.
7. Security and compliance
- Encrypt PHI in transit and at rest.
- Audit-log every access to and modification of patient data, and carry a correlation ID end to end.
- Enforce minimum-necessary access for integration operators and support users.
- Enforce PKCE on the public client so an intercepted authorization code cannot be exchanged by an attacker.
- Bind stored refresh tokens to the registered redirect URI and client ID, and rotate them on every use.
- Purge all cached patient data for an app-authorization on de-authorization, and prove the purge in the audit trail.
- Label every written resource with app-and-patient Provenance so patient-reported data can never be mistaken for clinician documentation.
Sample payload — Patient-reported blood pressure Observation written back to Epic
{
"resourceType": "Observation",
"status": "final",
"category": [{
"coding": [{
"system": "http://terminology.hl7.org/CodeSystem/observation-category",
"code": "vital-signs"
}, {
"system": "http://hl7.org/fhir/us/core/CodeSystem/us-core-category",
"code": "patient-reported"
}]
}],
"code": {
"coding": [{"system": "http://loinc.org", "code": "85354-9", "display": "Blood pressure panel"}]
},
"subject": {"reference": "Patient/eXYZ123"},
"effectiveDateTime": "2026-08-20T07:42:00-05:00",
"component": [{
"code": {"coding": [{"system": "http://loinc.org", "code": "8480-6", "display": "Systolic"}]},
"valueQuantity": {"value": 128, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]"}
}, {
"code": {"coding": [{"system": "http://loinc.org", "code": "8462-4", "display": "Diastolic"}]},
"valueQuantity": {"value": 82, "unit": "mmHg", "system": "http://unitsofmeasure.org", "code": "mm[Hg]"}
}]
}
Testing and validation
- Run the full Patient Standalone Launch against the Epic sandbox with a test patient and confirm PKCE, scope grant, and token exchange succeed end to end.
- Validate that a read for a resource outside the granted scope returns 403 with a scope-named message, not a 500.
- Write a patient-reported Observation and confirm it appears in the sandbox chart with correct category and Provenance.
- Simulate an invalid_grant on refresh and confirm the app receives a re-consent prompt rather than a retry storm.
- Exercise de-authorization and assert cached PHI for that app-authorization is purged and subsequent reads fail closed.
- Load-test per-app rate limiting to confirm a runaway polling client is throttled before it reaches Epic.
Phased rollout
Phase 1 — Connect
- Register the public client in the Epic vendor portal and pin the redirect URI and requested scopes.
- Stand up the Experience API OAuth2 proxy and complete a sandbox Patient Standalone Launch.
Phase 2 — Map and test
- Build DataWeave read mappings for the consented US Core resources and validate against sandbox data.
- Implement write-back with Provenance and validate payloads against US Core profiles before submission.
Phase 3 — Production
- Enable de-authorization handling, token rotation, and per-app rate limiting in production.
- Turn on absence-of-refresh alerting and correlation-ID tracing across all three API layers.
Success metrics
- Connect success rate: completed authorizations divided by initiated launches.
- Median token-exchange and refresh latency at the OAuth2 proxy.
- Write-back acceptance rate and dead-letter queue depth for patient-generated data.
- Count of scope-denied read attempts, trended to catch over-broad app requests.
- Time from de-authorization to full PHI cache purge for the affected app.
Troubleshooting
- Token exchange fails with invalid_client after the patient consents in MyChart. — Likely cause: The redirect URI or client ID sent to Epic does not exactly match the value registered in the vendor portal. Fix: Align the redirect URI byte-for-byte with the portal registration, confirm the public client type, and retry the launch.
- Patient-reported writes are accepted by the proxy but never appear in the Epic chart. — Likely cause: The Observation is missing the patient-reported category or a valid Provenance, so Epic silently rejects or filters it. Fix: Add the US Core patient-reported category and a Provenance naming app and patient, then resubmit from the dead-letter queue.
- Reads that worked yesterday now return invalid_grant on refresh. — Likely cause: The patient revoked the app in MyChart, invalidating the refresh token. Fix: Detect invalid_grant, purge the cached PHI, and surface a re-consent link instead of retrying the refresh.
- Requests for lab Observations return 403 while medication reads succeed. — Likely cause: The granted scope set includes patient/MedicationRequest but not patient/Observation. Fix: Update the app to request the Observation scope and have the patient re-authorize with the expanded consent.
Deliverable: A deployable Anypoint blueprint that fronts Epic patient-access SMART on FHIR with an Experience API for consumer apps: authorization proxy, US Core read endpoints, patient-write flows with provenance, dynamic client registration, scope enforcement, and a de-authorization revocation pipeline.