Skip to content

Commit

Permalink
print patient of X therapist v.4 + name of therapist logged on homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewaaa committed Dec 29, 2023
1 parent 7526e82 commit b3dc0b4
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 91 deletions.
8 changes: 6 additions & 2 deletions src/main/java/controller/homeTherapistServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import java.util.ArrayList;
import javax.servlet.http.HttpSession;
import javax.servlet.RequestDispatcher;
import model.entity.PersonalInfo;

import model.entity.*;
import model.service.personalinfo.PersonalInfo;

@WebServlet("/homeTherapistServlet")
public class homeTherapistServlet extends HttpServlet {
Expand All @@ -25,6 +26,7 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t
HttpSession session = request.getSession();

model.service.user.UserData userService = new model.service.user.UserData();
model.service.personalinfo.PersonalInfo piService= new PersonalInfo();

ArrayList<UserInfo> list_user=new ArrayList<>();
//String tipo=request.getParameter("type");
Expand All @@ -33,8 +35,10 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) t

session.setAttribute("list_user",list_user);

model.entity.PersonalInfo InfoLogged=piService.getPersonalInfoById(logged.getId());
session.setAttribute("NameSurnameLogged",InfoLogged.getFirstname()+" "+InfoLogged.getLastname());

response.sendRedirect("JSP/testTable.jsp");
response.sendRedirect("JSP/homeTherapist.jsp");
}


Expand Down
60 changes: 60 additions & 0 deletions src/main/java/model/DAO/DAOPersonalInfo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
package model.DAO;

import model.entity.PersonalInfo;
import model.entity.User;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class DAOPersonalInfo {

private PersonalInfo getPersonalInfoFromResultSet(ResultSet resultSet) throws SQLException {
PersonalInfo pi = new PersonalInfo();

pi.setIdUser(resultSet.getInt("ID_user"));
pi.setFirstname(resultSet.getString("Firstname"));
pi.setLastname(resultSet.getString("Lastname"));
pi.setDateOfBirth(resultSet.getDate("DateOfBirth"));
pi.setGender(resultSet.getString("Gender"));
pi.setAddress(resultSet.getString("Address"));
pi.setSsn(resultSet.getString("SSN"));
pi.setPhone(resultSet.getString("Phone"));
return pi;
}
public boolean createRegistry(int id, String name, String surname) {
Connection connection = null;
PreparedStatement preparedStatementPersonalInfo = null;
Expand Down Expand Up @@ -46,5 +64,47 @@ public boolean createRegistry(int id, String name, String surname) {

return false; // Default to false if an exception occurs
}

public PersonalInfo getPersonalInfoById(int id) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;

try {

connection = DAOConnection.getConnection();
String query = null;


query = "SELECT * FROM personal_info WHERE ID_user = ?";


preparedStatement = connection.prepareStatement(query);
preparedStatement.setObject(1, id);

resultSet = preparedStatement.executeQuery();

if (resultSet.next()) {
return getPersonalInfoFromResultSet(resultSet);
}

} catch (SQLException e) {
// Handle the exception (e.g., log or throw)
e.printStackTrace();
} finally {
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
DAOConnection.releaseConnection(connection);
} catch (SQLException e) {
// Handle the exception (e.g., log or throw)
e.printStackTrace();
}
}

return null; // or you may throw an exception here
}


}

1 change: 1 addition & 0 deletions src/main/java/model/service/personalinfo/PersonalInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
public class PersonalInfo {
DAOPersonalInfo personalInfoDAO = new DAOPersonalInfo();
public boolean createRegistry(int id, String name, String surname) {return personalInfoDAO.createRegistry(id, name, surname);}
public model.entity.PersonalInfo getPersonalInfoById(int id) {return personalInfoDAO.getPersonalInfoById(id); }
}
38 changes: 32 additions & 6 deletions src/main/webapp/CSS/homeTherapist.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
.table-container {
max-height: 350px; /* Altezza massima della tabella */
overflow-y: auto; /* Rendi scorrevole solo l'asse Y quando necessario */
}

table {
width: 100%;
border-collapse: collapse;
border-spacing: 0 35px; /* Imposta uno spazio vuoto tra le righe */
}

tr {

text-align: center; /* Centra il testo orizzontalmente */
vertical-align: middle; /* Centra verticalmente */
}

td {

text-align: center; /* Centra il testo orizzontalmente */
vertical-align: middle; /* Centra verticalmente */
}



/*----*/

