Skip to content
Snippets Groups Projects
Commit d5a960f2 authored by Jessie Ragot's avatar Jessie Ragot
Browse files

Upload MedicalDocument and design for view-medical-file restored, is functional

Change the home page depending on who is logged in, change the header (only for the doctor for the moment, as the other paths for patient and admin do not exist).
parent f20066b1
No related branches found
No related tags found
1 merge request!19[feature]models-change+authentification+registration
package com.projet.projetIndu.controllers; package com.projet.projetIndu.controllers;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import java.util.Collection;
@Controller @Controller
public class HomeController { public class HomeController {
@GetMapping("/") @GetMapping("/")
public String home() { public String home(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication != null && authentication.isAuthenticated() && !authentication.getPrincipal().equals("anonymousUser")) {
model.addAttribute("username", authentication.getName());
Collection<? extends GrantedAuthority> authorities = authentication.getAuthorities();
boolean isDoctor = authorities.stream().anyMatch(auth -> auth.getAuthority().equals("DOCTOR"));
model.addAttribute("isDoctor", isDoctor);
}
return "home"; return "home";
} }
} }
...@@ -14,9 +14,21 @@ ...@@ -14,9 +14,21 @@
<div class="flex justify-between items-center py-6"> <div class="flex justify-between items-center py-6">
<h1 class="text-2xl font-semibold text-gray-900">Gestion Dossiers Médicaux</h1> <h1 class="text-2xl font-semibold text-gray-900">Gestion Dossiers Médicaux</h1>
<div class="space-x-4"> <div class="space-x-4">
<a href="/doctors/dashboard" class="px-6 py-2 bg-green-500 text-white rounded-md hover:bg-green-600">Professionnel de santé</a> <th:block th:if="${isDoctor}">
<a href="/doctors/dashboard"
class="px-6 py-2 bg-green-500 text-white rounded-md hover:bg-green-600">Professionnel de
santé</a>
</th:block>
<th:block th:if="${username}">
<span class="text-gray-900 font-semibold">Bienvenue, <b th:text="${username}"></b> !</span>
<a href="/logout" class="ml-4 text-red-500 hover:text-red-700">Déconnexion</a>
</th:block>
<th:block th:unless="${username}">
<a th:href="@{/login}" class="text-blue-500 hover:text-blue-700">Connexion</a> <a th:href="@{/login}" class="text-blue-500 hover:text-blue-700">Connexion</a>
<a th:href="@{/register}" class="text-blue-500 hover:text-blue-700">Inscription</a> <a th:href="@{/register}" class="text-blue-500 hover:text-blue-700">Inscription</a>
</th:block>
</div> </div>
</div> </div>
</div> </div>
...@@ -26,16 +38,21 @@ ...@@ -26,16 +38,21 @@
<main class="mt-12"> <main class="mt-12">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="text-center"> <div class="text-center">
<h2 class="text-4xl font-bold text-gray-800">Bienvenue sur notre application de gestion de dossiers médicaux</h2> <h2 class="text-4xl font-bold text-gray-800">Bienvenue sur notre application de gestion de dossiers
<p class="mt-4 text-lg text-gray-600">Accédez facilement à vos dossiers médicaux et organisez vos rendez-vous en toute sécurité.</p> médicaux</h2>
<p class="mt-4 text-lg text-gray-600">Accédez facilement à vos dossiers médicaux et organisez vos
rendez-vous en toute sécurité.</p>
</div> </div>
<!-- Search Section --> <!-- Search Section -->
<div class="mt-8 text-center"> <div class="mt-8 text-center">
<form action="/doctors/search" method="get" class="max-w-md mx-auto flex items-center space-x-4"> <form action="/doctors/search" method="get" class="max-w-md mx-auto flex items-center space-x-4">
<input type="text" name="firstName" class="w-full px-4 py-2 border rounded-md" placeholder="Prénom du médecin"> <input type="text" name="firstName" class="w-full px-4 py-2 border rounded-md"
<input type="text" name="lastName" class="w-full px-4 py-2 border rounded-md" placeholder="Nom du médecin" required> placeholder="Prénom du médecin">
<button type="submit" class="px-6 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Rechercher</button> <input type="text" name="lastName" class="w-full px-4 py-2 border rounded-md"
placeholder="Nom du médecin" required>
<button type="submit" class="px-6 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600">Rechercher
</button>
</form> </form>
</div> </div>
</div> </div>
......
...@@ -3,63 +3,67 @@ ...@@ -3,63 +3,67 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dossier médical</title> <title>Détails du dossier médical</title>
<link rel="stylesheet" <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
</head> </head>
<body class="bg-light"> <body class="bg-light">
<div class="container mt-5"> <div class="container mt-5">
<h1 class="text-center mb-4">Détails du dossier médical</h1>
<!-- Titre du dossier médical --> <div th:if="${medicalFile}">
<h1 class="text-center mb-4">Dossier Médical de <span <h5 class="card-title">Dossier médical de :
th:text="${medicalFile.patient.firstName} + ' ' + ${medicalFile.patient.lastName}"></span></h1> <span th:text="${medicalFile.patient != null ? medicalFile.patient.firstName : 'Inconnu'}"></span>
<span th:text="${medicalFile.patient != null ? medicalFile.patient.lastName : ''}"></span>
<!-- Informations générales --> </h5>
<div class="card mb-4">
<div class="card-header bg-primary text-white">
<h3>Informations générales</h3>
</div>
<div class="card-body">
<p><strong>Allergies:</strong> <span th:text="${medicalFile.allergy}"></span></p>
<p><strong>Traitement:</strong> <span th:text="${medicalFile.treatment}"></span></p>
</div>
</div> </div>
<!-- Historique médical --> <!-- Historique médical -->
<div class="card mb-4"> <div class="mt-3">
<div class="card-header bg-success text-white"> <h5>Historique médical :</h5>
<h3>Historique médical</h3> <ul class="list-group">
</div> <li th:each="history : ${medicalFile.healthHistoricalList}" class="list-group-item">
<div class="card-body"> <strong>Antécédent:</strong> <span th:text="${history.antecedent}"></span><br>
<ul> <strong>Notes:</strong> <span th:text="${history.notes}"></span><br>
<li th:each="history : ${medicalFile.healthHistoricalList}"> <strong>Date de consultation:</strong> <span th:text="${history.consultationDate}"></span>
<p><strong>Antécédent:</strong> <span th:text="${history.antecedent}"></span></p>
<p><strong>Notes:</strong> <span th:text="${history.notes}"></span></p>
<p><strong>Date de consultation:</strong> <span th:text="${history.consultationDate}"></span></p>
</li> </li>
</ul> </ul>
</div> </div>
</div>
<!-- Documents --> <!-- Formulaire de téléchargement du document -->
<div class="card mb-4"> <form method="post" th:action="@{/medical-files/{id}/documents(id=${medicalFile.id})}" enctype="multipart/form-data"
<div class="card-header bg-info text-white"> class="mt-3">
<h3>Documents</h3> <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="@{/medical-files/{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})}"
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> </div>
<div class="card-body">
<ul>
<li th:each="document : ${medicalFile.documentList}">
<a th:href="@{/medical-files/{id}/documents/{docId}(id=${medicalFile.id}, docId=${document.id})}"
class="btn btn-link" th:text="${document.fileName}"></a>
</li> </li>
</ul> </ul>
</div> </div>
</div>
<!-- Retour à la liste -->
<a href="/medical-files" class="btn btn-secondary mt-3">Retour à la liste</a>
<a href="/medical-files" class="btn btn-primary mt-3">Retour à la liste</a>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment