├── Backend ├── .gitignore ├── README.md ├── configs │ └── db.js ├── index.js ├── middlewares │ ├── adminAuth.js │ ├── doctorAuth.js │ ├── nurseAuth.js │ └── patientAuth.js ├── models │ ├── Admin.model.js │ ├── Ambulance.model.js │ ├── Appointment.model.js │ ├── Bed.model.js │ ├── Doctor.model.js │ ├── Hospital.model.js │ ├── Nurse.model.js │ ├── Patient.model.js │ ├── Payment.model.js │ ├── Prescription.model.js │ └── Report.model.js ├── package-lock.json ├── package.json └── routes │ ├── Admins.Route.js │ ├── Ambulances.Route.js │ ├── Appointments.Route.js │ ├── Beds.Route.js │ ├── Doctors.Route.js │ ├── Hospitals.Route.js │ ├── Nurses.Route.js │ ├── Patients.Route.js │ ├── Payments.route.js │ ├── Prescriptions.Route.js │ └── Reports.Route.js ├── FrontEnd ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── Components │ ├── Footer │ │ └── Footer.jsx │ └── Navbar │ │ └── Navbar.jsx │ ├── Pages │ └── Dashboard │ │ ├── Dashboard-Login │ │ ├── DLogin.css │ │ └── DLogin.jsx │ │ └── Main-Dashboard │ │ ├── AllPages │ │ ├── Admin │ │ │ ├── AddBeds.jsx │ │ │ ├── Add_Admin.jsx │ │ │ ├── Add_Ambulance.jsx │ │ │ ├── Add_Doctor.jsx │ │ │ ├── Add_Nurse.jsx │ │ │ ├── Beds_Rooms.jsx │ │ │ ├── CSS │ │ │ │ ├── Add_Ambu.css │ │ │ │ ├── Add_Doctor.css │ │ │ │ └── Payment.css │ │ │ └── Check_Payment.jsx │ │ ├── Doctor │ │ │ ├── AllReport.jsx │ │ │ ├── CSS │ │ │ │ └── Doctor_Profile.css │ │ │ ├── Check_Appointment.jsx │ │ │ ├── Discharge_and_Create_Slip.jsx │ │ │ ├── Doctor_Profile.jsx │ │ │ └── Patient_Details.jsx │ │ └── Nurse │ │ │ ├── Add_Patient.jsx │ │ │ ├── Book_Appointment.jsx │ │ │ ├── CSS │ │ │ ├── Appointment.css │ │ │ ├── Book_appointment.css │ │ │ └── Profiles.css │ │ │ ├── MixedObjectData.js │ │ │ └── Nurse_Profile.jsx │ │ └── GlobalFiles │ │ ├── CommonCSS.css │ │ ├── FrontPage.jsx │ │ ├── Sidebar.jsx │ │ └── Topbar.jsx │ ├── Redux │ ├── Datas │ │ ├── action.js │ │ ├── reducer.js │ │ └── types.js │ ├── auth │ │ ├── action.js │ │ ├── reducer.js │ │ └── types.js │ ├── index.js │ └── store.js │ ├── Routes │ └── AllRoutes.jsx │ ├── img │ ├── admin.jpg │ ├── ambuone.png │ ├── ambuthree.png │ ├── ambutwo.png │ ├── banner.png │ ├── doctoravatar.png │ ├── nurseavatar.png │ └── profile.png │ └── index.js └── README.md /Backend/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env -------------------------------------------------------------------------------- /Backend/README.md: -------------------------------------------------------------------------------- 1 |

This is the backend made for the Hospital Management App.

2 | 3 |

Deployed on: Cyclic

