```
feat(surgical): 添加手术安排重复校验功能 BUG #278 - 在手术安排创建流程中增加重复校验逻辑 - 实现同一患者同一手术单号同一手术名称的唯一性约束 - 新增 existsDuplicateSchedule 数据库查询方法 - 添加 XML 映射文件中的重复校验 SQL 查询 - 防止相同手术安排的重复提交问题 ```
This commit is contained in:
@@ -94,6 +94,22 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi
|
||||
return R.fail("患者信息不存在");
|
||||
}
|
||||
}
|
||||
|
||||
// 校验是否重复手术安排
|
||||
// 同一患者 + 同一手术单号 + 同一手术名称 只能有一条有效安排记录
|
||||
if (opCreateScheduleDto.getPatientId() != null
|
||||
&& opCreateScheduleDto.getOperCode() != null && !opCreateScheduleDto.getOperCode().isEmpty()
|
||||
&& opCreateScheduleDto.getOperName() != null && !opCreateScheduleDto.getOperName().isEmpty()) {
|
||||
Boolean existsDuplicate = surgicalScheduleAppMapper.existsDuplicateSchedule(
|
||||
opCreateScheduleDto.getPatientId(),
|
||||
opCreateScheduleDto.getOperCode(),
|
||||
opCreateScheduleDto.getOperName()
|
||||
);
|
||||
if (existsDuplicate) {
|
||||
return R.fail("该患者此手术单号已存在手术安排,请勿重复提交");
|
||||
}
|
||||
}
|
||||
|
||||
//校验该时段内手术间是否被占用
|
||||
LocalDateTime scheduleDate = opCreateScheduleDto.getEntryTime();//入室时间
|
||||
String roomCode = opCreateScheduleDto.getRoomCode();//手术室编号
|
||||
|
||||
@@ -58,4 +58,14 @@ public interface SurgicalScheduleAppMapper {
|
||||
* @return 是否存在冲突的手术安排
|
||||
*/
|
||||
Boolean isScheduleConflict(LocalDateTime startTime, LocalDateTime endTime, String surgeryRoomId);
|
||||
|
||||
/**
|
||||
* 检查是否存在重复的手术安排
|
||||
*
|
||||
* @param patientId 患者ID
|
||||
* @param operCode 手术单号
|
||||
* @param operName 手术名称
|
||||
* @return 是否存在重复记录
|
||||
*/
|
||||
Boolean existsDuplicateSchedule(@Param("patientId") Long patientId, @Param("operCode") String operCode, @Param("operName") String operName);
|
||||
}
|
||||
|
||||
@@ -144,4 +144,13 @@
|
||||
AND entry_time >= #{startTime}
|
||||
AND end_time < #{endTime}
|
||||
</select>
|
||||
|
||||
<!-- 检查是否存在重复的手术安排 -->
|
||||
<select id="existsDuplicateSchedule" resultType="java.lang.Boolean">
|
||||
SELECT COUNT(*) > 0 FROM op_schedule
|
||||
WHERE patient_id = #{patientId}
|
||||
AND oper_code = #{operCode}
|
||||
AND oper_name = #{operName}
|
||||
AND delete_flag = '0'
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user