From 74165bbd25981d06a16bc42a8bd39dec644275ae Mon Sep 17 00:00:00 2001 From: lucashemi Date: Tue, 28 Feb 2023 17:57:23 -0300 Subject: update --- README.md | 8 ++- .../med/voll/api/controller/DoctorController.java | 5 ++ .../med/voll/api/controller/PatientController.java | 2 +- .../voll/api/domain/doctor/DoctorRepository.java | 5 ++ .../voll/api/domain/patient/PatientRepository.java | 2 +- .../voll/src/components/AppointmentModal.vue | 1 + .../voll/src/components/AppointmentsList.vue | 9 ++- web-client/voll/src/router/index.ts | 2 +- web-client/voll/src/views/AuthView.vue | 73 -------------------- web-client/voll/src/views/AuthenticationView.vue | 78 ++++++++++++++++++++++ web-client/voll/src/views/HomeView.vue | 6 +- 11 files changed, 109 insertions(+), 82 deletions(-) delete mode 100644 web-client/voll/src/views/AuthView.vue create mode 100644 web-client/voll/src/views/AuthenticationView.vue diff --git a/README.md b/README.md index c22f27c..7e2e728 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ -# Voll - Managing your clinic (WIP) +# Voll - Managing your clinic Voll is a webapp for managing medical clinics, you can register doctors and patients, schedule appointments and easily manage your clinic. The back-end is a rest api built in java/spring and the front-end is made with vue.js. -It's a work in progress, it's not possible to schedule appointments yet. +The main functions are done (doctor, patient and appointment crud). + +The front-end code needs some refactoring and things like colored notifications, more time options when scheduling a appointment. ## Tech-Stack @@ -39,7 +41,7 @@ Main technologies used in the project. ## Installation -1. Configure the application.properties file in the api src folder and create a database with the configured name. Build and run the api. +1. Configure the application.properties file in the api/src/main/resources folder and create a database with the configured name and a user to login. Build and run the api. 2. Go to the folder web-client/voll and run: diff --git a/api/src/main/java/med/voll/api/controller/DoctorController.java b/api/src/main/java/med/voll/api/controller/DoctorController.java index f87da56..f53093b 100644 --- a/api/src/main/java/med/voll/api/controller/DoctorController.java +++ b/api/src/main/java/med/voll/api/controller/DoctorController.java @@ -2,6 +2,7 @@ package med.voll.api.controller; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import jakarta.validation.Valid; +import jakarta.validation.ValidationException; import med.voll.api.domain.doctor.DoctorListingData; import med.voll.api.domain.doctor.Doctor; import med.voll.api.domain.doctor.DoctorRepository; @@ -54,6 +55,10 @@ public class DoctorController { @Transactional public ResponseEntity delete(@PathVariable Long id) { Doctor doctor = doctorRepository.getReferenceById(id); + var appointments = doctorRepository.findAnyAppointmentFromDoctor(id); + if (appointments != null) { + throw new ValidationException("Can't delete doctor with active appointments"); + } doctor.delete(); return ResponseEntity.noContent().build(); diff --git a/api/src/main/java/med/voll/api/controller/PatientController.java b/api/src/main/java/med/voll/api/controller/PatientController.java index 16c0973..7b2cd51 100644 --- a/api/src/main/java/med/voll/api/controller/PatientController.java +++ b/api/src/main/java/med/voll/api/controller/PatientController.java @@ -54,7 +54,7 @@ public class PatientController { @Transactional public ResponseEntity delete(@PathVariable Long id) { Patient patient = patientRepository.getReferenceById(id); - var appointments = patientRepository.findAnyAppointmentFrom(id); + var appointments = patientRepository.findAnyAppointmentFromPatient(id); if (appointments != null) { throw new ValidationException("Can't delete patient with active appointments"); } diff --git a/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java b/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java index 8cd6c46..c2f1567 100644 --- a/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java +++ b/api/src/main/java/med/voll/api/domain/doctor/DoctorRepository.java @@ -28,4 +28,9 @@ public interface DoctorRepository extends JpaRepository { where d.id = :id """) Boolean findActiveById(Long id); + + @Query(""" + select d.id from Doctor d join Appointment a on d.id = a.doctor.id where a.active = true and d.id = :id + """) + Long findAnyAppointmentFromDoctor(Long id); } diff --git a/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java b/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java index c53d47a..077dfa0 100644 --- a/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java +++ b/api/src/main/java/med/voll/api/domain/patient/PatientRepository.java @@ -19,5 +19,5 @@ public interface PatientRepository extends JpaRepository { @Query(""" select p.id from Patient p join Appointment a on p.id = a.patient.id where a.active = true and p.id = :id """) - Long findAnyAppointmentFrom(Long id); + Long findAnyAppointmentFromPatient(Long id); } diff --git a/web-client/voll/src/components/AppointmentModal.vue b/web-client/voll/src/components/AppointmentModal.vue index 451c039..0b06f3b 100644 --- a/web-client/voll/src/components/AppointmentModal.vue +++ b/web-client/voll/src/components/AppointmentModal.vue @@ -76,6 +76,7 @@ export default defineComponent({ } }).then(response => { console.log(response) + this.$emit('list') }).catch(error => { console.log(error) }) diff --git a/web-client/voll/src/components/AppointmentsList.vue b/web-client/voll/src/components/AppointmentsList.vue index 3a6623b..0e17319 100644 --- a/web-client/voll/src/components/AppointmentsList.vue +++ b/web-client/voll/src/components/AppointmentsList.vue @@ -23,7 +23,7 @@ - + - - \ No newline at end of file diff --git a/web-client/voll/src/views/AuthenticationView.vue b/web-client/voll/src/views/AuthenticationView.vue new file mode 100644 index 0000000..a01b869 --- /dev/null +++ b/web-client/voll/src/views/AuthenticationView.vue @@ -0,0 +1,78 @@ + + + + + \ No newline at end of file diff --git a/web-client/voll/src/views/HomeView.vue b/web-client/voll/src/views/HomeView.vue index 776e83c..292c26b 100644 --- a/web-client/voll/src/views/HomeView.vue +++ b/web-client/voll/src/views/HomeView.vue @@ -1,6 +1,6 @@