-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
59 changed files
with
7,923 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
ConnectionString = "mongodb+srv://ziyodilladev:ziyodilla123@cluster0.t9s2ir2.mongodb.net/clinic" | ||
BotToken = "6505035996:AAFzsw7c3edlkV0aWR06M-pPMqWr-YHQJco" | ||
PORT = 4000 | ||
AdminID = 1215206645 | ||
|
||
# ustozni idlari 5759292137 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
const Clinics = require("../../src/models/clinic"); | ||
|
||
exports.clinicAdd = async (req, res) => { | ||
const { email, password, phone, name, location, workingDays, workingHours } = | ||
req.body; | ||
const { imageName: img } = req; | ||
|
||
Clinics.create({ | ||
email, | ||
password, | ||
phone, | ||
name, | ||
img, | ||
location, | ||
workingDays, | ||
workingHours, | ||
}); | ||
res.status(201).json({ message: "Clinic added successfully" }); | ||
}; | ||
|
||
exports.clinicGetAll = async (req, res) => { | ||
const skip = req.params["skip"].split("=")[1]; | ||
const limit = req.params["limit"].split("=")[1]; | ||
const s = (skip - 1) * limit; | ||
const clinics = await Clinics.find() | ||
.skip(s) | ||
.limit(limit) | ||
.populate([ | ||
{ | ||
path: "clinicDoctors", | ||
populate: "doctorServiceID doctorOrders", | ||
}, | ||
"clinicServices", | ||
"clinicOrders", | ||
"clinicPharmacyOrders", | ||
"clinicPharmacy", | ||
]); | ||
|
||
const allData = await Clinics.find(); | ||
const total_page = Math.ceil(allData.length / limit); | ||
|
||
res.status(200).json({ data: clinics, total_page }); | ||
}; | ||
|
||
exports.clinicGet = async (req, res) => { | ||
const allData = await Clinics.find().populate([ | ||
{ | ||
path: "clinicDoctors", | ||
populate: "doctorServiceID doctorOrders", | ||
}, | ||
"clinicServices", | ||
"clinicOrders", | ||
"clinicPharmacyOrders", | ||
"clinicPharmacy", | ||
]); | ||
|
||
res.status(200).json({ data: allData }); | ||
}; | ||
|
||
exports.clinicGetOne = async (req, res) => { | ||
const { id } = req.params; | ||
const skip = req.params["skip"].split("=")[1]; | ||
const limit = req.params["limit"].split("=")[1]; | ||
const s = (skip - 1) * limit; | ||
const clinic = await Clinics.findById(id).populate([ | ||
{ | ||
path: "clinicDoctors", | ||
populate: "doctorServiceID doctorOrders", | ||
options: { | ||
skip: s, | ||
limit: limit, | ||
}, | ||
}, | ||
{ | ||
path: "clinicServices", | ||
options: { | ||
skip: s, | ||
limit: limit, | ||
}, | ||
}, | ||
"clinicOrders", | ||
"clinicPharmacyOrders", | ||
"clinicPharmacy", | ||
]); | ||
res.status(200).json({ data: clinic }); | ||
}; | ||
|
||
exports.clinicEdit = async (req, res) => { | ||
const { id } = req.params; | ||
const { email, password, phone, name, location, workingDays, workingHours } = | ||
req.body; | ||
const { imageName: img } = req; | ||
await Clinics.findByIdAndUpdate(id, { | ||
$set: { | ||
email, | ||
password, | ||
phone, | ||
name, | ||
img, | ||
location, | ||
workingDays, | ||
workingHours, | ||
}, | ||
}); | ||
|
||
res.status(200).json({ message: "Updated Clinic" }); | ||
}; | ||
|
||
exports.clinicDelete = async (req, res) => { | ||
const { id } = req.params; | ||
await Clinics.findByIdAndDelete(id); | ||
|
||
res.status(200).json({ message: "Deleted Clinic" }); | ||
}; | ||
|
||
exports.clinicSearch = async (req, res) => { | ||
const search = req.params["search"].split("=")[1].toLowerCase(); | ||
const clinics = await Clinics.find({}); | ||
|
||
const searchedClinics = clinics.filter((clinic) => | ||
clinic.name.toLowerCase().includes(search) | ||
); | ||
|
||
res.status(200).json({ data: searchedClinics }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
const Doctors = require("../../src/models/doctor"); | ||
const Clinics = require("../../src/models/clinic"); | ||
|
||
exports.doctorAdd = async (req, res) => { | ||
const { | ||
email, | ||
password, | ||
phone, | ||
fullName, | ||
workingDays, | ||
workingHours, | ||
salary, | ||
clinicID, | ||
doctorServiceID, | ||
} = req.body; | ||
const { imageName: img } = req; | ||
|
||
const doctors = await Doctors.create({ | ||
email, | ||
password, | ||
phone, | ||
fullName, | ||
workingDays, | ||
workingHours, | ||
salary, | ||
clinicID, | ||
doctorServiceID, | ||
img, | ||
}); | ||
|
||
// Get the clinic document. | ||
const clinic = await Clinics.findById(clinicID); | ||
if (!clinic) { | ||
return res.status(404).json({ message: "Clinic not found" }); | ||
} | ||
|
||
try { | ||
await Clinics.findByIdAndUpdate(clinicID, { | ||
$push: { | ||
clinicDoctors: doctors._id, | ||
}, | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
return res.status(500).json({ message: "Internal server error" }); | ||
} | ||
|
||
res.status(201).json({ message: "Doctor added successfully" }); | ||
}; | ||
|
||
exports.doctorGetAll = async (req, res) => { | ||
const skip = req.params["skip"].split("=")[1]; | ||
const limit = req.params["limit"].split("=")[1]; | ||
const s = (skip - 1) * limit; | ||
const doctors = await Doctors.find() | ||
.skip(s) | ||
.limit(limit) | ||
.populate("clinicID doctorServiceID doctorOrders"); | ||
|
||
const allData = await Doctors.find(); | ||
const total_page = Math.ceil(allData.length / limit); | ||
|
||
res.status(200).json({ data: doctors, total_page }); | ||
}; | ||
|
||
exports.doctorGet = async (req, res) => { | ||
const allData = await Doctors.find().populate( | ||
"clinicID doctorServiceID doctorOrders" | ||
); | ||
|
||
res.status(200).json({ data: allData }); | ||
}; | ||
|
||
exports.doctorGetOne = async (req, res) => { | ||
const { id } = req.params; | ||
const doctor = await Doctors.findById(id).populate( | ||
"clinicID doctorServiceID doctorOrders" | ||
); | ||
|
||
res.status(200).json({ data: doctor }); | ||
}; | ||
|
||
exports.doctorEdit = async (req, res) => { | ||
const { id } = req.params; | ||
const { | ||
email, | ||
password, | ||
phone, | ||
fullName, | ||
workingDays, | ||
workingHours, | ||
salary, | ||
clinicID, | ||
doctorServiceID, | ||
} = req.body; | ||
const { imageName: img } = req; | ||
await Doctors.findByIdAndUpdate(id, { | ||
$set: { | ||
email, | ||
password, | ||
phone, | ||
fullName, | ||
workingDays, | ||
workingHours, | ||
salary, | ||
clinicID, | ||
doctorServiceID, | ||
img, | ||
}, | ||
}); | ||
|
||
res.status(200).json({ message: "Updated doctor" }); | ||
}; | ||
|
||
exports.doctorDelete = async (req, res) => { | ||
const { id } = req.params; | ||
await Doctors.findByIdAndDelete(id); | ||
|
||
res.status(200).json({ message: "Deleted doctor" }); | ||
}; | ||
|
||
exports.doctorSearch = async (req, res) => { | ||
const search = req.params["search"].split("=")[1].toLowerCase(); | ||
const doctors = await Doctors.find({}); | ||
|
||
const searchedDoctors = doctors.filter((doctor) => | ||
doctor.fullName.toLowerCase().includes(search) | ||
); | ||
|
||
res.status(200).json({ data: searchedDoctors }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
const Doctors = require("../../src/models/doctor"); | ||
const Clinics = require("../../src/models/clinic"); | ||
const Patients = require("../../src/models/patient"); | ||
const Orders = require("../../src/models/order"); | ||
|
||
exports.orderAdd = async (req, res) => { | ||
const { | ||
scheduledDay, | ||
scheduledHour, | ||
serviceID, | ||
clinicID, | ||
doctorID, | ||
patientID, | ||
} = req.body; | ||
|
||
const orders = await Orders.create({ | ||
scheduledDay, | ||
scheduledHour, | ||
serviceID, | ||
clinicID, | ||
doctorID, | ||
patientID, | ||
}); | ||
try { | ||
await Clinics.findByIdAndUpdate(clinicID, { | ||
$push: { | ||
clinicOrders: orders._id, | ||
}, | ||
}); | ||
await Doctors.findByIdAndUpdate(doctorID, { | ||
$push: { | ||
doctorOrders: orders._id, | ||
}, | ||
}); | ||
await Patients.findByIdAndUpdate(patientID, { | ||
$push: { | ||
patientOrders: orders._id, | ||
}, | ||
}); | ||
} catch (error) { | ||
return res.status(500).json({ message: "Internal server error" }); | ||
} | ||
|
||
res.status(201).json({ message: "Order added successfully" }); | ||
}; | ||
|
||
exports.orderGetAll = async (req, res) => { | ||
const skip = req.params["skip"].split("=")[1]; | ||
const limit = req.params["limit"].split("=")[1]; | ||
const s = (skip - 1) * limit; | ||
const orders = await Orders.find() | ||
.skip(s) | ||
.limit(limit) | ||
.populate("serviceID clinicID doctorID patientID"); | ||
|
||
const allData = await Orders.find(); | ||
const total_page = Math.ceil(allData.length / limit); | ||
|
||
res.status(200).json({ data: orders, total_page }); | ||
}; | ||
|
||
exports.orderGet = async (req, res) => { | ||
const allData = await Orders.find().populate( | ||
"serviceID clinicID doctorID patientID" | ||
); | ||
|
||
res.status(200).json({ data: allData }); | ||
}; | ||
|
||
exports.orderGetOne = async (req, res) => { | ||
const { id } = req.params; | ||
const order = await Orders.findById(id).populate( | ||
"serviceID clinicID doctorID patientID" | ||
); | ||
|
||
res.status(200).json({ data: order }); | ||
}; | ||
|
||
exports.orderEdit = async (req, res) => { | ||
const { id } = req.params; | ||
const { | ||
scheduledDay, | ||
scheduledHour, | ||
serviceID, | ||
clinicID, | ||
doctorID, | ||
patientID, | ||
} = req.body; | ||
await Orders.findByIdAndUpdate(id, { | ||
$set: { | ||
scheduledDay, | ||
scheduledHour, | ||
serviceID, | ||
clinicID, | ||
doctorID, | ||
patientID, | ||
}, | ||
}); | ||
|
||
res.status(200).json({ message: "Updated order" }); | ||
}; | ||
|
||
exports.orderDelete = async (req, res) => { | ||
const { id } = req.params; | ||
await Orders.findByIdAndDelete(id); | ||
|
||
res.status(200).json({ message: "Deleted order" }); | ||
}; | ||
|
||
exports.orderStatusEdit = async (req, res) => { | ||
const { id } = req.params; | ||
const status = true; | ||
await Orders.findByIdAndUpdate(id, { | ||
$set: { | ||
status, | ||
}, | ||
}); | ||
|
||
res.status(200).json({ message: "Updated stauts order" }); | ||
}; |
Oops, something went wrong.