Browse Source

药品过敏原修改

zhoutg 4 years ago
parent
commit
3e1814c8d9

+ 156 - 107
src/main/java/com/diagbot/facade/TestFacade.java

@@ -9,8 +9,10 @@ import com.diagbot.dto.StandConvertCrfBatchDTO;
 import com.diagbot.dto.StandConvertCrfDTO;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
+import com.diagbot.util.BeanUtil;
 import com.diagbot.util.ExcelUtils;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.RedisUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.vo.Drug;
 import com.diagbot.vo.IndicationPushVO;
@@ -24,6 +26,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
 import java.io.File;
 import java.io.FileInputStream;
@@ -46,6 +49,8 @@ public class TestFacade {
     IndicationFacade indicationFacade;
     @Autowired
     StandConvertServiceClient standConvertServiceClient;
+    @Autowired
+    RedisUtil redisUtil;
 
     /**
      * 开单项数据测试
@@ -53,6 +58,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> importExcel(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -104,76 +110,92 @@ public class TestFacade {
 
             if (StringUtil.isNotEmpty(bean.getNeoType())) {
                 switch (bean.getNeoType()) {
-                    // case "1": // 性别
-                    //     if ("男性".equals(bean.getNeoName())) {
-                    //         indicationPushVO.setSex(1);
-                    //     } else if ("女性".equals(bean.getNeoName())) {
-                    //         indicationPushVO.setSex(2);
-                    //     }
-                    //     break;
-                    // case "2": // 化验, 示例:血小板计数,<,50,10^9/L
-                    //     String lisStr = bean.getNeoName();
-                    //     String[] lisArr = lisStr.split(",");
-                    //
-                    //     List<Lis> lisList = new ArrayList<>();
-                    //     Lis lisBean = new Lis();
-                    //     lisBean.setUniqueName(lisArr[0]);
-                    //     lisBean.setName(lisArr[0]);
-                    //     lisBean.setDetailName(lisArr[0]);
-                    //     lisBean.setValue(getValue(lisArr));
-                    //     lisList.add(lisBean);
-                    //     indicationPushVO.setLis(lisList);
-                    //     break;
-                    // case "3": // 临床表现
-                    //     indicationPushVO.setChief(bean.getNeoName());
-                    //     break;
-                    // case "4": //辅助检查描述
-                    //     indicationPushVO.setSymptom("B超:提示" + bean.getNeoName());
-                    //     break;
-                    // case "5": // 诊断
-                    //     List<Item> diag = new ArrayList<>();
-                    //     Item diagItem = new Item();
-                    //     diagItem.setName(bean.getNeoName());
-                    //     diagItem.setUniqueName(bean.getNeoName());
-                    //     diag.add(diagItem);
-                    //     indicationPushVO.setDiag(diag);
-                    //     break;
-                    // case "6": // 服用药品
-                    //     StringBuffer symptom = new StringBuffer("发病来,神志清,精神可,胃纳一般,睡眠可,二便无殊。一直服用");
-                    //     symptom.append(bean.getNeoName()).append("。");
-                    //     indicationPushVO.setSymptom(symptom.toString());
-                    //     break;
+                    case "1": // 性别
+                        if ("男性".equals(bean.getNeoName())) {
+                            indicationPushVO.setSex(1);
+                        } else if ("女性".equals(bean.getNeoName())) {
+                            indicationPushVO.setSex(2);
+                        }
+                        break;
+                    case "2": // 化验, 示例:血小板计数,<,50,10^9/L
+                        String lisStr = bean.getNeoName();
+                        String[] lisArr = lisStr.split(",");
+
+                        List<Lis> lisList = new ArrayList<>();
+                        Lis lisBean = new Lis();
+                        lisBean.setUniqueName(lisArr[0]);
+                        lisBean.setName(lisArr[0]);
+                        lisBean.setDetailName(lisArr[0]);
+                        lisBean.setValue(getValue(lisArr));
+                        lisList.add(lisBean);
+                        indicationPushVO.setLis(lisList);
+                        break;
+                    case "3": // 临床表现
+                        indicationPushVO.setChief(bean.getNeoName());
+                        break;
+                    case "4": //辅助检查描述
+                        indicationPushVO.setSymptom("B超:提示" + bean.getNeoName());
+                        break;
+                    case "5": // 诊断
+                        List<Item> diag = new ArrayList<>();
+                        Item diagItem = new Item();
+                        diagItem.setName(bean.getNeoName());
+                        diagItem.setUniqueName(bean.getNeoName());
+                        diag.add(diagItem);
+                        indicationPushVO.setDiag(diag);
+                        break;
+                    case "6": // 服用药品
+                        StringBuffer symptom = new StringBuffer("发病来,神志清,精神可,胃纳一般,睡眠可,二便无殊。一直服用");
+                        symptom.append(bean.getNeoName()).append("。");
+                        indicationPushVO.setSymptom(symptom.toString());
+                        break;
                     case "7" : // 药品过敏原
                         StringBuffer pastStr = new StringBuffer("");
-                        pastStr.append("有“").append(bean.getNeoName()).append("”过敏。");
-                        indicationPushVO.setPasts(pastStr.toString());
+                        if ("药品通用名称".equals(bean.getDrugType())) {
+                            pastStr.append("有“").append(bean.getNeoName()).append("”过敏。");
+                            indicationPushVO.setPasts(pastStr.toString());
+                        } else if ("药品类别".equals(bean.getDrugType())) {
+                            List<String> drugList = (List<String>)redisUtil.get("药品分类_" + bean.getNeoName());
+                            if (ListUtil.isNotEmpty(drugList)) {
+                                for (String s : drugList) {
+                                    pastStr = new StringBuffer("");
+                                    IndicationPushVO indicationPushCopy = new IndicationPushVO();
+                                    BeanUtil.copyProperties(indicationPushVO, indicationPushCopy);
+                                    pastStr.append("有“").append(s).append("”过敏。");
+                                    indicationPushCopy.setPasts(pastStr.toString());
+                                    indicationPushCopy.setMsg("过敏药品【" + s + "】");
+                                    indicationPushVOList.add(indicationPushCopy);
+                                }
+                            }
+                            continue;
+                        }
+                        break;
+                    case "12": // 体征
+                        StringBuffer sbVital = new StringBuffer();
+                        String[] vitalArr = bean.getNeoName().split(",");
+                        if (vitalArr.length > 1) {
+                            if ("收缩压".equals(vitalArr[0]) || "舒张压".equals(vitalArr[0])) {
+                                if ("收缩压".equals(vitalArr[0])) {
+                                    sbVital.append("血压");
+                                    sbVital.append(getValue(vitalArr) + "/100mmHg");
+                                    indicationPushVO.setVital(sbVital.toString());
+                                } else if ("舒张压".equals(vitalArr[0])) {
+                                    sbVital.append("血压");
+                                    sbVital.append("100/" + getValue(vitalArr) + "mmHg");
+                                    indicationPushVO.setVital(sbVital.toString());
+                                }
+                            } else {
+                                // 其他数值类型
+                                sbVital.append(vitalArr[0]);
+                                sbVital.append(getValue(vitalArr));
+                                sbVital.append(vitalArr[3]);
+                                indicationPushVO.setVital(sbVital.toString());
+                            }
+                        } else {
+                            sbVital.append(vitalArr[0]);
+                            indicationPushVO.setVital(sbVital.toString());
+                        }
                         break;
-                    // case "12": // 体征
-                    //     StringBuffer sbVital = new StringBuffer();
-                    //     String[] vitalArr = bean.getNeoName().split(",");
-                    //     if (vitalArr.length > 1) {
-                    //         if ("收缩压".equals(vitalArr[0]) || "舒张压".equals(vitalArr[0])) {
-                    //             if ("收缩压".equals(vitalArr[0])) {
-                    //                 sbVital.append("血压");
-                    //                 sbVital.append(getValue(vitalArr) + "/100mmHg");
-                    //                 indicationPushVO.setVital(sbVital.toString());
-                    //             } else if ("舒张压".equals(vitalArr[0])) {
-                    //                 sbVital.append("血压");
-                    //                 sbVital.append("100/" + getValue(vitalArr) + "mmHg");
-                    //                 indicationPushVO.setVital(sbVital.toString());
-                    //             }
-                    //         } else {
-                    //             // 其他数值类型
-                    //             sbVital.append(vitalArr[0]);
-                    //             sbVital.append(getValue(vitalArr));
-                    //             sbVital.append(vitalArr[3]);
-                    //             indicationPushVO.setVital(sbVital.toString());
-                    //         }
-                    //     } else {
-                    //         sbVital.append(vitalArr[0]);
-                    //         indicationPushVO.setVital(sbVital.toString());
-                    //     }
-                    //     break;
                     default:
                         continue;
                 }
@@ -181,7 +203,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "2");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "2", start);
         return map;
     }
 
@@ -191,6 +213,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testIndicationTransfusion(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -247,7 +270,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "2");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "2", start);
         return map;
     }
 
@@ -257,6 +280,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testHighRiskOperationExcel(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -279,7 +303,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "3");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "3", start);
         return map;
     }
 
@@ -289,6 +313,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testOtherTipLis(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -325,7 +350,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "4");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "4", start);
         return map;
     }
 
@@ -335,6 +360,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testOtherTipPacs(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -392,7 +418,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "4");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "4", start);
         return map;
     }
 
@@ -402,6 +428,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testOtherTipTransfusion(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -441,7 +468,7 @@ public class TestFacade {
             }
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "4");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "4", start);
         return map;
     }
 
@@ -451,6 +478,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> testHighRiskDrugExcel(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -473,7 +501,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "3");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "3", start);
         return map;
     }
 
@@ -483,6 +511,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> importCriticalLisExcel(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -522,7 +551,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "1");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "1", start);
         return map;
     }
 
@@ -532,6 +561,7 @@ public class TestFacade {
      * @param file
      */
     public Map<String, Object> importCriticalPacsExcel(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -553,7 +583,7 @@ public class TestFacade {
             indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = getDebugMap(indicationPushVOList, "1");
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "1", start);
         return map;
     }
 
@@ -632,6 +662,7 @@ public class TestFacade {
      * @return
      */
     public Map<String, Object> testHighRiskProcess(MultipartFile file, TestLineVO testLineVO) {
+        long start = System.currentTimeMillis();
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
         List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
@@ -798,25 +829,7 @@ public class TestFacade {
             //  indicationPushVOList.add(indicationPushVO);
         }
 
-        Map<String, Object> map = new LinkedHashMap<>();
-        List<String> msg = new ArrayList<>();
-        List<String> errMsg = new ArrayList<>();
-        for (IndicationPushVO indicationPushVO : indicationPushVOList) {
-            try {
-                IndicationDTO indicationDTO = indicationFacade.indicationFac(indicationPushVO);
-                if (ListUtil.isEmpty(indicationDTO.getHighRiskList())) {
-                    msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配" + indicationPushVO.getMsg());
-
-                }
-            } catch (Exception e) {
-                System.out.println(e.getMessage());
-                errMsg.add(indicationPushVO.getIdNum() + "行出错了");
-            }
-        }
-        map.put("总条数", indicationPushVOList.size() + "条");
-        map.put("出错条数", msg.size() + "条");
-        map.put("出错信息", msg);
-        map.put("程序报错", errMsg);
+        Map<String, Object> map = getDebugMap(indicationPushVOList, "3", start);
         return map;
     }
 
@@ -827,7 +840,7 @@ public class TestFacade {
      * @param ruleType
      * @return
      */
-    public Map getDebugMap(List<IndicationPushVO> indicationPushVOList, String ruleType) {
+    public Map getDebugMap(List<IndicationPushVO> indicationPushVOList, String ruleType, long start) {
         Map<String, Object> map = new LinkedHashMap<>();
         List<String> msg = new ArrayList<>();
         List<String> errMsg = new ArrayList<>();
@@ -837,22 +850,26 @@ public class TestFacade {
                 switch (ruleType) {
                     case "1":
                         if (ListUtil.isEmpty(indicationDTO.getCriticalValList())) {
-                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配");
+                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配,"
+                                    + (StringUtil.isNotBlank(indicationPushVO.getMsg()) ? indicationPushVO.getMsg() : ""));
                         }
                         break;
                     case "2":
                         if (ListUtil.isEmpty(indicationDTO.getBillMsgList())) {
-                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配");
+                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配。"
+                                    + (StringUtil.isNotBlank(indicationPushVO.getMsg()) ? indicationPushVO.getMsg() : ""));
                         }
                         break;
                     case "3":
                         if (ListUtil.isEmpty(indicationDTO.getHighRiskList())) {
-                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配");
+                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配。"
+                                    + (StringUtil.isNotBlank(indicationPushVO.getMsg()) ? indicationPushVO.getMsg() : ""));
                         }
                         break;
                     case "4":
                         if (ListUtil.isEmpty(indicationDTO.getOtherList())) {
-                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配");
+                            msg.add("第【" + indicationPushVO.getIdNum() + "】行未匹配。"
+                                    + (StringUtil.isNotBlank(indicationPushVO.getMsg()) ? indicationPushVO.getMsg() : ""));
                         }
                         break;
                     default:
@@ -867,6 +884,7 @@ public class TestFacade {
         map.put("出错条数", msg.size() + "条");
         map.put("出错信息", msg);
         map.put("程序报错", errMsg);
+        map.put("执行时间", (System.currentTimeMillis() - start) / 1000.0 + "秒");
         return map;
     }
 
@@ -879,21 +897,52 @@ public class TestFacade {
         indicationPushVO.setOperationOrder(operationOrder);
     }
 
-    private FileItem createFileItem(File file) {
-        String fieldName = "textField";
+    public Map testAll() {
+        Map<String, Object> map = new LinkedHashMap<>();
+        String picPathLis ="D:\\newSVN\\2020新版CDSS\\05.其他资料\\数据\\【危急值_化验】.xlsx";
+        String picPathPacs ="D:\\newSVN\\2020新版CDSS\\05.其他资料\\数据\\【危急值_辅检】.xls";
+        MultipartFile file = null;
+
+        file = getMulFileByPath(picPathLis);
+        Map<String, Object> criticalMapLis = importCriticalLisExcel(file, new TestLineVO());
+        map.put("【危急值_化验】",criticalMapLis);
+
+        file = getMulFileByPath(picPathPacs);
+        Map<String, Object> criticalMapPacs = importCriticalPacsExcel(file, new TestLineVO());
+        map.put("【危急值_辅检】",criticalMapPacs);
+        return map;
+    }
+
+    private MultipartFile getMulFileByPath(String picPath) {
+        FileItem fileItem = createFileItem(picPath);
+        MultipartFile mfile = new CommonsMultipartFile(fileItem);
+        return mfile;
+    }
+
+    private FileItem createFileItem(String filePath) {
         FileItemFactory factory = new DiskFileItemFactory(16, null);
-        FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
+        String textFieldName = "textField";
+        int num = filePath.lastIndexOf(".");
+        String extFile = filePath.substring(num);
+        FileItem item = factory.createItem(textFieldName, "text/plain", true,
+                "MyFileName" + extFile);
+        File newfile = new File(filePath);
         int bytesRead = 0;
         byte[] buffer = new byte[8192];
-        try {
-            FileInputStream fis = new FileInputStream(file);
+        try
+        {
+            FileInputStream fis = new FileInputStream(newfile);
             OutputStream os = item.getOutputStream();
-            while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
+            while ((bytesRead = fis.read(buffer, 0, 8192))
+                    != -1)
+            {
                 os.write(buffer, 0, bytesRead);
             }
             os.close();
             fis.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e)
+        {
             e.printStackTrace();
         }
         return item;

+ 2 - 2
src/main/java/com/diagbot/rule/DrugRule.java

@@ -42,9 +42,9 @@ public class DrugRule {
         if (ListUtil.isNotEmpty(drugList) && ListUtil.isNotEmpty(inputList)) {
             List<String> allDrug = new ArrayList<>();
             for (NodeNeoDTO nodeNeoDTO : drugList) {
-                if ("服用药品".equals(nodeNeoDTO.getTermtype()) || "药物过敏原".equals(nodeNeoDTO.getTermtype())) {
+                if ("药品".equals(nodeNeoDTO.getTermtype())) {
                     allDrug.add(nodeNeoDTO.getName());
-                } else if ("药品解剖学类别".equals(nodeNeoDTO.getTermtype())){
+                } else if ("药品类别".equals(nodeNeoDTO.getTermtype())){
                     String drugType = nodeNeoDTO.getName();
                     List<String> drugRedis = (List<String>)redisUtil.get(RedisEnum.drugType.getName() + drugType);
                     if (ListUtil.isNotEmpty(drugRedis)) {

+ 2 - 0
src/main/java/com/diagbot/vo/TestIndicationVO.java

@@ -245,4 +245,6 @@ public class TestIndicationVO implements Serializable {
     private String ageAll;
     @Excel(name="规则")
     private String ruleText;
+    @Excel(name="药品类型")
+    private String drugType;
 }

+ 5 - 0
src/main/java/com/diagbot/web/TestController.java

@@ -125,5 +125,10 @@ public class TestController {
         return RespDTO.onSuc(testFacade.testHighRiskProcess(file, testLineVO));
     }
 
+    @ApiOperation(value = "批量测试[zhoutg]", notes = "")
+    @PostMapping("/testAll")
+    public RespDTO<Map<String, Object>> testAll() {
+        return RespDTO.onSuc(testFacade.testAll());
+    }
 }