Exporting Elderly Assessment Data by ID

This section details the functionality for exporting elderly assessment data.

enter.html

This HTML file provides a user interface for initiating the data export process. It includes navigation links to other sections of the system such as information import, regular assessment, multi-condition query, data statistics, and data export itself. A search bar is also present for general searching. The primary focus of this page is to offer a link to a more specific export function.

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Elderly Assessment Data Export</title>
    <style>
        body {
            background-color: rgba(220, 220, 220, 0.32);
            font-family: Arial, sans-serif;
        }
        a {
            display: inline-block;
            width: 330px;
            height: 80px;
            background-color: dodgerblue;
            color: white;
            text-decoration: none;
            text-align: center;
            line-height: 80px;
            font-size: 20px;
            margin: 5px;
            border-radius: 8px;
        }
        a:hover {
            background-color: lightskyblue;
        }
        .select {
            background-color: lightskyblue;
        }
        .search-container {
            position: absolute;
            top: 10px;
            right: 10px;
        }
        .search-container input[type="text"] {
            padding: 8px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .search-container button {
            padding: 8px;
            font-size: 16px;
            background-color: dodgerblue;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .search-container button:hover {
            background-color: lightskyblue;
        }
        .div2 {
            display: flex;
            justify-content: space-around;
            align-items: center;
            height: 100px;
            background-color: #e1e0e0;
            padding: 0 20px;
        }
        .div2 p {
            font-size: 18px;
            color: #333;
            margin: 0;
            padding: 10px 20px;
            background-color: #f0f0f0;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        l{
            font-size: 18px;
            color: #5b5a5a;
            margin: 0;
            padding: 10px 20px;
            background-color: lightskyblue;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        input[type="submit"] {
            padding: 10px 20px;
            background-color: dodgerblue;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            background-position: center bottom;
        }
        input[type="submit"]:hover {
            background-color: lightskyblue;
        }
        a.multi-condition {
            font-size: 30px;
            color: #333;
            margin: 0;
            padding: 10px 20px;
            background-color: rgba(182, 182, 182, 0.18);
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        a.multi-condition:hover {
            background-color: lightskyblue;
        }
        .multi-condition-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="div1">
    ![](https://www.jkheb2030.org.cn/Content/peixun/img/logo.png)
</div>
<div class="search-container">
    <input type="text" placeholder="Search..." name="search" id="search">
    <button type="submit">Search</button>
</div>
<a href="informationadd.html">Import Elderly Information</a>
<a href="assessment1.html">Regular Elderly Assessment</a>
<a class="select" >Multi-condition Query for Assessment Data</a>
<a href="ability.html">Assessment Data Statistics</a>
<a href="enter.html">Export Assessment Data</a>
<br><br><br><br><br><br><br>
<div class="multi-condition-container">
    <a class="multi-condition" href="enter1.html">Query by ID Number</a><br>
</div>
</body>
</html>

enter1.html

This HTML page provides a form specifically for exporting assessment data using an individual's ID number. It maintains the overall styling and navigation from enter.html, but focuses the user interaction on entering an ID to retrieve and export the corresponding data.

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Elderly Assessment Data Export by ID</title>
    <style>
        body {
            background-color: rgba(220, 220, 220, 0.32);
            font-family: Arial, sans-serif;
        }
        a {
            display: inline-block;
            width: 330px;
            height: 80px;
            background-color: dodgerblue;
            color: white;
            text-decoration: none;
            text-align: center;
            line-height: 80px;
            font-size: 20px;
            margin: 5px;
            border-radius: 8px;
        }
        a:hover {
            background-color: lightskyblue;
        }
        .select {
            background-color: lightskyblue;
        }
        .search-container {
            position: absolute;
            top: 10px;
            right: 10px;
        }
        .search-container input[type="text"] {
            padding: 8px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .search-container button {
            padding: 8px;
            font-size: 16px;
            background-color: dodgerblue;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .search-container button:hover {
            background-color: lightskyblue;
        }
        .div2 {
            display: flex;
            justify-content: space-around;
            align-items: center;
            height: 100px;
            background-color: #e1e0e0;
            padding: 0 20px;
        }
        .div2 p {
            font-size: 18px;
            color: #333;
            margin: 0;
            padding: 10px 20px;
            background-color: #f0f0f0;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        l{
            font-size: 18px;
            color: #5b5a5a;
            margin: 0;
            padding: 10px 20px;
            background-color: lightskyblue;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        input[type="submit"] {
            padding: 10px 20px;
            background-color: dodgerblue;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
            background-position: center bottom;
        }
        input[type="submit"]:hover {
            background-color: lightskyblue;
        }
        a.multi-condition {
            font-size: 30px;
            color: #333;
            margin: 0;
            padding: 10px 20px;
            background-color: rgba(182, 182, 182, 0.18);
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        a.multi-condition:hover {
            background-color: lightskyblue;
        }
        .multi-condition-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            margin-top: 20px;
        }
    </style>
</head>
<body>
<div class="div1">
    ![](https://www.jkheb2030.org.cn/Content/peixun/img/logo.png)
</div>
<div class="search-container">
    <input type="text" placeholder="Search..." name="search" id="search">
    <button type="submit">Search</button>
</div>
<a href="informationadd.html">Import Elderly Information</a>
<a href="assessment1.html">Regular Elderly Assessment</a>
<a class="select" >Multi-condition Query for Assessment Data</a>
<a href="ability.html">Assessment Data Statistics</a>
<a href="enter.html">Export Assessment Data</a>
<br><br><br>
<form action="/work-demo/enter" method="post">
    <h2>Query and Export by ID Number</h2>
    <p>ID Number:<input type="text" name="number" id="number"></p>
    <input type="submit" value="Export">
</form>
</div>
</body>
</html>

enter.java

This Java servlet handles the POST request for exporting assessment data based on an ID number. It utilizes MyBatis for database interaction.

  1. Initialization: It sets the character encoding to UTF-8 and the content type to HTML with UTF-8 encoding for the response.
  2. Parameter Retrieval: It retrieves the ID number submitted through the form.
  3. Database Connection: It configures and establishes a connection to the database using MyBatis by loading mybatis-config.xml.
  4. Data Retrieval: It queries the database using the UserMapper to fetch ability data associated with the provided ID number.
  5. HTML Generation: It dynamically generates an HTML response that displays the retrieved assessment data in a structured table. This includes details on daily living activities, mental state, sensory perception, social participation, initial ability levels, change clauses, final ability levels, and auditor signatures.
  6. Cleanup: It commits the session and closes the database connection.
package work.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 work.mapper.UserMapper;
import work.pojo.ability;

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.PrintWriter;

@WebServlet("/enter")
public class enter 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"); // Resolve encoding issues
        resp.setContentType("text/html;charset=utf-8");
        String idNumber = req.getParameter("number");
        
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        ability assessmentData = userMapper.selectability(idNumber);
        
        PrintWriter writer = resp.getWriter();
        writer.println(
                "<html lang=\"en\">
<head>
    <meta charset=\"UTF-8\">
    <title>Assessment Data Export</title>
    <style>
        body {
            background-color: rgba(220, 220, 220, 0.32);
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
        }
        a {
            display: inline-block;
            width: 300px;
            height: 80px;
            background-color: dodgerblue;
            color: white;
            text-decoration: none;
            text-align: center;
            line-height: 80px;
            font-size: 20px;
            margin: 5px;
            border-radius: 8px;
        }
        a:hover {
            background-color: lightskyblue;
        }
        .select {
            background-color: lightskyblue;
        }
        .search-container {
            position: absolute;
            top: 10px;
            right: 10px;
        }
        .search-container input[type=\"text\"] {
            padding: 8px;
            font-size: 16px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .search-container button {
            padding: 8px;
            font-size: 16px;
            background-color: dodgerblue;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        .search-container button:hover {
            background-color: lightskyblue;
        }
        form {
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
            background-color: white;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
        h1, h2 {
            text-align: center;
            color: #333;
        }
        h1 {
            font-size: 28px;
            margin-bottom: 20px;
        }
        h2 {
            font-size: 24px;
            margin-top: 30px;
            margin-bottom: 15px;
        }
        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);
        }
        th, td {
            padding: 15px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f8f9fa;
            color: #333;
            font-weight: bold;
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #f1f1f1;
        }
        input[type="text"], input[type="radio"], input[type="checkbox"] {
            margin-right: 10px;
        }
        input[type="text"] {
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
            width: 100%;
            max-width: 300px;
        }
    </style>
</head>
<body>
<div class="div1">
    ![](https://www.jkheb2030.org.cn/Content/peixun/img/logo.png)
</div>
<div class="search-container">
    <input type="text" placeholder="Search..." name="search" id="search">
    <button type="submit">Search</button>
</div>
<a  href="informationadd.html">Import Elderly Information</a>
<a href="assessment1.html">Regular Elderly Assessment</a>
<a href="select1.html">Multi-condition Query for Assessment Data</a>
<a href="ability.html">Assessment Data Statistics</a>
<a class="select">Export Assessment Data</a>

<form action="/work-demo/abilityadd" method="post">
    <h1>Assessment Data Statistics</h1>
    <h2>Elderly Assessment Report</h2>
    ### Primary Indicator Scores

| Daily Living Activities | " + assessmentData.getDaily() + " |
|---|---|
| Mental State | " + assessmentData.getMental() + " |
| Sensory and Communication | " + assessmentData.getFeel() + " | Social Participation | " + assessmentData.getPublics() + " 
    <h3>Initial Elderly Ability Level</h3>
    <h4>0 No Impairment:</h4>
    <p>Daily living activities, mental state, sensory and communication scores are all 0, and social participation score is 0 or 1.</p>
    <h4>1 Mild Impairment:</h4>
    <p>Daily living activities score is 0, but at least one of mental state, sensory and communication scores is 1 or higher, or social participation score is 2.</p>
    <p>Or, daily living activities score is 1, and at least one of mental state, sensory and communication, or social participation scores is 0 or 1.</p>
    <h4>2 Moderate Impairment:</h4>
    <p>Daily living activities score is 1, but mental state, sensory and communication, and social participation scores are all 2, or one is 3.</p>
    <p>Or, daily living activities score is 2, and 1-2 of mental state, sensory and communication, or social participation scores are 1 or 2.</p>
    <h4>3 Severe Impairment:</h4>
    <p>Daily living activities score is 3.</p>
    <p>Or, daily living activities, mental state, sensory and communication, and social participation scores are all 2.</p>
    <p>Or, daily living activities score is 2, and at least one of mental state, sensory and communication, or social participation scores is 3.</p>
    | 0 No Impairment, 1 Mild, 2 Moderate, 3 Severe | " + assessmentData.getAbility1() + " |
|---|---|
    <h3>Level Change Clauses</h3>
    <p>0 No change conditions apply.</p>
    <p>1 Individuals with cognitive impairment/dementia or mental illness will have their ability level increased by one grade.</p>
    <p>2 Individuals who have experienced 2 or more falls, choking incidents, suicide attempts, or elopements within the last 30 days will have their ability level increased by one grade.</p>
    <p>3 Individuals in a coma will be directly assessed as severely impaired.</p>
    <p>4 If the initial level is determined as '3 Severe Impairment', the above conditions (1-3) will not affect the final level, and it will not be increased.</p>
    | Enter Level Change Conditions | " + assessmentData.getChanging() + " |
|---|---|
    <h3>Final Elderly Ability Level</h3>
    | 0 No Impairment, 1 Mild, 2 Moderate, 3 Severe | " + assessmentData.getAbility2() + " |
|---|---|
    | Auditor 1 Signature: | " + assessmentData.getAuditor1() + " |
|---|---|
| Auditor 2 Signature: | " + assessmentData.getAuditor2() + " |
| Information Provider Signature: | " + assessmentData.getProvider() + " |
| Date: | " + assessmentData.getDate() + " |
    <br>

</form>
</body>
</html>");
        
        sqlSession.commit();
        sqlSession.close();
    }
}

Tags: Elderly Care Assessment Data Export web development java

Posted on Sat, 04 Jul 2026 17:24:56 +0000 by truegilly