Преглед изворни кода

add 设备处理数据过程中病人与输注绑定

18339543638 пре 3 година
родитељ
комит
8b621c1adf

+ 179 - 0
coffee-system/src/main/java/com/coffee/bus/entity/common/CommonDeviceParam.java

@@ -0,0 +1,179 @@
+package com.coffee.bus.entity.common;
+
+import com.baomidou.mybatisplus.annotation.FieldStrategy;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.coffee.bus.enums.DeviceAlarmEnum;
+import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.DeviceTypeEnum;
+import com.coffee.bus.enums.FlowStatusEnum;
+import com.coffee.common.entity.RecordCreationEntity;
+import com.coffee.common.entity.RecordModifierEntity;
+import com.coffee.common.entity.TenantGenericEntity;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import javax.validation.constraints.DecimalMax;
+import javax.validation.constraints.DecimalMin;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName BaseDeviceParam.java
+ * @Description 设备公共参数信息
+ * @createTime 2022年05月05日 20:51:00
+ */
+@Accessors(chain = true)
+@Data
+public class CommonDeviceParam  extends TenantGenericEntity<String,String>  {
+    @ApiModelProperty(value = "网络泵id",readOnly = true)
+    private String deviceId;
+
+    @ApiModelProperty(value = "数据分类号,标识某些数据属于同一个输注",readOnly = true)
+    @JsonIgnoreProperties(allowSetters = true)
+    private String classification;
+
+    @ApiModelProperty(value = "数据编号",readOnly = true)
+    @JsonIgnoreProperties(allowSetters = true)
+    private String dataNumber;
+
+    @ApiModelProperty(value = "泵类型",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.NEVER)
+    private DeviceTypeEnum type;
+
+    @ApiModelProperty(value = "住院号")
+    private String patientCode;
+
+    @ApiModelProperty(value = "病区")
+    private String ward;
+
+    @ApiModelProperty(value = "床号")
+    private String bedNo;
+
+    @ApiModelProperty(value = "总量",readOnly = true)
+    @Max(value = 999,message = "总量最大值不得超过999")
+    @Min(value = 0,message ="总量最小值不得超过0" )
+    private Integer totalDose;
+
+    @ApiModelProperty(value = "公共参数-首次量",readOnly = true)
+    @Max(value = 50,message = "首次量最大值不得超过50")
+    @Min(value = 0,message ="首次量最小值不得超过0" )
+    private Integer firstDose;
+
+
+    @ApiModelProperty(value = "公共参数-剩余量",readOnly = true)
+    private BigDecimal remainDose;
+
+    @ApiModelProperty(value = "公共参数-已输入量",readOnly = true)
+    private BigDecimal inputDose;
+
+    @ApiModelProperty(value = "公共参数-追加量",readOnly = true)
+    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
+    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal appendDose;
+
+    @ApiModelProperty(value = "公共参数-追加锁时",readOnly = true)
+    @DecimalMax(value = "99",message = "PCA追加量最大值不得超过99")
+    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal appendLockTime;
+
+    @ApiModelProperty(value = "公共参数-极限量",readOnly = true)
+    @DecimalMax(value = "90",message = "PCA追加量最大值不得超过90")
+    @DecimalMin(value = "0",message ="PCA追加量最小值不得超过0" )
+    private BigDecimal maxDose;
+
+    @ApiModelProperty(value = "公共参数-自控锁时",readOnly = true)
+    private Integer selfControlLockTime;
+
+    @ApiModelProperty(value = "公共参数-自控次数",readOnly = true)
+    private Integer selfControlCount;
+
+    @ApiModelProperty(value = "公共参数-pca有效次数",readOnly = true)
+    private Integer pcaValidCount;
+
+    @ApiModelProperty(value = "公共参数-pca无效次数",readOnly = true)
+    private Integer pcaInvalidCount;
+
+    @ApiModelProperty(value = "公共参数-pca总按次数",readOnly = true)
+    private Integer pcaTotalCount;
+
+    @ApiModelProperty(value = "持续泵参数-持续量",readOnly = true)
+    @DecimalMax(value = "50",message = "持续给液量最大值不得超过50")
+    @DecimalMin(value = "0",message ="持续给液量最小值不得超过0" )
+    private BigDecimal continueDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲量",readOnly = true)
+    @Max(value = 20,message = "脉冲量最大值不得超过20")
+    @Min(value = 0,message ="脉冲量最小值不得超过0" )
+    private Integer pulseDose;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲锁时",readOnly = true)
+    @Max(value = 90,message = "脉冲锁时最大值不得超过90")
+    @Min(value = 30,message ="脉冲锁时最小值不得超过30" )
+    private Integer pulseLockTime;
+
+    @ApiModelProperty(value = "脉冲泵参数-脉冲首次锁时",readOnly = true)
+    @Max(value = 60,message = "脉冲首次锁时最大值不得超过60")
+    @Min(value = 0,message ="脉冲首次锁时最小值不得超过0" )
+    private Integer pulseFirstLockTime;
+
+    @ApiModelProperty(value = "智能泵参数-加档周期",readOnly = true)
+    @DecimalMax(value = "10",message = "加档周期最大值不得超过10")
+    @DecimalMin(value = "0.5",message ="加档周期最小值不得超过0.5" )
+    private BigDecimal flowUpCycle;
+
+    @ApiModelProperty(value = "智能泵参数-减档周期",readOnly = true)
+    @DecimalMax(value = "10",message = "减档周期最大值不得超过10")
+    @DecimalMin(value = "0.5",message ="减档周期最小值不得超过0.5" )
+    private BigDecimal flowDownCycle;
+
+    @ApiModelProperty(value = "智能泵参数-计次",readOnly = true)
+    @DecimalMax(value = "10",message = "PCA追加量最大值不得超过10")
+    @DecimalMin(value = "1",message ="PCA追加量最小值不得超过1" )
+    private BigDecimal flowCount;
+
+    @ApiModelProperty(value = "智能泵参数-上限",readOnly = true)
+    @DecimalMax(value = "50",message = "智能泵上限值最大值不得超过90")
+    @DecimalMin(value = "1",message ="智能泵上限值最小值不得超过0" )
+    private BigDecimal flowUpLimit;
+
+    @ApiModelProperty(value = "智能泵参数-下限",readOnly = true)
+    @DecimalMax(value = "50",message = "智能泵下限值最大值不得超过50")
+    @DecimalMin(value = "0.1",message ="智能泵下限值最小值不得超过0.1" )
+    private BigDecimal flowDownLimit;
+
+    @ApiModelProperty(value = "智能泵参数-自调比例",readOnly = true)
+    @DecimalMax(value = "95",message = "自调比例不得超过95")
+    @DecimalMin(value = "0",message ="自调比例最小值不得超过0" )
+    private BigDecimal flowAdjustRate;
+
+    @ApiModelProperty(value = "公共参数-电量",readOnly = true)
+    private Integer electricQuantity;
+
+    @ApiModelProperty(value = "泵运行状态",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceStatusEnum runState;
+
+    @ApiModelProperty(value = "报警信息",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.IGNORED)
+    private DeviceAlarmEnum alarm;
+
+    @ApiModelProperty(value = "输注即将结束提醒",readOnly = true)
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒",readOnly = true)
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒",readOnly = true)
+    private Boolean warnLowBattery;
+
+    @ApiModelProperty(value = "加减档提示",readOnly = true)
+    @TableField(updateStrategy = FieldStrategy.DEFAULT)
+    private FlowStatusEnum warnFlow;
+
+}

+ 36 - 21
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -11,6 +11,7 @@ import cn.hutool.crypto.asymmetric.SignAlgorithm;
 import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.annotation.IEnum;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -209,7 +210,7 @@ public class DeviceInfoListener {
      * @param device 接收到的设备数据
      * @return 是否发生了换泵操作
      */
-    private void handlePatient(BusDeviceRunningEntity device,List<Supplier<?>> suppliers){
+    private void handlePatient(BusDeviceRunningEntity device, AtomicBoolean newInfusion,List<Supplier<?>> suppliers){
         String deviceId = device.getDeviceId();
         DeviceOperator<DeviceCacheInfo> currentDeviceOperator = deviceRegistry.getOperator(deviceId);
         PatientOperator<PatientCacheInfo> currentPatientOperator = patientRegistry.getOperator(device.getTenantId(), device.getPatientCode());
@@ -222,8 +223,15 @@ public class DeviceInfoListener {
             log.error("病号:【{}】临床发生由无泵转为有泵",device.getPatientCode());
             patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
                     .eq(BusPatientEntity::getTenantId,device.getTenantId())
+                    .set(newInfusion.get(),BusPatientEntity::getInfusionId,device.getInfusionId())
                     .set(BusPatientEntity::getAlarm, null)
             );
+        }else {
+            if(newInfusion.get()){
+                patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,device.getPatientCode())
+                        .eq(BusPatientEntity::getTenantId,device.getTenantId())
+                        .set(newInfusion.get(),BusPatientEntity::getInfusionId,device.getInfusionId()));
+            }
         }
         //更新泵所绑定当前病人缓存信息
         suppliers.add(()->{
@@ -255,6 +263,7 @@ public class DeviceInfoListener {
                 log.error("病号:【{}】临床发生无泵报警",patientCode);
                 patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
                         .eq(BusPatientEntity::getTenantId,hospitalId)
+                        .set(BusPatientEntity::getInfusionId,null)
                         .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
                 );
                 suppliers.add(()->{
@@ -269,25 +278,31 @@ public class DeviceInfoListener {
                         o1.getStartTime().equals(o2.getStartTime())?0:o1.getStartTime().before(o2.getStartTime()) ? -1 : 1
 
                 );
+                UpdateWrapper<BusPatientEntity> update = new UpdateWrapper<>();
                 if(master.isPresent()){
                     log.error("病号:[{}],主泵变为[{}]",patientCode,master.get().getDeviceId());
                     deviceUsingService
                             .update(new UpdateWrapper<BusDeviceRunningEntity>().lambda()
                                     .eq(BusDeviceRunningEntity::getDeviceId,master.get().getDeviceId())
                                     .set(BusDeviceRunningEntity::getMaster,true));
+                    DeviceOperator<DeviceCacheInfo> operator = deviceRegistry.getOperator(master.get().getDeviceId());
+                    //更换输注信息
+                    update.lambda().eq(BusPatientEntity::getCode, patientCode)
+                            .eq(BusPatientEntity::getTenantId, hospitalId)
+                            .set(BusPatientEntity::getInfusionId, operator.getInfusionId());
                     suppliers.add(()->{
                         patientOperator.setBindDeviceId(master.get().getDeviceId());
                         patientOperator.setAllDevice(remainPatientBindDevices);
                         return null;
                     });
+                    if(remainPatientBindDevices.size()==1){
+                        //泵重复—>正常
+                        update.lambda()
+                                .set(BusPatientEntity::getAlarm, null);
+                    }
+                    patientService.update(update);
                 }
-                if(remainPatientBindDevices.size()==1){
-                    //泵重复—>正常
-                    patientService.update(new UpdateWrapper<BusPatientEntity>().lambda().eq(BusPatientEntity::getCode,patientCode)
-                            .eq(BusPatientEntity::getTenantId,hospitalId)
-                            .set(BusPatientEntity::getAlarm, null)
-                    );
-                }
+
             }
         }else {
             suppliers.add(()->{
@@ -376,7 +391,7 @@ public class DeviceInfoListener {
             if(Boolean.TRUE.equals(patientOperator.getFinished())){
                 //若临床已结束,则只有新的输注能够进行泵冲突处理
                 if(newInfusion.get()){
-                    handlePatient(device,cacheOperation);
+                    handlePatient(device,newInfusion,cacheOperation);
                     clinicService
                             .update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,patientOperator.getClinicId())
                                     .set(BusClinicEntity::getFinished,false));
@@ -387,7 +402,7 @@ public class DeviceInfoListener {
                     });
                 }
             }else {
-                handlePatient(device,cacheOperation);
+                handlePatient(device,newInfusion,cacheOperation);
             }
             //todo 输注参数发生变化
             cacheOperation.add(()->{
@@ -619,17 +634,17 @@ public class DeviceInfoListener {
         String now = DateUtil.yesterday().toString();
 
 
-        BusClinicEntity clinic = new BusClinicEntity();
-        clinic.setPatientCode("456");
-        clinic.setName("临床:"+ now);
-        clinic.setPatientName("病号:"+now);
-        clinic.setPatientGender(SexEnum.MAN);
-        clinic.setPatientAge(12);
-        clinic.setWard("病区:"+now);
-        clinic.setBedNo("床号:"+now);
-        clinic.setTenantId("1505808170691784706");
-        clinic.setStartTime(DateUtil.date(1651116958000L));
-        SpringUtil.publishEvent(new HisEvent(this,Arrays.asList(clinic),clinic.getTenantId()));
+//        BusClinicEntity clinic = new BusClinicEntity();
+//        clinic.setPatientCode("456");
+//        clinic.setName("临床:"+ now);
+//        clinic.setPatientName("病号:"+now);
+//        clinic.setPatientGender(SexEnum.MAN);
+//        clinic.setPatientAge(12);
+//        clinic.setWard("病区:"+now);
+//        clinic.setBedNo("床号:"+now);
+//        clinic.setTenantId("1505808170691784706");
+//        clinic.setStartTime(DateUtil.date(1651116958000L));
+//        SpringUtil.publishEvent(new HisEvent(this,Arrays.asList(clinic),clinic.getTenantId()));
 
     }