Ver código fonte

fix 修改监控输注查询

18339543638 3 anos atrás
pai
commit
843aa381b3

+ 4 - 1
coffee-common/src/main/java/com/coffee/common/crud/BaseService.java

@@ -199,7 +199,10 @@ public abstract class BaseService<M extends BaseMapper<E>, E,PK extends Serializ
     @Override
     public boolean updateBatchById(Collection<E> entityList) {
         entityList.forEach(this::validateBeforeUpdate);
-        entityList.forEach(this::postUpdate);
+        if (super.updateBatchById(entityList)) {
+            entityList.forEach(this::postUpdate);
+            return  true;
+        }
         return false;
     }
 

+ 6 - 8
coffee-system/src/main/java/com/coffee/bus/entity/BusClinicEntity.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
 import com.coffee.bus.bean.HisInfo;
 import com.coffee.common.entity.TenantGenericEntity;
 import com.coffee.common.enums.SexEnum;
@@ -85,21 +86,18 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
     @Length(max = 255,message = "手术医生不得超过255个字节")
     private String surgeryDoctor;
 
-    @ApiModelProperty(value = "手术名称")
-    @Length(max = 255,message = "手术名称不得超过255个字节")
-    private String surgeryName;
-
     @ApiModelProperty(value = "配置人员")
     private String configPerson;
 
     @ApiModelProperty(value = "配方")
-    private String formula;
+    @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
+    private List<FormulaDrugDomain> formula;
 
     @ApiModelProperty(value = "临床是否结束,0、未结束 1、结束 ")
     private Boolean finished;
 
     @ApiModelProperty(value = "临床使用过的设备号")
-    @TableField(typeHandler = FastjsonTypeHandler.class)
+    @TableField(typeHandler = FastjsonTypeHandler.class,javaType = true)
     private Set<String> deviceCodes;
 
     @TableField(fill = FieldFill.INSERT)
@@ -108,7 +106,7 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
 
     //todo
     @ApiModelProperty(value = "监护类型,1、有泵监护 0、无泵监护")
