lsp66

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

继续对c.2进行创建
‌elderlyAssessment.jsp‌
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

老年人能力初步等级评估

老年人能力初步等级评估

‌styles.css‌

body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
}

h1 {
text-align: center;
color: #333;
}

.form-group {
margin-bottom: 15px;
}

label {
display: block;
margin-bottom: 5px;
}

select {
width: 100%;
padding: 8px;
box-sizing: border-box;
}

button {
display: block;
width: 100%;
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
font-size: 16px;
}

button:hover {
background-color: #0056b3;
}
后台技术:JavaBean
‌AssessmentBean.java‌
public class AssessmentBean {
private int dailyLiving;
private int mentalStatus;
private int sensoryCommunication;
private int socialInvolvement;
private String preliminaryLevel;

// Getters and Setters
public int getDailyLiving() {
    return dailyLiving;
}

public void setDailyLiving(int dailyLiving) {
    this.dailyLiving = dailyLiving;
}

public int getMentalStatus() {
    return mentalStatus;
}

public void setMentalStatus(int mentalStatus) {
    this.mentalStatus = mentalStatus;
}

public int getSensoryCommunication() {
    return sensoryCommunication;
}

public void setSensoryCommunication(int sensoryCommunication) {
    this.sensoryCommunication = sensoryCommunication;
}

public int getSocialInvolvement() {
    return socialInvolvement;
}

public void setSocialInvolvement(int socialInvolvement) {
    this.socialInvolvement = socialInvolvement;
}

public String getPreliminaryLevel() {
    return preliminaryLevel;
}

public void setPreliminaryLevel(String preliminaryLevel) {
    this.preliminaryLevel = preliminaryLevel;
}

}
后台技术:Servlet
‌AssessmentServlet.java‌
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;
@WebServlet("/submitAssessment")
public class AssessmentServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
AssessmentBean assessmentBean = new AssessmentBean();
assessmentBean.setDailyLiving(Integer.parseInt(request.getParameter("dailyLiving")));
assessmentBean.setMentalStatus(Integer.parseInt(request.getParameter("mentalStatus")));
assessmentBean.setSensoryCommunication(Integer.parseInt(request.getParameter("sensoryCommunication")));
assessmentBean.setSocialInvolvement(Integer.parseInt(request.getParameter("socialInvolvement")));

    // Logic to determine preliminary level
    determinePreliminaryLevel(assessmentBean);

    // Here you can redirect to a result page or perform further processing
    response.sendRedirect("result.jsp");
}

private void determinePreliminaryLevel(AssessmentBean assessmentBean) {
    int dailyLiving = assessmentBean.getDailyLiving();
    int mentalStatus = assessmentBean.getMentalStatus();
    int sensoryCommunication = assessmentBean.getSensoryCommunication();
    int socialInvolvement = assessmentBean.getSocialInvolvement();

    String preliminaryLevel;

    if (dailyLiving == 0 && (mentalStatus == 1 || sensoryCommunication == 1 || socialInvolvement == 2)) {
        preliminaryLevel = "轻度失能";
    } else if (dailyLiving == 1 && (mentalStatus == 0 || mentalStatus == 1 || sensoryCommunication == 0 || sensoryCommunication == 1 || socialInvolvement == 0 || socialInvolvement == 1)) {
        preliminaryLevel = "轻度失能";
    } else if (dailyLiving == 1 && (mentalStatus == 2 || sensoryCommunication == 2 || socialInvolvement == 2 || mentalStatus == 3 || sensoryCommunication == 3 || socialInvolvement == 3)) {
        preliminaryLevel = "中度失能";
    } else if (dailyLiving == 2 && (mentalStatus == 2 || sensoryCommunication == 2 || socialInvolvement == 2 || mentalStatus == 3 || sensoryCommunication == 3 || socialInvolvement == 3)) {
        preliminaryLevel = "重度失能";
    } else if (dailyLiving == 3) {
        preliminaryLevel = "重度失能";
    } else if (dailyLiving == 2 && (mentalStatus == 2 || sensoryCommunication == 2 || socialInvolvement == 2) && !(mentalStatus == 3 || sensoryCommunication == 3 || socialInvolvement == 3)) {
        preliminaryLevel = "中度失能";
    } else {
        preliminaryLevel = "能力完好";
    }

    assessmentBean.setPreliminaryLevel(preliminaryLevel);
    // Optionally, you can store this in the database or session
}

}

posted on 2025-02-20 18:56  李世鹏66  阅读(17)  评论(0)    收藏  举报