|
|
@@ -7,8 +7,10 @@ import cn.tr.core.utils.JsonUtils;
|
|
|
import cn.tr.module.api.sys.tenant.SysTenantApi;
|
|
|
import cn.tr.module.api.sys.tenant.SysTenantPojo;
|
|
|
import cn.tr.module.smart.common.dto.NbPumpInfusionDTO;
|
|
|
+import cn.tr.module.smart.common.enums.FlowStatusEnum;
|
|
|
import cn.tr.module.smart.common.enums.InfusionBindType;
|
|
|
import cn.tr.module.smart.common.enums.RabbitMQConstant;
|
|
|
+import cn.tr.module.smart.common.mapper.BizDeviceAlarmMapper;
|
|
|
import cn.tr.module.smart.common.mapper.BizDeviceHistoryMapper;
|
|
|
import cn.tr.module.smart.common.mapper.BizDeviceMapper;
|
|
|
import cn.tr.module.smart.common.mapper.BizInfusionHistoryMapper;
|
|
|
@@ -23,6 +25,12 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.function.BiFunction;
|
|
|
+import java.util.function.Function;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
@@ -33,6 +41,7 @@ public class PatientMonitorListener {
|
|
|
private final BizPatientRepository patientRepository;
|
|
|
private final BizDeviceHistoryRepository deviceHistoryRepository;
|
|
|
private final BizDeviceRepository deviceRepository;
|
|
|
+ private final BizDeviceAlarmRepository deviceAlarmRepository;
|
|
|
@RabbitListener(queues = RabbitMQConstant.QUEUE_PATIENT_MONITOR)
|
|
|
@TenantIgnore
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -92,6 +101,11 @@ public class PatientMonitorListener {
|
|
|
log.debug("插入新的设备记录");
|
|
|
deviceRepository.insert(device);
|
|
|
}
|
|
|
+ //处理设备报警信息
|
|
|
+ BizDeviceAlarmPO bizDeviceAlarmPO = handleAlarmData(infusionHistory,oldInfusionHistory, deviceHistory);
|
|
|
+ if(ObjectUtil.isNotNull(bizDeviceAlarmPO)){
|
|
|
+ deviceAlarmRepository.insert(bizDeviceAlarmPO);
|
|
|
+ }
|
|
|
// 根据住院号查找患者信息
|
|
|
log.debug("开始精确查找患者信息,住院号: {}", source.getPatientCode());
|
|
|
BizPatientPO patientPO=patientRepository.selectOne(new LambdaQueryWrapper<BizPatientPO>()
|
|
|
@@ -144,4 +158,43 @@ public class PatientMonitorListener {
|
|
|
|
|
|
log.info("患者监护数据处理完成");
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 处理报警信息
|
|
|
+ * @author wangzl
|
|
|
+ * @date 2025/8/8
|
|
|
+ */
|
|
|
+ public BizDeviceAlarmPO handleAlarmData(BizInfusionHistoryPO infusionHistory, BizInfusionHistoryPO oldInfusionHistory, BizDeviceHistoryPO deviceHistory) {
|
|
|
+ //如果输入数据相同,则不处理
|
|
|
+ if(isEqual(infusionHistory, oldInfusionHistory)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ log.info("开始处理报警信息 新输注ID {} ,设备ID {}", infusionHistory.getId(), deviceHistory.getId());
|
|
|
+ BizDeviceAlarmPO alarmPO = BizDeviceAlarmMapper.INSTANCE.convertInfusionToPO(infusionHistory);
|
|
|
+ alarmPO.setDeviceType(deviceHistory.getDeviceType());
|
|
|
+ alarmPO.setDeviceId(deviceHistory.getId());
|
|
|
+ Function<BizInfusionHistoryPO, Boolean> check = o -> StrUtil.isNotBlank(o.getDeviceAlarm())
|
|
|
+ && !o.getDeviceAlarm().equals(FlowStatusEnum.None.name());
|
|
|
+ alarmPO.setAlarm(check.apply(infusionHistory));
|
|
|
+ return alarmPO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 校验输液历史记录是否相同
|
|
|
+ * @author wangzl
|
|
|
+ * @date 2025/8/8
|
|
|
+ */
|
|
|
+ public boolean isEqual(BizInfusionHistoryPO infusionHistory, BizInfusionHistoryPO oldInfusionHistory) {
|
|
|
+ if (infusionHistory == null && oldInfusionHistory == null) return true;
|
|
|
+ if (oldInfusionHistory == null || infusionHistory == null) return false;
|
|
|
+ List<BiFunction<BizInfusionHistoryPO, BizInfusionHistoryPO, Boolean>> checks = Arrays.asList(
|
|
|
+ (o, n) -> Objects.equals(o.getDeviceAlarm(), n.getDeviceAlarm()),
|
|
|
+ (o, n) -> Objects.equals(o.getWarnFlow(), n.getWarnFlow()),
|
|
|
+ (o, n) -> Objects.equals(o.getWarnAnalgesicPoor(), n.getWarnAnalgesicPoor()),
|
|
|
+ (o, n) -> Objects.equals(o.getWarnWillFinished(), n.getWarnWillFinished()),
|
|
|
+ (o, n) -> Objects.equals(o.getWarnLowBattery(), n.getWarnLowBattery())
|
|
|
+ );
|
|
|
+ return checks.stream().allMatch(check -> check.apply(oldInfusionHistory, infusionHistory));
|
|
|
+ }
|
|
|
+
|
|
|
}
|