diff --git a/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java index 82c57d1a093cdcbe3f824b26ada5dc05ae1c2dab..5809d6973a12da6b586ae744f85d71b06351cb54 100644 --- a/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java +++ b/src/main/java/com/projet/projetIndu/controllers/DoctorMedicalFileController.java @@ -51,7 +51,18 @@ public class DoctorMedicalFileController { return "redirect:/doctors/medical-files-doctor"; } - // Mettre à jour l'historique médical + @GetMapping("/{id}/history/add") + public String showAddHealthHistoryForm(@PathVariable Long id, Model model) { + MedicalFile medicalFile = medicalFileService.getMedicalFileById(id).orElse(null); + if (medicalFile != null) { + model.addAttribute("medicalFile", medicalFile); + return "add-health-history"; // Assurez-vous d'avoir une vue nommée "add-health-history.html" + } + model.addAttribute("errorMessage", "Dossier introuvable."); + return "error"; + } + + @PostMapping("/{id}/history") public String updateMedicalFileHistory(@PathVariable Long id, @RequestParam String antecedent, @@ -61,6 +72,7 @@ public class DoctorMedicalFileController { 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) { diff --git a/src/main/resources/templates/add-health-history.html b/src/main/resources/templates/add-health-history.html new file mode 100644 index 0000000000000000000000000000000000000000..c6fdf178e51fced0f8a62b3b31cd536b394668d4 --- /dev/null +++ b/src/main/resources/templates/add-health-history.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html lang="en" xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>Ajouter un Historique 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">Ajouter un Historique Médical</h1> + + <form th:action="@{/doctors/medical-files-doctor/{id}/history(id=${medicalFile.id})}" method="post"> + <div class="mb-3"> + <label for="antecedent" class="form-label">Antécédent</label> + <input type="text" class="form-control" id="antecedent" name="antecedent" required> + </div> + <div class="mb-3"> + <label for="notes" class="form-label">Notes</label> + <input type="text" class="form-control" id="notes" name="notes" required> + </div> + <div class="mb-3"> + <label for="consultationDate" class="form-label">Date de Consultation</label> + <input type="date" class="form-control" id="consultationDate" name="consultationDate" required> + </div> + <button type="submit" class="btn btn-primary">Ajouter</button> + </form> + + <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> diff --git a/src/main/resources/templates/view-medical-file-doctor.html b/src/main/resources/templates/view-medical-file-doctor.html index b53f4c0ff91ed57d7112de0ab2388443da20f58c..5fe935bb5e8327daf7ceef439b48fa11e98d19a5 100644 --- a/src/main/resources/templates/view-medical-file-doctor.html +++ b/src/main/resources/templates/view-medical-file-doctor.html @@ -1,5 +1,5 @@ <!DOCTYPE html> -<html lang="en"> +<html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> @@ -30,6 +30,13 @@ </ul> </div> + <!-- Bouton pour ajouter un HealthHistorical --> + <div class="mt-3"> + <a th:href="@{/doctors/medical-files-doctor/{id}/history/add(id=${medicalFile.id})}" class="btn btn-success"> + Ajouter un Historique Médical + </a> + </div> + <!-- Formulaire de téléchargement du document --> <form method="post" th:action="@{/doctors/medical-files-doctor/{id}/documents(id=${medicalFile.id})}" enctype="multipart/form-data"