From 7f52c05b43f91f3844267a9e60c70c647fc21b0d Mon Sep 17 00:00:00 2001 From: 10023r Date: Sat, 23 Dec 2023 21:51:56 +0300 Subject: [PATCH] ready patient page --- backend/src/controllers/DoctorController.ts | 1 + backend/src/init_data/init_data.ts | 2 +- backend/src/services/PatientsService.ts | 18 ++--- frontend/src/Pages/DoctorPage/DoctorPage.tsx | 7 +- .../src/Pages/PatientPage/PatientPage.tsx | 65 +++++++++---------- frontend/src/api/endpoints.ts | 3 +- frontend/src/api/requests.ts | 7 ++ 7 files changed, 54 insertions(+), 49 deletions(-) diff --git a/backend/src/controllers/DoctorController.ts b/backend/src/controllers/DoctorController.ts index a0f274f..a34a015 100644 --- a/backend/src/controllers/DoctorController.ts +++ b/backend/src/controllers/DoctorController.ts @@ -1,3 +1,4 @@ +// @ts-ignore import express from "express"; import { doctorsService } from "../services/DoctorsService"; diff --git a/backend/src/init_data/init_data.ts b/backend/src/init_data/init_data.ts index c374c71..d647b32 100644 --- a/backend/src/init_data/init_data.ts +++ b/backend/src/init_data/init_data.ts @@ -54,7 +54,7 @@ class DataInitializer { const doctorId = new Types.ObjectId(String(doctorUser?._id)) const testData: DoctorDto[] = [ - { _id: doctorId, name: "Ашыр", surname: "Мыратгилдиев", email: "doctor@example.com", contact: "123456789", experience: "5 years" }, + { _id: doctorId, name: "Ашыр", surname: "Мыратгелдиев", email: "doctor@example.com", contact: "123456789", experience: "5 years" }, ]; await DoctorMongoCollection.insertMany(testData); diff --git a/backend/src/services/PatientsService.ts b/backend/src/services/PatientsService.ts index 526a8c0..4f794ac 100644 --- a/backend/src/services/PatientsService.ts +++ b/backend/src/services/PatientsService.ts @@ -9,14 +9,14 @@ class PatientService { const objId = new mongoose.Types.ObjectId(id) const patient = await PatientsMongoCollection.findById(objId) - const appoitments = await AppoitmentMongoCollection.find({patient_id: objId}) + const appointments = await AppoitmentMongoCollection.find({patient_id: objId}) - let myAppoitments: { [key: string]: any }[] = []; + let myAppointments: { [key: string]: any }[] = []; - for(const appoitment of appoitments) { - const procedure = await ProceduresMongoCollection.findOne({_id: appoitment?.procedure_id}) - const doctor = await DoctorMongoCollection.findOne({_id: appoitment?.doctor_id}) - const date = appoitment?.date + for(const appointment of appointments) { + const procedure = await ProceduresMongoCollection.findOne({_id: appointment?.procedure_id}) + const doctor = await DoctorMongoCollection.findOne({_id: appointment?.doctor_id}) + const date = appointment?.date const appointmentDetails = { "date": date, "procedure": procedure?.name, @@ -24,11 +24,11 @@ class PatientService { }; console.log(appointmentDetails); - myAppoitments.push(appointmentDetails); + myAppointments.push(appointmentDetails); } - console.log({ "name": patient?.name, "surname": patient?.surname, "appoitments": myAppoitments}); + console.log({ "name": patient?.name, "surname": patient?.surname, "appointments": myAppointments}); - return { "name": patient?.name, "surname": patient?.surname, "appoitments": myAppoitments} + return { "name": patient?.name, "surname": patient?.surname, "appointments": myAppointments} } public async getAllPatients() { diff --git a/frontend/src/Pages/DoctorPage/DoctorPage.tsx b/frontend/src/Pages/DoctorPage/DoctorPage.tsx index 3c6e1c4..3cd74ee 100644 --- a/frontend/src/Pages/DoctorPage/DoctorPage.tsx +++ b/frontend/src/Pages/DoctorPage/DoctorPage.tsx @@ -11,7 +11,8 @@ import {useNavigate} from "react-router-dom"; function DoctorPage() { - const [info, setInfo] = useState({}) + let tmp: any = {} + const [info, setInfo] = useState(tmp) const navigate = useNavigate() const id = useSelector((state: any) => state.id) const [appointments, setAppointments] = useState([]) @@ -31,7 +32,7 @@ function DoctorPage() { const onChange = (event: any) => { const target = event.target const comparators: {[index: string]: any} = { - 'date': (x: any) => x.date.includes(new Date(target.value).toLocaleString('ru-RU', timeRepresentationOptions)), + 'date': (x: any) => x.date == (new Date(target.value).toLocaleString('ru-RU', timeRepresentationOptions)), 'procedure': (x: any) => x.procedure.includes(target.value), 'patient': (x: any) => x.patient.includes(target.value) } @@ -71,7 +72,7 @@ function DoctorPage() {

Patient