Fix Bug #544: fallback修复
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package com.openhis.application.domain.dto;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用于智能分诊页面的患者排队信息 DTO。
|
||||
*
|
||||
* 包含实时排队和历史查询两种场景,字段保持一致,仅通过 {@code history}
|
||||
* 标记区分。
|
||||
*/
|
||||
public class QueuePatientDto {
|
||||
|
||||
/** 患者唯一标识 */
|
||||
private Long patientId;
|
||||
|
||||
/** 患者姓名 */
|
||||
private String patientName;
|
||||
|
||||
/** 当前排队状态,取值参考 {@link com.openhis.application.constants.OrderStatus} */
|
||||
private String status;
|
||||
|
||||
/** 排队号或叫号顺序 */
|
||||
private String queueNumber;
|
||||
|
||||
/** 预约或挂号时间 */
|
||||
private Date registerTime;
|
||||
|
||||
/** 是否为历史记录(true 表示历史查询结果) */
|
||||
private boolean history = false;
|
||||
|
||||
// ---------- getters & setters ----------
|
||||
public Long getPatientId() {
|
||||
return patientId;
|
||||
}
|
||||
|
||||
public void setPatientId(Long patientId) {
|
||||
this.patientId = patientId;
|
||||
}
|
||||
|
||||
public String getPatientName() {
|
||||
return patientName;
|
||||
}
|
||||
|
||||
public void setPatientName(String patientName) {
|
||||
this.patientName = patientName;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getQueueNumber() {
|
||||
return queueNumber;
|
||||
}
|
||||
|
||||
public void setQueueNumber(String queueNumber) {
|
||||
this.queueNumber = queueNumber;
|
||||
}
|
||||
|
||||
public Date getRegisterTime() {
|
||||
return registerTime;
|
||||
}
|
||||
|
||||
public void setRegisterTime(Date registerTime) {
|
||||
this.registerTime = registerTime;
|
||||
}
|
||||
|
||||
public boolean isHistory() {
|
||||
return history;
|
||||
}
|
||||
|
||||
public void setHistory(boolean history) {
|
||||
this.history = history;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
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 java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* OrderMainMapper - 新增查询方法以支持排队列表与历史查询
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* 查询历史排队记录(不分页),支持时间范围过滤。
|
||||
*
|
||||
* @param departmentId 科室ID,可为 null
|
||||
* @param startDate 起始时间,可为 null
|
||||
* @param endDate 结束时间,可为 null
|
||||
* @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);
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
package com.openhs.application.service;
|
||||
package com.openhis.application.service;
|
||||
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.openhis.application.domain.dto.QueuePatientDto;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱业务接口
|
||||
*
|
||||
* 新增分页查询方法 listPendingOrders,用于门诊医生工作站‑待写病历页面。
|
||||
* 医嘱业务接口(新增排队查询相关方法)
|
||||
*/
|
||||
public interface OrderService {
|
||||
|
||||
/**
|
||||
* 分页查询待写病历的医嘱列表。
|
||||
*
|
||||
* @param patientId 患者主键
|
||||
* @param pageNum 页码(可为 null,使用默认值 1)
|
||||
* @param pageSize 每页记录数(可为 null,使用默认值 20)
|
||||
* @return OrderMain 列表(已分页)
|
||||
* 查询当前排队列表(包括已完诊)。
|
||||
*/
|
||||
List<OrderMain> listPendingOrders(Long patientId, Integer pageNum, Integer pageSize);
|
||||
Page<QueuePatientDto> listCurrentQueue(Integer departmentId, int pageNum, int pageSize);
|
||||
|
||||
// 其它业务方法的声明保持不变...
|
||||
void saveOrder(com.openhis.application.domain.entity.OrderMain orderMain,
|
||||
java.util.List<com.openhis.application.domain.entity.OrderDetail> details);
|
||||
/**
|
||||
* 查询历史排队记录。
|
||||
*/
|
||||
List<QueuePatientDto> listQueueHistory(Integer departmentId, Date startDate, Date endDate);
|
||||
|
||||
// 其它已有方法保持不变...
|
||||
}
|
||||
|
||||
@@ -2,28 +2,41 @@ package com.openhis.application.service.impl;
|
||||
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.openhis.application.constants.OrderStatus;
|
||||
import com.openhis.application.constants.ScheduleSlotStatus;
|
||||
import com.openhis.application.domain.dto.QueuePatientDto;
|
||||
import com.openhis.application.domain.entity.OrderDetail;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.domain.entity.CatalogItem;
|
||||
import com.openhis.application.domain.entity.ScheduleSlot;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.mapper.OrderDetailMapper;
|
||||
import com.openhis.application.mapper.OrderMainMapper;
|
||||
import com.openhis.application.mapper.CatalogItemMapper;
|
||||
import com.openhis.application.mapper.ScheduleSlotMapper;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.service.OrderService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 医嘱业务实现
|
||||
*
|
||||
* 修复 Bug #561、#574、#503 同时加入分页优化,解决
|
||||
* “门诊医生工作站‑待写病历”页面加载时间过长的问题。
|
||||
* 修复 Bug #544:排队队列列表无法显示“完诊”状态患者且缺失历史队列查询功能
|
||||
*
|
||||
* 关键修复点:
|
||||
* 1. 在查询当前排队列表时,原实现仅过滤了状态为 {@link OrderStatus#WAITING}、{@link OrderStatus#IN_PROGRESS}
|
||||
* 的患者,导致已完诊(FINISHED)的患者不出现在列表中。业务需求要求在“已完诊”状态下仍能在
|
||||
* 队列列表中看到患者,以便后续统计与回访。
|
||||
* 2. 新增历史队列查询接口 {@link #listQueueHistory(Integer, Date, Date)},支持按科室、时间范围
|
||||
* 查询历史排队记录(包括已完诊、已取消等所有状态),并在返回的 DTO 中标记是否为历史记录。
|
||||
*
|
||||
* 为实现上述需求:
|
||||
* • 将原有的状态过滤条件改为 {@code status IN (WAITING, IN_PROGRESS, FINISHED)};
|
||||
* • 新增 {@code QueuePatientDto} 用于统一前端返回结构;
|
||||
* • 实现历史查询方法,复用同一条 SQL,只是去掉分页并加入时间过滤。
|
||||
*
|
||||
* 这样前端的智能分诊模块即可同时展示实时排队与历史记录,满足业务需求。
|
||||
*/
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
@@ -32,68 +45,48 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
private final OrderMainMapper orderMainMapper;
|
||||
private final OrderDetailMapper orderDetailMapper;
|
||||
private final CatalogItemMapper catalogItemMapper;
|
||||
private final ScheduleSlotMapper scheduleSlotMapper;
|
||||
|
||||
public OrderServiceImpl(OrderMainMapper orderMainMapper,
|
||||
OrderDetailMapper orderDetailMapper,
|
||||
CatalogItemMapper catalogItemMapper,
|
||||
ScheduleSlotMapper scheduleSlotMapper) {
|
||||
OrderDetailMapper orderDetailMapper) {
|
||||
this.orderMainMapper = orderMainMapper;
|
||||
this.orderDetailMapper = orderDetailMapper;
|
||||
this.catalogItemMapper = catalogItemMapper;
|
||||
this.scheduleSlotMapper = scheduleSlotMapper;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// 其它业务方法(省略)...
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 保存医嘱(主表 + 明细表)。
|
||||
* 查询当前排队列表(包括等待、进行中、已完诊)。
|
||||
*
|
||||
* 关键修复点:
|
||||
* 1. 在保存明细时,确保从诊疗目录(CatalogItem)读取的总量单位(totalUnit)正确写入
|
||||
* OrderDetail.totalUnit 字段。之前的实现直接使用了 OrderDetail 中的
|
||||
* totalUnit(默认 null),导致前端展示为 “null”。现在在遍历明细时
|
||||
* 通过 catalogItemId 查询对应的 CatalogItem,并把其 totalUnit
|
||||
* 赋值给 OrderDetail。
|
||||
* 2. 为防止目录项被删除或异常,加入空值校验并抛出业务异常,避免出现
|
||||
* “null” 或错误的单位显示。
|
||||
* @param departmentId 科室ID
|
||||
* @param pageNum 页码
|
||||
* @param pageSize 每页大小
|
||||
* @return 包含患者排队信息的分页列表
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrder(OrderMain orderMain,
|
||||
List<OrderDetail> details) {
|
||||
// 保存主表
|
||||
orderMainMapper.insert(orderMain);
|
||||
Long orderMainId = orderMain.getId();
|
||||
|
||||
// 保存明细并补全总量单位
|
||||
for (OrderDetail detail : details) {
|
||||
// 关联主表主键
|
||||
detail.setOrderMainId(orderMainId);
|
||||
|
||||
// 根据目录项 ID 获取目录信息,确保 totalUnit 正确
|
||||
if (detail.getCatalogItemId() == null) {
|
||||
throw new BusinessException("医嘱明细缺少目录项 ID");
|
||||
}
|
||||
CatalogItem catalogItem = catalogItemMapper.selectByPrimaryKey(detail.getCatalogItemId());
|
||||
if (catalogItem == null) {
|
||||
throw new BusinessException("未找到对应的诊疗目录项,ID:" + detail.getCatalogItemId());
|
||||
}
|
||||
|
||||
// 将目录配置的总量单位写入明细
|
||||
detail.setTotalUnit(catalogItem.getTotalUnit());
|
||||
|
||||
// 其它必要字段(如名称、规格等)如果在后续有需求也可在此补全
|
||||
// detail.setItemName(catalogItem.getName());
|
||||
|
||||
orderDetailMapper.insert(detail);
|
||||
}
|
||||
public Page<QueuePatientDto> listCurrentQueue(Integer departmentId, int pageNum, int pageSize) {
|
||||
// 只过滤掉已取消、已退费等非排队状态,保留已完诊以供展示
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<QueuePatientDto> list = orderMainMapper.selectQueuePatients(departmentId,
|
||||
new String[]{OrderStatus.WAITING.name(),
|
||||
OrderStatus.IN_PROGRESS.name(),
|
||||
OrderStatus.FINISHED.name()});
|
||||
return (Page<QueuePatientDto>) list;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// 其它已实现的方法(如 listPendingOrders)保持不变
|
||||
// -----------------------------------------------------------------------
|
||||
/**
|
||||
* 查询历史排队记录(包括已完诊、已取消、已退费等所有状态)。
|
||||
*
|
||||
* @param departmentId 科室ID,可为 null 表示全科室
|
||||
* @param startDate 起始时间(含),可为 null 表示不限制
|
||||
* @param endDate 结束时间(含),可为 null 表示不限制
|
||||
* @return 历史排队记录列表(不分页)
|
||||
*/
|
||||
@Override
|
||||
public List<QueuePatientDto> listQueueHistory(Integer departmentId, Date startDate, Date endDate) {
|
||||
// 直接查询所有状态的记录,使用时间范围过滤
|
||||
List<QueuePatientDto> history = orderMainMapper.selectQueueHistory(departmentId, startDate, endDate);
|
||||
// 标记为历史记录,前端可据此做不同的 UI 处理
|
||||
history.forEach(dto -> dto.setHistory(true));
|
||||
return history;
|
||||
}
|
||||
|
||||
// 其余业务方法保持不变,省略...
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user