Files
zyt/APPOINTMENT_README.md
T
2026-03-04 15:32:30 +08:00

5.1 KiB

医生预约挂号系统

🎯 系统简介

基于医生排班的患者预约挂号系统,支持30分钟间隔的时间段预约,防止重复预约,并根据医生排班状态控制挂号可用性。

快速开始

1. 运行安装脚本

Windows:

install_appointment_system.bat

Linux/Mac:

chmod +x install_appointment_system.sh
./install_appointment_system.sh

2. 手动安装

如果安装脚本无法运行,请按以下步骤手动安装:

# 1. 创建数据库表
mysql -u username -p database < server/sql/doctor_appointment.sql

# 2. 清除缓存
cd server
php think clear

# 3. 测试API
curl "http://localhost/adminapi/doctor.appointment/availableSlots?doctor_id=1&appointment_date=2026-03-04&period=morning"

📚 文档导航

文档 说明 适用人群
APPOINTMENT_QUICK_START.md 快速开始指南 所有人
INSTALLATION_CHECKLIST.md 安装检查清单 运维人员
APPOINTMENT_COMPLETE.md 完整实现总结 开发人员
server/APPOINTMENT_BACKEND_SETUP.md 后端详细说明 后端开发
admin/APPOINTMENT_SYSTEM.md 系统设计文档 产品/开发
admin/APPOINTMENT_UI_UPDATE.md UI更新说明 前端开发

🎨 功能特性

用户界面

  • 预约方式选择(按时段/按医生)
  • 医生列表显示可用号源
  • 日期选择(未来7天)
  • 时间段网格显示(30分钟间隔)
  • 实时可用性检查
  • 表单验证

后端功能

  • 时间段自动生成
  • 排班状态检查
  • 号源数量控制
  • 并发冲突防止
  • 预约管理(创建/取消/列表)

🔌 API接口

GET  /adminapi/doctor.appointment/availableSlots  - 获取可用时间段
POST /adminapi/doctor.appointment/create          - 创建预约
POST /adminapi/doctor.appointment/cancel          - 取消预约
GET  /adminapi/doctor.appointment/lists           - 预约列表
GET  /adminapi/doctor.appointment/detail          - 预约详情
GET  /adminapi/doctor.appointment/doctorAvailability - 医生可用号源

💾 数据库

表结构

la_doctor_appointment
├── id (主键)
├── patient_id (患者ID)
├── doctor_id (医生ID)
├── roster_id (排班ID)
├── appointment_date (预约日期)
├── period (时段)
├── appointment_time (预约时间)
├── appointment_type (预约类型)
├── status (状态)
├── remark (备注)
├── create_time (创建时间)
└── update_time (更新时间)

创建表

mysql -u username -p database < server/sql/doctor_appointment.sql

🧪 测试

创建测试数据

INSERT INTO `la_doctor_roster` 
(`doctor_id`, `date`, `period`, `status`, `quota`, `max_patients`, `create_time`, `update_time`)
VALUES
(1, '2026-03-04', 'morning', 1, 10, 15, UNIX_TIMESTAMP(), UNIX_TIMESTAMP());

测试API

cd server
php test_appointment_api.php

测试前端

  1. 登录后台管理系统
  2. 进入"中医诊断"页面
  3. 点击"挂号"按钮
  4. 完成预约流程

⚙️ 配置

权限节点

在后台权限管理中添加:

doctor.appointment/availableSlots
doctor.appointment/create
doctor.appointment/cancel
doctor.appointment/lists
doctor.appointment/detail

业务规则

  • 时间段间隔: 30分钟
  • 上午时段: 09:00-11:30
  • 下午时段: 13:00-20:30
  • 预约条件: 医生排班且状态为"出诊"

🐛 故障排查

控制器不存在

cd server && php think clear

数据库表不存在

mysql -u username -p database < server/sql/doctor_appointment.sql

没有可用时间段

检查医生排班:

SELECT * FROM la_doctor_roster WHERE doctor_id = 1 AND status = 1;

📦 文件清单

后端 (6个文件)

  • server/app/common/model/doctor/Appointment.php
  • server/app/adminapi/controller/doctor/AppointmentController.php
  • server/app/adminapi/logic/doctor/AppointmentLogic.php
  • server/app/adminapi/validate/doctor/AppointmentValidate.php
  • server/app/adminapi/lists/doctor/AppointmentLists.php
  • server/sql/doctor_appointment.sql

前端 (3个文件)

  • admin/src/api/doctor.ts (已更新)
  • admin/src/views/tcm/diagnosis/appointment.vue (新建)
  • admin/src/views/tcm/diagnosis/index.vue (已更新)

🔧 技术栈

后端:

  • PHP 7.2+
  • ThinkPHP 6.0
  • MySQL 5.7+

前端:

  • Vue 3
  • TypeScript
  • Element Plus

📝 版本信息

  • 版本: 1.0.0
  • 状态: 开发完成
  • 创建时间: 2024-02-26

🎯 下一步

  1. 文件已创建
  2. 创建数据库表
  3. 清除缓存
  4. 配置权限
  5. 测试功能
  6. 上线使用

📞 获取帮助

遇到问题?查看:

  1. 安装检查清单
  2. 快速开始指南
  3. 完整实现总结

祝你使用愉快! 🎉