Database Schema
The ability assessment data is stored in a dedicated MySQL table with the following structure:
CREATE TABLE ability_assessment (
citizen_id VARCHAR(20),
daily_activity_score VARCHAR(10),
mental_state_score VARCHAR(10),
sensory_comm_score VARCHAR(10),
social_participation_score VARCHAR(10),
initial_level VARCHAR(10),
level_adjustment VARCHAR(10),
final_level VARCHAR(10),
evaluator_one VARCHAR(10),
evaluator_two VARCHAR(10),
information_provider VARCHAR(10),
assessment_date VARCHAR(10)
);
Entity Class
package assessment.pojo;
public class AbilityAssessment {
private String citizenId;
private String dailyActivityScore;
private String mentalStateScore;
private String sensoryCommScore;
private String socialParticipationScore;
private String initialLevel;
private String levelAdjustment;
private String finalLevel;
private String evaluatorOne;
private String evaluatorTwo;
private String informationProvider;
private String assessmentDate;
@Override
public String toString() {
return "AbilityAssessment{" +
"citizenId='" + citizenId + '\'' +
", dailyActivityScore='" + dailyActivityScore + '\'' +
", mentalStateScore='" + mentalStateScore + '\'' +
", sensoryCommScore='" + sensoryCommScore + '\'' +
", socialParticipationScore='" + socialParticipationScore + '\'' +
", initialLevel='" + initialLevel + '\'' +
", levelAdjustment='" + levelAdjustment + '\'' +
", finalLevel='" + finalLevel + '\'' +
", evaluatorOne='" + evaluatorOne + '\'' +
", evaluatorTwo='" + evaluatorTwo + '\'' +
", informationProvider='" + informationProvider + '\'' +
", assessmentDate='" + assessmentDate + '\'' +
'}';
}
public String getCitizenId() { return citizenId; }
public void setCitizenId(String citizenId) { this.citizenId = citizenId; }
public String getDailyActivityScore() { return dailyActivityScore; }
public void setDailyActivityScore(String dailyActivityScore) { this.dailyActivityScore = dailyActivityScore; }
public String getMentalStateScore() { return mentalStateScore; }
public void setMentalStateScore(String mentalStateScore) { this.mentalStateScore = mentalStateScore; }
public String getSensoryCommScore() { return sensoryCommScore; }
public void setSensoryCommScore(String sensoryCommScore) { this.sensoryCommScore = sensoryCommScore; }
public String getSocialParticipationScore() { return socialParticipationScore; }
public void setSocialParticipationScore(String socialParticipationScore) { this.socialParticipationScore = socialParticipationScore; }
public String getInitialLevel() { return initialLevel; }
public void setInitialLevel(String initialLevel) { this.initialLevel = initialLevel; }
public String getLevelAdjustment() { return levelAdjustment; }
public void setLevelAdjustment(String levelAdjustment) { this.levelAdjustment = levelAdjustment; }
public String getFinalLevel() { return finalLevel; }
public void setFinalLevel(String finalLevel) { this.finalLevel = finalLevel; }
public String getEvaluatorOne() { return evaluatorOne; }
public void setEvaluatorOne(String evaluatorOne) { this.evaluatorOne = evaluatorOne; }
public String getEvaluatorTwo() { return evaluatorTwo; }
public void setEvaluatorTwo(String evaluatorTwo) { this.evaluatorTwo = evaluatorTwo; }
public String getInformationProvider() { return informationProvider; }
public void setInformationProvider(String informationProvider) { this.informationProvider = informationProvider; }
public String getAssessmentDate() { return assessmentDate; }
public void setAssessmentDate(String assessmentDate) { this.assessmentDate = assessmentDate; }
}
Asssesment Form Interface
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Ability Data Statistics</title>
<style>
body {
background-color: rgba(220, 220, 220, 0.32);
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.nav-button {
display: inline-block;
width: 300px;
height: 80px;
background-color: #1e90ff;
color: white;
text-decoration: none;
text-align: center;
line-height: 80px;
font-size: 20px;
margin: 5px;
border-radius: 8px;
}
.nav-button:hover {
background-color: #87ceeb;
}
.nav-button.active {
background-color: #87ceeb;
}
.search-box {
position: absolute;
top: 10px;
right: 10px;
}
.search-box input[type="text"] {
padding: 8px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 4px;
}
.search-box button {
padding: 8px 16px;
font-size: 16px;
background-color: #1e90ff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.assessment-form {
max-width: 1000px;
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
h1, h2, h3 {
text-align: center;
color: #333;
}
.data-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
background-color: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.data-table th, .data-table td {
padding: 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
.data-table th {
background-color: #f8f9fa;
color: #333;
font-weight: bold;
}
.data-table tr:nth-child(even) {
background-color: #f9f9f9;
}
.data-table tr:hover {
background-color: #f1f1f1;
}
input[type="text"], input[type="number"], input[type="date"] {
padding: 8px;
border: 1px solid #ccc;
border-radius: 4px;
width: 100%;
max-width: 300px;
}
.submit-btn {
padding: 10px 20px;
background-color: #1e90ff;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
display: block;
margin: 20px auto;
}
.submit-btn:hover {
background-color: #87ceeb;
}
.description {
margin: 10px 0;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="search-box">
<input type="text" placeholder="Search..." name="search" id="search">
<button type="submit">Search</button>
</div>
<nav>
<a href="informationadd.html" class="nav-button">Elderly Information Import</a>
<a href="assessment1.html" class="nav-button">Periodic Ability Assessment</a>
<a href="select1.html" class="nav-button">Multi-Condition Query</a>
<a href="ability.html" class="nav-button active">Ability Data Statistics</a>
<a href="enter.html" class="nav-button">Data Export</a>
</nav>
<form class="assessment-form" action="/work-demo/abilitySubmit" method="post">
<h1>Ability Data Statistics</h1>
<h2>Elderly Ability Assessment Report</h2>
<hr>
<p>Citizen ID: <input type="text" name="citizenId" id="citizenId"></p>
<hr>
<table class="data-table">
<h3>Primary Indicator Ratings</h3>
<tr>
<th>Daily Activities</th>
<td><input type="number" id="dailyActivityScore" name="dailyActivityScore"></td>
</tr>
<tr>
<th>Mental State</th>
<td><input type="number" id="mentalStateScore" name="mentalStateScore"></td>
</tr>
<tr>
<th>Sensory and Communication</th>
<td><input type="number" id="sensoryCommScore" name="sensoryCommScore"></td>
</tr>
<tr>
<th>Social Participation</th>
<td><input type="number" id="socialParticipationScore" name="socialParticipationScore"></td>
</tr>
</table>
<h3>Initial Ability Classification</h3>
<p><strong>Level 0 - Competent:</strong> Daily activities, mental state, and sensory/communication all at level 0; social participation at level 0 or 1</p>
<p><strong>Level 1 - Mild Disability:</strong> Daily activities at level 0 but at least one of mental state or sensory/communication at level 1 or above, or social participation at level 2; OR daily activities at level 1 with at least one of mental state, sensory/communication, or social participation at level 0 or 1</p>
<p><strong>Level 2 - Moderate Disability:</strong> Daily activities at level 1 with mental state, sensory/communication, and social participation all at level 2 or at least one at level 3; OR daily activities at level 2 with 1-2 of mental state, sensory/communication, or social participation at level 1 or 2</p>
<p><strong>Level 3 - Severe Disability:</strong> Daily activities at level 3; OR all four categories at level 2; OR daily activities at level 2 with at least one of mental state, sensory/communication, or social participation at level 3</p>
<table class="data-table">
<tr>
<th>Level: 0-Competent, 1-Mild, 2-Moderate, 3-Severe</th>
<td><input type="number" id="initialLevel" name="initialLevel"></td>
</tr>
</table>
<h3>Level Adjustment Rules</h3>
<p><strong>0 - No adjustment applicable</strong></p>
<p><strong>1 - Cognitive impairment/dementia or psychiatric disorders:</strong> Raise one level from initial classification</p>
<p><strong>2 - Two or more falls, choking, suicide attempts, or wandering incidents in past 30 days:</strong> Raise one level from initial classification</p>
<p><strong>3 - Comatose state:</strong> Directly classify as severe disability</p>
<p><strong>4 - If initial level is already "3 - Severe":</strong> No further adjustments apply regardless of other conditions</p>
<table class="data-table">
<tr>
<th>Adjustment Code</th>
<td><input type="number" id="levelAdjustment" name="levelAdjustment"></td>
</tr>
</table>
<h3>Final Ability Classification</h3>
<table class="data-table">
<tr>
<th>Level: 0-Competent, 1-Mild, 2-Moderate, 3-Severe</th>
<td><input type="number" id="finalLevel" name="finalLevel"></td>
</tr>
</table>
<table class="data-table">
<tr>
<th>Evaluator 1 Signature:</th>
<td><input type="text" name="evaluatorOne" id="evaluatorOne"></td>
</tr>
<tr>
<th>Evaluator 2 Signature:</th>
<td><input type="text" name="evaluatorTwo" id="evaluatorTwo"></td>
</tr>
<tr>
<th>Information Provider Signature:</th>
<td><input type="text" name="informationProvider" id="informationProvider"></td>
</tr>
<tr>
<th>Assessment Date:</th>
<td><input type="date" name="assessmentDate" id="assessmentDate"></td>
</tr>
</table>
<input type="submit" class="submit-btn" value="Submit">
</form>
</body>
</html>
Form Submission Handler
package assessment.web;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import assessment.mapper.AbilityMapper;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
@WebServlet("/abilitySubmit")
public class AbilitySubmitServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
this.doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("UTF-8");
resp.setContentType("text/html;charset=utf-8");
String citizenId = req.getParameter("citizenId");
String dailyScore = req.getParameter("dailyActivityScore");
String mentalScore = req.getParameter("mentalStateScore");
String sensoryScore = req.getParameter("sensoryCommScore");
String socialScore = req.getParameter("socialParticipationScore");
String initialLvl = req.getParameter("initialLevel");
String adjustment = req.getParameter("levelAdjustment");
String finalLvl = req.getParameter("finalLevel");
String evalOne = req.getParameter("evaluatorOne");
String evalTwo = req.getParameter("evaluatorTwo");
String infoProvider = req.getParameter("informationProvider");
String assessDate = req.getParameter("assessmentDate");
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
SqlSession sqlSession = sqlSessionFactory.openSession();
AbilityMapper abilityMapper = sqlSession.getMapper(AbilityMapper.class);
int result = abilityMapper.insertAbilityRecord(
citizenId, dailyScore, mentalScore, sensoryScore, socialScore,
initialLvl, adjustment, finalLvl, evalOne, evalTwo, infoProvider, assessDate
);
Writer writer = resp.getWriter();
sqlSession.commit();
sqlSession.close();
if (result > 0) {
writer.write("<html><body>");
writer.write("<form id='redirectForm' action='/work-demo/exportData' method='post'>");
writer.write("<input type='hidden' name='citizenId' value='" + citizenId + "' />");
writer.write("</form>");
writer.write("<script type='text/javascript'>document.getElementById('redirectForm').submit();</script>");
writer.write("</body></html>");
} else {
writer.write("<html><body>");
writer.write("<p>Please resubmit the form...</p>");
writer.write("<script type='text/javascript'>setTimeout(function() { window.location.href = './ability.html'; }, 3000);</script>");
writer.write("</body></html>");
}
}
}
Mapper Interface Addtiion
package assessment.mapper;
public interface AbilityMapper {
int insertAbilityRecord(
String citizenId,
String dailyScore,
String mentalScore,
String sensoryScore,
String socialScore,
String initialLevel,
String adjustment,
String finalLevel,
String evalOne,
String evalTwo,
String provider,
String assessDate
);
}
MyBatis Mapper XML
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="assessment.mapper.AbilityMapper">
<insert id="insertAbilityRecord">
INSERT INTO ability_assessment (
citizen_id, daily_activity_score, mental_state_score,
sensory_comm_score, social_participation_score,
initial_level, level_adjustment, final_level,
evaluator_one, evaluator_two, information_provider, assessment_date
) VALUES (
#{citizenId}, #{dailyScore}, #{mentalScore},
#{sensoryScore}, #{socialScore},
#{initialLevel}, #{adjustment}, #{finalLevel},
#{evalOne}, #{evalTwo}, #{provider}, #{assessDate}
)
</insert>
</mapper>