-    @JsonIgnoreProperties
+    @JsonIgnoreProperties(allowGetters = true)
     private Boolean monitorType;
 
     public static BusClinicEntity of(HisInfo hisInfo){
@@ -128,7 +126,7 @@ public class BusClinicEntity extends TenantGenericEntity<String,String> {
         clinic.setStartTime(hisInfo.getOperationTime());
         //asa分级 todo
         //easymode todo
-        clinic.setFormula(hisInfo.getFormula());
+//        clinic.setFormula(hisInfo.getFormula());
         clinic.setConfigPerson(hisInfo.getConfigPerson());
         return clinic;
     }

+ 1 - 6
coffee-system/src/main/java/com/coffee/bus/entity/BusDeviceRunningEntity.java

@@ -18,13 +18,7 @@ import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.ToString;
 import lombok.experimental.Accessors;
-import org.apache.ibatis.type.EnumTypeHandler;
-import org.apache.ibatis.type.EnumTypeHandler;
 
-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;
 
@@ -106,6 +100,7 @@ public class BusDeviceRunningEntity extends CommonDeviceParam<String,String> {
         this.setBedNo(items.getString(PumpParams.bedNo));
         this.setTotalDose( items.getInteger(PumpParams.totalDose));
         this.setInputDose(items.getBigDecimal(PumpParams.finishedDose));
+        this.setRemainDose(BigDecimal.valueOf(this.getTotalDose()).subtract(this.getInputDose()));
         this.setFirstDose( items.getInteger(PumpParams.firstDosis));
         this.setMaxDose(items.getBigDecimal(PumpParams.maxDose));
         this.setAppendDose(items.getBigDecimal(PumpParams.singleDosis));

+ 0 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusHospitalEntity.java

@@ -3,7 +3,6 @@ package com.coffee.bus.entity;
 import com.baomidou.mybatisplus.annotation.*;
 import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
 import com.coffee.bus.bean.Script;
-import com.coffee.common.config.mybatis.DateToBigIntHandler;
 import com.coffee.common.entity.RecordCreationEntity;
 import com.coffee.common.entity.RecordModifierEntity;
 import io.swagger.annotations.ApiModel;

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/entity/BusPatientEntity.java

@@ -75,7 +75,7 @@ public class BusPatientEntity extends TenantGenericEntity<String,String> {
     public static BusPatientEntity of(BusClinicEntity clinic){
         BusPatientEntity patient = new BusPatientEntity();
         patient.setCode(clinic.getPatientCode());
-        patient.setName(clinic.getName());
+        patient.setName(clinic.getPatientName());
         patient.setGender(clinic.getPatientGender());
         patient.setClinicId(clinic.getId());
         patient.setTmpFinished(clinic.getFinished());

+ 73 - 13
coffee-system/src/main/java/com/coffee/bus/entity/PatientMonitorDomain.java

@@ -1,9 +1,12 @@
 package com.coffee.bus.entity;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.FieldStrategy;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.coffee.bus.enums.*;
 import com.coffee.common.enums.SexEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -53,10 +56,6 @@ public class PatientMonitorDomain {
     @ApiModelProperty(value = "公共参数-首次量")
     private Integer firstDose;
 
-    @ApiModelProperty(value = "加减档提示",readOnly = true)
-    @TableField(updateStrategy = FieldStrategy.DEFAULT)
-    private FlowStatusEnum warnFlow;
-
     @ApiModelProperty(value = "公共参数-电量",readOnly = true)
     private Integer electricQuantity;
 
@@ -127,15 +126,6 @@ public class PatientMonitorDomain {
     @ApiModelProperty(value = "报警信息")
     private DeviceAlarmEnum deviceAlarm;
 
-    @ApiModelProperty(value = "输注即将结束提醒")
-    private Boolean warnWillFinished;
-
-    @ApiModelProperty(value = "镇痛不足提醒")
-    private Boolean warnAnalgesicPoor;
-
-    @ApiModelProperty(value = "电量偏低提醒")
-    private Boolean warnLowBattery;
-
     @ApiModelProperty(value = "输注开始时间,即本次运行开机时间")
     private Date infusionStartTime;
 
@@ -169,4 +159,74 @@ public class PatientMonitorDomain {
 
     @ApiModelProperty("当前病人监护开始时间")
     private Date monitorStartTime;
+
+    @ApiModelProperty(value = "输注即将结束提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnWillFinished;
+
+    @ApiModelProperty(value = "镇痛不足提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnAnalgesicPoor;
+
+    @ApiModelProperty(value = "电量偏低提醒",hidden = true)
+    @JsonIgnore
+    private Boolean warnLowBattery;
+
+    @ApiModelProperty(value = "加减档提示",readOnly = true)
+    @JsonIgnore
+    private FlowStatusEnum warnFlow;
+
+    @ApiModelProperty("提醒字段")
+    private String warns;
+
+    private void judgeWarnWillFinished() {
+        if(!Boolean.TRUE.equals(this.warnWillFinished)){
+           return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="输注即将结束;";
+        }else {
+            this.warns=this.warns+"输注即将结束;";
+        }
+    }
+
+    private void judgeWarnAnalgesicPoor() {
+        if(!Boolean.TRUE.equals(this.warnAnalgesicPoor)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="镇痛不足;";
+        }else {
+            this.warns=this.warns+"镇痛不足;";
+        }
+    }
+
+    private void judgeWarnLowBattery() {
+        if(!Boolean.TRUE.equals(this.warnLowBattery)){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns="电量偏低;";
+        }else {
+            this.warns=this.warns+"电量偏低;";
+        }
+    }
+
+    private void judgeWarnFlow() {
+        if(this.warnFlow==null){
+            return;
+        }
+        if (StrUtil.isEmpty(this.warns)) {
+            this.warns=warnFlow.getText()+";";
+        }else {
+            this.warns=this.warns+warnFlow.getText()+";";
+        }
+    }
+
+    public void handleWarn(){
+        judgeWarnAnalgesicPoor();
+        judgeWarnFlow();
+        judgeWarnLowBattery();
+        judgeWarnWillFinished();
+    }
 }

+ 1 - 1
coffee-system/src/main/java/com/coffee/bus/enums/DeviceTypeEnum.java

@@ -17,7 +17,7 @@ import lombok.Getter;
 @JsonFormat(shape = JsonFormat.Shape.OBJECT)
 public enum DeviceTypeEnum implements IEnum<Integer> {
     no(0,"无泵"),
-    continuous(1,"持续型网络泵"),
+    continuous(1,"网络泵"),
     intelligent(2,"智能泵"),
     pulse(3,"脉冲泵"),
     other(4,"其他泵");

+ 32 - 0
coffee-system/src/main/java/com/coffee/bus/enums/WarnEnum.java

@@ -0,0 +1,32 @@
+package com.coffee.bus.enums;
+
+import com.baomidou.mybatisplus.annotation.IEnum;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author lifang
+ * @version 1.0.0
+ * @ClassName WarnEnum.java
+ * @Description TODO
+ * @createTime 2022年05月06日 16:53:00
+ */
+@Getter
+@AllArgsConstructor
+public enum  WarnEnum  implements IEnum<Integer> {
+    /**
+     * @see FlowStatusEnum 与该类保持一致
+     */
+    flowNone(0),
+    flowLimited(1),
+    flowMax(2),
+    flowUp(3),
+    flowDown(4),
+    flowLowest(5),
+
+    willFinished(6),
+    analPoor(7),
+    lowBattery(8),;
+
+    private Integer value;
+}

+ 2 - 1
coffee-system/src/main/java/com/coffee/bus/registry/patient/ClusterPatientRegistry.java

@@ -54,7 +54,8 @@ public class ClusterPatientRegistry implements PatientRegistry {
                 insert=true;
                 patient=new BusPatientEntity();
                 patient.setCode(patientCode);
-                patient.setClinicId("-1");
+                //默认为空字符串
+                patient.setClinicId("");
                 patient.setTenantId(hospitalId);
             }
             patientOperator.setCode(patientCode);

+ 8 - 2
coffee-system/src/main/java/com/coffee/bus/service/LocalBusPatientService.java

@@ -1,5 +1,6 @@
 package com.coffee.bus.service;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -46,6 +47,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     @Autowired
     @Lazy
     private PatientRegistry patientRegistry;
+
     @Override
     public void validateBeforeSave(BusPatientEntity entity) {
 
@@ -118,6 +120,9 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     public List<PatientMonitorDomain> selectAll(PatientMonitorQuery query) {
         Page<PatientMonitorDomain> page = new Page<>(0, 500, false);
         IPage<PatientMonitorDomain> result = this.baseMapper.selectMonitor(page,query);
+        if(CollectionUtil.isNotEmpty(result.getRecords())){
+            result.getRecords().forEach(PatientMonitorDomain::handleWarn);
+        }
         return result.getRecords();
     }
 
@@ -142,12 +147,13 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
     }
 
     /**
-     * 病人手动更新当前监控的临床信息
+     *
+     * 病人手动更新当前监控的临床信息 todo
      * @param clinic
      */
     @Transactional(rollbackFor = Exception.class)
     public void manualEdit(BusClinicEntity clinic) {
-        //先更新手术信息
+        //先更新手术信息 todo
         clinicService.saveOrUpdate(clinic);
         //后更新病人信息
         BusPatientEntity patient = BusPatientEntity.of(clinic);

+ 42 - 3
coffee-system/src/main/java/com/coffee/bus/service/dto/PatientMonitorQuery.java

@@ -1,11 +1,16 @@
 package com.coffee.bus.service.dto;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.coffee.bus.enums.DeviceAlarmEnum;
 import com.coffee.bus.enums.DeviceTypeEnum;
 import com.coffee.bus.enums.DeviceStatusEnum;
+import com.coffee.bus.enums.WarnEnum;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+
 import java.util.*;
 /**
  * @author lifang
@@ -41,12 +46,46 @@ public class PatientMonitorQuery {
     @ApiModelProperty("设备输注最后报警状态")
     private List<Integer> deviceAlarms;
 
-    @ApiModelProperty("设备输注最后即将结束警告")
+    @ApiModelProperty(value = "设备输注最后即将结束警告",hidden = true)
+    @JsonIgnore
     private boolean warnWillFinished;
 
-    @ApiModelProperty("设备输注最后镇痛不足警告")
+    @ApiModelProperty(value = "设备输注最后镇痛不足警告",hidden = true)
+    @JsonIgnore
     private boolean warnAnalgesicPoor;
 
-    @ApiModelProperty("设备输注最后低电量警告")
+    @ApiModelProperty(value = "设备输注最后低电量警告",hidden = true)
+    @JsonIgnore
     private boolean warnLowBattery;
+
+    @ApiModelProperty(value = "智能泵加减档警告",hidden = true)
+    private List<Integer> warnFlow;
+
+    /**
+     * 根据此提醒进行解析
+     * @see  com.coffee.bus.enums.WarnEnum
+     */
+    @ApiModelProperty(value = "提醒【0、智能泵-正常; 1、智能泵-加档受限; 2、智能泵-流速已达上限; 3、智能泵-加档; 4、智能泵-减档; 5、智能泵-低输注状态; 6、输注即将结束;7、镇痛不足;8、低电量】 ")
+    private List<WarnEnum> warns;
+
+    @ApiModelProperty("查询时间区间")
+    private List<Date> timeRange;
+
+    public void setWarns(List<WarnEnum> warns) {
+        this.warns = warns;
+        if(CollectionUtil.isNotEmpty(warns)){
+            warns.forEach(warn->{
+                if(warn==WarnEnum.analPoor){
+                    this.warnAnalgesicPoor=true;
+                }else if(warn==WarnEnum.willFinished){
+                    this.warnWillFinished=true;
+                }else if(warn==WarnEnum.lowBattery){
+                    this.warnLowBattery=true;
+                }else {
+                    this.warnFlow=Optional.ofNullable(warnFlow).orElse(new ArrayList<>());
+                    this.warnFlow.add(warn.getValue());
+                }
+            });
+        }
+    }
 }

+ 6 - 3
coffee-system/src/main/java/com/coffee/bus/websocket/listener/DeviceInfoListener.java

@@ -258,9 +258,9 @@ public class DeviceInfoListener {
             if(CollectionUtil.isEmpty(remainPatientBindDevices)){
                 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)
+                                .eq(BusPatientEntity::getTenantId,hospitalId)
+//                        .set(BusPatientEntity::getInfusionId,null)
+                                .set(BusPatientEntity::getAlarm, PatientAlarmEnum.DEVICE_NONE)
                 );
                 suppliers.add(()->{
                     //todo 发起无泵报警,处理原先泵的无泵信息
@@ -373,6 +373,9 @@ public class DeviceInfoListener {
      * @param cacheOperation 缓存操作
      */
     private void handleInfusion(BusDeviceRunningEntity device, DeviceOperator<DeviceCacheInfo> deviceOperator, AtomicBoolean newInfusion, List<Supplier<?>> cacheOperation) {
+        PatientOperator<PatientCacheInfo> operator = patientRegistry.getOperator(device.getPatientCode(), device.getTenantId());
+        device.setClinicId(operator.getClinicId());
+
         handleInfusionHistory(device,deviceOperator,newInfusion,cacheOperation);
         BusInfusionModifyEntity busInfusionModify = BusInfusionModifyEntity.parseRunningInfo(device);
         String signHex = busInfusionModify.signParam(sign);

+ 42 - 12
coffee-system/src/main/resources/mapper/bus/BusPatientMapper.xml

@@ -201,18 +201,45 @@
                     #{type, jdbcType=VARCHAR}
                 </foreach>
             </if>
-            <if test="query.deviceStatus != null and query.deviceStatus.size > 0">
-                and run_state in
-                <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator="," close=")">
-                    #{status, jdbcType=VARCHAR}
-                </foreach>
-            </if>
-            <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
-                or alarm in
-                <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
-                    #{alarm, jdbcType=VARCHAR}
-                </foreach>
-            </if>
+
+            <choose>
+                <when test="query.deviceStatus != null and query.deviceStatus.size > 0">
+                    and (
+                    run_state in
+                    <foreach item="status" index="index" collection="query.deviceStatus" open="(" separator=","
+                             close=")">
+                        #{status, jdbcType=VARCHAR}
+                    </foreach>
+                    <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
+                        or alarm in
+                        <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator=","
+                                 close=")">
+                            #{alarm, jdbcType=VARCHAR}
+                        </foreach>
+                    </if>
+                    )
+                </when>
+                <otherwise>
+                    <if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">
+                        and alarm in
+                        <foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">
+                            #{alarm, jdbcType=VARCHAR}
+                        </foreach>
+                    </if>
+                </otherwise>
+            </choose>
+            <!--<if test="query.deviceStatus != null and query.deviceStatus.size > 0">-->
+            <!--and run_state in-->
+            <!--<foreach item="status" index="index" collection="query.deviceStatus" open="(" separator="," close=")">-->
+            <!--#{status, jdbcType=VARCHAR}-->
+            <!--</foreach>-->
+            <!--</if>-->
+            <!--<if test="query.deviceAlarms != null and query.deviceAlarms.size > 0">-->
+            <!--or alarm in-->
+            <!--<foreach item="alarm" index="index" collection="query.deviceAlarms" open="(" separator="," close=")">-->
+            <!--#{alarm, jdbcType=VARCHAR}-->
+            <!--</foreach>-->
+            <!--</if>-->
             <if test="query.warnWillFinished != false or query.warnAnalgesicPoor != false or  query.warnLowBattery != false">
                 and (
                 <choose>
@@ -223,6 +250,9 @@
                 <if test="query.warnLowBattery != false"> or warn_low_battery=1 </if>
                 )
             </if>
+            <if test="query.warnFlow !=null">
+                and warn_flow= #{query.warnFlow}
+            </if>
         </where>
         ) as i on p.infusion_id=i.id
         left join bus_clinic c on i.clinic_id=c.id