A web application for managing doctor-patient relationships, medical histories, and prescriptions.
- User authentication (JWT-based) for doctors and patients
- Role-based access control
- Doctors can:
- View their patient list
- Add medical history records
- Prescribe medications
- Assign new patients
- Patients can:
- View their medical history
- View their prescriptions
- View their assigned doctors
- Backend: Node.js, Express, MongoDB, Mongoose
- Security: JWT Authentication, Bcrypt password hashing
- Database: MongoDB
/healthcare-app
/backend
/controllers # Request handlers
/models # Database schemas
/routes # API routes
/middleware # Custom middleware (auth, roles)
/utils # Utility functions
server.js # Express app setup
.env # Environment variables
/frontend # Frontend code (to be added)
/scripts
seed.js # Database seeding script
POST /api/auth/register- Register a new user (doctor or patient)POST /api/auth/login- Login and receive JWT tokenGET /api/auth/profile- Get user profile
GET /api/doctors/profile- Get doctor's profileGET /api/doctors/patients- Get all patients assigned to doctorGET /api/doctors/patients/:patientId- Get specific patient detailsPOST /api/doctors/patients/:patientId/medical-history- Add medical historyPOST /api/doctors/patients/:patientId/prescriptions- Add prescriptionPOST /api/doctors/assign-patient- Assign patient to doctor
GET /api/patients/profile- Get patient's profileGET /api/patients/medical-history- Get patient's medical historyGET /api/patients/prescriptions- Get patient's prescriptionsGET /api/patients/doctors- Get patient's assigned doctors
- Node.js (v14+)
- MongoDB
-
Clone the repository
git clone https://github.com/yourusername/healthcare-app.git cd healthcare-app -
Install backend dependencies
cd backend npm install -
Set up environment variables
- Create a
.envfile in the backend directory - Add the following variables:
PORT=5000 MONGODB_URI=mongodb://localhost:27017/healthcare-app JWT_SECRET=your_secure_jwt_secret_key_here
- Create a
-
Seed the database (optional)
cd ../scripts node seed.js -
Start the server
cd ../backend npm run dev
This application implements several security measures:
- JWT Authentication: All protected routes require a valid JWT token
- Role-Based Access Control: Different routes are accessible based on user roles
- Relationship Verification:
- Doctors can only access data for patients assigned to them
- Patients can only access their own data
- Password Hashing: User passwords are hashed using bcrypt
- Email: [email protected], Password: password123
- Email: [email protected], Password: password123
- Email: [email protected], Password: password123
- Email: [email protected], Password: password123
- Email: [email protected], Password: password123