Skip to content
Snippets Groups Projects
Commit d2ca23b4 authored by RAGOT Jessie's avatar RAGOT Jessie
Browse files

Merge branch 'feature/setting-up-the-superadmin' into 'main'

- Modification of the front for inscription, changeover to landscape

See merge request !21
parents d1f3037a ec566794
No related branches found
No related tags found
1 merge request!21- Modification of the front for inscription, changeover to landscape
Showing
with 618 additions and 86 deletions
......@@ -18,19 +18,21 @@ public class DatabaseSeeder implements CommandLineRunner {
private final DoctorRepository doctorRepository;
private final PatientRepository patientRepository;
private final AdminRepository adminRepository;
private final MedicalFileRepository medicalFileRepository;
private final MedicalDocumentRepository medicalDocumentRepository;
private final AppointmentRepository appointmentRepository;
private final PasswordEncoder passwordEncoder;
public DatabaseSeeder(DoctorRepository doctorRepository,
PatientRepository patientRepository,
PatientRepository patientRepository, AdminRepository adminRepository,
MedicalFileRepository medicalFileRepository,
MedicalDocumentRepository medicalDocumentRepository,
AppointmentRepository appointmentRepository,
PasswordEncoder passwordEncoder) {
this.doctorRepository = doctorRepository;
this.patientRepository = patientRepository;
this.adminRepository = adminRepository;
this.medicalFileRepository = medicalFileRepository;
this.medicalDocumentRepository = medicalDocumentRepository;
this.appointmentRepository = appointmentRepository;
......@@ -48,6 +50,9 @@ public class DatabaseSeeder implements CommandLineRunner {
Patient patient2 = new Patient("Alice", "Lemoine", LocalDate.parse("1990-05-15"), "0687654321", "alice.lemoine@example.com", "8 Rue du Lac", passwordEncoder.encode("test123"));
patientRepository.saveAll(List.of(patient1, patient2));
Admin admin1 = new Admin("root", "root", "0000000000", "root@example.com", passwordEncoder.encode("root123"));
adminRepository.save(admin1);
MedicalFile file1 = new MedicalFile(patient1, "Arachide", "Ibuprofene");
MedicalFile file2 = new MedicalFile(patient2, "Pollen", "Bisoprolol");
medicalFileRepository.saveAll(List.of(file1, file2));
......@@ -72,6 +77,7 @@ public class DatabaseSeeder implements CommandLineRunner {
System.out.println("Données insérées :");
System.out.println("Médecins : " + doctorRepository.count());
System.out.println("Patients : " + patientRepository.count());
System.out.println("Admin: " + adminRepository.count());
System.out.println("Dossiers médicaux : " + medicalFileRepository.count());
System.out.println("Documents médicaux : " + medicalDocumentRepository.count());
System.out.println("Rendez-vous : " + appointmentRepository.count());
......
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";
}
}
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";
}
}
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";
}
}
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";
}
}
......@@ -7,6 +7,7 @@ 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.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
......@@ -29,11 +30,11 @@ public class DoctorAppointmentController {
}
@GetMapping
public String showDoctorAppointments(Model model) {
public String showDoctorAppointments(Model model, Authentication authentication) {
Long doctorId = doctorService.getAuthenticatedDoctorId();
List<Appointment> appointments = appointmentService.getAppointmentsByDoctor(doctorId);
model.addAttribute("appointments", appointments);
return "appointments";
return "doctor-appointments";
}
@GetMapping("/create")
......@@ -47,10 +48,9 @@ public class DoctorAppointmentController {
model.addAttribute("doctor", doctor);
return "create-appointment";
return "create-appointment-doctor";
}
@PostMapping("/create")
public String createAppointment(@RequestParam("patientId") Long patientId,
@RequestParam("dateTime") String dateTime,
......@@ -81,12 +81,9 @@ public class DoctorAppointmentController {
return "redirect:/doctors/appointments";
}
@PostMapping("/{id}/cancel")
public String cancelAppointment(@PathVariable Long id) {
appointmentService.cancelAppointment(id);
return "redirect:/doctors/appointments";
}
}
......@@ -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);
......
......@@ -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);
......
package com.projet.projetIndu.controllers;
import com.projet.projetIndu.entities.User;
import com.projet.projetIndu.services.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
......@@ -8,19 +11,42 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.Collection;
import java.util.Optional;
@Controller
public class HomeController {
private final UserService userService;
@Autowired
public HomeController(UserService userService) {
this.userService = userService;
}
@GetMapping("/")
public String home(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated() && !authentication.getPrincipal().equals("anonymousUser")) {
model.addAttribute("username", authentication.getName());
String username = authentication.getName();
model.addAttribute("username", username);
Optional<User> userOptional = userService.getUserByUsername(username);
if (userOptional.isPresent()) {
User user = userOptional.get();
model.addAttribute("firstName", user.getFirstName());
model.addAttribute("lastName", user.getLastName());
}
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
boolean isDoctor = authorities.stream().anyMatch(auth -> auth.getAuthority().equals("DOCTOR"));
boolean isPatient = authorities.stream().anyMatch(auth -> auth.getAuthority().equals("PATIENT"));
boolean isAdmin = authorities.stream().anyMatch(auth -> auth.getAuthority().equals("ADMIN"));
model.addAttribute("isDoctor", isDoctor);
model.addAttribute("isPatient", isPatient);
model.addAttribute("isAdmin", isAdmin);
}
return "home";
......
......@@ -3,15 +3,18 @@ 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.security.core.Authentication;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;
@Controller
@RequestMapping("/patients/appointments") // L'URL commence bien par /patients/
@RequestMapping("/patients/appointments")
public class PatientAppointmentController {
private final AppointmentService appointmentService;
......@@ -23,11 +26,16 @@ public class PatientAppointmentController {
}
@GetMapping
public String showPatientAppointments(Model model) {
Long patientId = patientService.getAuthenticatedPatientId(); // Récupère l'ID du patient connecté
public String showPatientAppointments(Model model, Authentication authentication) {
Long patientId = patientService.getAuthenticatedPatientId();
List<Appointment> appointments = appointmentService.getAppointmentsByPatient(patientId);
model.addAttribute("appointments", appointments);
return "appointments";
}
return "patient-appointments"; // Utilisez la vue spécifique pour les patients
}
@PostMapping("/{id}/cancel")
public String cancelAppointment(@PathVariable Long id) {
appointmentService.cancelAppointment(id);
return "redirect:/patients/appointments";
}
}
......@@ -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";
......
package com.projet.projetIndu.entities;
import jakarta.persistence.Column;
import jakarta.persistence.DiscriminatorValue;
import jakarta.persistence.Entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Entity
@Getter
@Setter
@NoArgsConstructor
@DiscriminatorValue("ADMIN")
public class Admin extends User {
public Admin(String firstName, String lastName, String phoneNumber, String email, String password) {
super(firstName, lastName, phoneNumber, email, password);
this.role = Role.ADMIN;
}
}
......@@ -54,6 +54,6 @@ public class DoctorService {
}
}
//
package com.projet.projetIndu.services;
import com.projet.projetIndu.dto.UserRegistrationDTO;
import com.projet.projetIndu.entities.Admin;
import com.projet.projetIndu.entities.Doctor;
import com.projet.projetIndu.entities.Patient;
import com.projet.projetIndu.entities.Role;
import com.projet.projetIndu.entities.User;
import com.projet.projetIndu.repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -14,6 +14,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
......@@ -54,18 +55,9 @@ public class UserService implements UserDetailsService {
}
String encodedPassword = passwordEncoder.encode(userDTO.getPassword());
User user;
User user = null;
switch (userDTO.getRole()) {
case DOCTOR -> {
if (userDTO.getSpeciality() == null || userDTO.getSpeciality().isEmpty()) {
throw new IllegalArgumentException("Speciality is required for doctors");
}
Doctor doctor = new Doctor();
doctor.setSpeciality(userDTO.getSpeciality());
user = doctor;
}
case PATIENT -> {
if (Objects.requireNonNull(userDTO.getRole()) == Role.PATIENT) {
if (userDTO.getDateOfBirth() == null) {
throw new IllegalArgumentException("Date of birth is required for patients");
}
......@@ -76,16 +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");
}
case ADMIN -> {
user = new Admin();
Doctor doctor = new Doctor();
doctor.setSpeciality(userDTO.getSpeciality());
user = doctor;
}
default -> throw new IllegalArgumentException("Invalid role");
if (user == null) {
throw new IllegalArgumentException("Invalid role");
}
user.setFirstName(userDTO.getFirstName());
user.setLastName(userDTO.getLastName());
user.setPhoneNumber(userDTO.getPhoneNumber());
user.setEmail(userDTO.getEmail());
user.setPassword(encodedPassword);
user.setRole(userDTO.getRole());
......
<!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>
<!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">&copy; 2025 Gestion Dossiers Médicaux. Tous droits réservés.</p>
</div>
</footer>
</body>
</html>
<!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>
<!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>
<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>
<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>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
......@@ -26,7 +26,8 @@
<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="@{/appointments/{id}/cancel(id=${appointment.id})}" class="d-inline">
<form method="post" th:action="@{/doctors/appointments/{id}/cancel(id=${appointment.id})}"
class="d-inline">
<input type="hidden" name="_method" value="post"/>
<button type="submit" class="btn btn-danger btn-sm"
onclick="return confirm('Voulez-vous annuler ce rendez-vous ?');">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment