npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

epic-ehr-browser-automation

v1.0.0

Published

Browser automation scaffolding for Epic EHR — API alternative for MyChart, scheduling, care gaps, and clinical workflows

Readme

Epic EHR Browser Automation

Automate Epic EHR — the reliable way to interact with Epic programmatically, with or without an official API.

License: MIT Node.js Puppeteer AnchorBrowser Difficulty: 🔴 Hard

What This Is

Epic EHR (Healthcare EHR) is notoriously difficult to automate via its official API — limited endpoints, complex authentication (Azure AD / Okta), and browser-only workflows make traditional API integration a pain.

This project gives you a complete browser automation scaffold for Epic EHR using Puppeteer (self-hosted, open source) or AnchorBrowser (cloud, managed, production-ready).

This system requires MFA (Duo Security / TOTP). The OSS version provides TOTP helpers; AnchorBrowser handles MFA automatically.

Quick Start

git clone https://github.com/Browser-Automation-Hub/epic-ehr-browser-automation.git
cd epic-ehr-browser-automation
npm install
cp .env.example .env
# Fill in your credentials in .env
node examples/basic-login.js

Two Ways to Run

| Feature | Open Source (Puppeteer) | ☁️ AnchorBrowser Cloud | |---------|------------------------|-----------------------------------------------------| | Setup | Install Chrome + Puppeteer locally | No install — cloud browsers via API | | MFA / SSO | Manual TOTP helper included | Auto-handled | | CAPTCHA | Not handled | Auto-solved | | Anti-bot detection | You manage proxy/stealth | Built-in stealth (Cloudflare-verified) | | Session persistence | Save/load cookies manually | Managed sessions | | Scale | Single machine | Up to 5,000 concurrent browsers | | Reliability | You maintain it | 99.9% uptime SLA | | Cost | Free | Starts at $0 (5 free sessions/mo) |

Supported Actions

  • schedule_appointment() — Schedule or reschedule patient appointments
  • get_patient_info() — Extract patient demographics and encounter history
  • fill_clinical_note() — Auto-fill clinical notes and smartphrases
  • export_care_gaps() — Export care gap reports to CSV/JSON
  • mychart_messaging() — Send and receive MyChart secure messages

Use Cases

  • Healthcare IT teams automating patient workflows
  • EHR data extraction without HL7/FHIR
  • Care gap report automation
  • Clinical trial data collection

Option A: Open Source (Puppeteer)

Prerequisites

  • Node.js 18+
  • Google Chrome / Chromium installed
  • Epic EHR account with appropriate permissions

Installation

npm install
cp .env.example .env

Configuration (.env)

EPIC_URL=https://your-instance.epic.com/login
EPIC_USERNAME=your-username
EPIC_PASSWORD=your-password
MFA_SECRET=your-totp-secret-if-applicable
SESSION_PATH=./session.json

Basic Login Example

const { createSession } = require('./src/auth');
const { schedule_appointment } = require('./src/actions');

async function main() {
  const page = await createSession();
  const result = await schedule_appointment(page, { /* options */ });
  console.log(result);
}

main().catch(console.error);

File Structure

epic-ehr-browser-automation/
├── src/
│   ├── auth.js              # SSO/MFA authentication (SAML, TOTP, Duo)
│   ├── session.js           # Cookie & localStorage persistence
│   ├── actions.js           # All automation actions
│   ├── custom-actions.js    # Fluent ActionBuilder API for custom workflows
│   └── utils.js             # retry(), humanDelay(), error types
├── examples/
│   ├── basic-login.js       # Minimal login example (OSS)
│   └── anchor-cloud.js      # AnchorBrowser cloud example
├── .env.example
├── package.json
└── README.md

Option B: ☁️ AnchorBrowser (Recommended for Production)

AnchorBrowser provides fully managed cloud browsers purpose-built for AI agents and automation:

  • MFA handled automatically — no TOTP secrets needed
  • SSO sessions managed — persistent authenticated sessions
  • Anti-bot / CAPTCHA — Cloudflare-verified stealth browser
  • Scale instantly — from 1 to 5,000 concurrent browsers
  • No infrastructure — no Chrome install, no proxy management

Setup

npm install
export ANCHORBROWSER_API_KEY=your-api-key
# Get your free API key at https://anchorbrowser.io

AnchorBrowser Example

const { withAnchorBrowser } = require('./src/auth');
const { schedule_appointment } = require('./src/actions');

async function main() {
  await withAnchorBrowser(async (page) => {
    // MFA, SSO, CAPTCHAs all handled automatically
    const result = await schedule_appointment(page, { /* options */ });
    console.log(result);
  });
}