4 | -------------------------------------------------------------------------------- /Backend/configs/db.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | require("dotenv").config(); 3 | 4 | const connection = mongoose.connect(process.env.dbURL); 5 | 6 | module.exports = { connection }; 7 | -------------------------------------------------------------------------------- /Backend/index.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { connection } = require("./configs/db"); 3 | require("dotenv").config(); 4 | const cors = require("cors"); 5 | 6 | const adminRouter = require("./routes/Admins.Route"); 7 | const ambulanceRouter = require("./routes/Ambulances.Route"); 8 | const appointmentRouter = require("./routes/Appointments.Route"); 9 | const bedRouter = require("./routes/Beds.Route"); 10 | const doctorRouter = require("./routes/Doctors.Route"); 11 | const hospitalRouter = require("./routes/Hospitals.Route"); 12 | const nurseRouter = require("./routes/Nurses.Route"); 13 | const patientRouter = require("./routes/Patients.Route"); 14 | const paymentRouter = require("./routes/Payments.route"); 15 | const prescriptionRouter = require("./routes/Prescriptions.Route"); 16 | const reportRouter = require("./routes/Reports.Route"); 17 | 18 | const app = express(); 19 | 20 | app.use(express.json()); 21 | app.use(cors()); 22 | 23 | app.get("/", (req, res) => { 24 | res.send("Homepage"); 25 | }); 26 | 27 | app.use("/admin", adminRouter); 28 | app.use("/ambulances", ambulanceRouter); 29 | app.use("/appointments", appointmentRouter); 30 | app.use("/beds", bedRouter); 31 | app.use("/doctors", doctorRouter); 32 | app.use("/hospitals", hospitalRouter); 33 | app.use("/nurses", nurseRouter); 34 | app.use("/patients", patientRouter); 35 | app.use("/payments", paymentRouter); 36 | app.use("/prescriptions", prescriptionRouter); 37 | app.use("/reports", reportRouter); 38 | 39 | app.listen(process.env.port, async () => { 40 | try { 41 | await connection; 42 | console.log("Connected to DB"); 43 | } catch (error) { 44 | console.log("Unable to connect to DB"); 45 | console.log(error); 46 | } 47 | console.log(`Listening at port ${process.env.port}`); 48 | }); 49 | -------------------------------------------------------------------------------- /Backend/middlewares/adminAuth.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | require("dotenv").config(); 3 | 4 | const authenticate = (req, res, next) => { 5 | const token = req.headers.authorization; 6 | if (token) { 7 | const decoded = jwt.verify(token, process.env.key); 8 | if (decoded) { 9 | const adminID = decoded.adminID; 10 | req.body.adminID = adminID; 11 | next(); 12 | } else { 13 | res.send("You cannot edit this token."); 14 | } 15 | } else { 16 | res.send("Inadequate permissions, Please login first."); 17 | } 18 | }; 19 | 20 | module.exports = { authenticate }; 21 | -------------------------------------------------------------------------------- /Backend/middlewares/doctorAuth.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | require("dotenv").config(); 3 | 4 | const authenticate = (req, res, next) => { 5 | const token = req.headers.authorization; 6 | if (token) { 7 | const decoded = jwt.verify(token, process.env.key); 8 | if (decoded) { 9 | const doctorID = decoded.doctorID; 10 | req.body.doctorID = doctorID; 11 | next(); 12 | } else { 13 | res.send("You cannot edit this token."); 14 | } 15 | } else { 16 | res.send("Inadequate permissions, Please login first."); 17 | } 18 | }; 19 | 20 | module.exports = { authenticate }; 21 | -------------------------------------------------------------------------------- /Backend/middlewares/nurseAuth.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | require("dotenv").config(); 3 | 4 | const authenticate = (req, res, next) => { 5 | const token = req.headers.authorization; 6 | if (token) { 7 | const decoded = jwt.verify(token, process.env.key); 8 | if (decoded) { 9 | const nurseID = decoded.nurseID; 10 | req.body.nurseID = nurseID; 11 | next(); 12 | } else { 13 | res.send("You cannot edit this token."); 14 | } 15 | } else { 16 | res.send("Inadequate permissions, Please login first."); 17 | } 18 | }; 19 | 20 | module.exports = { authenticate }; 21 | -------------------------------------------------------------------------------- /Backend/middlewares/patientAuth.js: -------------------------------------------------------------------------------- 1 | const jwt = require("jsonwebtoken"); 2 | require("dotenv").config(); 3 | 4 | const authenticate = (req, res, next) => { 5 | const token = req.headers.authorization; 6 | if (token) { 7 | const decoded = jwt.verify(token, process.env.key); 8 | if (decoded) { 9 | const patientID = decoded.patientID; 10 | req.body.patientID = patientID; 11 | next(); 12 | } else { 13 | res.send("You cannot edit this token."); 14 | } 15 | } else { 16 | res.send("Inadequate permissions, Please login first."); 17 | } 18 | }; 19 | 20 | module.exports = { authenticate }; 21 | -------------------------------------------------------------------------------- /Backend/models/Admin.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const adminSchema = mongoose.Schema({ 4 | userType: { 5 | type: String, 6 | default: "admin", 7 | }, 8 | 9 | adminID: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | adminName: { 15 | type: String, 16 | }, 17 | 18 | email: { 19 | type: String, 20 | }, 21 | 22 | password: { 23 | type: String, 24 | required: true, 25 | }, 26 | 27 | gender: { 28 | type: String, 29 | }, 30 | 31 | age: { 32 | type: Number, 33 | }, 34 | 35 | mobile: { 36 | type: Number, 37 | minlength: 10, 38 | }, 39 | 40 | DOB: { 41 | type: String, 42 | }, 43 | 44 | address: { 45 | type: String, 46 | }, 47 | 48 | education: { 49 | type: String, 50 | }, 51 | 52 | image: { 53 | type: String, 54 | default: 55 | "https://res.cloudinary.com/diverse/image/upload/v1674562453/diverse/oipm1ecb1yudf9eln7az.jpg", 56 | }, 57 | }); 58 | 59 | const AdminModel = mongoose.model("admin", adminSchema); 60 | 61 | module.exports = { AdminModel }; 62 | -------------------------------------------------------------------------------- /Backend/models/Ambulance.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const ambulanceSchema = mongoose.Schema({ 4 | type: { 5 | type: String, 6 | required: true, 7 | }, 8 | 9 | charges: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | ambulanceID: { 15 | type: Number, 16 | required: true, 17 | }, 18 | 19 | ambulanceDriver: { 20 | type: String, 21 | required: true, 22 | }, 23 | 24 | number: { 25 | type: Number, 26 | required: true, 27 | }, 28 | }); 29 | 30 | const AmbulanceModel = mongoose.model("ambulance", ambulanceSchema); 31 | 32 | module.exports = { AmbulanceModel }; 33 | -------------------------------------------------------------------------------- /Backend/models/Appointment.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const appointmentSchema = mongoose.Schema({ 4 | userType: { 5 | type: String, 6 | default: "patient", 7 | }, 8 | 9 | patientID: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | patientName: { 15 | type: String, 16 | }, 17 | 18 | mobile: { 19 | type: Number, 20 | }, 21 | 22 | email: { 23 | type: String, 24 | }, 25 | 26 | address: { 27 | type: String, 28 | }, 29 | 30 | disease: { 31 | type: String, 32 | }, 33 | 34 | department: { 35 | type: String, 36 | }, 37 | 38 | time: { 39 | type: String, 40 | }, 41 | 42 | date: { 43 | type: String, 44 | }, 45 | 46 | age: { 47 | type: Number, 48 | required: true, 49 | }, 50 | 51 | gender: { 52 | type: String, 53 | required: true, 54 | }, 55 | }); 56 | 57 | const AppointmentModel = mongoose.model("appointment", appointmentSchema); 58 | 59 | module.exports = { AppointmentModel }; 60 | -------------------------------------------------------------------------------- /Backend/models/Bed.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const bedSchema = mongoose.Schema({ 4 | bedNumber: { 5 | type: Number, 6 | required: true, 7 | }, 8 | 9 | roomNumber: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | occupied: { 15 | type: String, 16 | }, 17 | 18 | patientID: { 19 | type: mongoose.Schema.Types.ObjectId, 20 | ref: "patient", 21 | }, 22 | }); 23 | 24 | const BedModel = mongoose.model("bed", bedSchema); 25 | 26 | module.exports = { BedModel }; 27 | -------------------------------------------------------------------------------- /Backend/models/Doctor.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const doctorSchema = mongoose.Schema({ 4 | userType: { 5 | type: String, 6 | default: "doctor", 7 | }, 8 | 9 | docID: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | docName: { 15 | type: String, 16 | }, 17 | 18 | mobile: { 19 | type: Number, 20 | }, 21 | 22 | email: { 23 | type: String, 24 | }, 25 | 26 | password: { 27 | type: String, 28 | required: true, 29 | }, 30 | 31 | age: { 32 | type: Number, 33 | }, 34 | 35 | gender: { 36 | type: String, 37 | }, 38 | 39 | bloodGroup: { 40 | type: String, 41 | }, 42 | 43 | DOB: { 44 | type: Date, 45 | }, 46 | 47 | address: { 48 | type: String, 49 | }, 50 | 51 | education: { 52 | type: String, 53 | }, 54 | 55 | department: { 56 | type: String, 57 | }, 58 | 59 | image: { 60 | type: String, 61 | default: 62 | "https://res.cloudinary.com/diverse/image/upload/v1674562453/diverse/oipm1ecb1yudf9eln7az.jpg", 63 | }, 64 | 65 | details: { 66 | type: String, 67 | }, 68 | }); 69 | 70 | const DoctorModel = mongoose.model("doctor", doctorSchema); 71 | 72 | module.exports = { DoctorModel }; 73 | -------------------------------------------------------------------------------- /Backend/models/Hospital.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const hospitalSchema = mongoose.Schema({ 4 | docNumbers: { 5 | type: Number, 6 | }, 7 | 8 | patientNumbers: { 9 | type: Number, 10 | }, 11 | 12 | nurseNumbers: { 13 | type: Number, 14 | }, 15 | 16 | ambulanceNumbers: { 17 | type: Number, 18 | }, 19 | 20 | roomsNumbers: { 21 | type: Number, 22 | }, 23 | 24 | bedNumbers: { 25 | type: Number, 26 | }, 27 | 28 | appointmentNumbers: { 29 | type: Number, 30 | }, 31 | 32 | reportsNumbers: { 33 | type: Number, 34 | }, 35 | }); 36 | 37 | const HospitalModel = mongoose.model("hospital", hospitalSchema); 38 | 39 | module.exports = { HospitalModel }; 40 | -------------------------------------------------------------------------------- /Backend/models/Nurse.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const nurseSchema = mongoose.Schema({ 4 | userType: { 5 | type: String, 6 | default: "nurse", 7 | }, 8 | 9 | nurseID: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | nurseName: { 15 | type: String, 16 | }, 17 | 18 | mobile: { 19 | type: Number, 20 | minlength: 10, 21 | }, 22 | 23 | email: { 24 | type: String, 25 | }, 26 | 27 | password: { 28 | type: String, 29 | required: true, 30 | }, 31 | 32 | age: { 33 | type: Number, 34 | }, 35 | 36 | gender: { 37 | type: String, 38 | }, 39 | 40 | bloodGroup: { 41 | type: String, 42 | }, 43 | 44 | DOB: { 45 | type: String, 46 | }, 47 | 48 | address: { 49 | type: String, 50 | }, 51 | 52 | education: { 53 | type: String, 54 | }, 55 | 56 | image: { 57 | type: String, 58 | default: 59 | "https://res.cloudinary.com/diverse/image/upload/v1674562453/diverse/oipm1ecb1yudf9eln7az.jpg", 60 | }, 61 | 62 | details: { 63 | type: String, 64 | }, 65 | }); 66 | 67 | const NurseModel = mongoose.model("nurse", nurseSchema); 68 | 69 | module.exports = { NurseModel }; 70 | -------------------------------------------------------------------------------- /Backend/models/Patient.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const patientSchema = mongoose.Schema({ 4 | userType: { 5 | type: String, 6 | default: "patient", 7 | }, 8 | 9 | patientID: { 10 | type: Number, 11 | required: true, 12 | }, 13 | 14 | patientName: { 15 | type: String, 16 | }, 17 | 18 | mobile: { 19 | type: Number, 20 | minlength: 10, 21 | }, 22 | 23 | email: { 24 | type: String, 25 | }, 26 | 27 | password: { 28 | type: String, 29 | default: "password", 30 | }, 31 | 32 | age: { 33 | type: Number, 34 | }, 35 | 36 | department: { 37 | type: String, 38 | }, 39 | 40 | gender: { 41 | type: String, 42 | }, 43 | 44 | bloodGroup: { 45 | type: String, 46 | }, 47 | 48 | DOB: { 49 | type: String, 50 | }, 51 | 52 | address: { 53 | type: String, 54 | }, 55 | 56 | image: { 57 | type: String, 58 | }, 59 | 60 | disease: { 61 | type: String, 62 | }, 63 | 64 | details: { 65 | type: String, 66 | }, 67 | 68 | admitted: { 69 | type: Boolean, 70 | default: true, 71 | }, 72 | 73 | date: { 74 | type: Date, 75 | }, 76 | 77 | docID: { 78 | type: mongoose.Schema.Types.ObjectId, 79 | ref: "doctor", 80 | }, 81 | 82 | nurseID: { 83 | type: mongoose.Schema.Types.ObjectId, 84 | ref: "nurse", 85 | }, 86 | }); 87 | 88 | const PatientModel = mongoose.model("patient", patientSchema); 89 | 90 | module.exports = { PatientModel }; 91 | -------------------------------------------------------------------------------- /Backend/models/Payment.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const paymentSchema = mongoose.Schema({ 4 | reportID: { 5 | type: mongoose.Schema.Types.ObjectId, 6 | ref: "report", 7 | required: true, 8 | }, 9 | 10 | paid: { 11 | type: Boolean, 12 | default: false, 13 | }, 14 | }); 15 | 16 | const PaymentModel = mongoose.model("payment", paymentSchema); 17 | 18 | module.exports = { PaymentModel }; 19 | -------------------------------------------------------------------------------- /Backend/models/Prescription.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const prescriptionSchema = mongoose.Schema({ 4 | docName: { 5 | type: String, 6 | required: true, 7 | }, 8 | 9 | nurseName: { 10 | type: String, 11 | required: true, 12 | }, 13 | 14 | hospital: { 15 | name: { 16 | type: String, 17 | required: true, 18 | }, 19 | address: { 20 | street: { 21 | type: String, 22 | required: true, 23 | }, 24 | city: { 25 | type: String, 26 | required: true, 27 | }, 28 | state: { 29 | type: String, 30 | required: true, 31 | }, 32 | pincode: { 33 | type: Number, 34 | required: true, 35 | }, 36 | }, 37 | phone: { 38 | type: Number, 39 | required: true, 40 | minlength: 11, 41 | }, 42 | }, 43 | 44 | medicines: { 45 | diagnosis: { 46 | type: String, 47 | }, 48 | medicineName: { 49 | type: String, 50 | required: true, 51 | }, 52 | type: { 53 | type: String, 54 | required: true, 55 | }, 56 | dosage: { 57 | quantity: { 58 | type: Number, 59 | required: true, 60 | }, 61 | duration: { 62 | type: Number, 63 | required: true, 64 | }, 65 | }, 66 | }, 67 | 68 | advice: { 69 | type: String, 70 | }, 71 | 72 | total: { 73 | type: Number, 74 | required: true, 75 | }, 76 | }); 77 | 78 | const PrescriptionModel = mongoose.model("prescription", prescriptionSchema); 79 | 80 | module.exports = { PrescriptionModel, prescriptionSchema }; 81 | -------------------------------------------------------------------------------- /Backend/models/Report.model.js: -------------------------------------------------------------------------------- 1 | const mongoose = require("mongoose"); 2 | 3 | const reportSchema = mongoose.Schema({ 4 | docName: { 5 | type: String, 6 | required: true, 7 | }, 8 | 9 | docDepartment: { 10 | type: String, 11 | required: true, 12 | }, 13 | 14 | docMobile: { 15 | type: Number, 16 | required: true, 17 | }, 18 | 19 | medicines: [ 20 | { 21 | medName: { 22 | type: String, 23 | }, 24 | dosage: { 25 | type: Number, 26 | }, 27 | duration: { 28 | type: String, 29 | }, 30 | }, 31 | ], 32 | 33 | extrainfo: { 34 | type: String, 35 | }, 36 | 37 | patientName: { 38 | type: String, 39 | required: true, 40 | }, 41 | 42 | patientAge: { 43 | type: Number, 44 | required: true, 45 | }, 46 | email: { 47 | type: String, 48 | required: true, 49 | }, 50 | patientGender: { 51 | type: String, 52 | required: true, 53 | }, 54 | 55 | patientMobile: { 56 | type: Number, 57 | required: true, 58 | }, 59 | 60 | patientBloodGroup: { 61 | type: String, 62 | required: true, 63 | }, 64 | 65 | patientDisease: { 66 | type: String, 67 | }, 68 | 69 | patientTemperature: { 70 | type: Number, 71 | }, 72 | 73 | patientWeight: { 74 | type: Number, 75 | }, 76 | 77 | patientBP: { 78 | type: Number, 79 | }, 80 | 81 | patientGlucose: { 82 | type: Number, 83 | }, 84 | 85 | date: { 86 | type: String, 87 | }, 88 | 89 | time: { 90 | type: String, 91 | }, 92 | }); 93 | 94 | const ReportModel = mongoose.model("report", reportSchema); 95 | 96 | module.exports = { ReportModel }; 97 | -------------------------------------------------------------------------------- /Backend/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hms-backend", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "dev": "nodemon index.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "bcrypt": "^5.1.0", 15 | "cors": "^2.8.5", 16 | "dotenv": "^16.0.3", 17 | "express": "^4.18.2", 18 | "jsonwebtoken": "^8.5.1", 19 | "mongoose": "^6.8.4", 20 | "nodemailer": "^6.9.0", 21 | "nodemon": "^2.0.20", 22 | "validator": "^13.7.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Backend/routes/Admins.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { AdminModel } = require("../models/Admin.model"); 3 | require("dotenv").config(); 4 | const jwt = require("jsonwebtoken"); 5 | const nodemailer = require("nodemailer"); 6 | const { NurseModel } = require("../models/Nurse.model"); 7 | const { DoctorModel } = require("../models/Doctor.model"); 8 | const { PatientModel } = require("../models/Patient.model"); 9 | 10 | const router = express.Router(); 11 | 12 | router.get("/", async (req, res) => { 13 | try { 14 | const admins = await AdminModel.find(); 15 | res.status(200).send(admins); 16 | } catch (error) { 17 | console.log(error); 18 | res.status(400).send({ error: "Something went wrong" }); 19 | } 20 | }); 21 | 22 | router.post("/register", async (req, res) => { 23 | const { email } = req.body; 24 | try { 25 | const admin = await AdminModel.findOne({ email }); 26 | if (admin) { 27 | return res.send({ 28 | message: "Admin already exists", 29 | }); 30 | } 31 | let value = new AdminModel(req.body); 32 | await value.save(); 33 | const data = await AdminModel.findOne({ email }); 34 | return res.send({ data, message: "Registered" }); 35 | } catch (error) { 36 | res.send({ message: "error" }); 37 | } 38 | }); 39 | 40 | router.post("/login", async (req, res) => { 41 | const { adminID, password } = req.body; 42 | try { 43 | const admin = await AdminModel.findOne({ adminID, password }); 44 | 45 | if (admin) { 46 | const token = jwt.sign({ foo: "bar" }, process.env.key, { 47 | expiresIn: "24h", 48 | }); 49 | res.send({ message: "Successful", user: admin, token: token }); 50 | } else { 51 | res.send({ message: "Wrong credentials" }); 52 | } 53 | } catch (error) { 54 | console.log({ message: "Error" }); 55 | console.log(error); 56 | } 57 | }); 58 | 59 | router.patch("/:adminId", async (req, res) => { 60 | const id = req.params.adminId; 61 | const payload = req.body; 62 | try { 63 | const admin = await AdminModel.findByIdAndUpdate({ _id: id }, payload); 64 | if (!admin) { 65 | res.status(404).send({ msg: `Admin with id ${id} not found` }); 66 | } 67 | res.status(200).send(`Admin with id ${id} updated`); 68 | } catch (error) { 69 | console.log(error); 70 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 71 | } 72 | }); 73 | 74 | router.delete("/:adminId", async (req, res) => { 75 | const id = req.params.adminId; 76 | try { 77 | const admin = await AdminModel.findByIdAndDelete({ _id: id }); 78 | if (!admin) { 79 | res.status(404).send({ msg: `Admin with id ${id} not found` }); 80 | } 81 | res.status(200).send(`Admin with id ${id} deleted`); 82 | } catch (error) { 83 | console.log(error); 84 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 85 | } 86 | }); 87 | 88 | router.post("/password", (req, res) => { 89 | const { email, userId, password } = req.body; 90 | 91 | const transporter = nodemailer.createTransport({ 92 | service: "gmail", 93 | auth: { 94 | user: "agrawaljoy1@gmail.com", 95 | pass: "zxkyjqfuhiizmxrg", 96 | }, 97 | }); 98 | 99 | const mailOptions = { 100 | from: "agrawaljoy1@gmail.com", 101 | to: email, 102 | subject: "Account ID and Password", 103 | text: `This is your User Id : ${userId} and Password : ${password} .`, 104 | }; 105 | 106 | transporter.sendMail(mailOptions, (error, info) => { 107 | if (error) { 108 | return res.send(error); 109 | } 110 | return res.send("Password reset email sent"); 111 | }); 112 | }); 113 | 114 | router.post("/forgot", async (req, res) => { 115 | const { email, type } = req.body; 116 | let user; 117 | let userId; 118 | let password; 119 | 120 | if (type == "nurse") { 121 | user = await NurseModel.find({ email }); 122 | userId = user[0]?.nurseID; 123 | password = user[0]?.password; 124 | } 125 | if (type == "patient") { 126 | user = await PatientModel.find({ email }); 127 | userId = user[0]?.nurseID; 128 | password = user[0]?.password; 129 | } 130 | 131 | if (type == "admin") { 132 | user = await AdminModel.find({ email }); 133 | userId = user[0]?.adminID; 134 | password = user[0]?.password; 135 | } 136 | 137 | if (type == "doctor") { 138 | user = await DoctorModel.find({ email }); 139 | userId = user[0]?.docID; 140 | password = user[0]?.password; 141 | } 142 | 143 | if (!user) { 144 | return res.send({ message: "User not found" }); 145 | } 146 | 147 | const transporter = nodemailer.createTransport({ 148 | service: "gmail", 149 | auth: { 150 | user: "agrawaljoy1@gmail.com", 151 | pass: "zxkyjqfuhiizmxrg", 152 | }, 153 | }); 154 | 155 | const mailOptions = { 156 | from: "agrawaljoy1@gmail.com", 157 | to: email, 158 | subject: "Account ID and Password", 159 | text: `This is your User Id : ${userId} and Password : ${password} .`, 160 | }; 161 | 162 | transporter.sendMail(mailOptions, (error, info) => { 163 | if (error) { 164 | return res.send(error); 165 | } 166 | return res.send("Password reset email sent"); 167 | }); 168 | }); 169 | 170 | module.exports = router; 171 | -------------------------------------------------------------------------------- /Backend/routes/Ambulances.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { AmbulanceModel } = require("../models/Ambulance.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | let query = req.query; 8 | try { 9 | const ambulances = await AmbulanceModel.find(query); 10 | res.status(200).send(ambulances); 11 | } catch (error) { 12 | console.log(error); 13 | res.status(400).send({ error: "Something went wrong" }); 14 | } 15 | }); 16 | 17 | router.post("/add", async (req, res) => { 18 | const payload = req.body; 19 | try { 20 | const ambulance = new AmbulanceModel(payload); 21 | await ambulance.save(); 22 | } catch (error) { 23 | res.send(error); 24 | } 25 | res.send("Ambulance Added Successfully"); 26 | }); 27 | 28 | router.patch("/:ambulanceId", async (req, res) => { 29 | const id = req.params.ambulanceId; 30 | const payload = req.body; 31 | try { 32 | const ambulance = await AmbulanceModel.findByIdAndUpdate( 33 | { _id: id }, 34 | payload 35 | ); 36 | if (!ambulance) { 37 | res.status(404).send({ msg: `Ambulance with id ${id} not found` }); 38 | } 39 | res.status(200).send(`Ambulance with id ${id} updated`); 40 | } catch (error) { 41 | console.log(error); 42 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 43 | } 44 | }); 45 | 46 | router.delete("/:ambulanceId", async (req, res) => { 47 | const id = req.params.ambulanceId; 48 | try { 49 | const ambulance = await AmbulanceModel.findByIdAndDelete({ _id: id }); 50 | if (!ambulance) { 51 | res.status(404).send({ msg: `Ambulance with id ${id} not found` }); 52 | } 53 | res.status(200).send(`Ambulance with id ${id} deleted`); 54 | } catch (error) { 55 | console.log(error); 56 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 57 | } 58 | }); 59 | 60 | module.exports = router; 61 | -------------------------------------------------------------------------------- /Backend/routes/Appointments.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { AppointmentModel } = require("../models/Appointment.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | let query = req.query; 8 | try { 9 | const appointments = await AppointmentModel.find(query); 10 | res.status(200).send(appointments); 11 | } catch (error) { 12 | console.log(error); 13 | res.status(400).send({ error: "Something went wrong" }); 14 | } 15 | }); 16 | 17 | router.post("/create", async (req, res) => { 18 | const payload = req.body; 19 | try { 20 | const appointment = new AppointmentModel(payload); 21 | await appointment.save(); 22 | } catch (error) { 23 | res.send(error); 24 | } 25 | res.send("Appointment successfully booked."); 26 | }); 27 | 28 | router.patch("/:appointmentId", async (req, res) => { 29 | const id = req.params.appointmentId; 30 | const payload = req.body; 31 | try { 32 | const appointment = await AppointmentModel.findByIdAndUpdate( 33 | { _id: id }, 34 | payload 35 | ); 36 | if (!appointment) { 37 | res.status(404).send({ msg: `Appointment with id ${id} not found` }); 38 | } 39 | res.status(200).send(`Appointment with id ${id} updated`); 40 | } catch (error) { 41 | console.log(error); 42 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 43 | } 44 | }); 45 | 46 | router.delete("/:appointmentId", async (req, res) => { 47 | const id = req.params.appointmentId; 48 | try { 49 | const appointment = await AppointmentModel.findByIdAndDelete({ _id: id }); 50 | if (!appointment) { 51 | res.status(404).send({ msg: `Appointment with id ${id} not found` }); 52 | } 53 | res.status(200).send(`Appointment with id ${id} deleted`); 54 | } catch (error) { 55 | console.log(error); 56 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 57 | } 58 | }); 59 | 60 | module.exports = router; 61 | -------------------------------------------------------------------------------- /Backend/routes/Beds.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { BedModel } = require("../models/Bed.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | try { 8 | const beds = await BedModel.find().populate([ 9 | { 10 | path: "patientID", 11 | populate: { 12 | path: "docID", 13 | }, 14 | }, 15 | { 16 | path: "patientID", 17 | populate: { 18 | path: "nurseID", 19 | }, 20 | }, 21 | ]); 22 | res.status(200).send(beds); 23 | } catch (error) { 24 | console.log(error); 25 | res.status(400).send({ error: "Something went wrong" }); 26 | } 27 | }); 28 | 29 | router.post("/single", async (req, res) => { 30 | const { bedNumber, roomNumber } = req.body; 31 | try { 32 | const bed = await BedModel.find({ bedNumber, roomNumber }); 33 | if (bed.length === 0) { 34 | return res.send({ message: "Bed not found" }); 35 | } 36 | if (bed[0].occupied === "available") { 37 | return res.send({ message: "Available", id: bed[0]._id }); 38 | } 39 | return res.send({ message: "Occupied" }); 40 | } catch (error) { 41 | res.send({ message: "No Bed", error }); 42 | } 43 | }); 44 | 45 | router.post("/add", async (req, res) => { 46 | const { bedNumber, roomNumber } = req.body; 47 | 48 | try { 49 | const bed = await BedModel.find({ bedNumber, roomNumber }); 50 | if (bed.length > 0) { 51 | return res.send({ message: "Bed already present" }); 52 | } else { 53 | const bed = new BedModel(req.body); 54 | await bed.save(); 55 | return res.send({ message: "Bed added successfully", bed }); 56 | } 57 | } catch (error) { 58 | res.send("Something went wrong, unable to add Bed."); 59 | console.log(error); 60 | } 61 | }); 62 | 63 | router.patch("/:bedId", async (req, res) => { 64 | const id = req.params.bedId; 65 | const payload = req.body; 66 | try { 67 | const bed = await BedModel.findByIdAndUpdate({ _id: id }, payload); 68 | if (!bed) { 69 | return res.status(404).send({ msg: `Bed with id ${id} not found` }); 70 | } 71 | return res.status(200).send(`Bed with id ${id} updated`); 72 | } catch (error) { 73 | console.log(error); 74 | res.status(400).send({ error }); 75 | } 76 | }); 77 | 78 | router.put("/discharge", async (req, res) => { 79 | const { _id } = req.body; 80 | try { 81 | const bed = BedModel.findById(_id); 82 | if (!bed) { 83 | return res.status(404).send({ message: `Bed not found` }); 84 | } 85 | await BedModel.findByIdAndUpdate({ _id }, req.body); 86 | await BedModel.updateOne({ _id }, { $unset: { patientID: 1 } }); 87 | const updatedBed = await BedModel.findById(_id); 88 | return res.status(200).send({ message: "Bed updated", bed: updatedBed }); 89 | } catch (error) { 90 | res.send({ message: error }); 91 | } 92 | 93 | // res.send({ message: "Successful" }); 94 | }); 95 | 96 | router.delete("/:bedId", async (req, res) => { 97 | const id = req.params.bedId; 98 | try { 99 | const bed = await BedModel.findByIdAndDelete({ _id: id }); 100 | if (!bed) { 101 | res.status(404).send({ msg: `Bed with id ${id} not found` }); 102 | } 103 | res.status(200).send(`Bed with id ${id} deleted`); 104 | } catch (error) { 105 | console.log(error); 106 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 107 | } 108 | }); 109 | 110 | module.exports = router; 111 | -------------------------------------------------------------------------------- /Backend/routes/Doctors.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { DoctorModel } = require("../models/Doctor.model"); 3 | require("dotenv").config(); 4 | const jwt = require("jsonwebtoken"); 5 | 6 | const router = express.Router(); 7 | 8 | router.get("/", async (req, res) => { 9 | try { 10 | const doctors = await DoctorModel.find(); 11 | res.status(200).send(doctors); 12 | } catch (error) { 13 | console.log(error); 14 | res.status(400).send({ error: "Something went wrong" }); 15 | } 16 | }); 17 | 18 | router.post("/register", async (req, res) => { 19 | const { email } = req.body; 20 | try { 21 | const doctor = await DoctorModel.findOne({ email }); 22 | if (doctor) { 23 | return res.send({ 24 | message: "Doctor already exists", 25 | }); 26 | } 27 | let value = new DoctorModel(req.body); 28 | await value.save(); 29 | const data = await DoctorModel.findOne({ email }); 30 | return res.send({ data, message: "Registered" }); 31 | } catch (error) { 32 | res.send({ message: "error" }); 33 | } 34 | }); 35 | 36 | router.post("/login", async (req, res) => { 37 | const { docID, password } = req.body; 38 | try { 39 | const doctor = await DoctorModel.findOne({ docID, password }); 40 | 41 | if (doctor) { 42 | const token = jwt.sign({ foo: "bar" }, process.env.key, { 43 | expiresIn: "24h", 44 | }); 45 | res.send({ message: "Successful", user: doctor, token: token }); 46 | } else { 47 | res.send({ message: "Wrong credentials" }); 48 | } 49 | } catch (error) { 50 | console.log({ message: "Error" }); 51 | console.log(error); 52 | } 53 | }); 54 | 55 | router.patch("/:doctorId", async (req, res) => { 56 | const id = req.params.doctorId; 57 | const payload = req.body; 58 | try { 59 | await DoctorModel.findByIdAndUpdate({ _id: id }, payload); 60 | const doctor = await DoctorModel.findById(id); 61 | if (!doctor) { 62 | return res 63 | .status(404) 64 | .send({ message: `Doctor with id ${id} not found` }); 65 | } 66 | res.status(200).send({ message: `Doctor Updated`, user: doctor }); 67 | } catch (error) { 68 | console.log(error); 69 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 70 | } 71 | }); 72 | 73 | router.delete("/:doctorId", async (req, res) => { 74 | const id = req.params.doctorId; 75 | try { 76 | const doctor = await DoctorModel.findByIdAndDelete({ _id: id }); 77 | if (!doctor) { 78 | res.status(404).send({ msg: `Doctor with id ${id} not found` }); 79 | } 80 | res.status(200).send(`Doctor with id ${id} deleted`); 81 | } catch (error) { 82 | console.log(error); 83 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 84 | } 85 | }); 86 | 87 | module.exports = router; 88 | -------------------------------------------------------------------------------- /Backend/routes/Hospitals.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { AdminModel } = require("../models/Admin.model"); 3 | const { AmbulanceModel } = require("../models/Ambulance.model"); 4 | const { AppointmentModel } = require("../models/Appointment.model"); 5 | const { BedModel } = require("../models/Bed.model"); 6 | const { DoctorModel } = require("../models/Doctor.model"); 7 | const { NurseModel } = require("../models/Nurse.model"); 8 | const { PatientModel } = require("../models/Patient.model"); 9 | const { ReportModel } = require("../models/Report.model"); 10 | 11 | const router = express.Router(); 12 | 13 | router.get("/", async (req, res) => { 14 | try { 15 | let admins = await AdminModel.find(); 16 | let patients = await PatientModel.find(); 17 | let ambulances = await AmbulanceModel.find(); 18 | let nurses = await NurseModel.find(); 19 | let beds = await BedModel.find(); 20 | let reports = await ReportModel.find(); 21 | let appointments = await AppointmentModel.find(); 22 | let doctors = await DoctorModel.find(); 23 | let data = { 24 | admin: admins.length, 25 | patient: patients.length, 26 | ambulance: ambulances.length, 27 | nurse: nurses.length, 28 | bed: beds.length, 29 | report: reports.length, 30 | doctor: doctors.length, 31 | appointment: appointments.length, 32 | }; 33 | res.status(200).send({ data }); 34 | } catch (error) { 35 | console.log(error); 36 | res.status(400).send({ error: "Something went wrong" }); 37 | } 38 | }); 39 | 40 | module.exports = router; 41 | -------------------------------------------------------------------------------- /Backend/routes/Nurses.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { NurseModel } = require("../models/Nurse.model"); 3 | require("dotenv").config(); 4 | const jwt = require("jsonwebtoken"); 5 | 6 | const router = express.Router(); 7 | 8 | router.get("/", async (req, res) => { 9 | try { 10 | const nurses = await NurseModel.find(); 11 | res.status(200).send(nurses); 12 | } catch (error) { 13 | console.log(error); 14 | res.status(400).send({ error: "Something went wrong" }); 15 | } 16 | }); 17 | 18 | 19 | router.post("/register", async (req, res) => { 20 | const { email } = req.body; 21 | try { 22 | const nurse = await NurseModel.findOne({ email }); 23 | if (nurse) { 24 | return res.send({ 25 | message: "Nurse already exists", 26 | }); 27 | } 28 | let value = new NurseModel(req.body); 29 | await value.save(); 30 | const data = await NurseModel.findOne({ email }); 31 | return res.send({ data, message: "Registered" }); 32 | } catch (error) { 33 | res.send({ message: "error" }); 34 | } 35 | }); 36 | 37 | 38 | router.post("/login", async (req, res) => { 39 | const { nurseID, password } = req.body; 40 | try { 41 | const nurse = await NurseModel.findOne({ nurseID, password }); 42 | 43 | if (nurse) { 44 | const token = jwt.sign({ foo: "bar" }, process.env.key, { 45 | expiresIn: "24h", 46 | }); 47 | res.send({ message: "Successful", user: nurse, token: token }); 48 | } else { 49 | res.send({ message: "Wrong credentials" }); 50 | } 51 | } catch (error) { 52 | console.log({ message: "Error" }); 53 | console.log(error); 54 | } 55 | }); 56 | 57 | router.patch("/:nurseId", async (req, res) => { 58 | const id = req.params.nurseId; 59 | const payload = req.body; 60 | try { 61 | await NurseModel.findByIdAndUpdate({ _id: id }, payload); 62 | const nurse = await NurseModel.findById(id); 63 | if (!nurse) { 64 | return res.status(404).send({ message: `Nurse with id ${id} not found` }); 65 | } 66 | res.status(200).send({ message: `Nurse Updated`, user: nurse }); 67 | } catch (error) { 68 | console.log(error); 69 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 70 | } 71 | }); 72 | 73 | router.delete("/:nurseId", async (req, res) => { 74 | const id = req.params.nurseId; 75 | try { 76 | const nurse = await NurseModel.findByIdAndDelete({ _id: id }); 77 | if (!nurse) { 78 | res.status(404).send({ msg: `Nurse with id ${id} not found` }); 79 | } 80 | res.status(200).send(`Nurse with id ${id} deleted`); 81 | } catch (error) { 82 | console.log(error); 83 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 84 | } 85 | }); 86 | 87 | module.exports = router; 88 | -------------------------------------------------------------------------------- /Backend/routes/Patients.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { PatientModel } = require("../models/Patient.model"); 3 | require("dotenv").config(); 4 | const jwt = require("jsonwebtoken"); 5 | const { ReportModel } = require("../models/Report.model"); 6 | 7 | const router = express.Router(); 8 | 9 | router.get("/", async (req, res) => { 10 | try { 11 | const patients = await PatientModel.find(); 12 | res.status(200).send({ patients }); 13 | } catch (error) { 14 | console.log(error); 15 | res.status(400).send({ error: "Something went wrong" }); 16 | } 17 | }); 18 | 19 | // This register route will be used when adding a patient via patient or doctor or admin 20 | router.post("/register", async (req, res) => { 21 | const { email } = req.body; 22 | try { 23 | const patient = await PatientModel.findOne({ email }); 24 | if (patient) { 25 | return res.send({ 26 | message: "Patient already exists", 27 | id: patient.patientID, 28 | }); 29 | } 30 | const newPatient = new PatientModel(req.body); 31 | await newPatient.save(); 32 | res.send({ id: newPatient.patientID }); 33 | } catch (error) { 34 | res.send({ error }); 35 | } 36 | }); 37 | 38 | router.post("/login", async (req, res) => { 39 | const { patientID, password } = req.body; 40 | try { 41 | const patient = await PatientModel.findOne({ patientID, password }); 42 | 43 | if (patient) { 44 | const token = jwt.sign({ foo: "bar" }, process.env.key, { 45 | expiresIn: "24h", 46 | }); 47 | let email = patient.email; 48 | let report = await ReportModel.find({ email }); 49 | res.send({ 50 | message: "Login Successful.", 51 | user: patient, 52 | token: token, 53 | report, 54 | }); 55 | } else { 56 | res.send({ message: "Wrong credentials, Please try again." }); 57 | } 58 | } catch (error) { 59 | console.log({ message: "Error occurred, unable to Login." }); 60 | console.log(error); 61 | } 62 | }); 63 | 64 | // Only Admin should be able to update or delete patient 65 | router.patch("/:patientId", async (req, res) => { 66 | const id = req.params.patientId; 67 | const payload = req.body; 68 | try { 69 | const patient = await PatientModel.findByIdAndUpdate({ _id: id }, payload); 70 | if (!patient) { 71 | res.status(404).send({ msg: `Patient with id ${id} not found` }); 72 | } 73 | res.status(200).send(`Patient with id ${id} updated`); 74 | } catch (error) { 75 | console.log(error); 76 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 77 | } 78 | }); 79 | 80 | router.delete("/:patientId", async (req, res) => { 81 | const id = req.params.patientId; 82 | try { 83 | const patient = await PatientModel.findByIdAndDelete({ _id: id }); 84 | if (!patient) { 85 | res.status(404).send({ msg: `Patient with id ${id} not found` }); 86 | } 87 | res.status(200).send(`Patient with id ${id} deleted`); 88 | } catch (error) { 89 | console.log(error); 90 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 91 | } 92 | }); 93 | 94 | module.exports = router; 95 | -------------------------------------------------------------------------------- /Backend/routes/Payments.route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { PaymentModel } = require("../models/Payment.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | try { 8 | const payments = await PaymentModel.find().populate({ 9 | path: "reportID", 10 | }); 11 | res.status(200).send(payments); 12 | } catch (error) { 13 | console.log(error); 14 | res.status(400).send({ error: "Something went wrong" }); 15 | } 16 | }); 17 | 18 | router.post("/add", async (req, res) => { 19 | const payload = req.body; 20 | try { 21 | const payment = new PaymentModel(payload); 22 | await payment.save(); 23 | res.send({ message: "Payment created successfully" }); 24 | } catch (error) { 25 | res.send("Error occurred, unable to receive the payment."); 26 | console.log(error); 27 | } 28 | }); 29 | 30 | router.patch("/:paymentId", async (req, res) => { 31 | const id = req.params.paymentId; 32 | const payload = req.body; 33 | try { 34 | const payment = await PaymentModel.findByIdAndUpdate({ _id: id }, payload); 35 | if (!payment) { 36 | res.status(404).send({ msg: `Payment with id ${id} not found` }); 37 | } 38 | res.status(200).send(`Payment with id ${id} updated`); 39 | } catch (error) { 40 | console.log(error); 41 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 42 | } 43 | }); 44 | 45 | router.delete("/:paymentId", async (req, res) => { 46 | const id = req.params.paymentId; 47 | try { 48 | const payment = await PaymentModel.findByIdAndDelete({ _id: id }); 49 | if (!payment) { 50 | res.status(404).send({ msg: `Payment with id ${id} not found` }); 51 | } 52 | res.status(200).send(`Payment with id ${id} deleted`); 53 | } catch (error) { 54 | console.log(error); 55 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 56 | } 57 | }); 58 | 59 | module.exports = router; 60 | -------------------------------------------------------------------------------- /Backend/routes/Prescriptions.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { PrescriptionModel } = require("../models/Prescription.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | let query = req.query; 8 | try { 9 | const prescriptions = await PrescriptionModel.find(query); 10 | res.status(200).send(prescriptions); 11 | } catch (error) { 12 | console.log(error); 13 | res.status(400).send({ error: "Something went wrong" }); 14 | } 15 | }); 16 | 17 | router.post("/create", async (req, res) => { 18 | const payload = req.body; 19 | try { 20 | const prescription = new PrescriptionModel(payload); 21 | await prescription.save(); 22 | } catch (error) { 23 | res.send("Error occurred, unable to create a prescription."); 24 | console.log(error); 25 | } 26 | res.send("Prescription successfully created."); 27 | }); 28 | 29 | router.patch("/:prescriptionId", async (req, res) => { 30 | const id = req.params.prescriptionId; 31 | const payload = req.body; 32 | try { 33 | const prescription = await PrescriptionModel.findByIdAndUpdate( 34 | { _id: id }, 35 | payload 36 | ); 37 | if (!prescription) { 38 | res.status(404).send({ msg: `Prescription with id ${id} not found` }); 39 | } 40 | res.status(200).send(`Prescription with id ${id} updated`); 41 | } catch (error) { 42 | console.log(error); 43 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 44 | } 45 | }); 46 | 47 | router.delete("/:prescriptionId", async (req, res) => { 48 | const id = req.params.prescriptionId; 49 | try { 50 | const prescription = await PrescriptionModel.findByIdAndDelete({ _id: id }); 51 | if (!prescription) { 52 | res.status(404).send({ msg: `Prescription with id ${id} not found` }); 53 | } 54 | res.status(200).send(`Prescription with id ${id} deleted`); 55 | } catch (error) { 56 | console.log(error); 57 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 58 | } 59 | }); 60 | 61 | module.exports = router; 62 | -------------------------------------------------------------------------------- /Backend/routes/Reports.Route.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const { ReportModel } = require("../models/Report.model"); 3 | 4 | const router = express.Router(); 5 | 6 | router.get("/", async (req, res) => { 7 | let query = req.query; 8 | try { 9 | const reports = await ReportModel.find(query); 10 | res.status(200).send(reports); 11 | } catch (error) { 12 | console.log(error); 13 | res.status(400).send({ error: "Something went wrong" }); 14 | } 15 | }); 16 | 17 | router.post("/create", async (req, res) => { 18 | const payload = req.body; 19 | try { 20 | const report = new ReportModel(payload); 21 | await report.save(); 22 | res.send({ message: "Report successfully created", report }); 23 | } catch (error) { 24 | res.send(error); 25 | } 26 | }); 27 | 28 | router.patch("/:reportId", async (req, res) => { 29 | const id = req.params.reportId; 30 | const payload = req.body; 31 | try { 32 | const report = await ReportModel.findByIdAndUpdate({ _id: id }, payload); 33 | if (!report) { 34 | res.status(404).send({ msg: `Report with id ${id} not found` }); 35 | } 36 | res.status(200).send(`Report with id ${id} updated`); 37 | } catch (error) { 38 | console.log(error); 39 | res.status(400).send({ error: "Something went wrong, unable to Update." }); 40 | } 41 | }); 42 | 43 | router.delete("/:reportId", async (req, res) => { 44 | const id = req.params.reportId; 45 | try { 46 | const report = await ReportModel.findByIdAndDelete({ _id: id }); 47 | if (!report) { 48 | res.status(404).send({ msg: `Report with id ${id} not found` }); 49 | } 50 | res.status(200).send(`Report with id ${id} deleted`); 51 | } catch (error) { 52 | console.log(error); 53 | res.status(400).send({ error: "Something went wrong, unable to Delete." }); 54 | } 55 | }); 56 | 57 | module.exports = router; 58 | -------------------------------------------------------------------------------- /FrontEnd/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /FrontEnd/README.md: -------------------------------------------------------------------------------- 1 | 2 | ## To Run Locally 3 | 4 | Clone the project 5 | 6 | ```bash 7 | git clone https://github.com/piyush-agrawal6/Hospital-Management-System.git 8 | ``` 9 | 10 | Go to the project directory 11 | 12 | ```bash 13 | cd Hospital-Management-System 14 | ``` 15 | 16 | Install dependencies 17 | 18 | ```bash 19 | npm install 20 | ``` 21 | 22 | Start the server 23 | 24 | ```bash 25 | npm run start 26 | ``` 27 | 28 | 29 | # Hospital Management System 30 | 31 | This a software to control all the management related to a hospital , like admitting patient , booking bed , calling a ambulance , managing payment and more. 32 | 33 | 34 | 35 | 36 | ## Tech Stack 37 | 38 | **Client:** 39 | 40 | - **React** 41 | - **Redux Thunk** 42 | - **Axios** 43 | - **Ant-Designs** 44 | 45 | **Server:** 46 | 47 | - **Node Js** 48 | - **Mongo DB** 49 | - **Express Js** 50 | - **Render** 51 | - **JWT** 52 | 53 | 54 | ## 🔗 Links 55 | Client - https://brain-labs.netlify.app/ 56 | 57 | Server - https://github.com/piyush-agrawal6/HMS-Backend 58 | 59 | ## Features 60 | 61 | - Admin controls 62 | - CRUD Operations 63 | - Admit Patients 64 | - Payment 65 | - Appointment booking 66 | 67 | 68 | ## Screenshots 69 | 70 | 71 | 1.Dashboard 72 | 73 | ![App Screenshot](https://i.ibb.co/1K6N1Hk/21-12-2022-12-45-28-REC.png) 74 | 75 | 76 | ## Blog / Presentation 77 | 78 | Presentation - 79 | 80 | Blog - 81 | 82 | 83 | ## Team Members / Contributors 84 | 85 | - [@Piyush Agrawal](https://github.com/piyush-agrawal6) 86 | - [@Udhaya Prakash](https://github.com/udhai-20) 87 | - [@Rajendra Patel](https://github.com/centauricoder01) 88 | 89 | -------------------------------------------------------------------------------- /FrontEnd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hms-backend", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@fullcalendar/core": "^6.0.3", 7 | "@fullcalendar/daygrid": "^6.0.3", 8 | "@fullcalendar/list": "^6.0.3", 9 | "@fullcalendar/timegrid": "^6.0.3", 10 | "@testing-library/jest-dom": "^5.16.5", 11 | "@testing-library/react": "^13.4.0", 12 | "@testing-library/user-event": "^13.5.0", 13 | "antd": "^5.0.3", 14 | "axios": "^1.2.0", 15 | "react": "^18.2.0", 16 | "react-dom": "^18.2.0", 17 | "react-icons": "^4.7.1", 18 | "react-redux": "^8.0.5", 19 | "react-router-dom": "^6.4.4", 20 | "react-scripts": "5.0.1", 21 | "react-toastify": "^9.1.1", 22 | "redux": "^4.2.0", 23 | "redux-thunk": "^2.4.2", 24 | "web-vitals": "^2.1.4" 25 | }, 26 | "scripts": { 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": [ 34 | "react-app", 35 | "react-app/jest" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FrontEnd/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centauricoder01/Hospital_Management_System/9a130466bc726006dc444de8b01c29854bf046e2/FrontEnd/public/favicon.ico -------------------------------------------------------------------------------- /FrontEnd/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /FrontEnd/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centauricoder01/Hospital_Management_System/9a130466bc726006dc444de8b01c29854bf046e2/FrontEnd/public/logo192.png -------------------------------------------------------------------------------- /FrontEnd/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/centauricoder01/Hospital_Management_System/9a130466bc726006dc444de8b01c29854bf046e2/FrontEnd/public/logo512.png -------------------------------------------------------------------------------- /FrontEnd/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /FrontEnd/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /FrontEnd/src/App.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700&display=swap"); 2 | 3 | * { 4 | margin: 0; 5 | padding: 0; 6 | box-sizing: border-box; 7 | } 8 | 9 | body { 10 | font-family: "Poppins", sans-serif; 11 | } 12 | 13 | .inputdiv input::placeholder { 14 | font-family: "Poppins", sans-serif; 15 | opacity: 1; /* Firefox */ 16 | } 17 | -------------------------------------------------------------------------------- /FrontEnd/src/App.js: -------------------------------------------------------------------------------- 1 | import "./App.css"; 2 | import AllRoutes from "./Routes/AllRoutes"; 3 | 4 | function App() { 5 | return ( 6 | <> 7 | 8 | 9 | ); 10 | } 11 | 12 | export default App; 13 | -------------------------------------------------------------------------------- /FrontEnd/src/Components/Footer/Footer.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const Footer = () => { 4 | return ( 5 |
Footer
6 | ) 7 | } 8 | 9 | export default Footer -------------------------------------------------------------------------------- /FrontEnd/src/Components/Navbar/Navbar.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | 3 | const Navbar = () => { 4 | return
Navbar
; 5 | }; 6 | 7 | export default Navbar; 8 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Dashboard-Login/DLogin.css: -------------------------------------------------------------------------------- 1 | .mainLoginPage { 2 | display: flex; 3 | justify-content: center; 4 | align-items: center; 5 | gap: 10rem; 6 | height: 100vh; 7 | background-color: rgba(255, 243, 243, 0.874); 8 | } 9 | 10 | .leftside { 11 | width: 50%; 12 | } 13 | 14 | .leftside img { 15 | width: 100%; 16 | } 17 | 18 | /* ********************************************************************** */ 19 | 20 | .rightside { 21 | padding: 2rem; 22 | align-items: center; 23 | text-align: center; 24 | width: 35%; 25 | border-radius: 10px; 26 | background-color: white; 27 | } 28 | 29 | .Profileimg { 30 | margin: auto; 31 | width: 26%; 32 | margin-top: 2rem; 33 | } 34 | 35 | .Profileimg img { 36 | width: 5rem; 37 | border-radius: 5rem; 38 | /* border: 1px solid red; */ 39 | } 40 | 41 | .radiobutton { 42 | width: 33%; 43 | font-size: 1.2rem; 44 | font-weight: bold; 45 | } 46 | 47 | .rightside > h1 { 48 | margin: 2rem; 49 | } 50 | 51 | .rightside input { 52 | display: block; 53 | width: 100%; 54 | background-color: rgba(250, 225, 225, 0.874); 55 | height: 3rem; 56 | font-size: 1.2rem; 57 | margin: 10px 0px; 58 | border-radius: 5px; 59 | border: none; 60 | padding: 10px; 61 | } 62 | 63 | .rightside button { 64 | width: 100%; 65 | height: 2.5rem; 66 | border-radius: 2rem; 67 | cursor: pointer; 68 | font-size: 1.3rem; 69 | font-weight: bolder; 70 | background-color: rgba(244, 133, 133, 0.874); 71 | border: none; 72 | margin-top: 1.5rem; 73 | } 74 | 75 | form h3 { 76 | text-align: left; 77 | } 78 | 79 | @media only screen and (max-width: 1024px) { 80 | .mainLoginPage { 81 | gap: 5rem; 82 | } 83 | 84 | .leftside { 85 | width: 45%; 86 | } 87 | .rightside { 88 | width: 40%; 89 | } 90 | } 91 | 92 | @media only screen and (max-width: 770px) { 93 | .mainLoginPage { 94 | gap: 0rem; 95 | } 96 | 97 | .leftside { 98 | display: none; 99 | } 100 | .rightside { 101 | width: 60%; 102 | } 103 | } 104 | 105 | @media only screen and (max-width: 550px) { 106 | .rightside { 107 | width: 80%; 108 | } 109 | } 110 | 111 | @media only screen and (max-width: 400px) { 112 | .rightside { 113 | width: 95%; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Dashboard-Login/DLogin.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { Radio } from "antd"; 3 | import banner from "../../../img/banner.png"; 4 | import admin from "../../../img/admin.jpg"; 5 | import "./DLogin.css"; 6 | import { useDispatch } from "react-redux"; 7 | import { useNavigate } from "react-router-dom"; 8 | import { 9 | AdminLogin, 10 | DoctorLogin, 11 | forgetPassword, 12 | NurseLogin, 13 | } from "../../../Redux/auth/action"; 14 | import { ToastContainer, toast } from "react-toastify"; 15 | import "react-toastify/dist/ReactToastify.css"; 16 | import { Drawer } from "antd"; 17 | const notify = (text) => toast(text); 18 | 19 | const DLogin = () => { 20 | const [open, setOpen] = useState(false); 21 | 22 | const showDrawer = () => { 23 | setOpen(true); 24 | }; 25 | 26 | const onClose = () => { 27 | setOpen(false); 28 | }; 29 | 30 | // ************************************************ 31 | const [Loading, setLoading] = useState(false); 32 | const [placement, SetPlacement] = useState("Nurse"); 33 | const [formvalue, setFormvalue] = useState({ 34 | ID: "", 35 | password: "", 36 | }); 37 | const dispatch = useDispatch(); 38 | 39 | const Handlechange = (e) => { 40 | setFormvalue({ ...formvalue, [e.target.name]: e.target.value }); 41 | }; 42 | const navigate = useNavigate(); 43 | const HandleSubmit = (e) => { 44 | e.preventDefault(); 45 | setLoading(true); 46 | if (formvalue.ID !== "" && formvalue.password !== "") { 47 | if (placement === "Nurse") { 48 | let data = { 49 | ...formvalue, 50 | nurseID: formvalue.ID, 51 | }; 52 | dispatch(NurseLogin(data)).then((res) => { 53 | if (res.message === "Successful") { 54 | notify("Login Successful"); 55 | setLoading(false); 56 | return navigate("/dashboard"); 57 | } 58 | if (res.message === "Wrong credentials") { 59 | setLoading(false); 60 | 61 | notify("Wrong credentials"); 62 | } 63 | if (res.message === "Error") { 64 | setLoading(false); 65 | 66 | notify("Something went Wrong, Please Try Again"); 67 | } 68 | }); 69 | } else if (placement === "Doctor") { 70 | let data = { 71 | ...formvalue, 72 | docID: formvalue.ID, 73 | }; 74 | console.log(data); 75 | dispatch(DoctorLogin(data)).then((res) => { 76 | if (res.message === "Successful") { 77 | notify("Login Successful"); 78 | setLoading(false); 79 | 80 | return navigate("/dashboard"); 81 | } 82 | if (res.message === "Wrong credentials") { 83 | setLoading(false); 84 | 85 | notify("Wrong credentials"); 86 | } 87 | if (res.message === "Error") { 88 | setLoading(false); 89 | 90 | notify("Something went Wrong, Please Try Again"); 91 | } 92 | }); 93 | } else if (placement === "Admin") { 94 | let data = { 95 | ...formvalue, 96 | adminID: formvalue.ID, 97 | }; 98 | dispatch(AdminLogin(data)).then((res) => { 99 | if (res.message === "Successful") { 100 | notify("Login Successful"); 101 | setLoading(false); 102 | 103 | return navigate("/dashboard"); 104 | } 105 | if (res.message === "Wrong credentials") { 106 | setLoading(false); 107 | 108 | notify("Wrong credentials"); 109 | } 110 | if (res.message === "Error") { 111 | setLoading(false); 112 | 113 | notify("Something went Wrong, Please Try Again"); 114 | } 115 | }); 116 | } 117 | } 118 | }; 119 | 120 | const placementChange = (e) => { 121 | SetPlacement(e.target.value); 122 | }; 123 | 124 | const [ForgetPassword, setForgetPassword] = useState({ 125 | type: "", 126 | email: "", 127 | }); 128 | 129 | const HandleForgetPassword = (e) => { 130 | setForgetPassword({ ...ForgetPassword, [e.target.name]: e.target.value }); 131 | }; 132 | 133 | const [forgetLoading, setforgetLoading] = useState(false); 134 | 135 | const HandleChangePassword = () => { 136 | if (ForgetPassword.type === "") { 137 | return notify("Please Fill all Details"); 138 | } 139 | setforgetLoading(true); 140 | dispatch(forgetPassword(ForgetPassword)).then((res) => { 141 | if (res.message === "User not found") { 142 | setforgetLoading(false); 143 | return notify("User Not Found"); 144 | } 145 | setForgetPassword({ 146 | type: "", 147 | email: "", 148 | }); 149 | onClose(); 150 | setforgetLoading(false); 151 | return notify("Account Details Send"); 152 | }); 153 | }; 154 | 155 | return ( 156 | <> 157 | 158 | 159 |
160 |
161 | banner 162 |
163 |
164 |

Login

165 |
166 | 171 | 172 | Nurse 173 | 174 | 175 | Doctor 176 | 177 | 178 | Admin 179 | 180 | 181 |
182 |
183 | profile 184 |
185 |
186 |
187 |

{placement} ID

188 | 195 |

Password

196 | 203 | 204 |

205 | Forget Password?{" "} 206 | 210 | Get it on Email ! 211 | 212 |

213 | 214 | {/* ********************************************************* */} 215 | 221 |
222 | 223 | 224 | 235 |
236 |
237 | 240 | 258 |
259 | 260 | 277 |
278 |
279 |
280 |
281 |
282 | 283 | ); 284 | }; 285 | 286 | export default DLogin; 287 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Main-Dashboard/AllPages/Admin/AddBeds.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { useDispatch, useSelector } from "react-redux"; 3 | import Sidebar from "../../GlobalFiles/Sidebar"; 4 | import { AddBed } from "../../../../../Redux/Datas/action"; 5 | import { ToastContainer, toast } from "react-toastify"; 6 | import "react-toastify/dist/ReactToastify.css"; 7 | import { Navigate } from "react-router-dom"; 8 | const notify = (text) => toast(text); 9 | 10 | const AddBeds = () => { 11 | const { data } = useSelector((store) => store.auth); 12 | 13 | const InitData = { 14 | roomNumber: "none", 15 | bedNumber: "", 16 | occupied: "available", 17 | }; 18 | const [BedData, setBedData] = useState(InitData); 19 | 20 | const [loading, setloading] = useState(false); 21 | 22 | const dispatch = useDispatch(); 23 | 24 | const HandleAmbuChange = (e) => { 25 | setBedData({ 26 | ...BedData, 27 | [e.target.name]: e.target.value, 28 | }); 29 | }; 30 | 31 | const HandleAmbuSubmit = (e) => { 32 | e.preventDefault(); 33 | setloading(true); 34 | dispatch(AddBed(BedData)); 35 | setloading(false); 36 | setBedData(InitData); 37 | notify("Bed Added"); 38 | }; 39 | 40 | if (data?.isAuthticated === false) { 41 | return ; 42 | } 43 | 44 | if (data?.user.userType !== "admin") { 45 | return ; 46 | } 47 | 48 | return ( 49 | <> 50 | 51 |
52 | 53 |
54 |
55 |

Add Beds

56 | 57 | {/* ******************************************************** */} 58 |
59 |
60 | 61 |
62 | 70 |
71 |
72 |
73 | 74 |
75 | 83 |
84 |
85 | 86 | 89 |
90 |
91 |
92 |
93 | 94 | ); 95 | }; 96 | 97 | export default AddBeds; 98 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Main-Dashboard/AllPages/Admin/Add_Admin.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import { useDispatch, useSelector } from "react-redux"; 3 | import { AdminRegister, SendPassword } from "../../../../../Redux/auth/action"; 4 | import Sidebar from "../../GlobalFiles/Sidebar"; 5 | import admin from "../../../../../img/admin.jpg"; 6 | import { ToastContainer, toast } from "react-toastify"; 7 | import "react-toastify/dist/ReactToastify.css"; 8 | import { Navigate } from "react-router-dom"; 9 | const notify = (text) => toast(text); 10 | 11 | const Add_Admin = () => { 12 | const { data } = useSelector((store) => store.auth); 13 | 14 | const [loading, setloading] = useState(false); 15 | 16 | const InitData = { 17 | adminName: "", 18 | age: "", 19 | mobile: "", 20 | email: "", 21 | gender: "", 22 | DOB: "", 23 | address: "", 24 | education: "", 25 | adminID: Date.now(), 26 | password: "", 27 | }; 28 | const [AdminValue, setAdminValue] = useState(InitData); 29 | 30 | const HandleDoctorChange = (e) => { 31 | setAdminValue({ ...AdminValue, [e.target.name]: e.target.value }); 32 | }; 33 | const dispatch = useDispatch(); 34 | 35 | const HandleDoctorSubmit = (e) => { 36 | e.preventDefault(); 37 | setloading(true); 38 | dispatch(AdminRegister(AdminValue)).then((res) => { 39 | if (res.message === "Admin already exists") { 40 | setloading(false); 41 | return notify("Admin Already Exist"); 42 | } 43 | if (res.message === "error") { 44 | setloading(false); 45 | return notify("Something went wrong, Please try Again"); 46 | } 47 | notify("Admin Added"); 48 | 49 | let data = { 50 | email: res.data.email, 51 | password: res.data.password, 52 | userId: res.data.adminID, 53 | }; 54 | dispatch(SendPassword(data)).then((res) => notify("Account Detais Sent")); 55 | setloading(false); 56 | setAdminValue(InitData); 57 | }); 58 | }; 59 | 60 | if (data?.isAuthticated === false) { 61 | return ; 62 | } 63 | 64 | if (data?.user.userType !== "admin") { 65 | return ; 66 | } 67 | 68 | return ( 69 | <> 70 | 71 |
72 | 73 |
74 |
75 |

Add Admin

76 | doctor 77 |
78 |
79 | 80 |
81 | 89 |
90 |
91 |
92 | 93 |
94 | 102 |
103 |
104 |
105 | 106 |
107 | 115 |
116 |
117 |
118 | 119 |
120 | 128 |
129 |
130 |
131 | 132 |
133 | 144 |
145 |
146 |
147 | 148 |
149 | 157 |
158 |
159 |
160 | 161 |
162 | 170 |
171 |
172 |
173 | 174 |
175 | 183 |
184 |
185 |
186 | 187 |
188 | 196 |
197 |
198 | 199 | 202 |
203 |
204 |
205 |
206 | 207 | ); 208 | }; 209 | 210 | export default Add_Admin; 211 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Main-Dashboard/AllPages/Admin/Add_Ambulance.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import one from "../../../../../img/ambuone.png"; 3 | import two from "../../../../../img/ambutwo.png"; 4 | import three from "../../../../../img/ambuthree.png"; 5 | import "./CSS/Add_Ambu.css"; 6 | import { useDispatch, useSelector } from "react-redux"; 7 | import { AmbulanceRegister } from "../../../../../Redux/auth/action"; 8 | import Sidebar from "../../GlobalFiles/Sidebar"; 9 | import { ToastContainer, toast } from "react-toastify"; 10 | import "react-toastify/dist/ReactToastify.css"; 11 | import { Navigate } from "react-router-dom"; 12 | const notify = (text) => toast(text); 13 | 14 | const Add_Ambulance = () => { 15 | const { data } = useSelector((store) => store.auth); 16 | 17 | let [ambuType, setambuType] = useState("none"); 18 | 19 | const [AmbuData, setAmbuDate] = useState({ 20 | type: "none", 21 | charges: "", 22 | ambulanceID: "", 23 | ambulanceDriver: "", 24 | number: "", 25 | }); 26 | 27 | const [loading, setloading] = useState(false); 28 | 29 | const dispatch = useDispatch(); 30 | 31 | const HandleAmbuChange = (e) => { 32 | setAmbuDate({ 33 | ...AmbuData, 34 | [e.target.name]: e.target.value, 35 | }); 36 | }; 37 | 38 | const HandleAmbuSubmit = (e) => { 39 | e.preventDefault(); 40 | setloading(true); 41 | let data = { 42 | ...AmbuData, 43 | type: ambuType, 44 | }; 45 | dispatch(AmbulanceRegister(data)); 46 | setloading(false); 47 | notify("Ambulance Added"); 48 | }; 49 | 50 | if (data?.isAuthticated === false) { 51 | return ; 52 | } 53 | 54 | if (data?.user.userType !== "admin") { 55 | return ; 56 | } 57 | 58 | return ( 59 | <> 60 | 61 |
62 | 63 |
64 |
65 |

Add Ambulance

66 |
67 | first_img setambuType("Mobile ICU Ambulance")} 71 | /> 72 | first_img setambuType("Basic Life Support Ambulance")} 76 | /> 77 | first_img setambuType("Collective Ambulance")} 81 | /> 82 |
83 | {/* ******************************************************** */} 84 |
85 |
86 | 87 |
88 | 96 |
97 |
98 |
99 | 100 |
101 | 109 |
110 |
111 |
112 | 113 |
114 | 122 |
123 |
124 |
125 | 126 |
127 | 135 |
136 |
137 |
138 | 139 |
140 | 148 |
149 |
150 | 153 |
154 |
155 |
156 |
157 | 158 | ); 159 | }; 160 | 161 | export default Add_Ambulance; 162 | -------------------------------------------------------------------------------- /FrontEnd/src/Pages/Dashboard/Main-Dashboard/AllPages/Admin/Add_Doctor.jsx: -------------------------------------------------------------------------------- 1 | import React, { useState } from "react"; 2 | import "./CSS/Add_Doctor.css"; 3 | import doctor from "../../../../../img/doctoravatar.png"; 4 | import { useDispatch, useSelector } from "react-redux"; 5 | import { DoctorRegister, SendPassword } from "../../../../../Redux/auth/action"; 6 | import Sidebar from "../../GlobalFiles/Sidebar"; 7 | 8 | import { ToastContainer, toast } from "react-toastify"; 9 | import "react-toastify/dist/ReactToastify.css"; 10 | import { Navigate } from "react-router-dom"; 11 | const notify = (text) => toast(text); 12 | 13 | const AddDoctor = () => { 14 | const { data } = useSelector((store) => store.auth); 15 | 16 | const dispatch = useDispatch(); 17 | 18 | const [loading, setLoading] = useState(false); 19 | 20 | const initData = { 21 | docName: "", 22 | age: "", 23 | mobile: "", 24 | email: "", 25 | bloodGroup: "", 26 | gender: "", 27 | DOB: "", 28 | address: "", 29 | education: "", 30 | department: "", 31 | docID: Date.now(), 32 | password: "", 33 | details: "", 34 | }; 35 | const [DoctorValue, setDoctorValue] = useState(initData); 36 | 37 | const HandleDoctorChange = (e) => { 38 | setDoctorValue({ ...DoctorValue, [e.target.name]: e.target.value }); 39 | }; 40 | 41 | const HandleDoctorSubmit = (e) => { 42 | e.preventDefault(); 43 | setLoading(true); 44 | dispatch(DoctorRegister(DoctorValue)).then((res) => { 45 | if (res.message === "Doctor already exists") { 46 | setLoading(false); 47 | return notify("Doctor Already Exist"); 48 | } 49 | if (res.message === "error") { 50 | setLoading(false); 51 | return notify("Something went wrong, Please try Again"); 52 | } 53 | 54 | let data = { 55 | email: res.data.email, 56 | password: res.data.password, 57 | userId: res.data.docID, 58 | }; 59 | console.log(data, "DOCTOR REGISTER SUCCESSFULLY"); 60 | dispatch(SendPassword(data)).then((res) => notify("Account Detais Sent")); 61 | setLoading(false); 62 | setDoctorValue(initData); 63 | }); 64 | }; 65 | 66 | if (data?.isAuthticated === false) { 67 | return ; 68 | } 69 | 70 | if (data?.user.userType !== "admin") { 71 | return ; 72 | } 73 | 74 | return ( 75 | <> 76 | 77 |
78 | 79 |
80 |
81 |

Add Doctors

82 | doctor 83 |
84 |
85 | 86 |
87 | 95 |
96 |
97 |
98 | 99 |
100 | 108 |
109 |
110 |
111 | 112 |
113 | 121 |
122 |
123 |
124 | 125 |
126 | 134 |
135 |
136 |
137 | 138 |
139 | 150 |
151 |
152 |
153 | 154 |
155 | 171 |
172 |
173 |
174 | 175 |
176 | 184 |
185 |
186 |
187 | 188 |
189 | 197 |
198 |
199 |
200 | 201 |
202 | 210 |
211 |
212 |
213 | 214 |
215 | 231 |
232 |
233 | 234 |
235 | 236 |
237 | 245 |
246 |
247 |
248 | 249 |
250 |