A production-ready Electronic Health Record (EHR) web application with comprehensive patient management, clinical workflows, lab integration, pharmacy, and care coordination features.
This EHR system is designed following real-world hospital workflows with role-based access control, comprehensive audit logging, and HIPAA-style security best practices.
β
Patient Management - Complete patient demographics, medical history, diagnoses, medications, and allergies
β
Clinical Documentation - SOAP format clinical notes and treatment plans
β
Lab Integration - Lab order management and result uploads
β
Pharmacy - Electronic prescriptions and medication dispensing
β
Care Coordination - Referrals and external data sharing
β
Role-Based Access - 5 user roles with specific permissions
β
Audit Logging - Comprehensive tracking of all data access
β
Security - JWT authentication, bcrypt password hashing, SQL injection protection
- Runtime: Node.js v18+
- Framework: Express.js
- Database: MySQL 8.0+
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
- Security: Helmet, CORS
- Framework: React 18
- Build Tool: Vite
- Styling: Tailwind CSS
- Routing: React Router v6
- HTTP Client: Axios
- Icons: Lucide React
- Date Handling: date-fns
Before running this application, ensure you have:
- Node.js (v18 or higher)
- MySQL (v8.0 or higher)
- npm or yarn package manager
cd ehr-system# Login to MySQL
mysql -u root -p
# Create database and import schema
mysql -u root -p < database/schema.sql
# Import sample data (optional)
mysql -u root -p ehr_system < database/seed.sqlcd backend
# Install dependencies
npm install
# Create environment file
copy .env.example .env
# Edit .env file with your MySQL credentials
# DB_HOST=localhost
# DB_USER=root
# DB_PASSWORD=your_password
# DB_NAME=ehr_system
# JWT_SECRET=your_secret_key_here
# Start the backend server
npm startThe backend API will run on http://localhost:5000
cd frontend
# Install dependencies
npm install
# Start the development server
npm run devThe frontend application will run on http://localhost:5173
The system comes with pre-configured users for testing:
| Role | Username | Password | Description |
|---|---|---|---|
| Admin | admin | password123 | System administration |
| Doctor | dr.smith | password123 | Primary care physician |
| Doctor | dr.jones | password123 | Specialist |
| Nurse | nurse.wilson | password123 | Registered nurse |
| Lab Technician | lab.tech | password123 | Laboratory technician |
| Pharmacist | pharmacist | password123 | Licensed pharmacist |
ehr-system/
βββ backend/
β βββ config/
β β βββ database.js # MySQL connection pool
β βββ controllers/
β β βββ authController.js # Authentication logic
β β βββ patientController.js # Patient management
β β βββ clinicalController.js# Clinical notes & vitals
β β βββ labController.js # Lab orders & results
β β βββ pharmacyController.js# Prescriptions
β β βββ careController.js # Referrals & sharing
β β βββ adminController.js # User & audit management
β βββ middleware/
β β βββ auth.js # JWT & RBAC middleware
β β βββ audit.js # Audit logging
β βββ routes/
β β βββ auth.routes.js
β β βββ patient.routes.js
β β βββ clinical.routes.js
β β βββ lab.routes.js
β β βββ pharmacy.routes.js
β β βββ care.routes.js
β β βββ admin.routes.js
β βββ server.js # Express app entry point
β βββ package.json
β βββ .env.example
βββ frontend/
β βββ src/
β β βββ components/
β β β βββ Auth/
β β β β βββ Login.jsx
β β β βββ Layout/
β β β βββ Sidebar.jsx
β β βββ context/
β β β βββ AuthContext.jsx
β β βββ pages/
β β β βββ Doctor/
β β β β βββ DoctorDashboard.jsx
β β β βββ Nurse/
β β β β βββ NurseDashboard.jsx
β β β βββ Lab/
β β β β βββ LabDashboard.jsx
β β β βββ Pharmacy/
β β β β βββ PharmacyDashboard.jsx
β β β βββ Admin/
β β β β βββ AdminDashboard.jsx
β β β βββ Patients/
β β β βββ PatientList.jsx
β β β βββ PatientProfile.jsx
β β β βββ PatientRegistration.jsx
β β βββ utils/
β β β βββ api.js # Axios instance
β β βββ App.jsx # Main app component
β β βββ main.jsx # React entry point
β β βββ index.css # Global styles
β βββ index.html
β βββ package.json
β βββ vite.config.js
β βββ tailwind.config.js
βββ database/
βββ schema.sql # Database schema
βββ seed.sql # Sample data
- JWT Authentication: Secure token-based authentication
- Password Hashing: bcrypt with salt rounds
- Role-Based Access Control: 5 distinct user roles with specific permissions
- Audit Logging: All patient data access is logged
- Input Validation: Protection against SQL injection
- CORS: Configured for secure cross-origin requests
- Helmet: Security headers for Express
- User management (create, update, deactivate)
- View audit logs
- System configuration
- Full patient access
- Register and manage patients
- Create clinical notes (SOAP format)
- Order lab tests
- Create prescriptions
- Create referrals
- View all patient data
- View patients
- Record vitals
- Add care notes
- View medical history
- View lab orders
- Upload lab results
- Create imaging records
- View prescriptions
- Dispense medications
- Track medication inventory
The system uses a normalized MySQL database with 20+ tables:
- users - System users with roles
- patients - Patient demographics
- medical_history - Past illnesses, surgeries, family history
- diagnoses - Current and past diagnoses (ICD-style)
- medications - Current and past medications
- allergies - Drug and food allergies
- clinical_notes - SOAP format documentation
- treatment_plans - Treatment plans and follow-ups
- lab_orders - Lab test orders
- lab_results - Test results
- imaging_records - X-ray, CT, MRI records
- prescriptions - Electronic prescriptions
- prescription_dispenses - Dispensing tracking
- vitals - Patient vital signs
- referrals - Referral management
- external_shares - Data sharing tracking
- audit_logs - Comprehensive audit trail
See API_DOCUMENTATION.md for complete API reference.
- Login: Use one of the default credentials
- Doctor Workflow:
- Register a new patient
- View patient profile
- Add clinical notes
- Order lab test
- Create prescription
- Lab Workflow:
- View pending lab orders
- Upload results
- Pharmacy Workflow:
- View prescription queue
- Dispense medication
- Admin Workflow:
- View audit logs
- Manage users
cd backend
npm run dev # Uses nodemon for auto-reloadcd frontend
npm run dev # Vite dev server with HMR# Frontend
cd frontend
npm run build
# Backend (no build needed, runs directly)
cd backend
NODE_ENV=production npm start- Verify MySQL is running
- Check credentials in
.env - Ensure database
ehr_systemexists
- Backend: Change
PORTin.env - Frontend: Change port in
vite.config.js
- Ensure backend
FRONTEND_URLmatches frontend URL - Check CORS configuration in
server.js
MIT License - See LICENSE file for details
For issues and questions, please create an issue in the repository.
Built with β€οΈ for healthcare professionals