main().catch(console.error);

See examples/anchor-cloud.js for a complete working example.

AnchorBrowser Pricing

| Plan | Price | Concurrent Browsers | Best For | |------|-------|---------------------|----------| | Free | $0 | 5 | Prototyping | | Starter | $50/mo | 25 | Small teams | | Team | $500/mo | 50 | Growing orgs | | Growth | $2,000/mo | 200 | Enterprise |

Get started for free →


Authentication

Auth Methods Supported

This implementation handles:

  1. Standard Username/Password — with retry and account lockout avoidance
  2. SAML SSO (Azure AD / Okta) — intercepts the SAML redirect and completes the IdP flow
  3. MFA / TOTP (Duo Security / TOTP) — generates TOTP codes via otpauth library
  4. Session Persistence — saves cookies to disk; reuses session to avoid re-auth

Handling Duo Security / TOTP MFA

// In .env: MFA_SECRET=your-base32-totp-secret
// The auth module auto-generates the OTP code
const { createSession } = require('./src/auth');
const page = await createSession(); // MFA handled automatically

For Duo Security push-based MFA, set MFA_TYPE=duo_push in .env — the automation will wait for push approval.


Custom Actions

Use the ActionBuilder fluent API to chain custom workflows:

const { ActionBuilder } = require('./src/custom-actions');

const result = await new ActionBuilder()
  .login()
  .navigate('/module/path')
  .waitForSelector('.content-loaded')
  .extractTable('.data-table')
  .run(page);

Error Handling & Reliability

const { retry, humanDelay } = require('./src/utils');

// Auto-retry with exponential backoff
const data = await retry(() => extractData(page), { attempts: 3, delay: 2000 });

// Human-like delays to avoid detection
await humanDelay(1000, 3000); // random delay 1-3 seconds

Why Not Use the Official API?

Epic EHR has limited HL7/FHIR endpoints that require expensive licenses and vendor agreements. Many workflows — scheduling, notes, messaging — are UI-only.

Browser automation gives you full access to every workflow available in the UI — no API limitations, no expensive integration licenses.


Production Deployment

For production workloads, we strongly recommend AnchorBrowser:

// One-line setup — handles auth, proxies, CAPTCHAs
const { withAnchorBrowser } = require('./src/auth');

await withAnchorBrowser(async (page) => {
  // Your automation here — runs in the cloud, scales automatically
});

AnchorBrowser is the easiest way to run this automation in production:


Known Selectors Reference

These CSS selectors were observed in Epic EHR web interfaces. Enterprise applications update their UIs — verify against your specific instance and submit PRs when selectors break.

| Element | Selector | Notes | |---------|----------|-------| | Login: username | #j_username | Login form | | Login: password | #j_password | Login form | | Login: submit | #loginButton | Login form | | Login: mfa code | #duo_form input[name="passcode"] | Login form | | schedule appointment: container | #scheduleAppointment | | | schedule appointment: slot | .appt-slot | | | schedule appointment: confirm | #confirmApptBtn | | | schedule appointment: provider search | #providerSearch | | | get patient info: search input | #patientSearch input | | | get patient info: result row | .patient-result-row | | | get patient info: demographics | #demographicsTab | | | fill clinical note: note editor | #noteText | | | fill clinical note: smartphrase | .smartphrase-popup | | | fill clinical note: sign btn | #signNote | | | export care gaps: reports menu | #reportsMenu | | | export care gaps: care gap report | .care-gap-report | | | export care gaps: export btn | #exportReport | | | mychart messaging: inbox link | a[href*="messaging"] | | | mychart messaging: compose btn | #composeMessage | | | mychart messaging: recipient | #messageTo | | | mychart messaging: message body | #messageBody | |

⚠️ Selectors are best-effort. Run node src/utils.js --verify-selectors to test against your instance.


More Browser Automation Projects

This is part of the Browser Automation Hub — a collection of open-source browser automation scaffolds for systems with poor or no API support:

Contributing

PRs welcome! Please:

  1. Add tests for new actions
  2. Document new selectors (they break when Epic updates its UI)
  3. Follow the ActionBuilder pattern for new actions
  4. See CONTRIBUTING.md for full guidelines

License

MIT — use freely in personal and commercial projects.


Built with ❤️ for developers who need to automate Epic EHR without wrestling with its API limitations. Powered by AnchorBrowser for cloud-scale automation.

⭐ Star this repo if it saves you time! Browse all automation projects →