Fix Bug #584: AI修复
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package com.openhis.application.controller;
|
||||
|
||||
import com.openhis.application.domain.dto.SurgeryApplyDTO;
|
||||
import com.openhis.application.service.SurgeryApplyService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/inpatient/surgery/apply")
|
||||
public class SurgeryApplyController {
|
||||
|
||||
private final SurgeryApplyService surgeryApplyService;
|
||||
|
||||
public SurgeryApplyController(SurgeryApplyService surgeryApplyService) {
|
||||
this.surgeryApplyService = surgeryApplyService;
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public ResponseEntity<?> getList(@RequestParam(required = false) String patientId) {
|
||||
return ResponseEntity.ok(surgeryApplyService.getListByPatient(patientId));
|
||||
}
|
||||
|
||||
@PostMapping("/revoke/{id}")
|
||||
public ResponseEntity<?> revoke(@PathVariable Long id) {
|
||||
surgeryApplyService.revokeApply(id);
|
||||
return ResponseEntity.ok("撤回成功");
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<?> delete(@PathVariable Long id) {
|
||||
surgeryApplyService.deleteApply(id);
|
||||
return ResponseEntity.ok("删除成功");
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<?> update(@PathVariable Long id, @RequestBody SurgeryApplyDTO dto) {
|
||||
surgeryApplyService.updateApply(id, dto);
|
||||
return ResponseEntity.ok("更新成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.openhis.application.service.impl;
|
||||
|
||||
import com.openhis.application.domain.dto.SurgeryApplyDTO;
|
||||
import com.openhis.application.domain.entity.OrderMain;
|
||||
import com.openhis.application.domain.entity.SurgeryApply;
|
||||
import com.openhis.application.exception.BusinessException;
|
||||
import com.openhis.application.mapper.OrderMainMapper;
|
||||
import com.openhis.application.mapper.SurgeryApplyMapper;
|
||||
import com.openhis.application.service.SurgeryApplyService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SurgeryApplyServiceImpl implements SurgeryApplyService {
|
||||
|
||||
private final SurgeryApplyMapper surgeryApplyMapper;
|
||||
private final OrderMainMapper orderMainMapper;
|
||||
|
||||
public SurgeryApplyServiceImpl(SurgeryApplyMapper surgeryApplyMapper, OrderMainMapper orderMainMapper) {
|
||||
this.surgeryApplyMapper = surgeryApplyMapper;
|
||||
this.orderMainMapper = orderMainMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SurgeryApply> getListByPatient(String patientId) {
|
||||
return surgeryApplyMapper.selectByPatientId(patientId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void revokeApply(Long applyId) {
|
||||
SurgeryApply apply = surgeryApplyMapper.selectById(applyId);
|
||||
if (apply == null) throw new BusinessException("手术申请单不存在");
|
||||
if (apply.getStatus() != 1) throw new BusinessException("仅已签发状态可撤回");
|
||||
|
||||
// 校验护士是否已校对 (假设 order_main.status >= 2 表示已校对/已执行)
|
||||
OrderMain relatedOrder = orderMainMapper.selectBySurgeryApplyId(applyId);
|
||||
if (relatedOrder != null && relatedOrder.getStatus() >= 2) {
|
||||
throw new BusinessException("撤回失败!该手术申请已由病区护士已校对,请致电病区护士处理。");
|
||||
}
|
||||
|
||||
// 状态回滚至 0-待签发
|
||||
apply.setStatus(0);
|
||||
surgeryApplyMapper.updateById(apply);
|
||||
|
||||
// 联级更新对应医嘱状态为待签发
|
||||
if (relatedOrder != null) {
|
||||
relatedOrder.setStatus(0);
|
||||
orderMainMapper.updateById(relatedOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteApply(Long applyId) {
|
||||
SurgeryApply apply = surgeryApplyMapper.selectById(applyId);
|
||||
if (apply == null) throw new BusinessException("手术申请单不存在");
|
||||
if (apply.getStatus() != 0) throw new BusinessException("仅待签发状态可删除");
|
||||
|
||||
// 逻辑删除/作废:状态置为 7-已作废
|
||||
apply.setStatus(7);
|
||||
surgeryApplyMapper.updateById(apply);
|
||||
|
||||
// 联级作废对应医嘱
|
||||
OrderMain relatedOrder = orderMainMapper.selectBySurgeryApplyId(applyId);
|
||||
if (relatedOrder != null) {
|
||||
relatedOrder.setStatus(7);
|
||||
orderMainMapper.updateById(relatedOrder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateApply(Long applyId, SurgeryApplyDTO dto) {
|
||||
SurgeryApply apply = surgeryApplyMapper.selectById(applyId);
|
||||
if (apply == null || apply.getStatus() != 0) {
|
||||
throw new BusinessException("仅待签发状态可编辑");
|
||||
}
|
||||
// 映射 DTO 到 Entity 并更新
|
||||
apply.setSurgeryName(dto.getSurgeryName());
|
||||
apply.setDiagnosis(dto.getDiagnosis());
|
||||
apply.setRemark(dto.getRemark());
|
||||
surgeryApplyMapper.updateById(apply);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user