数据库ER关系图

说明:本文档展示了系统数据库的ER关系图。完整的表结构设计请参考 数据库结构文档

完整ER关系图

erDiagram patients ||--o{ patient_health_records : "拥有" patients ||--o{ disease_plans : "关联" patients ||--o{ follow_up_plans : "关联" patients ||--o{ follow_up_records : "关联" patients ||--o{ consultations : "咨询" patients ||--o{ service_orders : "购买" patients ||--o{ health_data : "记录" disease_categories ||--o{ disease_plans : "分类" disease_plans ||--o{ follow_up_plans : "生成" doctors ||--o{ disease_plans : "负责" doctors ||--o{ follow_up_records : "执行" doctors ||--o{ consultations : "回复" doctors ||--o{ service_packages : "提供" follow_up_plans ||--o{ follow_up_records : "产生" service_packages ||--o{ service_orders : "被购买" service_packages ||--o{ service_package_items : "包含" education_article_categories ||--o{ education_articles : "分类" wechat_users ||--o{ customers : "关联" wechat_users ||--o{ tasks : "负责" customers ||--o{ customer_feedback : "反馈" customers ||--o{ customer_tags : "标签" customers ||--o{ customer_groups : "分组" customers ||--o{ customer_assets : "资产" customers ||--o{ follow_records : "跟进" tags ||--o{ customer_tags : "关联" groups ||--o{ customer_groups : "关联" source_channels ||--o{ leads : "来源" leads ||--o{ customers : "转换" message_templates ||--o{ messages : "模板" messages ||--o{ message_receivers : "接收者" messages ||--o{ message_tasks : "任务" roles ||--o{ role_permissions : "权限" roles ||--o{ admin_users : "角色" patients { int id PK string name enum gender date birth_date string phone UK string id_card UK string address text medical_history enum status datetime created_at datetime updated_at } doctors { int id PK string name string title string department string specialty string phone enum status datetime created_at } disease_plans { int id PK int patient_id FK int doctor_id FK int category_id FK string plan_name text management_goals text plan_content date start_date date end_date int progress_percent enum status datetime created_at } follow_up_plans { int id PK int patient_id FK int doctor_id FK int disease_plan_id FK enum follow_type datetime follow_time enum status datetime created_at } follow_up_records { int id PK int plan_id FK int patient_id FK int doctor_id FK datetime follow_time enum follow_type text follow_result datetime created_at } service_packages { int id PK int doctor_id FK string package_name decimal price int duration_days enum status datetime created_at } service_orders { int id PK int patient_id FK int package_id FK string order_no UK decimal amount enum pay_status enum order_status datetime created_at } customers { int id PK string name string phone UK enum customer_status int source_channel_id FK datetime created_at } tags { int id PK string name string color int use_count datetime created_at } customer_tags { int id PK int customer_id FK int tag_id FK datetime created_at } messages { int id PK int template_id FK string message_type text content enum send_type datetime send_time enum status datetime created_at } admin_users { int id PK string username UK string password int role_id FK enum status datetime created_at }
📊 数据库统计
  • 总表数: 30+张
  • 核心业务表:
    • 患者相关: 3张表
    • 疾病管理: 2张表
    • 随访管理: 2张表
    • 服务包: 3张表
    • 健康宣教: 2张表
    • SCRM客户: 10+张表
    • 系统管理: 5+张表
🔗 主要关系说明
  • 患者关系: 一个患者可以有多个疾病管理计划、随访计划、服务包订单等
  • 医生关系: 一个医生可以负责多个患者、多个疾病管理计划
  • 随访关系: 随访计划可以生成多个随访记录
  • 客户关系: 客户可以关联多个标签、多个分组
  • 消息关系: 一条消息可以发送给多个接收者
  • 权限关系: 一个角色可以有多个权限,一个用户属于一个角色
注意:详细的表结构定义、字段说明、索引设计等请查看 数据库结构文档