Files
his/openhis-server-new/sql/20260115_add_table_triage_queue_item.sql
赵云 818564f5ba Fix Bug #400: 门诊医生站点击【完诊】后,triage_queue_item 表 status 字段未按规范更新为 30
根因分析:
triage_queue_item.status 字段在 DDL 中定义为 VARCHAR(50),但 Java 实体
TriageQueueItem.status 为 Integer 类型,应用层使用 TriageQueueStatus 枚举值
(0/10/20/30/40) 进行读写。数据类型不匹配导致 MyBatis-Plus 无法正确映射 status 字段,
完诊时使用 LambdaUpdateWrapper 更新 status=30 操作失败。

修复方案:
1. 修正 DDL:将 status 字段类型从 VARCHAR(50) 改为 INTEGER
2. 新增迁移 SQL:修改已有数据库表的 status 字段类型为 INTEGER

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 14:00:45 +08:00

36 lines
1.7 KiB
SQL
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 智能分诊排队:队列持久化表(与 TriageQueueItem.java 字段一致)
-- 注意:必须在后端实际连接的 schema 中执行dev环境是 hisdevtest环境是 histestprd环境是 hisprd
-- 执行前请先确认SET search_path TO hisdev; (或对应的 schema
CREATE TABLE IF NOT EXISTS triage_queue_item (
id BIGSERIAL PRIMARY KEY,
tenant_id INTEGER NOT NULL,
queue_date DATE NOT NULL,
organization_id BIGINT NOT NULL,
organization_name VARCHAR(255),
encounter_id BIGINT NOT NULL,
patient_id BIGINT,
patient_name VARCHAR(255),
healthcare_name VARCHAR(255),
practitioner_name VARCHAR(255),
status INTEGER NOT NULL DEFAULT 0, -- 分诊队列状态: 0=WAITING(等待), 10=CALLING(叫号中), 20=IN_CLINIC(诊中), 30=COMPLETED(已完成), 40=SKIPPED(已跳过)
queue_order INTEGER NOT NULL,
create_time TIMESTAMP,
update_time TIMESTAMP,
delete_flag CHAR(1) NOT NULL DEFAULT '0'
);
-- 常用查询索引:按租户/科室/日期/状态/顺序取队列
CREATE INDEX IF NOT EXISTS idx_triage_queue_item_list
ON triage_queue_item (tenant_id, queue_date, organization_id, delete_flag, status, queue_order);
-- 防重复:同一天同租户同科室同就诊记录只能在队列里一条(未删除)
CREATE UNIQUE INDEX IF NOT EXISTS uq_triage_queue_item_encounter
ON triage_queue_item (tenant_id, queue_date, organization_id, encounter_id, delete_flag)
WHERE delete_flag = '0';
-- 就诊记录ID索引用于关联查询
CREATE INDEX IF NOT EXISTS idx_triage_queue_item_encounter_id
ON triage_queue_item (encounter_id);