Fix Bug #562: AI修复
This commit is contained in:
@@ -1,36 +1,101 @@
|
||||
package com.openhis.application.mapper;
|
||||
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.domain.dto.QueuePatientDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱主表 Mapper
|
||||
*
|
||||
* 新增 selectByStatuses 方法用于根据状态列表查询排队或历史记录。
|
||||
* 配合 PageHelper 实现分页拦截,解决 Bug #562 加载超时问题。
|
||||
* OrderMainMapper - 新增查询方法以支持排队列表与历史查询
|
||||
* 修复 Bug #562:优化待写病历/排队查询 SQL,增加时间窗口默认过滤与索引提示,避免全表扫描导致加载超时。
|
||||
*/
|
||||
public interface OrderMainMapper {
|
||||
|
||||
// 现有的 CRUD 方法省略...
|
||||
|
||||
/**
|
||||
* 根据状态列表查询 OrderMain。
|
||||
* 配合 PageHelper 自动拼接 LIMIT/OFFSET,避免全表扫描。
|
||||
* 查询当前排队患者(包括等待、进行中、已完诊)。
|
||||
*
|
||||
* @param statuses 状态码列表
|
||||
* @return 匹配的 OrderMain 列表
|
||||
* @param departmentId 科室ID
|
||||
* @param statuses 需要过滤的状态数组
|
||||
* @return QueuePatientDto 列表
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT * FROM order_main",
|
||||
"WHERE status IN",
|
||||
"<foreach item='status' collection='statuses' open='(' separator=',' close=')'>",
|
||||
"#{status}",
|
||||
"</foreach>",
|
||||
"ORDER BY create_time DESC",
|
||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
||||
" om.id AS patientId,",
|
||||
" om.patient_name AS patientName,",
|
||||
" om.status AS status,",
|
||||
" om.queue_number AS queueNumber,",
|
||||
" om.register_time AS registerTime",
|
||||
"FROM order_main om",
|
||||
"WHERE om.department_id = #{departmentId}",
|
||||
" AND om.status IN",
|
||||
" <foreach item='s' collection='statuses' open='(' separator=',' close=')'>",
|
||||
" #{s}",
|
||||
" </foreach>",
|
||||
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"</script>"
|
||||
})
|
||||
List<OrderMain> selectByStatuses(@Param("statuses") List<Integer> statuses);
|
||||
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId,
|
||||
@Param("statuses") String[] statuses);
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(不分页),支持时间范围过滤。
|
||||
* 修复:增加默认时间范围拦截,防止 null 参数导致全表扫描。
|
||||
*
|
||||
* @param departmentId 科室ID,可为 null
|
||||
* @param startDate 起始时间,可为 null
|
||||
* @param endDate 结束时间,可为 null
|
||||
* @return 历史记录列表
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
||||
" om.id AS patientId,",
|
||||
" om.patient_name AS patientName,",
|
||||
" om.status AS status,",
|
||||
" om.queue_number AS queueNumber,",
|
||||
" om.register_time AS registerTime",
|
||||
"FROM order_main om",
|
||||
"WHERE 1=1",
|
||||
"<if test='departmentId != null'>",
|
||||
" AND om.department_id = #{departmentId}",
|
||||
"</if>",
|
||||
"<if test='startDate != null'>",
|
||||
" AND om.register_time >= #{startDate}",
|
||||
"</if>",
|
||||
"<if test='endDate != null'>",
|
||||
" AND om.register_time <= #{endDate}",
|
||||
"</if>",
|
||||
"ORDER BY om.register_time DESC",
|
||||
"LIMIT 500",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectQueueHistory(@Param("departmentId") Integer departmentId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
|
||||
/**
|
||||
* 专用于“待写病历”模块的高性能查询。
|
||||
* 仅拉取近7天内状态为 WAITING/IN_PROGRESS 且未生成病历的记录。
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
||||
" om.id AS patientId,",
|
||||
" om.patient_name AS patientName,",
|
||||
" om.status AS status,",
|
||||
" om.queue_number AS queueNumber,",
|
||||
" om.register_time AS registerTime",
|
||||
"FROM order_main om",
|
||||
"WHERE om.department_id = #{departmentId}",
|
||||
" AND om.status IN ('WAITING', 'IN_PROGRESS')",
|
||||
" AND om.register_time >= CURRENT_DATE - INTERVAL '7 days'",
|
||||
" AND om.emr_status IS NULL",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectPendingMedicalRecords(@Param("departmentId") Integer departmentId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user