html {
margin: 0px;
height: 100%;
Expand Down Expand Up @@ -93,7 +120,7 @@ a {

.element-home-logopedista .overlap-group {
position: absolute;
width: 499px;
width: 600px;
height: 61px;
top: 54px;
left: 76px;
Expand Down Expand Up @@ -175,10 +202,8 @@ a {
}

.element-home-logopedista .element {
position: absolute;
width: 41px;
position: relative;
top: 8px;
left: 2px;
font-family: "Poppins", Helvetica;
font-weight: 600;
color: #199a8e;
Expand Down Expand Up @@ -431,12 +456,13 @@ a {
position: absolute;
width: 102px;
top: 467px;
left: 14px;
left: 0px;
font-family: "Poppins", Helvetica;
font-weight: 600;
color: #221f1f;
font-size: 7px;
font-size: 10px;
letter-spacing: 0;
text-align: center; /* Allinea il testo al centro orizzontalmente */
line-height: normal;
}

Expand Down
165 changes: 82 additions & 83 deletions src/main/webapp/JSP/homeTherapist.jsp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<%@ page import="model.entity.*"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="../CSS/homeTherapistGuide.css" />
<link rel="stylesheet" href="../CSS/homeTherapist.css" />
<title></title>
</head>
<body>
<div class="element-home-logopedista">
Expand All @@ -12,91 +17,85 @@
<div class="button-only-text"><button class="button">Invita paziente</button></div>
</div>
<div class="pop-up">
<div class="text-wrapper-2">PAZIENTI</div>
<div class="overlap-group">
<div class="doctor">
<div class="group">
<div class="overlap-group-wrapper">
<div class="overlap-group-2">
<div class="inizio-terapia-gg-mm">Inizio Terapia:&nbsp;&nbsp;gg/mm/yyy</div>
<div class="text-wrapper">Nome Cognome</div>
</div>
</div>
</div>
</div>
<div class="others-progress">
<div class="element-wrapper"><div class="element">72%</div></div>
</div>
<div class="image"></div>
</div>
<div class="overlap-2">
<div class="doctor-2">
<div class="group-wrapper">
<div class="overlap-group-wrapper">
<div class="overlap-group-2">
<div class="inizio-terapia-gg-mm">Inizio Terapia:&nbsp;&nbsp;gg/mm/yyy</div>
<div class="text-wrapper">Nome Cognome</div>
</div>
</div>
</div>
<div class="div-wrapper">
<div class="group">
<div class="overlap-group-wrapper">
<div class="overlap-group-2">
<div class="inizio-terapia-gg-mm">Inizio Terapia:&nbsp;&nbsp;gg/mm/yyy</div>
<div class="text-wrapper">Nome Cognome</div>
</div>
</div>
</div>
</div>
<div class="doctor-3">
<div class="group">
<div class="overlap-group-wrapper">
<div class="overlap-group-2">
<div class="inizio-terapia-gg-mm">Inizio Terapia:&nbsp;&nbsp;gg/mm/yyy</div>
<div class="text-wrapper">Nome Cognome</div>
</div>
</div>
</div>
</div>
<div class="doctor-4">
<div class="group">
<div class="overlap-group-wrapper">
<div class="overlap-group-2">
<div class="inizio-terapia-gg-mm">Inizio Terapia:&nbsp;&nbsp;gg/mm/yyy</div>
<div class="text-wrapper">Nome Cognome</div>
</div>
</div>
</div>
</div>
</div>
<div class="overlap-wrapper">
<div class="element-wrapper"><div class="element">72%</div></div>
</div>
<div class="others-progress-2">
<div class="element-wrapper"><div class="element">72%</div></div>
</div>
<div class="others-progress-3">
<div class="element-wrapper"><div class="element">72%</div></div>
</div>
<div class="others-progress-4">
<div class="element-wrapper"><div class="element">72%</div></div>
</div>
<div class="table-container" id="tableContainer">

<table>
<thead class="table-header">
<tr>
<th></th> <!--icon-->
<th></th> <!--full name-->
<th>Inizio Terapia</th> <!--start date of therapy-->
<th>Progressi</th> <!--progress-->
</tr>
</thead>
<tbody>
<%
if(session.getAttribute("list_user")!=null) {
@SuppressWarnings("unchecked")
ArrayList<UserInfo> list_user=(ArrayList<UserInfo>) session.getAttribute("list_user");
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
for(UserInfo u: list_user){
%>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>
<tr>
<td><svg xmlns="http://www.w3.org/2000/svg" height="16" width="18" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 96c48.6 0 88 39.4 88 88s-39.4 88-88 88-88-39.4-88-88 39.4-88 88-88zm0 344c-58.7 0-111.3-26.6-146.5-68.2 18.8-35.4 55.6-59.8 98.5-59.8 2.4 0 4.8 .4 7.1 1.1 13 4.2 26.6 6.9 40.9 6.9 14.3 0 28-2.7 40.9-6.9 2.3-.7 4.7-1.1 7.1-1.1 42.9 0 79.7 24.4 98.5 59.8C359.3 421.4 306.7 448 248 448z"/></svg></td>
<td><%=u.getFirstname()%> <%=u.getLastname()%></td>
<td><%= sdf.format(u.getActivationDate()) %></td>
<td>
<div class="element-wrapper"><div class="element">72%</div></div>
</td>
</tr>

<div class="image-2">
<img class="ellipse" src="../images/homeTherapist/ellipse-28.png" />
<div class="image-3">
<img class="ellipse" src="../images/homeTherapist/ellipse-28.png" />
<div class="image-4">
<img class="ellipse" src="../images/homeTherapist/ellipse-28.png" />
<div class="image-5">
<img class="ellipse" src="../images/homeTherapist/ellipse-28.png" />
</div>
</div>
</div>
</div>
<%
}
}
%>
</tbody>
</table>
</div>

<div class="text-wrapper-2">PAZIENTI</div>
</div>
</div>
<div class="overlap-3">
<div class="rectangle-2"></div>
Expand All @@ -109,7 +108,7 @@
<img class="img" src="../images/homeTherapist/image.png" />
<img class="logovettoriale" src="../images/homeTherapist/logovettoriale-1.png" />
<img class="line" src="../images/homeTherapist/line-9.svg" />
<div class="text-wrapper-3">Dr Nome Cognome</div>
<div class="text-wrapper-3">Dr.</br> <%=session.getAttribute("NameSurnameLogged")%></div>
<img class="ellipse-2" src="../images/homeTherapist/ellipse-94.svg" />
</div>
<div class="material-symbols-wrapper">
Expand All @@ -119,4 +118,4 @@
</div>
</div>
</body>
</html>
</html>

0 comments on commit b3dc0b4

Please sign in to comment.