From 6117e53e3a96dfa68257fd0bb9826361dea8e739 Mon Sep 17 00:00:00 2001 From: Anand Suthar Date: Mon, 1 Jul 2024 23:35:02 +0530 Subject: [PATCH] Added models --- src/app/models/bookedAppointment.ts | 49 ++++++++++++ src/app/models/commonDisease.ts | 18 +++++ src/app/models/doctor.ts | 105 +++++++++++++++++++++++++ src/app/models/hospital.ts | 118 ++++++++++++++++++++++++++++ src/app/models/hospitalsData.ts | 59 ++++++++++++++ src/app/models/index.ts | 23 ++++++ src/app/models/medicalHistory.ts | 55 +++++++++++++ src/app/models/patient.ts | 99 +++++++++++++++++++++++ src/app/models/receptionist.ts | 73 +++++++++++++++++ src/app/models/transaction.ts | 38 +++++++++ src/app/models/userLog.ts | 33 ++++++++ 11 files changed, 670 insertions(+) create mode 100644 src/app/models/bookedAppointment.ts create mode 100644 src/app/models/commonDisease.ts create mode 100644 src/app/models/doctor.ts create mode 100644 src/app/models/hospital.ts create mode 100644 src/app/models/hospitalsData.ts create mode 100644 src/app/models/index.ts create mode 100644 src/app/models/medicalHistory.ts create mode 100644 src/app/models/patient.ts create mode 100644 src/app/models/receptionist.ts create mode 100644 src/app/models/transaction.ts create mode 100644 src/app/models/userLog.ts diff --git a/src/app/models/bookedAppointment.ts b/src/app/models/bookedAppointment.ts new file mode 100644 index 00000000..f5174526 --- /dev/null +++ b/src/app/models/bookedAppointment.ts @@ -0,0 +1,49 @@ +import mongoose from "mongoose"; + +export interface BookedAppointment extends mongoose.Document { + date: string; + timing: string; + state: string; + city: string; + hospital: { + id: mongoose.Schema.Types.ObjectId; + name: string; + }; + disease: string; + note: string; + approved: string; + patient_id: mongoose.Schema.Types.ObjectId; + doctor_id: mongoose.Schema.Types.ObjectId; + receptionist_id: mongoose.Schema.Types.ObjectId; +} + +const bookedAppointmentsSchema = new mongoose.Schema( + { + _id: { type: mongoose.Schema.Types.ObjectId, required: true }, + date: { type: Date, required: true }, + timing: { type: String, required: false }, + state: { type: String, required: true }, + city: { type: String, required: true }, + hospital: { + id: { type: mongoose.Schema.Types.ObjectId, required: true }, + name: { type: String, required: true }, + }, + disease: { type: String, required: true }, + note: { type: String, required: true }, + approved: { + type: String, + enum: ["pending", "approved", "rejected"], + default: "pending", + }, + patient_id: { type: mongoose.Schema.Types.ObjectId, required: true }, + doctor_id: { type: mongoose.Schema.Types.ObjectId }, + receptionist_id: { type: mongoose.Schema.Types.ObjectId }, + }, + { collection: "bookedAppointments" } +); + +export default mongoose.models.BookedAppointment || + mongoose.model( + "BookedAppointment", + bookedAppointmentsSchema + ); diff --git a/src/app/models/commonDisease.ts b/src/app/models/commonDisease.ts new file mode 100644 index 00000000..af885a36 --- /dev/null +++ b/src/app/models/commonDisease.ts @@ -0,0 +1,18 @@ +import mongoose from "mongoose"; + +export interface CommonDiseases extends mongoose.Document { + commonDiseases: [String]; +} + +const diseaseSchema = new mongoose.Schema( + { + _id: { type: mongoose.Schema.Types.ObjectId, required: true }, + commonDiseases: [String], + }, + { + collection: "commonDiseases", + } +); + +export default mongoose.models.CommonDiseases || + mongoose.model("CommonDiseases", diseaseSchema); diff --git a/src/app/models/doctor.ts b/src/app/models/doctor.ts new file mode 100644 index 00000000..a11820d3 --- /dev/null +++ b/src/app/models/doctor.ts @@ -0,0 +1,105 @@ +import mongoose from "mongoose"; + +export interface Doctor extends mongoose.Document { + firstname: string; + lastname: string; + username: string; + email: string; + password: string; + role: string; + otp: string; + dob: string; + gender: string; + contact: string; + profile: string; + address: { + address_line_1: string; + address_line_2: string; + city: string; + state: string; + country: string; + zip_code: string; + }; + current_hospital: mongoose.Schema.Types.ObjectId; + specialty: string; + patients: []; +} + +const addressSchema = new mongoose.Schema({ + address_line_1: String, + address_line_2: String, + city: String, + state: String, + country: String, + zip_code: String, +}); + +const doctorSchema = new mongoose.Schema( + { + _id: { type: mongoose.Schema.Types.ObjectId, required: true }, + firstname: { + type: String, + required: true, + }, + lastname: { + type: String, + required: true, + }, + username: { + type: String, + required: true, + unique: true, + }, + email: { + type: String, + required: true, + unique: true, + }, + password: { + type: String, + required: true, + }, + role: { + type: String, + default: "doctor", + }, + otp: String, + dob: { + type: Date, + required: false, + }, + gender: { + type: String, + enum: ["Male", "Female", "Other"], + required: false, + }, + contact: { + type: String, + required: true, + }, + profile: { + type: String, + }, + address: addressSchema, + current_hospital: { + type: mongoose.Schema.Types.ObjectId, + ref: "Hospital", + }, + specialty: { + type: String, + required: true, + }, + patients: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Patient", + }, + ], + }, + { + collection: "doctor", + } +); + +export default mongoose.models.Doctor || + mongoose.model("Doctor", doctorSchema); diff --git a/src/app/models/hospital.ts b/src/app/models/hospital.ts new file mode 100644 index 00000000..6c2a05ee --- /dev/null +++ b/src/app/models/hospital.ts @@ -0,0 +1,118 @@ +import mongoose from "mongoose"; + +export interface Hospital extends mongoose.Document { + firstname: string; + lastname: string; + username: string; + email: string; + password: string; + role: string; + otp: string; + dob: string; + gender: string; + contact: string; + profile: string; + address: { + address_line_1: string; + address_line_2: string; + city: string; + state: string; + country: string; + zip_code: string; + }; + patients: []; + doctors: []; + receptionists: []; +} + +const hospitalSchema = new mongoose.Schema( + { + _id: { type: mongoose.Schema.Types.ObjectId, required: true }, + firstname: { + type: String, + required: true, + }, + lastname: { + type: String, + required: true, + }, + username: { + type: String, + required: true, + unique: true, + }, + email: { + type: String, + required: true, + unique: true, + }, + password: { + type: String, + required: true, + }, + role: { + type: String, + default: "hospital", + }, + otp: { + type: String, + }, + contact: { + type: String, + required: true, + }, + profile: { + type: String, + }, + address: { + address_line_1: { + type: String, + required: true, + }, + address_line_2: { + type: String, + }, + city: { + type: String, + required: true, + }, + state: { + type: String, + required: true, + }, + country: { + type: String, + required: true, + }, + zip_code: { + type: String, + required: true, + }, + }, + patients: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Patient", + }, + ], + doctors: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Doctor", + }, + ], + receptionists: [ + { + type: mongoose.Schema.Types.ObjectId, + ref: "Receptionist", + }, + ], + }, + + { + collection: "hospital", + } +); + +export default mongoose.models.Hospital || + mongoose.model("Hospital", hospitalSchema); diff --git a/src/app/models/hospitalsData.ts b/src/app/models/hospitalsData.ts new file mode 100644 index 00000000..d7fefe41 --- /dev/null +++ b/src/app/models/hospitalsData.ts @@ -0,0 +1,59 @@ +// import mongoose from "mongoose"; + +// export interface CityStateHospital extends mongoose.Document { +// State: { +// City: [ +// { +// hospital_id: null; +// hospital_name: "Apollo Hospitals"; +// appointment_charge: "250"; +// }, +// { +// hospital_id: null; +// hospital_name: "Yashoda Hospitals"; +// appointment_charge: "250"; +// }, +// { +// hospital_id: null; +// hospital_name: "KIMS Hospitals"; +// appointment_charge: "250"; +// }, +// { +// hospital_id: null; +// hospital_name: "Continental Hospitals"; +// appointment_charge: "250"; +// }, +// { +// hospital_id: null; +// hospital_name: "Sunshine Hospitals"; +// appointment_charge: "250"; +// } +// ]; +// }; +// } + +// const hospitalsDataSchema = new mongoose.Schema({ +// hospital_id: String, +// hospital_name: { type: String, required: true }, +// appointment_charge: { type: String, required: true }, +// }); + +// const cityStateSchema = new mongoose.Schema( +// { +// _id: { type: mongoose.Schema.Types.ObjectId, required: true }, +// state: String, +// cities: [ +// { +// city_name: { type: String, required: true }, +// hospitals: [hospitalsDataSchema], +// }, +// ], +// }, +// { +// collection: "citystate_hospitals", +// } +// ); + +// const HospitalsData = mongoose.model("HospitalsData", cityStateSchema); + +// export default HospitalsData; diff --git a/src/app/models/index.ts b/src/app/models/index.ts new file mode 100644 index 00000000..51826afb --- /dev/null +++ b/src/app/models/index.ts @@ -0,0 +1,23 @@ +import BookedAppointment from "./BookedAppointment"; +import CommonDiseases from "./CommonDisease"; +// import Doctor from "./Doctor"; +// import Hospital from "./Hospital"; +// import HospitalsData from "./HospitalsData"; +// import MedicalHistory from "./MedicalHistory"; +import Patient from "./patient"; +// import Receptionist from "./Receptionist"; +// import Transaction from "./Transaction"; +// import UserLog from "./UserLog"; + +export { + BookedAppointment, + CommonDiseases, + // Doctor, + // Hospital, + // HospitalsData, + // MedicalHistory, + Patient, + // Receptionist, + // Transaction, + // UserLog, +}; diff --git a/src/app/models/medicalHistory.ts b/src/app/models/medicalHistory.ts new file mode 100644 index 00000000..9236510a --- /dev/null +++ b/src/app/models/medicalHistory.ts @@ -0,0 +1,55 @@ +import mongoose from "mongoose"; + +export interface MedicalHistory extends mongoose.Document { + hospital: mongoose.Schema.Types.ObjectId; + patient: mongoose.Schema.Types.ObjectId; + doctor: mongoose.Schema.Types.ObjectId; + start_date: string; + end_date: string; + TreatmentStatus: string; + disease: string; +} + +const medicalHistorySchema = new mongoose.Schema( + { + _id: { type: mongoose.Schema.Types.ObjectId, required: true }, + hospital: { + type: mongoose.Schema.Types.ObjectId, + ref: "Hospital", + required: true, + }, + patient: { + type: mongoose.Schema.Types.ObjectId, + ref: "Patient", + required: true, + }, + doctor: { + type: mongoose.Schema.Types.ObjectId, + ref: "Doctor", + required: true, + }, + start_date: { + type: Date, + required: true, + }, + end_date: { + type: Date, + required: true, + }, + TreatmentStatus: { + type: String, + enum: ["Ongoing", "Completed", "Cancelled"], + default: "Ongoing", + }, + disease: { + type: String, + required: true, + }, + }, + { + collection: "medicalhistory", + } +); + +export default mongoose.models.MedicalHistory || + mongoose.model("MedicalHistory", medicalHistorySchema); diff --git a/src/app/models/patient.ts b/src/app/models/patient.ts new file mode 100644 index 00000000..c72dbd3c --- /dev/null +++ b/src/app/models/patient.ts @@ -0,0 +1,99 @@ +import mongoose from "mongoose"; + +export interface Patient extends mongoose.Document { + firstname: string; + lastname: string; + username: string; + email: string; + password: string; + role: string; + otp: string; + dob: string; + gender: string; + contact: string; + profile: string; + address: { + address_line_1: string; + address_line_2: string; + city: string; + state: string; + country: string; + zip_code: string; + }; + current_hospital: mongoose.Schema.Types.ObjectId; + physicalDetails: { + age: number; + blood: string; + height: number; + weight: number; + }; + progress: { + generalHealth: number; + waterBalance: number; + currentTreatment: number; + pendingAppointments: number; + }; + medicines: [ + { + name: string; + dosage: string; + frequency: string; + } + ]; + healthConditions: number[]; +} + +const addressSchema = new mongoose.Schema({ + address_line_1: String, + address_line_2: String, + city: String, + state: String, + country: String, + zip_code: String, +}); + +const medicineSchema = new mongoose.Schema({ + name: String, + dosage: String, + frequency: String, +}); + +const patientSchema = new mongoose.Schema( + { + firstname: { type: String, required: true }, + lastname: { type: String, required: true }, + username: { type: String, required: true, unique: true }, + email: { type: String, required: true, unique: true }, + password: { type: String, required: true }, + role: { type: String, required: true, default: "patient" }, + otp: String, + dob: { type: Date, required: false }, + gender: { + type: String, + required: false, + enum: ["Male", "Female", "Other"], + }, + contact: { type: String, required: false }, + profile: String, + address: addressSchema, + current_hospital: { type: mongoose.Schema.Types.ObjectId, ref: "Hospital" }, + physicalDetails: { + age: Number, + blood: String, + height: Number, + weight: Number, + }, + progress: { + generalHealth: Number, + waterBalance: Number, + currentTreatment: Number, + pendingAppointments: Number, + }, + medicines: [medicineSchema], + healthConditions: [Number], + }, + { collection: "patient" } +); + +export default mongoose.models.Patient || + mongoose.model("Patient", patientSchema); diff --git a/src/app/models/receptionist.ts b/src/app/models/receptionist.ts new file mode 100644 index 00000000..e3d0bdce --- /dev/null +++ b/src/app/models/receptionist.ts @@ -0,0 +1,73 @@ +import mongoose from "mongoose"; + +const addressSchema = new mongoose.Schema({ + address_line_1: String, + address_line_2: String, + city: String, + state: String, + country: String, + zip_code: String, +}); + +export interface Receptionist extends mongoose.Document { + firstname: { type: String; required: true }; + lastname: { type: String; required: true }; + username: { type: String; required: true; unique: true }; + email: { type: String; required: true; unique: true }; + password: { type: String; required: true }; + role: { type: String; required: true; default: "patient" }; + otp: String; + dob: { type: Date; required: false }; + gender: { + type: String; + required: false; + enum: ["Male", "Female", "Other"]; + }; + contact: { type: String; required: false }; + profile: String; + address: { + address_line_1: string; + address_line_2: string; + city: string; + state: string; + country: string; + zip_code: string; + }; + current_hospital: mongoose.Schema.Types.ObjectId; + dailyCount: { + approved: Number; + pending: Number; + waiting: Number; + }; +} + +const receptionistSchema = new mongoose.Schema( + { + firstname: { type: String, required: true }, + lastname: { type: String, required: true }, + username: { type: String, required: true, unique: true }, + email: { type: String, required: true, unique: true }, + password: { type: String, required: true }, + role: { type: String, required: true, default: "receptionist" }, + otp: String, + dob: { type: Date, required: false }, + gender: { + type: String, + required: false, + enum: ["Male", "Female", "Other"], + }, + contact: { type: String, required: false }, + profile: String, + address: addressSchema, + current_hospital: { type: mongoose.Schema.Types.ObjectId, ref: "Hospital" }, + dailyCount: { + approved: { type: Number, default: 0 }, + pending: { type: Number, default: 0 }, + waiting: { type: Number, default: 0 }, + }, + }, + { collection: "receptionist" } +); + +export default mongoose.models.Receptionist || + mongoose.model("Receptionist", receptionistSchema); diff --git a/src/app/models/transaction.ts b/src/app/models/transaction.ts new file mode 100644 index 00000000..3274d9f5 --- /dev/null +++ b/src/app/models/transaction.ts @@ -0,0 +1,38 @@ +import mongoose from "mongoose"; + +export interface Transaction extends mongoose.Document { + transaction_id: string; + timestamp: Date; + patient_id: mongoose.Schema.Types.ObjectId; + hospital_id: mongoose.Schema.Types.ObjectId; + disease: string; + description: string; + amount: number; + status: string; +} + +const transactionSchema = new mongoose.Schema({ + transaction_id: { type: String, required: true, unique: true }, + timestamp: { type: Date, required: true }, + patient: { + type: mongoose.Schema.Types.ObjectId, + ref: "Patient", + required: true, + }, + hospital: { + type: mongoose.Schema.Types.ObjectId, + ref: "Hospital", + required: true, + }, + disease: { type: String, required: true }, + description: { type: String, required: true }, + amount: { type: Number, required: true }, + status: { + type: String, + required: true, + enum: ["Success", "Failed", "Pending"], + }, +}); + +export default mongoose.models.Transaction || + mongoose.model("Transaction", transactionSchema); diff --git a/src/app/models/userLog.ts b/src/app/models/userLog.ts new file mode 100644 index 00000000..d9989f2f --- /dev/null +++ b/src/app/models/userLog.ts @@ -0,0 +1,33 @@ +import mongoose from "mongoose"; + +export interface UserLog extends mongoose.Document { + username: string; + name: string; + email: string; + action: string; + userType: string; + timing: string; + device: string; + ip: string; + location: string; +} + +const userLogSchema = new mongoose.Schema( + { + username: { type: String, required: true }, + name: { type: String, required: true }, + email: { type: String, required: true }, + action: { type: String, required: true }, + userType: { type: String, required: true }, + timing: { type: Date, required: true }, + device: { type: String, required: true }, + ip: { type: String, required: true }, + location: String, + }, + { + collection: "user_logs", + } +); + +export default mongoose.models.UserLog || + mongoose.model("UserLog", userLogSchema);