Skip to content

ARPANPATRA111/Medix-manager

Β 
Β 

Repository files navigation

Hospital Management System (HMS)

A comprehensive hospital management system built with Next.js 16, TypeScript, Prisma, SQLite, and NextAuth for authentication.

πŸš€ Features

βœ… Completed Modules

Authentication & Authorization

  • NextAuth.js integration with credentials provider
  • Role-based access control (RBAC) with 8 user roles:
    • Admin, Doctor, Nurse, Receptionist, Lab Technician, Radiologist, Pharmacist, Accountant
  • Secure password hashing with bcrypt
  • Protected routes with middleware
  • Session management

Patient Management

  • Patient registration with comprehensive form validation
  • Patient search by name, MRN, phone, or email
  • Patient details view with medical history
  • Visit history tracking
  • Allergy and blood group management
  • Emergency contact information
  • Responsive design with mobile and desktop views

Dashboard

  • Role-based dashboard with different views per user type
  • Real-time statistics including:
    • Total patients
    • Today's appointments
    • Pending lab orders
    • Low stock drugs
    • Bed occupancy rates
    • Unpaid bills
  • Quick actions for common tasks
  • Notification system for important alerts

Database Schema

  • Comprehensive SQLite database with 30+ tables
  • Proper relationships and foreign keys
  • Data integrity with constraints
  • Activity logging for audit trails
  • Soft delete for important records

πŸ—οΈ In Progress

  • Appointment booking system with conflict checking
  • OPD/IPD workflows
  • Laboratory management
  • Pharmacy management

🎯 Planned Features

  • Ward and bed management
  • Radiology module
  • Prescription management
  • Billing and invoicing
  • Reports and analytics

πŸ› οΈ Technology Stack

  • Framework: Next.js 16 with App Router
  • Language: TypeScript
  • Database: SQLite with Prisma ORM
  • Authentication: NextAuth.js
  • UI Components: shadcn/ui + Radix UI
  • Styling: Tailwind CSS
  • Forms: React Hook Form + Zod validation
  • Icons: Lucide React
  • Date Handling: date-fns

πŸ“‹ Prerequisites

  • Node.js 18.0.0 or higher
  • npm or yarn package manager

πŸš€ Getting Started

1. Install Dependencies

npm install

2. Environment Setup

The .env file is already configured with:

  • SQLite database connection
  • NextAuth secret and URL
  • Default admin credentials

3. Database Setup

# Generate Prisma client
npx prisma generate

# Run migrations (already done)
npx prisma migrate dev

# Seed the database with sample data
npx prisma db seed

4. Start Development Server

npm run dev
# or
yarn dev

Open http://localhost:3000 with your browser to access the application.

πŸ‘₯ Default User Accounts

Role Email Password Access
Admin admin@hospital.com admin123 Full system access
Doctor doctor@hospital.com admin123 Patient care, prescriptions
Nurse nurse@hospital.com admin123 Ward management, vitals
Lab Technician lab@hospital.com admin123 Laboratory tests
Pharmacist pharmacy@hospital.com admin123 Medication management

πŸ—οΈ Project Structure

src/
β”œβ”€β”€ app/                    # Next.js App Router
β”‚   β”œβ”€β”€ api/               # API routes
β”‚   β”œβ”€β”€ auth/              # Authentication pages
β”‚   β”œβ”€β”€ dashboard/         # Protected dashboard pages
β”‚   └── layout.tsx         # Root layout
β”œβ”€β”€ components/            # React components
β”‚   β”œβ”€β”€ ui/                # shadcn/ui components
β”‚   β”œβ”€β”€ layout/            # Layout components
β”‚   └── patients/          # Patient-specific components
β”œβ”€β”€ lib/                   # Utilities and configurations
β”‚   β”œβ”€β”€ actions/           # Server actions
β”‚   β”œβ”€β”€ validations/       # Zod schemas
β”‚   β”œβ”€β”€ auth.ts           # NextAuth configuration
β”‚   └── db.ts             # Database connection
β”œβ”€β”€ types/                 # TypeScript type definitions
└── middleware.ts          # Route protection middleware

prisma/
β”œβ”€β”€ schema.prisma          # Database schema
β”œβ”€β”€ migrations/            # Database migrations
└── seed.ts               # Database seeding script

πŸ”’ Security Features

  • Password hashing with bcrypt
  • CSRF protection via NextAuth
  • SQL injection prevention via Prisma ORM
  • Role-based access control
  • Input validation with Zod
  • Activity logging for audit trails

πŸ“Š Database Design

