A full-stack healthcare management platform with role-based access for physicians and patients. Built with Next.js frontend and a Node.js + MySQL backend that integrates public health datasets (CMS, Synthea, RxNorm, DailyMed, Orange Book). Physicians get context‑aware insights (coverage, costs, research), while patients get plain‑language guidance, adherence tools, and price transparency.
- Right info, right provider, right time: surfacing formulary tiering, PA/ST/QL, and cost signals alongside the patient’s EMR.
- Evidence & safety: auto‑ingest FDA DailyMed PDFs → extract SPL → clinical flags + HCP summary via LLM (strict JSON).
- Cost transparency: estimate out‑of‑pocket by plan/coverage level, retail vs mail, preferred/non‑preferred.
- Datasets integrated: CMS (formulary, costs), Synthea (EMR), RxNorm (drug IDs), DailyMed (labels), Orange Book (TE codes).
frontend/ # Next.js 15 (App Router, TS, Tailwind, shadcn/ui, Clerk)
backend/ # Express API (mysql2/promise, axios, pdf-parse, OpenAI)
- Physicians: patient lists, EMR timeline, prescription flow with safety checks, FDA/clinical feed, notifications, AI summaries.
- Patients: medication manager, recovery timeline, daily checklist, cost & coverage view, appointment tracking.
- Next.js 15 (App Router) · TypeScript · Tailwind · shadcn/ui · Clerk · React Context · lucide-react · date-fns
cd frontend
npm install
npm run devCreate frontend/.env.local:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=/dashboard
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=/dashboardProject layout mirrors the standard app/ router, components/, contexts/, types/, lib/.
- Language/Libs: Node 18+, Express,
mysql2/promise,axios,pdf-parse. - External APIs: DailyMed (SPL PDFs), RxNav (RxNorm), OpenAI (LLM JSON generation).
- Database: AWS RDS MySQL 8.x. DB name:
pharmacy.
backend/src/server.js– Express app, endpoints, health, graceful shutdown.backend/src/utils.js– PDF parsing, DB snapshot builder, LLM prompts and callers.backend/src/config/database.js– (not shown) pooled connection helpers:testConnection,initializeDatabase,executeQuery.
PORT=5001
DB_HOST=<rds-endpoint>
DB_PORT=3306
DB_USER=rxuser
DB_PASSWORD=********
DB_NAME=pharmacy
DB_SSL=true
# OpenAI
OPENAI_API_KEY=sk-****************
OPENAI_BASE=https://api.openai.com/v1
OPENAI_FETCH_MODEL=gpt-4o-mini # for extraction
OPENAI_REASONING_MODEL=gpt-4o-mini # for comparative report (can be a reasoning model)cd backend
npm install
npm run dev
# API root
# -> http://localhost:5001/- CMS (Centers for Medicare & Medicaid Services) — formulary, plan, beneficiary cost files (tiers, PA/ST/QL, coverage levels). Source: data.cms.gov.
- Synthea — synthetic EMR: patients, allergies, medications, observations. Source: synthetichealth.github.io/synthea.
- RxNorm (RxNav) — canonical drug identifiers (RXCUI), properties, brand/generic links. Source: rxnav.nlm.nih.gov.
- DailyMed — FDA drug labels (SPL PDFs). Source: dailymed.nlm.nih.gov.
- Orange Book (FDA) — approved products & therapeutic equivalence.
These power: plan coverage + costs, safe EMR prototyping, consistent drug IDs, label‑based safety parsing, and substitution guidance.
- RDS MySQL 8.x instance, parameter group with
local_infile=1,max_allowed_packet=64M, UTF‑8 defaults. - Security Group: TCP 3306 inbound from dev IP(s) / API host; automated backups enabled.
- Users:
rxuser(password auth). Optional IAM DB Auth user if enabled.
allergies
cms_basic_formulary
cms_beneficiary_cost
cms_indication_coverage
cms_plan_info
cms_plan_map
feature_scope_patients
medications
observations
patients
patients_backup
payer_plan_catalog
payer_transitions
payers
-- Enable local infile on client
-- mysql ... --local-infile=1
LOAD DATA LOCAL INFILE '/path/basic_formulary.txt'
INTO TABLE cms_basic_formulary
CHARACTER SET utf8mb4
FIELDS TERMINATED BY '|' LINES TERMINATED BY '\n'
IGNORE 1 LINES;
LOAD DATA LOCAL INFILE '/path/allergies.csv'
INTO TABLE allergies
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES;If you encounter
ERROR 1300(encoding), convert input to UTF‑8 during load.
GET /health– uptime & envGET /– API index & example routesGET /api/test– simple heartbeatGET /api/db-test– validates DB connectivity
GET /api/drug-label.pdf?rxcui=RXCUIProxy DailyMed SPL PDF by RxCUI.POST /api/evidence/digest-rxcuiBody:{ rxcui, patientId }Flow: RxCUI → DailyMed PDF → text → EMR snapshot + coverage → LLM JSON (flags + HCP summary + coverage fields).
GET /api/coverage?patientId=...&rxcui=...Returns{ covered, tier, priorAuthorization, stepTherapy, quantityLimit, quantityLimitAmount, quantityLimitDays }.GET /api/cost?patientId=...&rxcui=...&daysSupply=30&coverageLevel=Initial%20Coverage&channel=RETAIL&preferred=1Returns estimated out‑of‑pocket based on plan/channel/preference.
POST /api/alternativeBody:{ rxcui }Finds disease fromcms_indication_coverage, enumerates alternative RxCUIs, extracts SPL JSON for each, and returns a comparative study (similarity % + doctor_note) via LLM.
Note on Views: Some sample queries reference
v_patient_formulary,v_drug_plan_coverage, andv_drug_cost_matrix. If you are not using SQL views, replace these with equivalent JOINs acrosscms_*,payers, andpayer_transitions. (You can also add lightweight views later for readability/perf.)
pool–mysql2/promisepool using env‑driven config.parsePdfToText(buffer)– PDF → raw text (nulls stripped, trimmed).getPatientSnapshotAndCostSignals(patientId, rxcui)– returns{ core, allergies, meds, coverage:{ plan, formulary, estimatedCost } }.buildSPLPrompt(pdfText)– extractor prompt: outputs concise SPL JSON (drug_name, indications, MoA, etc.).buildPrompt({...})– clinical decision prompt: flags (high/medium/info) + HCP summary + coverage fields; strict JSON.buildReportPrompt(results, inputRxcui)– comparative study across alternatives (similarity % buckets + short doctor_note).callLLM(prompt, model)– OpenAI Chat Completions; extracts only the JSON object from response text.
MIT
Built by the CuraRX team using CMS, Synthea, RxNorm, DailyMed, and FDA Orange Book data.