Skip to content

Commit

Permalink
Added models
Browse files Browse the repository at this point in the history
  • Loading branch information
ad956 committed Jul 1, 2024
1 parent dc9930a commit 6117e53
Show file tree
Hide file tree
Showing 11 changed files with 670 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/app/models/bookedAppointment.ts
Original file line number Diff line number Diff line change
@@ -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>(
"BookedAppointment",
bookedAppointmentsSchema
);
18 changes: 18 additions & 0 deletions src/app/models/commonDisease.ts
Original file line number Diff line number Diff line change
@@ -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>("CommonDiseases", diseaseSchema);
105 changes: 105 additions & 0 deletions src/app/models/doctor.ts
Original file line number Diff line number Diff line change
@@ -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>("Doctor", doctorSchema);
118 changes: 118 additions & 0 deletions src/app/models/hospital.ts
Original file line number Diff line number Diff line change
@@ -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>("Hospital", hospitalSchema);
59 changes: 59 additions & 0 deletions src/app/models/hospitalsData.ts
Original file line number Diff line number Diff line change
@@ -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;
23 changes: 23 additions & 0 deletions src/app/models/index.ts
Original file line number Diff line number Diff line change
@@ -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,
};
Loading

0 comments on commit 6117e53

Please sign in to comment.