Deliver real-time medication-change and therapy-alternative recommendations to Epic prescribers inside EpicCare order entry using CDS Hooks order-select and order-sign, backed by MuleSoft API-led services over a drug knowledge base, formulary, and patient FHIR context.
Tags: healthcare, epic, fhir, smart-on-fhir, us-core, provider, api-led, interoperability
Medication Ordering Decision Support
Objective: Prescribers at order entry need timely, patient-specific medication guidance — renal dose adjustment, therapeutic duplication, drug-drug and drug-allergy conflicts, and formulary-preferred alternatives — without leaving the workflow. The failure mode is either silence when a card is warranted or noise that gets click-fatigued away. Done looks like a CDS Hooks service that receives order-select and order-sign from EpicCare, hydrates patient context via FHIR prefetch, evaluates a drug knowledge base and the site formulary, and returns concise, actionable cards with one-click suggestions inside the CDS Hook latency budget. This accelerator packages the Medication Ordering Decision Support Epic Data Sharing Playbook as a MuleSoft-anchored solution plan.
What's Getting Built
- CDS Hooks (Experience API) — serves the discovery endpoint and per-hook services and returns ranked cards with suggestions ·
GET /cds-services, POST /cds-services/order-select, POST /cds-services/order-sign
- Rule Orchestration (Process API) — normalizes orders to RxNorm and runs interaction, duplicate, dose, and renal checks in parallel ·
POST /evaluate, GET /rules/version
- Drug Knowledge Base (System API) — checks drug-drug and drug-allergy interactions, duplicate therapy, and dose ranges ·
POST /interactions, GET /dose-range/{rxnorm}
- Formulary (System API) — returns formulary status and preferred therapeutic alternatives keyed by RxNorm and tenant ·
GET /formulary/{rxnorm}, GET /alternatives/{rxnorm}
- Epic FHIR R4 (System API) — live prefetch fallback reads for patient context under a hard timeout ·
GET /MedicationRequest?patient={id}, GET /AllergyIntolerance?patient={id}, GET /Observation?patient={id}
- Context Cache (Object Store) — caches knowledge-base and formulary responses keyed by normalized code and tenant to stay under budget ·
GET /{key}, PUT /{key}
Prerequisites
- Epic App Orchard listing with a registered CDS Hooks service and OAuth 2.0 client for order-select and order-sign contexts in Hyperdrive and Haiku.
- SMART Backend Services (client-credentials) or SMART on FHIR launch registered so the service can resolve FHIR prefetch and follow-up reads against the Epic FHIR R4 endpoint.
- Access to a maintained drug knowledge base (First Databank, Medi-Span, or equivalent) for interaction, dose, and duplicate-therapy checks.
- Current formulary and therapeutic-alternative tables published to a queryable source keyed by RxNorm and payer or facility.
- Anypoint Platform environment with API Manager, a low-latency cache (Object Store v2 or Redis), and DataWeave for FHIR-to-card transforms.
- US Core profiles for Patient, MedicationRequest, AllergyIntolerance, Condition, and Observation confirmed available in the Epic sandbox.
1. Epic interfaces and standards
This accelerator implements the Medication Ordering Decision Support Epic Data Sharing Playbook. Register the connecting app on Epic on FHIR and confirm the customer has the relevant Epic modules licensed before building.
- EpicCare order entry via Hyperdrive and Haiku
- CDS Hooks order-select and order-sign services
- FHIR R4 MedicationRequest, AllergyIntolerance, Condition, Observation, Patient
- SMART on FHIR and SMART Backend Services OAuth 2.0
- US Core profiles and RxNorm coding
- Epic App Orchard registration
Architecture
2. Business requirements
- Fire cards on order-select for early guidance and re-evaluate on order-sign as the safety gate before the order commits.
- Return dose-adjustment, duplicate-therapy, interaction, allergy, and formulary-alternative cards, each with a one-click suggestion where a safer or preferred order can be substituted.
- Suppress low-value alerts by severity threshold and per-prescriber override history so the signal survives click fatigue.
- Stay inside the CDS Hook response budget, target p95 under 500 ms end to end, or the card will not render before the prescriber signs.
- Never block signing; decision support advises, it does not hard-stop, and every card must carry a clear rationale and source.
3. Hook ingestion and prefetch
- Expose the CDS Hooks discovery endpoint and per-hook services as an Experience API fronted by API Manager.
- Declare prefetch templates for Patient, active MedicationRequest, AllergyIntolerance, Condition, and recent renal and hepatic Observation results so the payload arrives complete.
- Validate the incoming JWT against the Epic-issued key set and reject hooks whose fhirServer does not match the registered tenant.
- Fall back to live FHIR reads via the System API only when prefetch is absent, and cap that path with a hard timeout so it never blows the latency budget.
- Stamp every hook with a correlation ID propagated to knowledge-base and FHIR calls for end-to-end tracing.
4. Rule orchestration and normalization
- Normalize the drafted order and active medication list to RxNorm before any knowledge-base lookup so codes reconcile across sources.
- Run interaction, duplicate-therapy, dose-range, and renal-dose checks in parallel in the Process API and merge results by severity.
- Compute creatinine clearance from the prefetched Observation and demographics to drive renal dose suggestions rather than relying on a static threshold.
- Query the formulary System API for preferred therapeutic alternatives and attach them as suggestion resources the prescriber can accept.
- Cache knowledge-base and formulary responses keyed by normalized code and tenant to keep repeat evaluations under budget.
5. Card and suggestion construction
- Build CDS Hooks cards in DataWeave with summary, detail, indicator, source, and, where applicable, a suggestion carrying a replacement MedicationRequest.
- Set indicator to info, warning, or critical strictly from knowledge-base severity, and keep summaries under one line so they read at a glance.
- Attach an override reason set to suggestion-bearing cards so declines are captured structurally, not lost.
- Include a source label and link so the prescriber can see why the card fired, which is what turns advice into trust.
- Emit at most a small, ranked set of cards per hook, dropping the tail rather than flooding the ordering screen.
6. Error handling and operations
- Return an empty cards array rather than an error when a downstream check fails, so a knowledge-base outage never breaks order entry.
- Alert on the absence of expected cards for known high-risk order patterns, which is the failure mode dashboards miss most often.
- Route malformed or unauthorized hooks to a dead-letter queue with the correlation ID for replay and audit.
- Track per-card fire rate, accept rate, and override rate; a card accepted near zero percent is noise and should be retuned or retired.
- Version the rule set and knowledge-base edition behind the Process API so recommendation changes are traceable to a release.
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.
- Validate the CDS Hooks JWT signature and issuer on every request and scope the SMART Backend Services token to the minimum FHIR resources the prefetch and reads require.
- Treat the fhirAuthorization access token passed in the hook as short-lived and never persist it beyond the request lifecycle.
- Isolate the drug knowledge-base license and formulary data per tenant so one site cannot see another site formulary or overrides.
- Log override reasons and card outcomes to an immutable audit store for clinical-safety review, keyed by correlation ID rather than raw patient identifiers.
Sample payload — CDS Hooks order-select request from EpicCare
{ "hook": "order-select", "hookInstance": "d1577c69-dfbe-44ad", "fhirServer": "https://fhir.epic.example.org/api/FHIR/R4", "context": { "userId": "Practitioner/ePr123", "patientId": "Patient/eXy456", "selections": ["MedicationRequest/draft-789"], "draftOrders": { "resourceType": "Bundle", "type": "collection", "entry": [ { "resource": { "resourceType": "MedicationRequest", "id": "draft-789", "status": "draft", "intent": "order", "medicationCodeableConcept": { "coding": [ { "system": "http://www.nlm.nih.gov/research/umls/rxnorm", "code": "197361", "display": "Enoxaparin 40 MG/0.4ML Injectable" } ] }, "subject": { "reference": "Patient/eXy456" } } } ] } }, "prefetch": { "renalFunction": { "resourceType": "Observation", "status": "final", "code": { "coding": [ { "system": "http://loinc.org", "code": "33914-3", "display": "eGFR" } ] }, "valueQuantity": { "value": 24, "unit": "mL/min/1.73m2" } } } }
Testing and validation
- Replay recorded order-select and order-sign hooks against the Experience API and assert cards, indicators, and suggestions match expected knowledge-base output.
- Test the renal-dose path with an eGFR observation below threshold and confirm a dose-adjustment card with a corrected MedicationRequest suggestion is returned.
- Verify a duplicate-therapy card fires when the drafted order overlaps an active MedicationRequest in the prefetch bundle.
- Load-test to confirm p95 end-to-end latency stays under the CDS Hook budget with knowledge-base and formulary caches warm and cold.
- Confirm a simulated knowledge-base outage yields an empty cards array and never a 5xx that would surface as an error in Hyperdrive.
- Validate JWT rejection paths, expired, wrong issuer, and mismatched fhirServer, route to the dead-letter queue.
Phased rollout
Phase 1 — Connect
- Register the CDS Hooks service and OAuth client in Epic App Orchard and confirm discovery resolves from the sandbox.
- Stand up System APIs to the drug knowledge base, formulary source, and Epic FHIR R4 sandbox with SMART Backend Services auth.
Phase 2 — Map and test
- Author DataWeave transforms for RxNorm normalization and card and suggestion construction, and wire the Process API rule orchestration.
- Replay sandbox hooks across dose, duplicate, interaction, allergy, and formulary scenarios and tune severity thresholds against override rates.
Phase 3 — Production
- Enable order-select and order-sign in a pilot EpicCare ordering context with shadow logging before cards render to prescribers.
- Promote to production with card fire, accept, and override dashboards live and alerting on missing high-risk cards.
Success metrics
- p95 CDS Hooks response latency under 500 ms across order-select and order-sign.
- Card accept rate above the tuning floor per card type, with near-zero-accept cards flagged for retirement.
- Override-with-reason capture rate at or near 100 percent on suggestion-bearing cards.
- Renal and duplicate-therapy cards fire on at least 95 percent of qualifying drafted orders in validation replay.
- Zero order-entry-blocking errors attributable to the decision-support service per release.
Troubleshooting
- Cards never render in Hyperdrive even though the service returns 200. — Likely cause: The service exceeded the CDS Hook timeout and Epic discarded the response. Fix: Enforce a hard timeout on downstream knowledge-base and FHIR calls, serve from cache on warm paths, and return partial cards rather than waiting on every check.
- Knowledge-base lookups miss and return no interaction cards for a known interacting pair. — Likely cause: The drafted order or active meds were not normalized to RxNorm before lookup. Fix: Normalize all codings to RxNorm in the Process API before knowledge-base calls and log any codes that fail to map for coverage review.
- Prescribers report alert fatigue and dismiss cards without reading them. — Likely cause: Low-severity cards are firing above the useful threshold and drowning the critical ones. Fix: Raise the severity floor, cap cards per hook, and rank by accept rate so only high-value cards render.
- Follow-up FHIR reads intermittently return 401 during hook processing. — Likely cause: The SMART Backend Services access token expired mid-request or lacked scope. Fix: Cache and proactively refresh the client-credentials token before expiry and confirm the registered scopes cover every prefetch and read resource.
Deliverable: A deployed CDS Hooks decision-support service, registered in Epic App Orchard for order-select and order-sign in Hyperdrive and Haiku, returning medication-change and therapy-alternative cards backed by MuleSoft System and Process APIs over a knowledge base, formulary, and patient FHIR context.