Jelajahi Sumber

运行病历评分时生成对应的患者类型

songxinlu 3 tahun lalu
induk
melakukan
d55e2c5f4b

+ 23 - 35
src/main/java/com/diagbot/aop/RunBehospitalInfoTypeAspect.java

@@ -2,16 +2,11 @@ package com.diagbot.aop;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.diagbot.entity.MedNewsNotice;
-import com.diagbot.entity.SysUser;
-import com.diagbot.enums.IsDeleteEnum;
-import com.diagbot.enums.NewsNoticeTypeEnum;
-import com.diagbot.facade.MedNewsNoticeFacade;
-import com.diagbot.facade.SysUserFacade;
-import com.diagbot.util.DateUtil;
+import com.diagbot.entity.SysTaskCron;
+import com.diagbot.facade.MedCheckWorkFacade;
+import com.diagbot.facade.SysTaskCronFacade;
 import com.diagbot.util.HttpUtils;
 import com.diagbot.util.StringUtil;
-import com.diagbot.util.SysUserUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.aspectj.lang.JoinPoint;
@@ -33,12 +28,13 @@ import java.util.Map;
 @Component
 public class RunBehospitalInfoTypeAspect {
     @Autowired
-    private MedNewsNoticeFacade medNewsNoticeFacade;
+    private MedCheckWorkFacade medCheckWorkFacade;
     @Autowired
-    private SysUserFacade sysUserFacade;
+    private SysTaskCronFacade sysTaskCronFacade;
 
-    // 操作配置织入点
-    @Pointcut("execution(public * com.diagbot.web.BehospitalInfoController.analyzeApi(..))"+
+    // 操作配置织入点 analyze_rpc
+    @Pointcut("execution(public * com.diagbot.web.BehospitalInfoController.analyzeApi(..))" +
+            "||execution(public * com.diagbot.web.BehospitalInfoController.analyze_rpc(..))" +
             "||execution(public * com.diagbot.web.BehospitalInfoController.analyzeRun(..))")
     public void makeTypePointCut() {
     }
@@ -56,8 +52,8 @@ public class RunBehospitalInfoTypeAspect {
             //获取请求入参
             String params = getRequestParams(joinPoint);
             if (StringUtils.isNotBlank(params)) {
-                //存储消息通知
-                saveNewsNotice(params);
+                //生成患者类型
+                makeType(params);
             }
         } catch (Exception e) {
             e.printStackTrace();
@@ -70,32 +66,24 @@ public class RunBehospitalInfoTypeAspect {
      * @param params
      * @Return void
      */
-    private void saveNewsNotice(String params) {
+    private void makeType(String params) {
         //参数处理
-        MedNewsNotice newsNotice = paramHandler(params);
-        if (newsNotice != null) {
-            medNewsNoticeFacade.save(newsNotice);
-        }
-    }
-
-    /**
-     * 参数处理
-     *
-     * @param params
-     * @Return java.lang.String
-     */
-    private MedNewsNotice paramHandler(String params) {
         if (StringUtil.isNotEmpty(params) && "{".equals(params.substring(0, 1))) {
             JSONObject paramJSON = JSONObject.parseObject(params);
-            if (paramJSON.getJSONArray("behospitalCodes") == null
-                    || StringUtil.isBlank(paramJSON.getString("checkId"))
-                    || StringUtil.isBlank(paramJSON.getString("distributionType"))
-                    || StringUtil.isBlank(paramJSON.getString("checkName"))) {
-                return null;
+            if (StringUtil.isBlank(paramJSON.getString("behospitalCode"))) {
+                return;
+            }
+            SysTaskCron task = sysTaskCronFacade.getOne(new QueryWrapper<SysTaskCron>()
+                    .eq("cron_code", "TASK019"), false);
+            //2.执行定时任务
+            if (null != task && StringUtil.isNotBlank(task.getCron())) {
+                try {
+                    medCheckWorkFacade.execute(task.getParam(), paramJSON.getString("behospitalCode"));
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
             }
-            //获取分配者用户名
         }
-        return null;
     }
 
 

+ 72 - 14
src/main/java/com/diagbot/facade/MedCheckWorkFacade.java

@@ -2,13 +2,16 @@ package com.diagbot.facade;
 
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BasDeptInfoDTO;
 import com.diagbot.dto.BehospitalInfoAgeDTO;
 import com.diagbot.dto.CheckWorkDTO;
 import com.diagbot.dto.MedicalRecordDTO;
+import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.entity.MedBehospitalType;
 import com.diagbot.entity.MedCheckInfo;
+import com.diagbot.entity.MedicalRecord;
 import com.diagbot.entity.SysTaskCron;
 import com.diagbot.entity.SysUser;
 import com.diagbot.enums.CheckJobTypeEnum;
@@ -18,6 +21,7 @@ import com.diagbot.exception.CommonException;
 import com.diagbot.service.impl.MedBehospitalTypeServiceImpl;
 import com.diagbot.service.impl.MedCheckInfoServiceImpl;
 import com.diagbot.service.impl.MedicalRecordServiceImpl;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.StringUtil;
@@ -180,6 +184,56 @@ public class MedCheckWorkFacade {
         }
     }
 
+
+    /**
+     * @Author songxl
+     * @Description 获取每日住院患者的类型(出院、病危、抢救。。。)
+     * @Date 2021/5/11
+     * @Param [param]
+     * @Return void
+     * @MethodName execute
+     */
+    public void execute(String param, String behospitalCode) {
+        if (StringUtil.isBlank(behospitalCode) || StringUtil.isBlank(param)) {
+            return;
+        }
+        JSONObject paramJson = JSONObject.parseObject(param);
+        JSONObject typeValue = paramJson.getJSONObject("typeVal");
+        JSONObject typeName = paramJson.getJSONObject("typeName");
+        int searchSize = paramJson.getInteger("searchSize");
+        int batchSize = paramJson.getInteger("batchSize");
+
+
+        //定义批量插入的集合
+        HashMap<String, MedBehospitalType> medBehospitalTypeMap = new HashMap<>();
+        //1.获取有指定文书、没有患者类型的患者数据
+        RecordTypeVO recordContentVO = new RecordTypeVO();
+        recordContentVO.setModeList(new ArrayList<>(typeValue.keySet()));
+        List<MedicalRecord> medicalRecords = medicalRecordServiceImpl.list(new QueryWrapper<MedicalRecord>()
+                .eq("is_deleted", IsDeleteEnum.N.getKey())
+                .eq(SysUserUtils.getCurrentHospitalID() != null, "hospital_id", SysUserUtils.getCurrentHospitalID())
+                .eq("behospital_code", behospitalCode));
+        List<MedicalRecordDTO> medicalRecordList = BeanUtil.listCopyTo(medicalRecords, MedicalRecordDTO.class);
+        if (medicalRecordList != null && !medicalRecordList.isEmpty()) {
+            getPatientRecordType(medBehospitalTypeMap, medicalRecordList, typeValue, typeName);
+        }
+        //2.批量执行插入操作
+        try {
+            if (medBehospitalTypeMap != null && medBehospitalTypeMap.size() > 0) {
+                //删除原来的插入新的
+                medBehospitalTypeServiceImpl.remove(new UpdateWrapper<MedBehospitalType>()
+                        .eq("is_deleted", IsDeleteEnum.N.getKey())
+                        .eq(SysUserUtils.getCurrentHospitalID() != null, "hospital_id", SysUserUtils.getCurrentHospitalID())
+                        .in("behospital_code", medBehospitalTypeMap.keySet()));
+
+                List<MedBehospitalType> medBehospitalTypeList = new ArrayList<>(medBehospitalTypeMap.values());
+                medBehospitalTypeServiceImpl.saveOrUpdateBatch(medBehospitalTypeList, batchSize);
+            }
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+    }
+
     /**
      * @Author songxl
      * @Description 获取患者类型存入批量插入map
@@ -200,23 +254,27 @@ public class MedCheckWorkFacade {
         for (MedicalRecordDTO medicalRecordDTO : medicalRecordList) {
             //2.判断批量插入map中有没有这个患者
             if (medBehospitalTypeMap.containsKey(medicalRecordDTO.getBehospitalCode())) {
-                //3.比较这两次的分值大小
-                int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
-                int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
-                if (nval > lval) {
-                    medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
-                    medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
-                            .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
+                if (typeName.containsKey(medicalRecordDTO.getModeId() + "")) {
+                    //3.比较这两次的分值大小
+                    int lval = medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).getValue();
+                    int nval = typeValue.getInteger(medicalRecordDTO.getModeId() + "");
+                    if (nval > lval) {
+                        medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode()).setValue(nval);
+                        medBehospitalTypeMap.get(medicalRecordDTO.getBehospitalCode())
+                                .setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
+                    }
                 }
             } else {
                 //4.获取分值记录这个患者
-                MedBehospitalType medBehospitalType = new MedBehospitalType();
-                medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
-                medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
-                medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
-                medBehospitalType.setCreateTime(DateUtil.now());
-                medBehospitalType.setHospitalId(medicalRecordDTO.getHospitalId());
-                medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
+                if (typeName.containsKey(medicalRecordDTO.getModeId() + "")) {
+                    MedBehospitalType medBehospitalType = new MedBehospitalType();
+                    medBehospitalType.setBehospitalCode(medicalRecordDTO.getBehospitalCode());
+                    medBehospitalType.setBehospitalType(typeName.getString(medicalRecordDTO.getModeId() + ""));
+                    medBehospitalType.setValue(typeValue.getInteger(medicalRecordDTO.getModeId() + ""));
+                    medBehospitalType.setCreateTime(DateUtil.now());
+                    medBehospitalType.setHospitalId(medicalRecordDTO.getHospitalId());
+                    medBehospitalTypeMap.put(medicalRecordDTO.getBehospitalCode(), medBehospitalType);
+                }
             }
         }
     }