A comprehensive full-stack Hospital Administration Management System built with Node.js, Express, PostgreSQL, and vanilla JavaScript.
- Authentication & Authorization: Role-based access control (SUPER_ADMIN, ADMIN, DOCTOR, NURSE, RECEPTIONIST, ACCOUNTANT, LAB_TECHNICIAN)
- Patient Management: Complete patient profiles with medical history and documents
- Appointment Scheduling: Doctor calendar with conflict detection
- Ward & Bed Management: Visual bed occupancy tracking
- Inventory Management: Medicine and supply tracking with low-stock alerts
- Billing System: Invoice generation and payment tracking
- Interactive Dashboards: Real-time charts and analytics
- Audit Logging: Complete audit trail for sensitive operations
- Secure: JWT authentication, password hashing, input validation
- Backend: Node.js, Express.js, Sequelize ORM
- Database: PostgreSQL
- Frontend: HTML5, CSS3, Vanilla JavaScript, Chart.js
- Deployment: Docker & Docker Compose
- Testing: Jest, Supertest
hospital-admin-system/
├── backend/
│ ├── src/
│ │ ├── config/ # Database and logger config
│ │ ├── controllers/ # Request handlers
│ │ ├── models/ # Database models
│ │ ├── routes/ # API routes
│ │ ├── middleware/ # Auth, error handling
│ │ ├── services/ # Business logic
│ │ ├── utils/ # Helper functions
│ │ └── index.js # Server entry point
│ ├── tests/ # Test files
│ ├── Dockerfile
│ └── package.json
├── frontend/
│ ├── index.html
│ ├── assets/
│ │ ├── css/styles.css
│ │ └── js/
│ │ ├── api.js # API client
│ │ ├── app.js # Main app logic
│ │ └── modules/ # Page modules
│ └── pages/
├── docker-compose.yml
├── nginx.conf
└── README.md
- Docker & Docker Compose
- Node.js 18+ (for local development)
- PostgreSQL 15+ (for local development)
- Clone the repository:
cd hospital-admin-system- Start services:
docker-compose up -d- Initialize database (first time):
docker-compose exec backend npm run seed- Access the application:
- Frontend: http://localhost
- Backend API: http://localhost:3000/api
- Health check: http://localhost:3000/health
- Install PostgreSQL and create database:
psql -U postgres
CREATE DATABASE hospital_admin_db;- Backend setup:
cd backend
cp .env.example .env
# Edit .env with your database credentials
npm install
npm run migrate
npm run seed
npm run dev- Frontend setup:
cd frontend
# Open index.html in your browser or use a local server
python -m http.server 8000
# Then visit http://localhost:8000- User: Staff accounts with roles and permissions
- Patient: Patient information and medical history
- Staff: Employee details and scheduling
- Appointment: Scheduling and calendar management
- Ward/Room/Bed: Facility hierarchy and occupancy
- Encounter: Patient visit records
- InventoryItem: Medicine and supply tracking
- Invoice: Billing and payment records
- LabOrder: Laboratory test orders
- AuditLog: Action tracking and compliance
POST /api/auth/register- Register new userPOST /api/auth/login- Login and get JWT tokenPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/logout- LogoutPOST /api/auth/change-password- Change passwordPOST /api/auth/request-password-reset- Request password resetPOST /api/auth/reset-password- Reset password with token
POST /api/patients- Create patientGET /api/patients- List patients (paginated, searchable)GET /api/patients/:id- Get patient detailsPUT /api/patients/:id- Update patientDELETE /api/patients/:id- Delete patient
POST /api/appointments- Create appointmentGET /api/appointments- List appointments (filterable by date, doctor, patient, status)GET /api/appointments/:id- Get appointment detailsPUT /api/appointments/:id- Update appointmentPATCH /api/appointments/:id/cancel- Cancel appointment
POST /api/wards- Create wardGET /api/wards- List wardsGET /api/wards/:id- Get ward with rooms and bedsPUT /api/wards/:id- Update wardPOST /api/wards/:wardId/beds- Create bedPATCH /api/wards/beds/:id/status- Update bed statusGET /api/wards/beds/status- Get bed occupancy status
POST /api/inventory- Create inventory itemGET /api/inventory- List items (filterable, searchable)GET /api/inventory/:id- Get item detailsPUT /api/inventory/:id- Update itemPATCH /api/inventory/:id/adjust- Adjust quantityGET /api/inventory/low-stock- Get low-stock items
POST /api/invoices- Create invoiceGET /api/invoices- List invoices (filterable by date, status, patient)GET /api/invoices/:id- Get invoice detailsPATCH /api/invoices/:id/status- Update invoice status
- SUPER_ADMIN - Full system access
- ADMIN - All features except super admin functions
- DOCTOR - Patient management, appointments, prescriptions
- NURSE - Ward management, patient care
- RECEPTIONIST - Patient registration, appointments
- ACCOUNTANT - Billing, invoices, inventory
- LAB_TECHNICIAN - Lab order management
{
"userId": "uuid",
"role": "DOCTOR",
"iat": 1234567890,
"exp": 1234654290
}curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "doctor1@hospital.com",
"password": "Doctor@123"
}'curl -X POST http://localhost:3000/api/patients \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"name": "John Doe",
"dateOfBirth": "1990-01-15",
"gender": "MALE",
"email": "john@example.com",
"contactNumber": "555-1234"
}'curl -X GET http://localhost:3000/api/appointments?from=2024-01-01&to=2024-01-31 \
-H "Authorization: Bearer YOUR_TOKEN"cd backend
npm test
npm run test:watch # Watch modenpm test -- --coveragedocker-compose -f docker-compose.yml -f docker-compose.prod.yml up -dCopy .env.example to .env and configure:
NODE_ENV=production
DB_HOST=your-db-host
DB_PASSWORD=your-secure-password
JWT_SECRET=your-secret-key- Connection pooling enabled
- Paginated API responses
- Database indexes on frequently queried fields
- Request rate limiting
- Gzip compression enabled
- Password hashing with bcrypt (10 salt rounds)
- JWT token-based authentication
- CORS protection
- Helmet security headers
- Input validation & sanitization
- SQL injection prevention via Sequelize ORM
- Audit logging for sensitive operations
- HTTPS recommended for production
- Winston logger with file rotation
- Request logging middleware
- Error tracking
- Audit trail for all data modifications
- WebSocket support for real-time updates
- Email notifications for appointments
- SMS alerts for emergencies
- HL7/FHIR compatibility
- Advanced analytics and reporting
- Mobile app (React Native)
- Payment gateway integration
- AI-based appointment scheduling
Guidelines for contributing to this project:
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes and commit:
git commit -am 'Add feature' - Push to the branch:
git push origin feature/your-feature - Submit a pull request
This project is licensed under the ISC License.
For issues or questions:
- Create an issue in the repository
- Email support@hospital-admin.com
- Check documentation in
/docs
- Initial release
- Core features: Patient, Appointment, Ward, Inventory, Billing management
- Authentication & Authorization
- Dashboard with analytics
- Docker deployment
Last Updated: November 2024