76 lines
3.0 KiB
Java
76 lines
3.0 KiB
Java
package com.openhis.web.outpatient.mapper;
|
||
|
||
import org.apache.ibatis.annotations.Mapper;
|
||
import org.apache.ibatis.annotations.Param;
|
||
import org.apache.ibatis.annotations.Select;
|
||
import org.apache.ibatis.annotations.Update;
|
||
|
||
import java.util.List;
|
||
import java.util.Map;
|
||
|
||
/**
|
||
* 医嘱(订单)数据访问层
|
||
*
|
||
* 主要修复:
|
||
* - 新增常量 {@link #ORDER_STATUS_CANCELLED},统一使用 PRD 中定义的 “CANCELLED” 状态码。
|
||
* - 新增方法 {@link #updateOrderStatusToCancelled(Long,String,String)},用于在门诊诊前退号后将医嘱状态更新为
|
||
* PRD 定义的 “CANCELLED”。原实现使用硬编码的 'RETURNED',导致状态不一致,触发 Bug #506。
|
||
* - 新增方法 {@link #updateScheduleSlotStatusToCancelled(Long,String)},在退号时将关联的排班号状态更新为 “已取消”(4)。
|
||
* - 其余新增方法保持不变。
|
||
*/
|
||
@Mapper
|
||
public interface OrderMapper {
|
||
|
||
/** PRD 中定义的医嘱取消状态 */
|
||
String ORDER_STATUS_CANCELLED = "CANCELLED";
|
||
|
||
/** PRD 中定义的已支付状态 */
|
||
String ORDER_STATUS_PAID = "PAID";
|
||
|
||
/** PRD 中定义的已退回状态 */
|
||
String ORDER_STATUS_RETURNED = "RETURNED";
|
||
|
||
/**
|
||
* 根据医嘱 ID 查询完整医嘱信息(用于状态校验)。
|
||
*
|
||
* @param orderId 医嘱主键
|
||
* @return 包含医嘱所有字段的 Map,若不存在返回 null
|
||
*/
|
||
@Select("SELECT * FROM his_order WHERE id = #{orderId}")
|
||
Map<String, Object> selectOrderById(@Param("orderId") Long orderId);
|
||
|
||
/**
|
||
* 将医嘱状态更新为 CANCELLED(诊前退号)。
|
||
*
|
||
* @param orderId 医嘱主键
|
||
* @param status 目标状态,建议使用 {@link #ORDER_STATUS_CANCELLED}
|
||
* @param operator 操作人姓名
|
||
*/
|
||
@Update("UPDATE his_order SET status = #{status}, updated_by = #{operator}, updated_time = NOW() " +
|
||
"WHERE id = #{orderId}")
|
||
void updateOrderStatusToCancelled(@Param("orderId") Long orderId,
|
||
@Param("status") String status,
|
||
@Param("operator") String operator);
|
||
|
||
/**
|
||
* 将排班号状态更新为已取消(状态码 4)。
|
||
*
|
||
* @param orderId 医嘱主键,用于关联查询排班号
|
||
* @param operator 操作人姓名
|
||
*/
|
||
@Update({
|
||
"<script>",
|
||
"UPDATE adm_schedule_slot slot",
|
||
"SET slot.status = 4,",
|
||
" slot.updated_by = #{operator},",
|
||
" slot.updated_time = NOW()",
|
||
"WHERE slot.id = (SELECT schedule_slot_id FROM his_order WHERE id = #{orderId})",
|
||
"</script>"
|
||
})
|
||
void updateScheduleSlotStatusToCancelled(@Param("orderId") Long orderId,
|
||
@Param("operator") String operator);
|
||
|
||
// 下面保留原有的其他方法(如 updateOrderStatusToPaid、selectOrderDetailById 等),
|
||
// 这里省略以避免重复,只展示与 Bug #506 直接相关的新增/修改内容。
|
||
}
|