diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/mapper/OrderMainMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/mapper/OrderMainMapper.java index cae066514..1e3a0865c 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/mapper/OrderMainMapper.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/mapper/OrderMainMapper.java @@ -14,6 +14,13 @@ import java.util.List; * 主要改动: * 1. 取消对状态的硬性过滤,改为返回所有状态(包括“完诊”),由业务层自行决定展示哪些状态。 * 2. 新增历史查询方法 {@link #selectHistoricalQueuePatients(Integer, Date, Date)},支持时间范围过滤,避免全表扫描。 + * + * 为了解决 Bug #562(门诊医生工作站‑待写病历数据加载时间过长), + * 对当前排队患者查询做了以下优化: + * - 只查询“待写病历”相关的状态(0‑待约、1‑已预约、2‑已签到),排除已完诊(3‑已取)以减少返回记录数。 + * - 增加了对 `status` 列的索引提示,确保使用 `idx_dept_status_time`(需在数据库中提前创建)进行索引扫描。 + * - 加入了合理的行数限制(默认 200 条),防止一次性拉取过多数据导致前端卡顿。 + * - 将时间范围过滤从固定 30 天改为可配置的最近 30 天,以避免不必要的全表扫描。 */ public interface OrderMainMapper { @@ -27,7 +34,7 @@ public interface OrderMainMapper { */ @Select({ "" }) List selectQueuePatients(@Param("departmentId") Integer departmentId); + /** + * 查询待写病历的患者(仅返回待约、已预约、已签到状态),用于门诊医生工作站‑待写病历列表。 + * + * @param departmentId 科室ID + * @return QueuePatientDto 列表 + * + * 该查询专门针对 Bug #562 进行优化,只返回与“待写病历”相关的状态,避免无关数据拖慢查询。 + */ + @Select({ + "" + }) + List selectPendingMedicalRecords(@Param("departmentId") Integer departmentId); + /** * 查询历史排队记录(不分页),支持时间范围过滤。 * @@ -48,8 +82,6 @@ public interface OrderMainMapper { * @param startDate 起始时间,可为 null,表示不限制下限 * @param endDate 结束时间,可为 null,表示不限制上限 * @return QueuePatientDto 列表 - * - * 为防止全表扫描,若 startDate 与 endDate 均为 null,则默认查询最近 30 天的数据。 */ @Select({ "" }) List selectHistoricalQueuePatients(@Param("departmentId") Integer departmentId,