|
|
@@ -1,5 +1,6 @@
|
|
|
package com.coffee.bus.websocket.listener;
|
|
|
|
|
|
+import cn.hutool.core.comparator.CompareUtil;
|
|
|
import cn.hutool.core.map.MapUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
@@ -8,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.coffee.bus.entity.*;
|
|
|
+import com.coffee.bus.enums.DeviceTypeEnum;
|
|
|
+import com.coffee.bus.enums.FlowStatusEnum;
|
|
|
import com.coffee.bus.enums.PatientAlarmEnum;
|
|
|
import com.coffee.bus.hospital.HospitalManagerRegister;
|
|
|
import com.coffee.bus.registry.device.DeviceRegistry;
|
|
|
@@ -23,6 +26,7 @@ import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
@@ -95,6 +99,7 @@ public class DeviceInfoListener {
|
|
|
List<Supplier<?>> cacheOperation=new ArrayList<>();
|
|
|
//格式化病号
|
|
|
formatPatientCode(device);
|
|
|
+
|
|
|
//处理输注参数
|
|
|
BusInfusionHistoryEntity infusionHistory = handleInfusionHistory(device, deviceOperator, cacheOperation);
|
|
|
//处理输注修改参数
|
|
|
@@ -113,15 +118,12 @@ public class DeviceInfoListener {
|
|
|
.set(BusDeviceEntity::getType,device.getType())
|
|
|
);
|
|
|
infusionHistoryService.save(infusionHistory);
|
|
|
- patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()
|
|
|
- .eq(BusPatientEntity::getId,device.getPatientId())
|
|
|
- .set(BusPatientEntity::getCode,device.getFormatPatientCode()));
|
|
|
}else {
|
|
|
infusionHistoryService.updateById(infusionHistory);
|
|
|
}
|
|
|
|
|
|
cacheOperation.add(()->{
|
|
|
- wsPublishUtils.publishPatientMonitor(device.getPatientCode(),device.getTenantId());
|
|
|
+ wsPublishUtils.publishPatientMonitor(device.getPatientId(),device.getTenantId());
|
|
|
if (Boolean.TRUE.equals(device.isResetUndo())||Boolean.TRUE.equals(device.isInfusionModify())) {
|
|
|
if (Boolean.TRUE.equals(device.isInfusionModify())) {
|
|
|
wsPublishUtils.publishDeviceNone(device.getTenantId());
|
|
|
@@ -150,6 +152,37 @@ public class DeviceInfoListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 是否存在加档受限、存在则跳过判定,不存在则判定加减档标识
|
|
|
+ * 1、新输注则忽略
|
|
|
+ * 2、与上次流速进行比较,降低为减档,增加为加档
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/6/30 9:53
|
|
|
+ * @param device
|
|
|
+ * @param deviceOperator
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ private void handleIntelligent(BusDeviceRunningEntity device, DeviceOperator deviceOperator) {
|
|
|
+ if(DeviceTypeEnum.intelligent.equals(device.getType())
|
|
|
+ &&null!=device.getWarnFlow()
|
|
|
+ && Boolean.FALSE.equals(device.isNewInfusion())){
|
|
|
+ BigDecimal lastContinueDose = deviceOperator.getContinueDose();
|
|
|
+ if(lastContinueDose==null){
|
|
|
+ log.warn("设备【{}】流速在缓存中不存在",device.getContinueDose());
|
|
|
+ }else {
|
|
|
+ if(CompareUtil.compare(device.getContinueDose(),lastContinueDose)>0){
|
|
|
+ device.setWarnFlow(FlowStatusEnum.Up);
|
|
|
+ }else if(CompareUtil.compare(device.getContinueDose(),lastContinueDose)<0){
|
|
|
+ device.setWarnFlow(FlowStatusEnum.Down);
|
|
|
+ }else {
|
|
|
+ device.setWarnFlow(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
private void init(BusDeviceRunningEntity device) {
|
|
|
String deviceId = device.getDeviceId();
|
|
|
//默认格式化住院号=设备上传住院号
|
|
|
@@ -184,28 +217,35 @@ public class DeviceInfoListener {
|
|
|
long runningInfusionCount = infusionHistoryService.count(new QueryWrapper<BusInfusionHistoryEntity>().lambda()
|
|
|
.eq(BusInfusionHistoryEntity::getFinished, false)
|
|
|
.eq(BusInfusionHistoryEntity::getIsUndo,false)
|
|
|
- .eq(BusInfusionHistoryEntity::getPatientCode, device.getPatientCode())
|
|
|
- .eq(BusInfusionHistoryEntity::getTenantId, device.getTenantId()));
|
|
|
+ .eq(BusInfusionHistoryEntity::getPatientId, device.getPatientId()));
|
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
.lambda()
|
|
|
- .eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
- .eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
- //已撤泵重启的输注不再作为主泵进行判定
|
|
|
- .set(Boolean.FALSE.equals(device.isResetUndo()),BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
+ .eq(BusPatientEntity::getId,device.getPatientId())
|
|
|
+ //已撤泵且修改参数的输注不再作为主泵进行判定
|
|
|
+ .set(device.isNewInfusion(),BusPatientEntity::getInfusionId,device.getInfusionId())
|
|
|
+ .set(device.isNewInfusion(),BusPatientEntity::getOriginCode,device.getPatientCode())
|
|
|
+ .set(device.isNewInfusion(),BusPatientEntity::getCode,device.getFormatPatientCode())
|
|
|
.set(runningInfusionCount>0,BusPatientEntity::getAlarm,PatientAlarmEnum.DEVICE_REPEAT)
|
|
|
.set(runningInfusionCount==0,BusPatientEntity::getAlarm,PatientAlarmEnum.NONE));
|
|
|
if(device.isNewInfusion()){
|
|
|
BusInfusionHistoryEntity lastInfusion = infusionHistoryService.lastInfusion(deviceId);
|
|
|
- if(lastInfusion!=null&&ObjectUtil.notEqual(device.getPatientCode(),lastInfusion.getPatientCode())){
|
|
|
+ if(lastInfusion!=null&&ObjectUtil.notEqual(device.getPatientId(),lastInfusion.getPatientId())){
|
|
|
//输注设备被占用
|
|
|
BusInfusionHistoryEntity normalInfusion = infusionHistoryService.deviceOccupation(lastInfusion);
|
|
|
+ if(log.isDebugEnabled()){
|
|
|
+ log.debug("住院号【{}】输注设备被占用,最后一条输注信息为【{}】",lastInfusion.getPatientCode(),JSONUtil.toJsonStr(lastInfusion));
|
|
|
+ }
|
|
|
if(normalInfusion!=null){
|
|
|
String patientId = lastInfusion.getPatientId();
|
|
|
BusPatientEntity lastPatient = patientService.getById(patientId);
|
|
|
+ if(log.isDebugEnabled()){
|
|
|
+ log.debug("住院号病人信息,【{}】,输注设备被占用,切换设备",JSONUtil.toJsonStr(lastPatient));
|
|
|
+ }
|
|
|
patientRegistry
|
|
|
- .getOperator(lastInfusion.getTenantId(),lastPatient.getOriginCode()).setBindDeviceId(normalInfusion.getDeviceId());
|
|
|
+ .getOperator(lastInfusion.getTenantId(),lastPatient.getOriginCode())
|
|
|
+ .setBindDeviceId(normalInfusion.getDeviceId());
|
|
|
suppliers.add(()->{
|
|
|
- wsPublishUtils.publishPatientMonitor(lastInfusion.getPatientCode(),lastInfusion.getTenantId());
|
|
|
+ wsPublishUtils.publishPatientMonitor(lastInfusion.getPatientId(),lastInfusion.getTenantId());
|
|
|
return null;
|
|
|
});
|
|
|
}
|
|
|
@@ -223,8 +263,7 @@ public class DeviceInfoListener {
|
|
|
}else if(!clinicFinished){
|
|
|
//临床未结束,切换当前输注信息为主输注
|
|
|
patientService.update(new UpdateWrapper<BusPatientEntity>().lambda()
|
|
|
- .eq(BusPatientEntity::getCode,device.getPatientCode())
|
|
|
- .eq(BusPatientEntity::getTenantId,device.getTenantId())
|
|
|
+ .eq(BusPatientEntity::getId,device.getPatientId())
|
|
|
.set(BusPatientEntity::getInfusionId,device.getInfusionId()));
|
|
|
device.setMaster(true);
|
|
|
suppliers.add(()->{
|
|
|
@@ -250,7 +289,8 @@ public class DeviceInfoListener {
|
|
|
PatientOperator patientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode(),MapUtil.of("startTime", device.getStartTime()));
|
|
|
device.setClinicId(patientOperator.getClinicId());
|
|
|
device.setPatientId(patientOperator.getPatientId());
|
|
|
-
|
|
|
+ //智能泵处理
|
|
|
+ handleIntelligent(device,deviceOperator);
|
|
|
BusInfusionHistoryEntity infusionHistory = BusInfusionHistoryEntity.parseRunningInfo(device);
|
|
|
String originInfusionId = deviceOperator.getInfusionId();
|
|
|
if(ObjectUtil.equal(device.getDeviceId(),patientOperator.getBindDeviceId())){
|
|
|
@@ -281,6 +321,7 @@ public class DeviceInfoListener {
|
|
|
deviceOperator.setClassification(device.getClassification());
|
|
|
deviceOperator.setStartTime(infusionHistory.getStartTime());
|
|
|
deviceOperator.setTenantId(device.getTenantId());
|
|
|
+ deviceOperator.setContinueDose(device.getContinueDose());
|
|
|
}
|
|
|
return null;
|
|
|
});
|