diff --git a/src/main/java/com/projet/projetIndu/controllers/AdminAppointmentController.java b/src/main/java/com/projet/projetIndu/controllers/AdminAppointmentController.java new file mode 100644 index 0000000000000000000000000000000000000000..d456eb4af6c4e1212d98a39ab69684d575ce167c --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/AdminAppointmentController.java @@ -0,0 +1,80 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.entities.Appointment; +import com.projet.projetIndu.entities.AppointmentStatus; +import com.projet.projetIndu.entities.Doctor; +import com.projet.projetIndu.entities.Patient; +import com.projet.projetIndu.services.AppointmentService; +import com.projet.projetIndu.services.DoctorService; +import com.projet.projetIndu.services.PatientService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.List; + +@Controller +@RequestMapping("/admin/admin-appointments") +public class AdminAppointmentController { + + private final AppointmentService appointmentService; + private final DoctorService doctorService; + private final PatientService patientService; + + public AdminAppointmentController(AppointmentService appointmentService, DoctorService doctorService, PatientService patientService) { + this.appointmentService = appointmentService; + this.doctorService = doctorService; + this.patientService = patientService; + } + + @GetMapping + public String appointments(Model model) { + model.addAttribute("appointments", appointmentService.getAllAppointments()); + return "admin-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); + return "create-appointment-admin"; + } + + @PostMapping("/create") + public String createAppointment(@RequestParam("patientId") Long patientId, + @RequestParam("dateTime") String dateTime, + @RequestParam("reason") String reason, + @RequestParam("doctorId") Long doctorId) { + + Doctor doctor = doctorService.getDoctorById(doctorId) + .orElseThrow(() -> new RuntimeException("Médecin introuvable")); + Patient patient = patientService.getPatientById(patientId) + .orElseThrow(() -> new RuntimeException("Patient introuvable")); + + LocalDateTime parsedDateTime = LocalDateTime.parse(dateTime); + + Appointment appointment = new Appointment(); + appointment.setDoctor(doctor); + appointment.setPatient(patient); + appointment.setDateTime(parsedDateTime); + appointment.setStatus(AppointmentStatus.PENDING); + appointment.setReason(reason); + + appointmentService.saveAppointment(appointment); + + return "redirect:/admin/admin-appointments"; + } + + @PostMapping("/admin/appointments/{id}/cancel") + public String cancelAppointment(@PathVariable Long id) { + appointmentService.cancelAppointment(id); + return "redirect:/admin/admin-appointments"; + } +} + + + diff --git a/src/main/java/com/projet/projetIndu/controllers/AdminController.java b/src/main/java/com/projet/projetIndu/controllers/AdminController.java new file mode 100644 index 0000000000000000000000000000000000000000..7b5cfa3eb850de60869b78798c9c5c7075de9557 --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/AdminController.java @@ -0,0 +1,50 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.entities.Doctor; +import com.projet.projetIndu.services.DoctorService; +import com.projet.projetIndu.services.PatientService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller +@RequestMapping("/admin") +public class AdminController { + + @Autowired + private DoctorService doctorService; + @Autowired + private PatientService patientService; + + @GetMapping("/dashboard") + public String adminDashboard() { + return "admin-dashboard"; + } + + @GetMapping("/createDoctor") + public String createDoctorForm(Model model) { + model.addAttribute("doctor", new Doctor()); + return "create-doctor"; + } + + @PostMapping("/createDoctor") + public String createDoctor(Doctor doctor) { + doctorService.saveDoctor(doctor); + return "redirect:/admin/doctors"; + } + + @GetMapping("/patients") + public String patients(Model model) { + model.addAttribute("patients", patientService.getAllPatients()); + return "patients"; + } + + @GetMapping("/doctors") + public String doctors(Model model) { + model.addAttribute("doctors", doctorService.getAllDoctors()); + return "doctors"; + } +} diff --git a/src/main/java/com/projet/projetIndu/controllers/AdminMedicalFileController.java b/src/main/java/com/projet/projetIndu/controllers/AdminMedicalFileController.java new file mode 100644 index 0000000000000000000000000000000000000000..dd2a9cb74369673552ec861f563a41956424a9d5 --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/AdminMedicalFileController.java @@ -0,0 +1,118 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.entities.MedicalDocument; +import com.projet.projetIndu.entities.MedicalFile; +import com.projet.projetIndu.repositories.MedicalDocumentRepository; +import com.projet.projetIndu.services.MedicalFileService; +import org.springframework.http.*; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; + +import java.io.IOException; +import java.time.LocalDate; +import java.util.Optional; + +@Controller +@RequestMapping("/admin/medical-files-admin") +public class AdminMedicalFileController { + + private final MedicalFileService medicalFileService; + private final MedicalDocumentRepository medicalDocumentRepository; + + public AdminMedicalFileController(MedicalFileService medicalFileService, MedicalDocumentRepository medicalDocumentRepository) { + this.medicalFileService = medicalFileService; + this.medicalDocumentRepository = medicalDocumentRepository; + } + + @GetMapping + public String listMedicalFiles(Model model) { + model.addAttribute("medicalFiles", medicalFileService.getAllMedicalFiles()); + return "medical-files-admin"; + } + + @GetMapping("/{id}") + public String viewMedicalFile(@PathVariable Long id, Model model) { + MedicalFile medicalFile = medicalFileService.getMedicalFileById(id).orElse(null); + if (medicalFile != null) { + model.addAttribute("medicalFile", medicalFile); + return "view-medical-file-admin"; + } + model.addAttribute("errorMessage", "Dossier introuvable."); + return "error"; + } + + @PostMapping("/create") + public String createMedicalFile(@ModelAttribute MedicalFile medicalFile) { + medicalFileService.saveMedicalFiles(medicalFile); + return "redirect:/admin/medical-files-admin"; + } + + @PostMapping("/{id}/history") + public String updateMedicalFileHistory(@PathVariable Long id, + @RequestParam String antecedent, + @RequestParam String notes, + @RequestParam LocalDate consultationDate) { + medicalFileService.updateMedicalFileHistory(id, antecedent, notes, consultationDate); + return "redirect:/admin/medical-files-admin/" + id; + } + + @PostMapping("/{id}/documents") + public String uploadMedicalFileDocument(@PathVariable Long id, @RequestParam("document") MultipartFile document, RedirectAttributes redirectAttributes) { + try { + medicalFileService.uploadMedicalFileDocument(id, document); + } catch (IOException e) { + e.printStackTrace(); + redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de l'upload du document."); + return "redirect:/admin/medical-files-admin/" + id; + } + return "redirect:/admin/medical-files-admin/" + id; + } + + @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); + } + } + + @DeleteMapping("/{id}/documents/{docId}") + public String deleteDocument(@PathVariable Long id, @PathVariable Long docId, RedirectAttributes redirectAttributes) { + Optional<MedicalDocument> document = medicalDocumentRepository.findById(docId); + + if (document.isPresent()) { + medicalDocumentRepository.delete(document.get()); + redirectAttributes.addFlashAttribute("successMessage", "Document supprimé avec succès."); + } else { + redirectAttributes.addFlashAttribute("errorMessage", "Document introuvable."); + } + + return "redirect:/admin/medical-files-admin/" + id; + } + + @DeleteMapping("/{id}") + public String deleteMedicalFile(@PathVariable Long id, RedirectAttributes redirectAttributes) { + try { + medicalFileService.deleteMedicalFileById(id); + redirectAttributes.addFlashAttribute("successMessage", "Dossier médical supprimé avec succès."); + } catch (Exception e) { + redirectAttributes.addFlashAttribute("errorMessage", "Erreur lors de la suppression du dossier médical."); + } + return "redirect:/admin/medical-files-admin"; + } +} + + diff --git a/src/main/java/com/projet/projetIndu/controllers/AdminRegisterController.java b/src/main/java/com/projet/projetIndu/controllers/AdminRegisterController.java new file mode 100644 index 0000000000000000000000000000000000000000..dc5f62af8a93b9bb280c062a0d24bc051b2c89bb --- /dev/null +++ b/src/main/java/com/projet/projetIndu/controllers/AdminRegisterController.java @@ -0,0 +1,62 @@ +package com.projet.projetIndu.controllers; + +import com.projet.projetIndu.dto.UserRegistrationDTO; +import com.projet.projetIndu.entities.Role; +import com.projet.projetIndu.services.UserService; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; + +@Controller +@RequestMapping("/admin") +public class AdminRegisterController { + + private final UserService userService; + + public AdminRegisterController(UserService userService) { + this.userService = userService; + } + + // Affiche le formulaire d'inscription pour les médecins + @GetMapping("/register-doctor") + public String showRegisterDoctorForm(Model model) { + model.addAttribute("doctor", new UserRegistrationDTO()); + return "create-doctor"; + } + + // Traite l'inscription d'un médecin + @PostMapping("/register-doctor") + public String registerDoctor( + @RequestParam String firstName, + @RequestParam String lastName, + @RequestParam String email, + @RequestParam String password, + @RequestParam String speciality, + Model model) { + + if (userService.getUserByUsername(email).isPresent()) { + model.addAttribute("error", "Le médecin existe déjà !"); + return "create-doctor"; + } + + UserRegistrationDTO dto = new UserRegistrationDTO(); + dto.setFirstName(firstName); + dto.setLastName(lastName); + dto.setEmail(email); + dto.setPassword(password); + dto.setRole(Role.DOCTOR); + dto.setSpeciality(speciality); + + try { + userService.registerUser(dto); + } catch (IllegalArgumentException e) { + model.addAttribute("error", e.getMessage()); + return "create-doctor"; + } + + return "redirect:/admin/doctors"; + } +} diff --git a/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java index 39396c59420eb17730947ea26ea4a3afc1a80968..097e252a87c51f2a3ce1f68f594b969c20b50e09 100644 --- a/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorAppointmentController.java @@ -48,7 +48,7 @@ public class DoctorAppointmentController { model.addAttribute("doctor", doctor); - return "create-appointment"; + return "create-appointment-doctor"; } @PostMapping("/create") diff --git a/src/main/java/com/projet/projetIndu/controllers/DoctorController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorController.java index b93ce58fdaeabc2b74b49cb387205a8fb4c48186..62bf98dd9b38fd16d4ecade1ad049d1d572dd09a 100644 --- a/src/main/java/com/projet/projetIndu/controllers/DoctorController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorController.java @@ -4,7 +4,9 @@ import com.projet.projetIndu.entities.Doctor; import com.projet.projetIndu.services.DoctorService; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import java.util.List; @@ -25,19 +27,6 @@ public class DoctorController { return "doctors"; } - @GetMapping("/create") - public String showCreateForm(Model model) { - model.addAttribute("doctor", new Doctor()); - return "create-doctor"; - } - - - @PostMapping - public String createDoctor(@ModelAttribute Doctor doctor) { - doctorService.saveDoctor(doctor); - return "redirect:/doctors"; - } - @GetMapping("/search") public String searchDoctor(@RequestParam("firstName") String firstName, @RequestParam("lastName") String lastName, Model model) { List<Doctor> doctors = doctorService.getDoctorByName(firstName, lastName); diff --git a/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java index 6adfe0da71774101b8e9d4d9d45cd46697083a7f..82c57d1a093cdcbe3f824b26ada5dc05ae1c2dab 100644 --- a/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java @@ -27,14 +27,12 @@ public class DoctorMedicalFileController { this.medicalDocumentRepository = medicalDocumentRepository; } - // Afficher tous les dossiers médicaux @GetMapping public String listMedicalFiles(Model model) { 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) { MedicalFile medicalFile = medicalFileService.getMedicalFileById(id).orElse(null); diff --git a/src/main/java/com/projet/projetIndu/controllers/AuthController.java b/src/main/java/com/projet/projetIndu/controllers/PatientRegisterController.java similarity index 86% rename from src/main/java/com/projet/projetIndu/controllers/AuthController.java rename to src/main/java/com/projet/projetIndu/controllers/PatientRegisterController.java index 8a20b5ddb10029e855fbddd0adc5dab3dd0dbf34..d6bcc0fae5587cc445ab88a25234df6f59d4771e 100644 --- a/src/main/java/com/projet/projetIndu/controllers/AuthController.java +++ b/src/main/java/com/projet/projetIndu/controllers/PatientRegisterController.java @@ -12,20 +12,19 @@ import org.springframework.web.bind.annotation.RequestParam; import java.time.LocalDate; @Controller -public class AuthController { +public class PatientRegisterController { private final UserService userService; - public AuthController(UserService userService) { + public PatientRegisterController(UserService userService) { this.userService = userService; } // Affiche le formulaire d'inscription @GetMapping("/register") public String showRegisterForm() { - return "register"; + return "register-patient"; } - // Traite l'inscription @PostMapping("/register") public String registerUser( @RequestParam String firstName, @@ -40,7 +39,7 @@ public class AuthController { if (userService.getUserByUsername(email).isPresent()) { model.addAttribute("error", "L'utilisateur existe déjà !"); - return "register"; + return "register-patient"; } Role userRole; @@ -48,7 +47,7 @@ public class AuthController { userRole = Role.valueOf(role.toUpperCase()); } catch (IllegalArgumentException e) { model.addAttribute("error", "Rôle invalide !"); - return "register"; + return "register-patient"; } UserRegistrationDTO dto = new UserRegistrationDTO(); @@ -61,16 +60,13 @@ public class AuthController { if (userRole == Role.PATIENT) { dto.setDateOfBirth(dateOfBirth != null ? LocalDate.parse(dateOfBirth) : null); dto.setAddress(address); - } else if (userRole == Role.DOCTOR) { - dto.setSpeciality(speciality); } - // Enregistrer l'utilisateur try { userService.registerUser(dto); } catch (IllegalArgumentException e) { model.addAttribute("error", e.getMessage()); - return "register"; + return "register-patient"; } return "redirect:/login?registered=true"; diff --git a/src/main/java/com/projet/projetIndu/services/UserService.java b/src/main/java/com/projet/projetIndu/services/UserService.java index 314af3edf80e44c1436ca2b5b1934ab8a239e496..3d883a11889446a3f0433ac8ae1ed43bb2cf8626 100644 --- a/src/main/java/com/projet/projetIndu/services/UserService.java +++ b/src/main/java/com/projet/projetIndu/services/UserService.java @@ -1,6 +1,7 @@ package com.projet.projetIndu.services; import com.projet.projetIndu.dto.UserRegistrationDTO; +import com.projet.projetIndu.entities.Doctor; import com.projet.projetIndu.entities.Patient; import com.projet.projetIndu.entities.Role; import com.projet.projetIndu.entities.User; @@ -67,12 +68,21 @@ public class UserService implements UserDetailsService { patient.setDateOfBirth(userDTO.getDateOfBirth()); patient.setAddress(userDTO.getAddress()); user = patient; + } else if (userDTO.getRole() == Role.DOCTOR) { + if (userDTO.getSpeciality() == null || userDTO.getSpeciality().isBlank()) { + throw new IllegalArgumentException("Speciality is required for doctors"); + } + Doctor doctor = new Doctor(); + doctor.setSpeciality(userDTO.getSpeciality()); + user = doctor; + } + + if (user == null) { + throw new IllegalArgumentException("Invalid role"); } - assert user != null; user.setFirstName(userDTO.getFirstName()); user.setLastName(userDTO.getLastName()); - user.setPhoneNumber(userDTO.getPhoneNumber()); user.setEmail(userDTO.getEmail()); user.setPassword(encodedPassword); user.setRole(userDTO.getRole()); diff --git a/src/main/resources/templates/admin-appointments.html b/src/main/resources/templates/admin-appointments.html new file mode 100644 index 0000000000000000000000000000000000000000..6e4fb7b2726df2028d59bb76384371998b80fddb --- /dev/null +++ b/src/main/resources/templates/admin-appointments.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Rendez-vous</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">Liste des rendez-vous</h1> + + <a href="/admin/admin-appointments/create" class="btn btn-primary mb-3">Créer un nouveau rendez-vous</a> + + <table class="table table-bordered table-striped"> + <thead class="table-dark"> + <tr> + <th>Patient</th> + <th>Médecin</th> + <th>Date et heure</th> + <th>Statut</th> + <th>Actions</th> + </tr> + </thead> + <tbody> + <tr th:each="appointment : ${appointments}"> + <td th:text="${appointment.patient.firstName + ' ' + appointment.patient.lastName}"></td> + <td th:text="${appointment.doctor.firstName + ' ' + appointment.doctor.lastName}"></td> + <td th:text="${#temporals.format(appointment.dateTime, 'dd/MM/yyyy HH:mm')}"></td> + <td th:text="${appointment.status}"></td> + <td> + <form method="post" th:action="@{/admin/admin-appointments/{id}/cancel(id=${appointment.id})}" + class="d-inline"> + <button type="submit" class="btn btn-danger btn-sm" + onclick="return confirm('Voulez-vous annuler ce rendez-vous ?');"> + Annuler + </button> + </form> + </td> + </tr> + </tbody> + </table> +</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/admin-dashboard.html b/src/main/resources/templates/admin-dashboard.html new file mode 100644 index 0000000000000000000000000000000000000000..7e5b2971a0e55c1d23b999668a008ecfbfb7a9b9 --- /dev/null +++ b/src/main/resources/templates/admin-dashboard.html @@ -0,0 +1,68 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <title>Tableau de Bord Admin</title> + <script src="https://cdn.tailwindcss.com"></script> +</head> +<body class="bg-gray-100 font-sans leading-normal tracking-normal"> + +<!-- Header --> +<header class="bg-white shadow-md"> + <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> + <div class="flex justify-between items-center py-6"> + <h1 class="text-2xl font-semibold text-gray-900">Tableau de Bord Admin</h1> + <a href="/" class="text-blue-500 hover:text-blue-700">Retour à l'accueil</a> + </div> + </div> +</header> + +<!-- Main Section --> +<main class="mt-12"> + <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> + <h2 class="text-3xl font-bold text-gray-800 text-center">Bienvenue sur votre tableau de bord</h2> + <p class="mt-4 text-lg text-gray-600 text-center">Gérez les médecins, les dossiers médicaux, les rendez-vous et + les patients.</p> + + <div class="mt-8 grid grid-cols-1 md:grid-cols-2 gap-6"> + <a href="/admin/createDoctor" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <h3 class="text-xl font-semibold text-gray-800">Créer un Médecin</h3> + <p class="mt-2 text-gray-600">Ajouter un nouveau médecin au système.</p> + </a> + + <a href="/admin/medical-files-admin" 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">Consulter tous les dossiers médicaux.</p> + </a> + + <a href="/admin/admin-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> + <p class="text-gray-600">Gérer les rendez-vous des médecins et des patients.</p> + </div> + </a> + + <a href="/admin/patients" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <h3 class="text-xl font-semibold text-gray-800">Patients</h3> + <p class="mt-2 text-gray-600">Consulter la liste de tous les patients.</p> + </a> + + <a href="/admin/doctors" class="p-6 bg-white shadow-md rounded-lg hover:shadow-lg transition"> + <h3 class="text-xl font-semibold text-gray-800">Médecins</h3> + <p class="mt-2 text-gray-600">Consulter la liste de tous les médecins.</p> + </a> + </div> + </div> +</main> + +<!-- Footer --> +<footer class="bg-white shadow-md mt-16"> + <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-4 text-center"> + <p class="text-sm text-gray-600">© 2025 Gestion Dossiers Médicaux. Tous droits réservés.</p> + </div> +</footer> + +</body> +</html> diff --git a/src/main/resources/templates/create-appointment-admin.html b/src/main/resources/templates/create-appointment-admin.html new file mode 100644 index 0000000000000000000000000000000000000000..1998c5f90863399c12f82cf7052558a9619193ce --- /dev/null +++ b/src/main/resources/templates/create-appointment-admin.html @@ -0,0 +1,58 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Créer un rendez-vous</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">Créer un rendez-vous</h1> + + <form method="post" th:action="@{/admin/admin-appointments/create}"> + <!-- Sélecteur du Patient --> + <div class="mb-3"> + <label class="form-label">Patient :</label> + <select class="form-select" name="patientId" required> + <option value="">Sélectionner un patient</option> + <option th:each="patient : ${patients}" + th:value="${patient.id}" + th:text="${patient.firstName + ' ' + patient.lastName}"> + </option> + </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> + </div> + + <!-- Champ Date et Heure --> + <div class="mb-3"> + <label class="form-label">Date et heure :</label> + <input type="datetime-local" class="form-control" name="dateTime" required> + </div> + + <!-- Champ Motif --> + <div class="mb-3"> + <label class="form-label">Motif :</label> + <input type="text" class="form-control" name="reason" required> + </div> + + <button type="submit" class="btn btn-success">Créer le rendez-vous</button> + <a href="/admin/admin-appointments" th:href="@{/admin/admin-appointments}" class="btn btn-secondary">Annuler</a> + </form> +</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/create-appointment.html b/src/main/resources/templates/create-appointment-doctor.html similarity index 100% rename from src/main/resources/templates/create-appointment.html rename to src/main/resources/templates/create-appointment-doctor.html diff --git a/src/main/resources/templates/create-doctor.html b/src/main/resources/templates/create-doctor.html index e10580fc479b02227f746b10d699661cf4d451cf..9650775169f2191742e1373a0ca8956418aaab8f 100644 --- a/src/main/resources/templates/create-doctor.html +++ b/src/main/resources/templates/create-doctor.html @@ -1,25 +1,48 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="fr" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Créer un médecin</title> + <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"> </head> -<body> -<h1>Ajouter un médecin</h1> -<form action="#" th:action="@{/doctors}" th:object="${doctor}" method="post"> - <label for="firstName">Prénom:</label> - <input type="text" id="firstName" th:field="*{firstName}" required /><br> +<body class="bg-light"> - <label for="lastName">Nom:</label> - <input type="text" id="lastName" th:field="*{lastName}" required /><br> +<div class="container d-flex justify-content-center align-items-center vh-100"> + <div class="card shadow p-4" style="width: 500px; border-radius: 10px;"> + <h3 class="text-center mb-3">Ajouter un médecin</h3> + <form th:action="@{/admin/register-doctor}" th:object="${doctor}" method="post"> + <div class="row"> + <div class="col-md-6 mb-3"> + <label for="firstName" class="form-label">Prénom</label> + <input type="text" class="form-control" id="firstName" th:field="*{firstName}" required> + </div> + <div class="col-md-6 mb-3"> + <label for="lastName" class="form-label">Nom</label> + <input type="text" class="form-control" id="lastName" th:field="*{lastName}" required> + </div> + <div class="col-md-6 mb-3"> + <label for="email" class="form-label">Email</label> + <input type="email" class="form-control" id="email" th:field="*{email}" required> + </div> + <div class="col-md-6 mb-3"> + <label for="password" class="form-label">Mot de passe</label> + <input type="password" class="form-control" id="password" th:field="*{password}" required> + </div> + <div class="col-md-12 mb-3"> + <label for="speciality" class="form-label">Spécialité</label> + <input type="text" class="form-control" id="speciality" th:field="*{speciality}" required> + </div> + <input type="hidden" name="role" value="DOCTOR"> + </div> + <button type="submit" class="btn btn-success w-100">Ajouter</button> + </form> + <div class="text-center mt-3"> + <a href="/admin/doctors" class="btn btn-outline-secondary w-100">Annuler</a> + </div> + </div> +</div> - <label for="speciality">Spécialité:</label> - <input type="text" id="speciality" th:field="*{speciality}" required /><br> - - <label for="email">Email:</label> - <input type="email" id="email" th:field="*{email}" required /><br> - - <button type="submit">Ajouter</button> -</form> +<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/medical-files-admin.html b/src/main/resources/templates/medical-files-admin.html new file mode 100644 index 0000000000000000000000000000000000000000..5dde72bff2aa23bfb21b83f0af1aa5112466d916 --- /dev/null +++ b/src/main/resources/templates/medical-files-admin.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Dossiers Médicaux</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">Liste des dossiers médicaux</h1> + + <table class="table table-striped table-bordered"> + <thead class="table-dark"> + <tr> + <th>ID</th> + <th>Patient</th> + <th>Actions</th> + </tr> + </thead> + <tbody> + <tr th:each="file : ${medicalFiles}"> + <td th:text="${file.id}"></td> + <td th:text="${file.patient.firstName + ' ' + file.patient.lastName}"></td> + <td> + <a th:href="@{/admin/medical-files-admin/{id}(id=${file.id})}" class="btn btn-info">Consulter</a> + </td> + </tr> + </tbody> + </table> + + <a href="/admin/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/patients.html b/src/main/resources/templates/patients.html new file mode 100644 index 0000000000000000000000000000000000000000..832019cdd64294ac5db9377ac6576a159c093467 --- /dev/null +++ b/src/main/resources/templates/patients.html @@ -0,0 +1,36 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Liste des Patients</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">Liste des Patients</h1> + + <table class="table table-striped table-bordered"> + <thead class="table-dark"> + <tr> + <th>ID</th> + <th>Nom</th> + <th>Email</th> + </tr> + </thead> + <tbody> + <tr th:each="patient : ${patients}"> + <td th:text="${patient.id}"></td> + <td th:text="${patient.firstName + ' ' + patient.lastName}"></td> + <td th:text="${patient.email}"></td> + </tr> + </tbody> + </table> + + <a href="/admin/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/register.html b/src/main/resources/templates/register-patient.html similarity index 100% rename from src/main/resources/templates/register.html rename to src/main/resources/templates/register-patient.html diff --git a/src/main/resources/templates/view-medical-file-admin.html b/src/main/resources/templates/view-medical-file-admin.html new file mode 100644 index 0000000000000000000000000000000000000000..3469c0ffe21efc5e44da0f0ef4af3d08b15fd833 --- /dev/null +++ b/src/main/resources/templates/view-medical-file-admin.html @@ -0,0 +1,71 @@ +<!DOCTYPE html> +<html lang="fr"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Détails du 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">Détails du dossier médical</h1> + + <div th:if="${medicalFile}"> + <h5 class="card-title">Dossier médical de : + <span th:text="${medicalFile.patient.firstName + ' ' + medicalFile.patient.lastName}"></span> + </h5> + </div> + + <!-- 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> + + <!-- Formulaire de téléchargement du document --> + <form method="post" th:action="@{/admin/medical-files-admin/{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"/> + <button type="submit" class="btn btn-primary">Uploader le document</button> + </form> + + <!-- 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="@{/admin/medical-files-admin/{id}/documents/{docId}(id=${medicalFile.id}, docId=${doc.id})}" + class="btn btn-sm btn-warning"> + Télécharger + </a> + <form th:action="@{/admin/medical-files-admin/{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" + onclick="return confirm('Voulez-vous vraiment supprimer ce document ?');"> + Supprimer + </button> + </form> + </div> + </li> + </ul> + </div> + + <a href="/admin/medical-files-admin" 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>