The system includes comprehensive entities:

  • Users & Authentication (Users, Sessions, Accounts)
  • Medical Staff (Doctors, Nurses, Lab Technicians, Pharmacists)
  • Patients (Patient records, emergency contacts)
  • Appointments (Scheduling, doctor availability)
  • Medical Records (Visits, vitals, nurse notes)
  • Ward Management (Wards, beds, admissions)
  • Laboratory (Tests, orders, results)
  • Radiology (Imaging tests, reports)
  • Pharmacy (Drugs, prescriptions, dispensing)
  • Billing (Services, bills, payments)
  • Audit (Activity logs)

🎨 UI/UX Features

  • Responsive design for all screen sizes
  • Clean, modern interface with consistent styling
  • Loading states and error handling
  • Form validation with real-time feedback
  • Toast notifications for user feedback
  • Keyboard navigation support
  • Accessible components with proper ARIA labels

πŸ“ˆ Performance Optimizations

  • Server Components for improved performance
  • Client-side caching with React Query patterns
  • Optimistic updates for better UX
  • Lazy loading for large datasets
  • Proper database indexing

πŸ§ͺ Development Features

  • TypeScript for type safety
  • ESLint for code quality
  • Prettier integration ready
  • Hot reload in development
  • Error boundaries for graceful error handling

πŸ“ API Endpoints

Authentication

  • GET/POST /api/auth/* - NextAuth endpoints

Patients (Server Actions)

  • createPatient() - Create new patient
  • updatePatient() - Update patient information
  • searchPatients() - Search patients by various criteria
  • getPatientById() - Get detailed patient information

πŸš€ Deployment

The application is ready for deployment on:

  • Vercel (recommended for Next.js)
  • Netlify
  • Railway
  • Docker containers

For production deployment:

  1. Update environment variables
  2. Configure production database
  3. Set up proper domain and SSL
  4. Enable database backups

πŸ”„ Development Roadmap

Phase 1 (Completed)

  • Authentication system
  • Patient management
  • Basic dashboard
  • Database schema

Phase 2 (In Progress)

  • Appointment scheduling
  • Doctor schedules
  • Conflict checking
  • OPD workflows

Phase 3 (Planned)

  • IPD management
  • Ward and bed assignment
  • Laboratory module
  • Radiology integration

Phase 4 (Future)

  • Pharmacy management
  • Prescription workflows
  • Billing system
  • Reports and analytics

πŸ“Š System Metrics

  • Database Tables: 30+
  • UI Components: 20+ shadcn/ui components
  • User Roles: 8 different roles
  • Validation Schemas: Comprehensive Zod validation
  • Security Features: Multi-layer protection

🀝 Contributing

This is a production-style hospital management system. For contributions:

  1. Follow TypeScript best practices
  2. Ensure proper validation with Zod
  3. Add comprehensive error handling
  4. Test on multiple screen sizes
  5. Maintain security standards

🌐 Deployment to Vercel

This project is ready for deployment to Vercel. See the detailed DEPLOYMENT_GUIDE.md for step-by-step instructions.

Quick Deployment Steps:

  1. Database Migration: Switch from SQLite to PostgreSQL (already configured)
  2. Set up PostgreSQL: Use Vercel Postgres, Supabase, or Neon
  3. Configure Environment Variables: Add DATABASE_URL, NEXTAUTH_SECRET, NEXTAUTH_URL
  4. Deploy: Push to GitHub or use Vercel CLI
# Quick deploy with Vercel CLI
npm i -g vercel
vercel login
vercel --prod

Important Changes for Production:

  • βœ… Database provider changed to PostgreSQL
  • βœ… Build scripts updated for Vercel
  • βœ… Environment configuration ready
  • βœ… Prisma migrations configured

⚠️ Note: SQLite cannot be used on Vercel. You must use a cloud database like PostgreSQL.

πŸ“§ Support

For issues or questions about the hospital management system, please refer to:

  • Database schema documentation in /prisma/schema.prisma
  • Component documentation in respective files
  • DEPLOYMENT_GUIDE.md for deployment help
  • GitHub Issues for bug reports

⚠️ Important Notes

  • Data Security: Ensure proper backup procedures in production
  • HIPAA Compliance: Additional measures needed for healthcare data
  • Performance: Monitor database performance with larger datasets
  • Updates: Keep dependencies updated for security
  • Database: PostgreSQL required for Vercel deployment

Built with ❀️ for modern healthcare management

About

A comprehensive hospital management system built with Next.js 16, TypeScript, Prisma, SQLite, and NextAuth for authentication.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • TypeScript 98.8%
  • CSS 1.1%
  • JavaScript 0.1%