Files
zhican/tcm-diagnosis.html
T
2026-04-08 16:00:44 +08:00

494 lines
16 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>木欣中医辨证开方系统</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Microsoft YaHei', Arial, sans-serif;
background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 12px;
box-shadow: 0 4px 20px rgba(76, 175, 80, 0.15);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
color: white;
padding: 30px 20px;
text-align: center;
}
.header h1 {
font-size: 24px;
margin-bottom: 5px;
}
.header p {
font-size: 14px;
opacity: 0.9;
}
.content {
padding: 30px;
}
.section {
display: none;
}
.section.active {
display: block;
}
.form-group {
margin-bottom: 20px;
}
.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 500;
color: #333;
}
.input-field {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
}
.symptoms-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 15px;
}
.symptom-item {
display: flex;
align-items: center;
}
.symptom-item input[type="checkbox"] {
width: 18px;
height: 18px;
margin-right: 10px;
cursor: pointer;
accent-color: #4caf50;
}
.symptom-item label {
margin: 0;
cursor: pointer;
flex: 1;
}
.button-group {
display: flex;
gap: 10px;
margin-top: 30px;
justify-content: center;
}
button {
padding: 12px 30px;
border: none;
border-radius: 6px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s ease;
font-weight: 500;
}
.btn-primary {
background: #4caf50;
color: white;
}
.btn-primary:hover {
background: #45a049;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}
.btn-secondary {
background: #e0e0e0;
color: #333;
}
.btn-secondary:hover {
background: #d0d0d0;
}
.btn-print {
background: #2196f3;
color: white;
}
.btn-print:hover {
background: #0b7dda;
}
.prescription {
background: #f9fff9;
border: 2px solid #4caf50;
border-radius: 8px;
padding: 25px;
margin-bottom: 20px;
}
.prescription-header {
text-align: center;
border-bottom: 2px solid #4caf50;
padding-bottom: 15px;
margin-bottom: 20px;
}
.prescription-header h2 {
color: #4caf50;
font-size: 24px;
margin-bottom: 5px;
}
.prescription-info {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 20px;
font-size: 14px;
}
.info-item {
display: flex;
justify-content: space-between;
}
.info-label {
font-weight: 600;
color: #4caf50;
}
.prescription-section {
margin-bottom: 20px;
}
.prescription-section h3 {
color: #4caf50;
font-size: 16px;
margin-bottom: 10px;
border-left: 4px solid #4caf50;
padding-left: 10px;
}
.medicine-item {
background: white;
padding: 12px;
margin-bottom: 10px;
border-radius: 6px;
border-left: 3px solid #81c784;
}
.medicine-name {
font-weight: 600;
color: #333;
margin-bottom: 5px;
}
.medicine-detail {
font-size: 13px;
color: #666;
margin: 3px 0;
}
.suggestion {
background: #fff3e0;
border-left: 4px solid #ff9800;
padding: 12px;
border-radius: 4px;
color: #e65100;
font-size: 14px;
line-height: 1.6;
}
.error-message {
background: #ffebee;
color: #c62828;
padding: 12px;
border-radius: 6px;
margin-bottom: 20px;
display: none;
}
.error-message.show {
display: block;
}
@media print {
body {
background: white;
}
.button-group {
display: none;
}
.container {
box-shadow: none;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🌿 木欣中医辨证开方系统</h1>
<p>根据症状智能诊断,生成个性化处方</p>
</div>
<div class="content">
<!-- 诊断页面 -->
<div class="section active" id="diagnosis-section">
<div class="form-group">
<label>患者姓名</label>
<input type="text" id="patient-name" class="input-field" placeholder="请输入患者姓名">
</div>
<div class="form-group">
<label>请选择症状(可多选)</label>
<div class="symptoms-grid" id="symptoms-container"></div>
</div>
<div class="error-message" id="error-msg"></div>
<div class="button-group">
<button class="btn-primary" onclick="diagnose()">确认诊断</button>
</div>
</div>
<!-- 处方页面 -->
<div class="section" id="prescription-section">
<div id="prescription-content"></div>
<div class="button-group">
<button class="btn-print" onclick="printPrescription()">打印处方</button>
<button class="btn-secondary" onclick="newDiagnosis()">重新诊断</button>
</div>
</div>
</div>
</div>
<script>
// 症状数据
const symptoms = [
'头痛', '头晕', '失眠', '多梦', '疲劳',
'口干', '便秘', '腹泻', '腹胀', '食欲不振',
'手脚冰冷', '怕冷', '易出汗', '口苦', '咽干',
'腰酸', '关节痛', '皮肤干燥', '易感冒', '心烦',
'月经不调', '潮热', '眼干', '目赤', '鼻塞',
'喉咙痛', '胸闷', '心悸', '手脚酸软', '便溏'
];
// 诊断规则和处方数据
const diagnoses = [
{
name: '气虚体质',
symptoms: ['疲劳', '食欲不振', '易感冒', '易出汗'],
prescription: [
{ name: '黄芪', dosage: '15g', usage: '水煎服', effect: '补气健脾' },
{ name: '党参', dosage: '12g', usage: '水煎服', effect: '益气补中' },
{ name: '白术', dosage: '10g', usage: '水煎服', effect: '健脾益气' },
{ name: '甘草', dosage: '6g', usage: '水煎服', effect: '调和诸药' }
],
suggestion: '避免过度劳累,保证充足睡眠。饮食清淡易消化,可适当进补。'
},
{
name: '阴虚体质',
symptoms: ['口干', '皮肤干燥', '咽干', '便秘', '手脚冰冷'],
prescription: [
{ name: '麦冬', dosage: '12g', usage: '水煎服', effect: '滋阴润肺' },
{ name: '生地黄', dosage: '15g', usage: '水煎服', effect: '滋阴补血' },
{ name: '玉竹', dosage: '10g', usage: '水煎服', effect: '滋阴润肺' },
{ name: '百合', dosage: '12g', usage: '水煎服', effect: '润肺安神' }
],
suggestion: '避免熬夜,少食辛辣刺激食物。多喝温水,适当食用滋阴食物如银耳、蜂蜜。'
},
{
name: '湿热体质',
symptoms: ['口苦', '腹胀', '腹泻', '皮肤干燥', '便秘'],
prescription: [
{ name: '茯苓', dosage: '15g', usage: '水煎服', effect: '健脾利湿' },
{ name: '薏米', dosage: '20g', usage: '水煎服', effect: '健脾祛湿' },
{ name: '黄芩', dosage: '10g', usage: '水煎服', effect: '清热燥湿' },
{ name: '甘草', dosage: '6g', usage: '水煎服', effect: '调和诸药' }
],
suggestion: '避免油腻厚腻食物,戒烟限酒。适度运动,促进代谢。'
},
{
name: '失眠症',
symptoms: ['失眠', '多梦', '心', '头晕', '疲劳'],
prescription: [
{ name: '酸枣仁', dosage: '15g', usage: '水煎服', effect: '宁心安神' },
{ name: '龙骨', dosage: '20g', usage: '水煎服', effect: '镇心安神' },
{ name: '茯神', dosage: '12g', usage: '水煎服', effect: '宁心安神' },
{ name: '甘草', dosage: '6g', usage: '水煎服', effect: '调和诸药' }
],
suggestion: '建立规律作息,睡前避免使用电子产品。可适当泡脚,放松身心。'
},
{
name: '阳虚体质',
symptoms: ['怕冷', '手脚冰冷', '腹泻', '疲劳', '易感冒'],
prescription: [
{ name: '肉桂', dosage: '6g', usage: '水煎服', effect: '温阳扶阳' },
{ name: '干姜', dosage: '6g', usage: '水煎服', effect: '温中散寒' },
{ name: '附子', dosage: '10g', usage: '水煎服', effect: '温阳扶阳' },
{ name: '甘草', dosage: '6g', usage: '水煎服', effect: '调和诸药' }
],
suggestion: '避免接触冷水,保暖很重要。多食温阳食物如羊肉、生姜。适度运动增强体质。'
}
];
// 初始化症状复选框
function initSymptoms() {
const container = document.getElementById('symptoms-container');
symptoms.forEach(symptom => {
const div = document.createElement('div');
div.className = 'symptom-item';
div.innerHTML = `
<input type="checkbox" id="symptom-${symptom}" value="${symptom}">
<label for="symptom-${symptom}">${symptom}</label>
`;
container.appendChild(div);
});
}
// 诊断函数
function diagnose() {
const name = document.getElementById('patient-name').value.trim();
const errorMsg = document.getElementById('error-msg');
if (!name) {
errorMsg.textContent = '请输入患者姓名';
errorMsg.classList.add('show');
return;
}
const selectedSymptoms = Array.from(document.querySelectorAll('#symptoms-container input:checked'))
.map(input => input.value);
if (selectedSymptoms.length === 0) {
errorMsg.textContent = '请至少选择一个症状';
errorMsg.classList.add('show');
return;
}
errorMsg.classList.remove('show');
// 匹配诊断
let matchedDiagnosis = null;
let maxMatch = 0;
diagnoses.forEach(diagnosis => {
const matchCount = selectedSymptoms.filter(s => diagnosis.symptoms.includes(s)).length;
if (matchCount > maxMatch) {
maxMatch = matchCount;
matchedDiagnosis = diagnosis;
}
});
if (!matchedDiagnosis) {
matchedDiagnosis = diagnoses[0];
}
// 显示处方
showPrescription(name, matchedDiagnosis);
}
// 显示处方
function showPrescription(name, diagnosis) {
const now = new Date();
const dateStr = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')}`;
let html = `
<div class="prescription">
<div class="prescription-header">
<h2>${diagnosis.name}</h2>
<p>中医辨证处方</p>
</div>
<div class="prescription-info">
<div class="info-item">
<span class="info-label">患者姓名:</span>
<span>${name}</span>
</div>
<div class="info-item">
<span class="info-label">处方日期:</span>
<span>${dateStr}</span>
</div>
</div>
<div class="prescription-section">
<h3>处方药物</h3>
`;
diagnosis.prescription.forEach(medicine => {
html += `
<div class="medicine-item">
<div class="medicine-name">${medicine.name}</div>
<div class="medicine-detail">用量:${medicine.dosage}</div>
<div class="medicine-detail">用法:${medicine.usage}</div>
<div class="medicine-detail">功效:${medicine.effect}</div>
</div>
`;
});
html += `
</div>
<div class="prescription-section">
<h3>医嘱建议</h3>
<div class="suggestion">${diagnosis.suggestion}</div>
</div>
</div>
`;
document.getElementById('prescription-content').innerHTML = html;
document.getElementById('diagnosis-section').classList.remove('active');
document.getElementById('prescription-section').classList.add('active');
}
// 打印处方
function printPrescription() {
window.print();
}
// 重新诊断
function newDiagnosis() {
document.getElementById('patient-name').value = '';
document.querySelectorAll('#symptoms-container input:checked').forEach(input => {
input.checked = false;
});
document.getElementById('error-msg').classList.remove('show');
document.getElementById('diagnosis-section').classList.add('active');
document.getElementById('prescription-section').classList.remove('active');
}
// 页面加载时初始化
window.addEventListener('DOMContentLoaded', initSymptoms);
</script>
</body>
</html>