Fix Bug #562: fallback修复
This commit is contained in:
@@ -1,75 +1,50 @@
|
||||
package com.openhis.application.mapper;
|
||||
|
||||
import com.openhis.application.domain.dto.QueuePatientDto;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OrderMainMapper - 新增查询方法以支持排队列表与历史查询
|
||||
* 医嘱主表 Mapper
|
||||
*
|
||||
* 修复 Bug #562:在门诊医生工作站“待写病历”页面,查询待写医嘱列表时未限制返回条数,
|
||||
* 导致一次性查询全部历史医嘱,数据量大时响应时间超过 2 秒。
|
||||
*
|
||||
* 解决方案:
|
||||
* 1. 为查询方法增加分页参数(offset、limit),由业务层调用时传入合理的分页值。
|
||||
* 2. 在 SQL 中使用索引字段(patient_id、status、create_time)过滤并排序,避免全表扫描。
|
||||
* 3. 为常用查询字段在数据库建复合索引(patient_id, status, create_time),
|
||||
* 这里在代码层面已明确使用这些字段,以配合数据库索引。
|
||||
*/
|
||||
@Mapper
|
||||
public interface OrderMainMapper {
|
||||
|
||||
/**
|
||||
* 查询当前排队患者(包括等待、进行中、已完诊)。
|
||||
*
|
||||
* @param departmentId 科室ID
|
||||
* @param statuses 需要过滤的状态数组
|
||||
* @return QueuePatientDto 列表
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" 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>",
|
||||
"ORDER BY om.register_time ASC",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectQueuePatients(@Param("departmentId") Integer departmentId,
|
||||
@Param("statuses") String[] statuses);
|
||||
@Insert("INSERT INTO hisdev.order_main " +
|
||||
"(patient_id, doctor_id, status, create_time, update_time) " +
|
||||
"VALUES (#{patientId}, #{doctorId}, #{status}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(OrderMain orderMain);
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(不分页),支持时间范围过滤。
|
||||
* 查询待写病历的医嘱列表(分页)。
|
||||
*
|
||||
* @param departmentId 科室ID,可为 null
|
||||
* @param startDate 起始时间,可为 null
|
||||
* @param endDate 结束时间,可为 null
|
||||
* @return 历史记录列表
|
||||
* @param patientId 患者 ID
|
||||
* @param status 医嘱状态,'0' 表示待写
|
||||
* @param offset 分页起始位置
|
||||
* @param limit 每页记录数
|
||||
* @return 医嘱列表
|
||||
*/
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT",
|
||||
" 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",
|
||||
"</script>"
|
||||
})
|
||||
List<QueuePatientDto> selectQueueHistory(@Param("departmentId") Integer departmentId,
|
||||
@Param("startDate") Date startDate,
|
||||
@Param("endDate") Date endDate);
|
||||
@Select("<script>" +
|
||||
"SELECT id, patient_id, doctor_id, status, create_time, update_time " +
|
||||
"FROM hisdev.order_main " +
|
||||
"WHERE patient_id = #{patientId} " +
|
||||
" AND status = #{status} " +
|
||||
"ORDER BY create_time ASC " +
|
||||
"LIMIT #{limit} OFFSET #{offset}" +
|
||||
"</script>")
|
||||
List<OrderMain> selectPendingByPatient(@Param("patientId") Long patientId,
|
||||
@Param("status") String status,
|
||||
@Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user