1222carnivore  

今日代码:完善了相应的结果页面,写出了等级变更条款的相应判断程序

  <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mental Health Assessment Result</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        .result-container {
            border: 1px solid #ccc;
            padding: 20px;
            margin-top: 20px;
        }
        .result-title {
            font-size: 24px;
            color: #333;
        }
        .result-description {
            font-size: 16px;
            color: #555;
        }
    </style>
</head>
<body>
    <h1>Mental Health Assessment Result</h1>
    <div class="result-container">
        <div class="result-title">Final Capability Level: <span id="capability-level"></span></div>
        <div class="result-description" id="description"></div>
    </div>

    <script>
        // Example data from the assessment
        const assessmentData = {
            cognitiveFunction: 1,
            aggressiveBehavior: 0,
            depressionSymptoms: 0,
            spiritResult: "normal", // Possible values: "normal", "comatose"
            hasCognitiveIssues: true, // Simulated result based on rules
            hadIncidents: false // Simulated result based on rules
        };

        // Function to determine capability level
        function determineCapabilityLevel(data) {
            let initialLevel = 0;

            if (data.hasCognitiveIssues) {
                initialLevel++;
            }
            if (data.hadIncidents) {
                initialLevel++;
            }

            // Rule 3: If in a coma state, directly rate as severely disabled (level 3)
            if (data.spiritResult.toLowerCase() === "comatose") {
                return 3;
            }

            // Rule 4: If initially determined as severely disabled (level 3), do not increase further
            if (initialLevel >= 3) {
                return 3;
            }

            return initialLevel;
        }

        const capabilityLevel = determineCapabilityLevel(assessmentData);
        document.getElementById('capability-level').textContent = capabilityLevel;

        let description = "";
        switch (capabilityLevel) {
            case 0:
                description = "有认知障碍/痴呆、精神疾病者";
                break;
            case 1:
                description = "2近30天内发生过2次及以上跌倒、噎食、自杀、走失者";
                break;
            case 2:
                description = "昏迷状态";
                break;
            default:
                description = "Unable to determine capability level.";
        }
        document.getElementById('description').textContent = description;
    </script>
</body>
</html>
posted on 2025-02-20 18:16  作业-----  阅读(12)  评论(0)    收藏  举报