diff --git a/src/main/java/com/projet/projetIndu/controllers/AppointmentController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java similarity index 68% rename from src/main/java/com/projet/projetIndu/controllers/AppointmentController.java rename to src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java index a5213cd392752819445d9b024dbc3eb78790ec2b..2935ac62a615355ec6e2b6c1821f0b2da546f1a1 100644 --- a/src/main/java/com/projet/projetIndu/controllers/AppointmentController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java @@ -15,54 +15,52 @@ import java.time.LocalDateTime; import java.util.List; @Controller -@RequestMapping("/appointments") // Toutes les routes commenceront par /appointments -public class AppointmentController { +@RequestMapping("/doctors/appointments") +public class DoctorAppointmentController { private final AppointmentService appointmentService; private final DoctorService doctorService; private final PatientService patientService; - - public AppointmentController(AppointmentService appointmentService, DoctorService doctorService, PatientService patientService) { + public DoctorAppointmentController(AppointmentService appointmentService, DoctorService doctorService, PatientService patientService) { this.appointmentService = appointmentService; this.doctorService = doctorService; this.patientService = patientService; } @GetMapping - public String showAppointments(Model model) { - List<Appointment> appointments = appointmentService.getAllAppointments(); - model.addAttribute("appointments", appointments); - return "appointments"; - } - - @GetMapping("/doctor/{doctorId}") - public String listAppointmentsForDoctor(@PathVariable Long doctorId, Model model) { + public String showDoctorAppointments(Model model) { + Long doctorId = doctorService.getAuthenticatedDoctorId(); List<Appointment> appointments = appointmentService.getAppointmentsByDoctor(doctorId); model.addAttribute("appointments", appointments); return "appointments"; } - @GetMapping("/create") public String showCreateForm(Model model) { model.addAttribute("appointment", new Appointment()); - List<Patient> patients = patientService.getAllPatients(); - List<Doctor> doctors = doctorService.getAllDoctors(); - model.addAttribute("patients", patients); - model.addAttribute("doctors", doctors); + Long doctorId = doctorService.getAuthenticatedDoctorId(); + Doctor doctor = doctorService.getDoctorById(doctorId) + .orElseThrow(() -> new RuntimeException("Médecin introuvable")); + + model.addAttribute("doctor", doctor); return "create-appointment"; } @PostMapping("/create") - public String createAppointment(@RequestParam("doctorId") Long doctorId, - @RequestParam("patientId") Long patientId, + public String createAppointment(@RequestParam("patientId") Long patientId, @RequestParam("dateTime") String dateTime, - @RequestParam("reason") String reason) { + @RequestParam("reason") String reason, + @RequestParam("doctorId") Long doctorId) { + + Long authenticatedDoctorId = doctorService.getAuthenticatedDoctorId(); + if (!authenticatedDoctorId.equals(doctorId)) { + throw new RuntimeException("Le médecin authentifié ne peut pas prendre des rendez-vous pour un autre médecin."); + } Doctor doctor = doctorService.getDoctorById(doctorId) .orElseThrow(() -> new RuntimeException("Médecin introuvable")); @@ -80,16 +78,15 @@ public class AppointmentController { appointmentService.saveAppointment(appointment); - return "redirect:/appointments"; + return "redirect:/doctors/appointments"; } - - @PostMapping("/{id}/cancel") public String cancelAppointment(@PathVariable Long id) { appointmentService.cancelAppointment(id); - return "redirect:/appointments"; + return "redirect:/doctors/appointments"; } } + diff --git a/src/main/java/com/projet/projetIndu/controllers/MedicalFileController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java similarity index 80% rename from src/main/java/com/projet/projetIndu/controllers/MedicalFileController.java rename to src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java index c8bad472512959f849e0f3182606ea209c531357..6adfe0da71774101b8e9d4d9d45cd46697083a7f 100644 --- a/src/main/java/com/projet/projetIndu/controllers/MedicalFileController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java @@ -13,17 +13,16 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes; import java.io.IOException; import java.time.LocalDate; -import java.util.List; import java.util.Optional; @Controller -@RequestMapping("/medical-files") -public class MedicalFileController { +@RequestMapping("/doctors/medical-files-doctor") +public class DoctorMedicalFileController { private final MedicalFileService medicalFileService; private final MedicalDocumentRepository medicalDocumentRepository; - public MedicalFileController(MedicalFileService medicalFileService, MedicalDocumentRepository medicalDocumentRepository) { + public DoctorMedicalFileController(MedicalFileService medicalFileService, MedicalDocumentRepository medicalDocumentRepository) { this.medicalFileService = medicalFileService; this.medicalDocumentRepository = medicalDocumentRepository; } @@ -31,29 +30,27 @@ public class MedicalFileController { // Afficher tous les dossiers médicaux @GetMapping public String listMedicalFiles(Model model) { - List<MedicalFile> medicalFiles = medicalFileService.getAllMedicalFiles(); - System.out.println("Dossiers médicaux récupérés : " + medicalFiles.size()); - model.addAttribute("medicalFiles", medicalFiles); - return "medical-files"; + model.addAttribute("medicalFiles", medicalFileService.getAllMedicalFiles()); + return "medical-files-doctor"; } - // Afficher un dossier médical spécifique @GetMapping("/{id}") public String viewMedicalFile(@PathVariable Long id, Model model) { - return medicalFileService.getMedicalFileById(id) - .map(medicalFile -> { - model.addAttribute("medicalFile", medicalFile); - return "view-medical-file"; - }) - .orElse("error"); + MedicalFile medicalFile = medicalFileService.getMedicalFileById(id).orElse(null); + if (medicalFile != null) { + model.addAttribute("medicalFile", medicalFile); + return "view-medical-file-doctor"; + } + model.addAttribute("errorMessage", "Dossier introuvable."); + return "error"; } // Créer un dossier médical @PostMapping("/create") public String createMedicalFile(@ModelAttribute MedicalFile medicalFile) { medicalFileService.saveMedicalFiles(medicalFile); - return "redirect:/medical-files"; + return "redirect:/doctors/medical-files-doctor"; } // Mettre à jour l'historique médical @@ -63,10 +60,9 @@ public class MedicalFileController { @RequestParam String notes, @RequestParam LocalDate consultationDate) { medicalFileService.updateMedicalFileHistory(id, antecedent, notes, consultationDate); - return "redirect:/medical-files/" + id; + return "redirect:/doctors/medical-files-doctor/" + id; } - // Ajouter un document à un dossier médical @PostMapping("/{id}/documents") public String uploadMedicalFileDocument(@PathVariable Long id, @RequestParam("document") MultipartFile document, RedirectAttributes redirectAttributes) { @@ -75,12 +71,11 @@ public class MedicalFileController { } catch (IOException e) { e.printStackTrace(); redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'upload du document."); - return "redirect:/medical-files/" + id; + return "redirect:/doctors/medical-files-doctor/" + id; } - return "redirect:/medical-files/" + id; + return "redirect:/doctors/medical-files-doctor/" + id; } - // Télécharger un document médical @GetMapping("/{id}/documents/{docId}") @ResponseBody @@ -100,7 +95,6 @@ public class MedicalFileController { } } - // Supprimer un document médical @DeleteMapping("/{id}/documents/{docId}") public String deleteDocument(@PathVariable Long id, @PathVariable Long docId, RedirectAttributes redirectAttributes) { @@ -113,10 +107,9 @@ public class MedicalFileController { redirectAttributes.addFlashAttribute("errorMessage", "Document introuvable."); } - return "redirect:/medical-files/" + id; + return "redirect:/doctors/medical-files-doctor/" + id; } - // Supprimer un dossier médical @DeleteMapping("/{id}") public String deleteMedicalFile(@PathVariable Long id, RedirectAttributes redirectAttributes) { @@ -126,7 +119,6 @@ public class MedicalFileController { } catch (Exception e) { redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de la suppression du dossier médical."); } - return "redirect:/medical-files"; + return "redirect:/doctors/medical-files-doctor"; } - } diff --git a/src/main/java/com/projet/projetIndu/controllers/PatientAppointmentController.java b/src/main/java/com/projet/projetIndu/controllers/PatientAppointmentController.java new file mode 100644 index 0000000000000000000000000000000000000000..ed97a4bfe2f7c9ce6cab6db6211406900b3442c8 --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/PatientAppointmentController.java @@ -0,0 +1,33 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.entities.Appointment; +import com.projet.projetIndu.services.AppointmentService; +import com.projet.projetIndu.services.PatientService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.List; + +@Controller +@RequestMapping("/patients/appointments") // L'URL commence bien par /patients/ +public class PatientAppointmentController { + + private final AppointmentService appointmentService; + private final PatientService patientService; + + public PatientAppointmentController(AppointmentService appointmentService, PatientService patientService) { + this.appointmentService = appointmentService; + this.patientService = patientService; + } + + @GetMapping + public String showPatientAppointments(Model model) { + Long patientId = patientService.getAuthenticatedPatientId(); // Récupère l'ID du patient connecté + List<Appointment> appointments = appointmentService.getAppointmentsByPatient(patientId); + model.addAttribute("appointments", appointments); + return "appointments"; + } +} + diff --git a/src/main/java/com/projet/projetIndu/controllers/PatientMedicalFileController.java b/src/main/java/com/projet/projetIndu/controllers/PatientMedicalFileController.java new file mode 100644 index 0000000000000000000000000000000000000000..f47af20333737360b9c364da31b44caf1110b527 --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/PatientMedicalFileController.java @@ -0,0 +1,73 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.entities.MedicalDocument; +import com.projet.projetIndu.entities.MedicalFile; +import com.projet.projetIndu.entities.Patient; +import com.projet.projetIndu.services.MedicalFileService; +import com.projet.projetIndu.services.PatientService; +import org.springframework.http.*; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +@Controller +@RequestMapping("/patients/medical-files-patient") +public class PatientMedicalFileController { + + private final MedicalFileService medicalFileService; + private final PatientService patientService; + + public PatientMedicalFileController(MedicalFileService medicalFileService, PatientService patientService) { + this.medicalFileService = medicalFileService; + this.patientService = patientService; + } + + // Afficher le dossier médical du patient connecté + @GetMapping + public String viewMedicalFile(Model model) { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + String currentUsername = authentication.getName(); // Récupérer l'email du patient authentifié + + // Récupérer le patient correspondant à cet email + Patient patient = patientService.getPatientByEmail(currentUsername).orElse(null); + + if (patient != null) { + // Récupérer le dossier médical pour ce patient (un seul dossier par patient) + MedicalFile medicalFile = medicalFileService.getMedicalFileByPatientId(patient.getId()).orElse(null); + + if (medicalFile != null) { + model.addAttribute("medicalFile", medicalFile); + return "medical-files-patient"; // Afficher le dossier médical + } + } + + model.addAttribute("errorMessage", "Dossier médical introuvable."); + return "error"; // Vue d'erreur si aucun dossier n'est trouvé + } + + + // Télécharger un document médical + @GetMapping("/{id}/documents/{docId}") + @ResponseBody + public ResponseEntity<byte[]> getMedicalFileDocument(@PathVariable Long id, @PathVariable Long docId) { + try { + MedicalDocument document = medicalFileService.getMedicalFileDocument(id, docId); + + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); + headers.setContentDisposition(ContentDisposition.attachment() + .filename(document.getFileName()) + .build()); + + return new ResponseEntity<>(document.getFileData(), headers, HttpStatus.OK); + } catch (RuntimeException e) { + return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null); + } + } +} + diff --git a/src/main/java/com/projet/projetIndu/repositories/AppointmentRepository.java b/src/main/java/com/projet/projetIndu/repositories/AppointmentRepository.java index e30256390d482a2aa43779b434d3c2abf4d5e1d7..9f2b3a494e60d202782ce505c2ec704f2c008333 100644 --- a/src/main/java/com/projet/projetIndu/repositories/AppointmentRepository.java +++ b/src/main/java/com/projet/projetIndu/repositories/AppointmentRepository.java @@ -12,4 +12,6 @@ public interface AppointmentRepository extends JpaRepository<Appointment, Long> Optional<Appointment> findByDateTime(LocalDateTime dateTime); List<Appointment> findByDoctorId(Long doctorId); + + List<Appointment> findByPatientId(Long patientId); } diff --git a/src/main/java/com/projet/projetIndu/repositories/MedicalFileRepository.java b/src/main/java/com/projet/projetIndu/repositories/MedicalFileRepository.java index 54f79ccf4eacc1bcce09978871aa887cb2df20e1..4841839eb6138cb667a106f8620963642ef1a86b 100644 --- a/src/main/java/com/projet/projetIndu/repositories/MedicalFileRepository.java +++ b/src/main/java/com/projet/projetIndu/repositories/MedicalFileRepository.java @@ -3,6 +3,9 @@ package com.projet.projetIndu.repositories; import com.projet.projetIndu.entities.MedicalFile; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface MedicalFileRepository extends JpaRepository<MedicalFile, Long> { + Optional<MedicalFile> findByPatientId(Long patientId); } diff --git a/src/main/java/com/projet/projetIndu/security/SecurityConfig.java b/src/main/java/com/projet/projetIndu/security/SecurityConfig.java index da719e5a33f845f3eb6f4d628f3835459ad7e32b..39405d8c97f171ab581ae7658fd81125b8cbefd9 100644 --- a/src/main/java/com/projet/projetIndu/security/SecurityConfig.java +++ b/src/main/java/com/projet/projetIndu/security/SecurityConfig.java @@ -25,7 +25,7 @@ public class SecurityConfig { public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .authorizeHttpRequests(auth -> auth - .requestMatchers("/", "/register", "/login", "/css/**", "/js/**").permitAll() // Pages publiques + .requestMatchers("/", "/register", "/login", "/css/**", "/js/**", "/doctors/search").permitAll() // Pages publiques .requestMatchers("/admin/**").hasAuthority("ADMIN") .requestMatchers("/doctors/**").hasAuthority("DOCTOR") .requestMatchers("/patients/**").hasAuthority("PATIENT") diff --git a/src/main/java/com/projet/projetIndu/services/AppointmentService.java b/src/main/java/com/projet/projetIndu/services/AppointmentService.java index c3c99b04737481453b060f3bb93f351a7097f660..b56966828179ea823a4275dd0a2827e4e61d80a7 100644 --- a/src/main/java/com/projet/projetIndu/services/AppointmentService.java +++ b/src/main/java/com/projet/projetIndu/services/AppointmentService.java @@ -6,7 +6,6 @@ import com.projet.projetIndu.repositories.AppointmentRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -53,5 +52,9 @@ public class AppointmentService { return appointmentRepository.findByDoctorId(doctorId); } + public List<Appointment> getAppointmentsByPatient(Long patientId) { + return appointmentRepository.findByPatientId(patientId); + } + } diff --git a/src/main/java/com/projet/projetIndu/services/DoctorService.java b/src/main/java/com/projet/projetIndu/services/DoctorService.java index 0ce1ff0fac11b1ec92887b5584e5dade9eca1b6b..baf0f70a6fe0ac9668704ae7085cbb25f6e2ded6 100644 --- a/src/main/java/com/projet/projetIndu/services/DoctorService.java +++ b/src/main/java/com/projet/projetIndu/services/DoctorService.java @@ -3,9 +3,10 @@ package com.projet.projetIndu.services; import com.projet.projetIndu.entities.Doctor; import com.projet.projetIndu.repositories.DoctorRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; -import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -43,23 +44,16 @@ public class DoctorService { public void deleteDoctorById(Long id) { doctorRepository.deleteById(id); } + + public Long getAuthenticatedDoctorId() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + String email = authentication.getName(); + return doctorRepository.findByEmail(email) + .map(Doctor::getId) + .orElseThrow(() -> new RuntimeException("Médecin non trouvé")); + } } -// ///Pour le codage en dur (à retirer ensuite avec la BDD) -// public List<Doctor> getAllDoctors() { -// return Arrays.asList( -// new Doctor(1L, "Jean", "Dupont", "Cardiologue", "jean.dupont@example.com"), -// new Doctor(2L, "Marie", "Curie", "Radiologue", "marie.curie@example.com"), -// new Doctor(3L, "Paul", "Durand", "Généraliste", "paul.durand@example.com") -// ); -// } // -// // Pour le dur -// public List<Doctor> getDoctorByName(String firstName, String lastName) { -// return getAllDoctors().stream() -// .filter(doctor -> doctor.getFirstName().toLowerCase().contains(firstName.toLowerCase()) || -// doctor.getLastName().toLowerCase().contains(lastName.toLowerCase())) -// .toList(); -// } diff --git a/src/main/java/com/projet/projetIndu/services/MedicalFileService.java b/src/main/java/com/projet/projetIndu/services/MedicalFileService.java index a789deaff4fa4f8a70c78fdfc36338bc59b089e6..89d02c230479ceca8490beb076e2ba0aa0cb65e6 100644 --- a/src/main/java/com/projet/projetIndu/services/MedicalFileService.java +++ b/src/main/java/com/projet/projetIndu/services/MedicalFileService.java @@ -110,6 +110,10 @@ public class MedicalFileService { .orElseThrow(() -> new RuntimeException("Document introuvable.")); } + public Optional<MedicalFile> getMedicalFileByPatientId(Long patientId) { + return medicalFileRepository.findByPatientId(patientId); + } + } diff --git a/src/main/java/com/projet/projetIndu/services/PatientService.java b/src/main/java/com/projet/projetIndu/services/PatientService.java index 48d0fe6548c13005fad2ae22fbc8a85695ad3478..0edbe55f592777951839ec41c3cfbabb83231fd0 100644 --- a/src/main/java/com/projet/projetIndu/services/PatientService.java +++ b/src/main/java/com/projet/projetIndu/services/PatientService.java @@ -3,6 +3,8 @@ package com.projet.projetIndu.services; import com.projet.projetIndu.entities.Patient; import com.projet.projetIndu.repositories.PatientRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import java.util.List; @@ -37,4 +39,14 @@ public class PatientService { public void deletePatientById(Long id) { patientRepository.deleteById(id); } + + + public Long getAuthenticatedPatientId() { + Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); + String email = authentication.getName(); + + return patientRepository.findByEmail(email) + .map(Patient::getId) + .orElseThrow(() -> new RuntimeException("Patient non trouvé")); + } } diff --git a/src/main/resources/templates/appointments.html b/src/main/resources/templates/appointments.html index 427ef001f1c6c8c4b17eebe81553884130379c7e..cafccf15abb5b279f795a64cddaaded069ab25d7 100644 --- a/src/main/resources/templates/appointments.html +++ b/src/main/resources/templates/appointments.html @@ -38,8 +38,7 @@ </tbody> </table> - <a href="/appointments/create" class="btn btn-primary mt-3">Créer un nouveau rendez-vous</a> - <a href="/doctors/dashboard" class="btn btn-secondary mt-3">Retour au tableau de bord</a> + <a href="/doctors/appointments/create" class="btn btn-primary mt-3">Créer un nouveau rendez-vous</a> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> diff --git a/src/main/resources/templates/create-appointment.html b/src/main/resources/templates/create-appointment.html index 4ab3f6a2203235beef84ea19646723b2ec442dca..b23775e6387feafe557af2bb44f2088120f90175 100644 --- a/src/main/resources/templates/create-appointment.html +++ b/src/main/resources/templates/create-appointment.html @@ -11,7 +11,7 @@ <div class="container mt-5"> <h1 class="text-center mb-4">Créer un rendez-vous</h1> - <form method="post" th:action="@{/appointments/create}"> + <form method="post" th:action="@{/doctors/appointments/create}"> <!-- Sélecteur du Patient --> <div class="mb-3"> <label class="form-label">Patient :</label> @@ -24,16 +24,12 @@ </select> </div> - <!-- Sélecteur du Médecin --> <div class="mb-3"> <label class="form-label">Médecin :</label> - <select class="form-select" name="doctorId" required> - <option value="">Sélectionner un médecin</option> - <option th:each="doctor : ${doctors}" - th:value="${doctor.id}" - th:text="${doctor.firstName + ' ' + doctor.lastName}"> - </option> - </select> + <input type="hidden" name="doctorId" th:value="${doctor.id}"> + <!-- Affichage du nom du médecin authentifié --> + <input type="text" class="form-control" th:value="'Dr. ' + ${doctor.firstName} + ' ' + ${doctor.lastName}" + readonly> </div> <!-- Champ Date et Heure --> @@ -49,7 +45,7 @@ </div> <button type="submit" class="btn btn-success">Créer le rendez-vous</button> - <a href="/appointments" th:href="@{/appointments}" class="btn btn-secondary">Annuler</a> + <a href="/doctors/appointments" th:href="@{/doctors/appointments}" class="btn btn-secondary">Annuler</a> </form> </div> diff --git a/src/main/resources/templates/doctor-dashboard.html b/src/main/resources/templates/doctor-dashboard.html index b6c86c374b55ebf8b4dd70991f7615955d143da1..b31bed1886a75e59ede21a6c92316405c43b4a0f 100644 --- a/src/main/resources/templates/doctor-dashboard.html +++ b/src/main/resources/templates/doctor-dashboard.html @@ -31,12 +31,13 @@ <p class="mt-2 text-gray-600">Consulter et gérer la liste de vos patients.</p> </a> - <a href="/medical-files" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <a href="/doctors/medical-files-doctor" + class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> <h3 class="text-xl font-semibold text-gray-800">Dossiers Médicaux</h3> <p class="mt-2 text-gray-600">Accéder aux dossiers médicaux de vos patients.</p> </a> - <a href="/appointments" + <a href="/doctors/appointments" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition md:col-span-2 flex items-center justify-center text-center"> <div class="space-y-2"> <h3 class="text-xl font-semibold text-gray-800">Rendez-vous</h3> diff --git a/src/main/resources/templates/medical-files.html b/src/main/resources/templates/medical-files-doctor.html similarity index 82% rename from src/main/resources/templates/medical-files.html rename to src/main/resources/templates/medical-files-doctor.html index 368bb306f39366661a7d3f74a626405f86e4e31e..e66073852bb154107a0e076849e6575573b71816 100644 --- a/src/main/resources/templates/medical-files.html +++ b/src/main/resources/templates/medical-files-doctor.html @@ -4,8 +4,7 @@ <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Liste des dossiers médicaux</title> - <link rel="stylesheet" - href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> </head> <body class="bg-light"> @@ -39,13 +38,13 @@ </td> <td> - <a th:href="@{/medical-files/{id}(id=${file.id})}" class="btn btn-info">Consulter</a> + <a th:href="@{/doctors/medical-files-doctor/{id}(id=${file.id})}" class="btn btn-info">Consulter</a> </td> </tr> </tbody> </table> - <a href="/" class="btn btn-primary mt-3">Retour à l'accueil</a> + <a href="/doctors/dashboard" class="btn btn-primary mt-3">Retour à l'accueil</a> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> diff --git a/src/main/resources/templates/medical-files-patient.html b/src/main/resources/templates/medical-files-patient.html new file mode 100644 index 0000000000000000000000000000000000000000..77e6507f5eb8090d8a8688430436175152055c9f --- /dev/null +++ b/src/main/resources/templates/medical-files-patient.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Mon Dossier Médical</title> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> +</head> +<body class="bg-light"> + +<div class="container mt-5"> + <h1 class="text-center mb-4">Mon Dossier Médical</h1> + + <div th:if="${medicalFile}"> + <h5 class="card-title">Dossier médical de : + <span th:text="${medicalFile.patient != null ? medicalFile.patient.firstName : 'Inconnu'}"></span> + <span th:text="${medicalFile.patient != null ? medicalFile.patient.lastName : ''}"></span> + </h5> + + <!-- Historique médical --> + <div class="mt-3"> + <h5>Historique médical :</h5> + <ul class="list-group"> + <li th:each="history : ${medicalFile.healthHistoricalList}" class="list-group-item"> + <strong>Antécédent:</strong> <span th:text="${history.antecedent}"></span><br> + <strong>Notes:</strong> <span th:text="${history.notes}"></span><br> + <strong>Date de consultation:</strong> <span th:text="${history.consultationDate}"></span> + </li> + </ul> + </div> + + <!-- Liste des documents avec lien de téléchargement --> + <div class="mt-3"> + <h5>Documents disponibles :</h5> + <ul class="list-group"> + <li th:each="doc : ${medicalFile.documentList}" + class="list-group-item d-flex justify-content-between align-items-center"> + <span th:text="${doc.fileName}"></span> + <div> + <a th:href="@{/patients/medical-files-patient/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" + class="btn btn-sm btn-warning"> + Télécharger + </a> + </div> + </li> + </ul> + </div> + </div> + + <a href="/patients/dashboard" class="btn btn-primary mt-3">Retour à l'accueil</a> +</div> + +<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> +</body> +</html> diff --git a/src/main/resources/templates/patient-dashboard.html b/src/main/resources/templates/patient-dashboard.html index f750bee251f999075ad832570dce21f6a1b4a713..78819ac101da0a65cd4523391e87b5bad8771134 100644 --- a/src/main/resources/templates/patient-dashboard.html +++ b/src/main/resources/templates/patient-dashboard.html @@ -24,12 +24,12 @@ <p class="mt-2 text-gray-600">Voir les informations de votre médecin.</p> </a> - <a href="/medical-files" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> - <h3 class="text-xl font-semibold text-gray-800">Mes Dossiers Médicaux</h3> - <p class="mt-2 text-gray-600">Consulter vos dossiers médicaux.</p> + <a href="/patients/medical-files-patient" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <h3 class="text-xl font-semibold text-gray-800">Mon Dossier Médical</h3> + <p class="mt-2 text-gray-600">Consulter votre dossier médical.</p> </a> - <a href="/appointments" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <a href="/patients/appointments" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> <h3 class="text-xl font-semibold text-gray-800">Mes Rendez-vous</h3> <p class="mt-2 text-gray-600">Voir et gérer vos rendez-vous.</p> </a> diff --git a/src/main/resources/templates/view-medical-file.html b/src/main/resources/templates/view-medical-file-doctor.html similarity index 84% rename from src/main/resources/templates/view-medical-file.html rename to src/main/resources/templates/view-medical-file-doctor.html index b336c379e7103434453881bc8923845dba625522..b53f4c0ff91ed57d7112de0ab2388443da20f58c 100644 --- a/src/main/resources/templates/view-medical-file.html +++ b/src/main/resources/templates/view-medical-file-doctor.html @@ -31,7 +31,8 @@ </div> <!-- Formulaire de téléchargement du document --> - <form method="post" th:action="@{/medical-files/{id}/documents(id=${medicalFile.id})}" enctype="multipart/form-data" + <form method="post" th:action="@{/doctors/medical-files-doctor/{id}/documents(id=${medicalFile.id})}" + enctype="multipart/form-data" class="mt-3"> <label for="file" class="form-label">Importer un document :</label> <input type="file" name="document" id="file" class="form-control mb-2"/> @@ -46,11 +47,11 @@ class="list-group-item d-flex justify-content-between align-items-center"> <span th:text="${doc.fileName}"></span> <div> - <a th:href="@{/medical-files/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" + <a th:href="@{/doctors/medical-files-doctor/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" class="btn btn-sm btn-warning"> Télécharger </a> - <form th:action="@{/medical-files/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" + <form th:action="@{/doctors/medical-files-doctor/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" method="post" class="d-inline"> <input type="hidden" name="_method" value="delete"/> <button type="submit" class="btn btn-sm btn-danger" @@ -63,9 +64,9 @@ </ul> </div> - <a href="/medical-files" class="btn btn-primary mt-3">Retour à la liste</a> + <a href="/doctors/medical-files-doctor" class="btn btn-primary mt-3">Retour à la liste</a> </div> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> </body> -</html> \ No newline at end of file +</html>