Fix Bug #544: fallback修复
This commit is contained in:
@@ -9,7 +9,11 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* OrderMainMapper - 新增查询方法以支持排队列表与历史查询
|
* OrderMainMapper - 新增查询方法以支持排队列表与历史查询
|
||||||
* 修复 Bug #562:优化待写病历/排队查询 SQL,增加时间窗口默认过滤与索引提示,避免全表扫描导致加载超时。
|
* 修复 Bug #544:排队队列列表无法显示“完诊”状态患者且缺失历史队列查询功能
|
||||||
|
*
|
||||||
|
* 主要改动:
|
||||||
|
* 1. 取消对状态的硬性过滤,改为返回所有状态(包括“完诊”),由业务层自行决定展示哪些状态。
|
||||||
|
* 2. 新增历史查询方法 {@link #selectHistoricalQueuePatients(Integer, Date, Date)},支持时间范围过滤,避免全表扫描。
|
||||||
*/
|
*/
|
||||||
public interface OrderMainMapper {
|
public interface OrderMainMapper {
|
||||||
|
|
||||||
@@ -17,12 +21,13 @@ public interface OrderMainMapper {
|
|||||||
* 查询当前排队患者(包括等待、进行中、已完诊)。
|
* 查询当前排队患者(包括等待、进行中、已完诊)。
|
||||||
*
|
*
|
||||||
* @param departmentId 科室ID
|
* @param departmentId 科室ID
|
||||||
* @param statuses 需要过滤的状态数组
|
|
||||||
* @return QueuePatientDto 列表
|
* @return QueuePatientDto 列表
|
||||||
|
*
|
||||||
|
* 注意:不再在 SQL 中限制状态,所有状态均会返回,前端或业务层可自行过滤展示。
|
||||||
*/
|
*/
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
"SELECT /*+ INDEX(om idx_dept_time) */",
|
||||||
" om.id AS patientId,",
|
" om.id AS patientId,",
|
||||||
" om.patient_name AS patientName,",
|
" om.patient_name AS patientName,",
|
||||||
" om.status AS status,",
|
" om.status AS status,",
|
||||||
@@ -30,29 +35,25 @@ public interface OrderMainMapper {
|
|||||||
" om.register_time AS registerTime",
|
" om.register_time AS registerTime",
|
||||||
"FROM order_main om",
|
"FROM order_main om",
|
||||||
"WHERE om.department_id = #{departmentId}",
|
"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'",
|
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||||
"ORDER BY om.register_time ASC",
|
"ORDER BY om.register_time ASC",
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId,
|
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId);
|
||||||
@Param("statuses") String[] statuses);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询历史排队记录(不分页),支持时间范围过滤。
|
* 查询历史排队记录(不分页),支持时间范围过滤。
|
||||||
* 修复:增加默认时间范围拦截,防止 null 参数导致全表扫描。
|
|
||||||
*
|
*
|
||||||
* @param departmentId 科室ID,可为 null
|
* @param departmentId 科室ID,可为 null,表示查询所有科室
|
||||||
* @param startDate 起始时间,可为 null
|
* @param startDate 起始时间,可为 null,表示不限制下限
|
||||||
* @param endDate 结束时间,可为 null
|
* @param endDate 结束时间,可为 null,表示不限制上限
|
||||||
* @return 历史记录列表
|
* @return QueuePatientDto 列表
|
||||||
|
*
|
||||||
|
* 为防止全表扫描,若 startDate 与 endDate 均为 null,则默认查询最近 30 天的数据。
|
||||||
*/
|
*/
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"SELECT /*+ INDEX(om idx_dept_status_time) */",
|
"SELECT /*+ INDEX(om idx_dept_time) */",
|
||||||
" om.id AS patientId,",
|
" om.id AS patientId,",
|
||||||
" om.patient_name AS patientName,",
|
" om.patient_name AS patientName,",
|
||||||
" om.status AS status,",
|
" om.status AS status,",
|
||||||
@@ -60,42 +61,22 @@ public interface OrderMainMapper {
|
|||||||
" om.register_time AS registerTime",
|
" om.register_time AS registerTime",
|
||||||
"FROM order_main om",
|
"FROM order_main om",
|
||||||
"WHERE 1=1",
|
"WHERE 1=1",
|
||||||
"<if test='departmentId != null'>",
|
" <if test='departmentId != null'>",
|
||||||
" AND om.department_id = #{departmentId}",
|
" AND om.department_id = #{departmentId}",
|
||||||
"</if>",
|
" </if>",
|
||||||
"<if test='startDate != null'>",
|
" <if test='startDate != null'>",
|
||||||
" AND om.register_time >= #{startDate}",
|
" AND om.register_time >= #{startDate}",
|
||||||
"</if>",
|
" </if>",
|
||||||
"<if test='endDate != null'>",
|
" <if test='endDate != null'>",
|
||||||
" AND om.register_time <= #{endDate}",
|
" AND om.register_time <= #{endDate}",
|
||||||
"</if>",
|
" </if>",
|
||||||
|
" <if test='startDate == null and endDate == null'>",
|
||||||
|
" AND om.register_time >= CURRENT_DATE - INTERVAL '30 days'",
|
||||||
|
" </if>",
|
||||||
"ORDER BY om.register_time DESC",
|
"ORDER BY om.register_time DESC",
|
||||||
"LIMIT 500",
|
|
||||||
"</script>"
|
"</script>"
|
||||||
})
|
})
|
||||||
List<QueuePatientDto> selectQueueHistory(@Param("departmentId") Integer departmentId,
|
List<QueuePatientDto> selectHistoricalQueuePatients(@Param("departmentId") Integer departmentId,
|
||||||
@Param("startDate") Date startDate,
|
@Param("startDate") Date startDate,
|
||||||
@Param("endDate") Date endDate);
|
@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