|
@@ -0,0 +1,515 @@
|
|
|
+package com.diagbot.facade;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.entity.KlConcept;
|
|
|
+import com.diagbot.entity.KlDiagnose;
|
|
|
+import com.diagbot.enums.DiagnoseLexiconTypeEnum;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
+import com.diagbot.enums.LexiconExtEnum;
|
|
|
+import com.diagbot.service.KlConceptService;
|
|
|
+import com.diagbot.util.*;
|
|
|
+import com.diagbot.vo.*;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
+import com.google.common.collect.Maps;
|
|
|
+import org.apache.commons.collections4.map.LinkedMap;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.ListIterator;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.function.Function;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Description:
|
|
|
+ * @author: zhoutg
|
|
|
+ * @time: 2021/3/15 11:42
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class KlDiagnoseImportFacade {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Qualifier("klConceptServiceImpl")
|
|
|
+ private KlConceptService klConceptService;
|
|
|
+ @Autowired
|
|
|
+ KlDiagnoseFacade klDiagnoseFacade;
|
|
|
+
|
|
|
+ public Map<String, Object> importDiagnose(MultipartFile file, DiagnoseImportVO diagnoseImportVO) {
|
|
|
+ Map<String, Object> errMessage = new LinkedHashMap<>(); // 错误提示语
|
|
|
+ List<ImportDiagnoseResVO> allData = Lists.newArrayList(); // 最终需要保存的数据
|
|
|
+ // 校验数据
|
|
|
+ Boolean allFlag = verifyData(file, diagnoseImportVO, errMessage, allData);
|
|
|
+
|
|
|
+ // 保存数据
|
|
|
+ if (allFlag) {
|
|
|
+ saveData(allData);
|
|
|
+ }
|
|
|
+ return errMessage;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验数据
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @param diagnoseImportVO
|
|
|
+ * @param diagMessage
|
|
|
+ * @param allData
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Boolean verifyData(MultipartFile file, DiagnoseImportVO diagnoseImportVO, Map<String, Object> diagMessage, List<ImportDiagnoseResVO> allData) {
|
|
|
+ Boolean allFlag = true;
|
|
|
+ List<String> diagtypes = Lists.newArrayList("拟诊", "确诊", "警惕");
|
|
|
+ // 获取标准词库Map
|
|
|
+ Map<String, KlConcept> concept_map = getConceptMap();
|
|
|
+
|
|
|
+ // 获取所有的sheet和序号的对应关系
|
|
|
+ Map<String, Integer> sheetNumNameMap = dealExcel(file);
|
|
|
+ // 指定诊断列表
|
|
|
+ List<String> diags = diagnoseImportVO.getDiags();
|
|
|
+ if (ListUtil.isNotEmpty(diags)) {
|
|
|
+ List<String> allErrMsg = Lists.newArrayList();
|
|
|
+ Map<String, Integer> inputNumNameMap = new LinkedMap<>();
|
|
|
+ for (String diag : diags) {
|
|
|
+ if (!sheetNumNameMap.containsKey(diag)) {
|
|
|
+ allErrMsg.add(String.format("输入的诊断: %s不在下面的sheet中", "【" + diag + "】"));
|
|
|
+ } else {
|
|
|
+ inputNumNameMap.put(diag, sheetNumNameMap.get(diag));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(allErrMsg)) {
|
|
|
+ diagMessage.put("输入校验", StringUtils.join(allErrMsg, "; "));
|
|
|
+ allFlag = false;
|
|
|
+ return allFlag;
|
|
|
+ } else {
|
|
|
+ sheetNumNameMap = inputNumNameMap;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map.Entry<String, Integer> sheet : sheetNumNameMap.entrySet()) {
|
|
|
+ List<String> currentErrMsg = Lists.newArrayList();
|
|
|
+ String sheetName = sheet.getKey();
|
|
|
+ Integer sheetNum = sheet.getValue();
|
|
|
+ ImportDiagnoseResVO importDiagnoseResVO = new ImportDiagnoseResVO();
|
|
|
+
|
|
|
+ // 校验疾病名称【sheetName】
|
|
|
+ KlConcept klConcept = concept_map.get(sheetName + "_" + String.valueOf(LexiconEnum.Disease.getKey()));
|
|
|
+ if (klConcept != null) {
|
|
|
+ importDiagnoseResVO.setDiseaseName(sheetName);
|
|
|
+ importDiagnoseResVO.setDiseaseId(klConcept.getId());
|
|
|
+ } else {
|
|
|
+ currentErrMsg.add(String.format("sheetName: %s不是标准词", "【" + sheetName + "】"));
|
|
|
+ }
|
|
|
+ // 校验其他行数据、格式
|
|
|
+ List<ImportDiagnoseVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, sheetNum.intValue(), ImportDiagnoseVO.class);
|
|
|
+ //处理公式(确诊)
|
|
|
+ List<String> orderList = processFormula(data, diagtypes);
|
|
|
+ dealVerify(currentErrMsg, orderList, diagtypes, data, concept_map);
|
|
|
+
|
|
|
+ // 数据赋值
|
|
|
+ if (ListUtil.isEmpty(currentErrMsg)) {
|
|
|
+ data = dealImportDiagnose(diagtypes, data, concept_map);
|
|
|
+ // 添加到正确数据列表
|
|
|
+ importDiagnoseResVO.setImportDiagnoseVOList(data);
|
|
|
+ allData.add(importDiagnoseResVO);
|
|
|
+ } else {
|
|
|
+ allFlag = false;
|
|
|
+ diagMessage.put(sheetName, StringUtils.join(currentErrMsg.stream().distinct().collect(Collectors.toList()), "; "));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return allFlag;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> processFormula(List<ImportDiagnoseVO> data, List<String> diagtypes) {
|
|
|
+ List<String> orderList = Lists.newArrayList();
|
|
|
+ Map<String, List<String>> typeCollect = Maps.newHashMap();
|
|
|
+ if (ListUtil.isNotEmpty(data)) {
|
|
|
+ ListIterator<ImportDiagnoseVO> it = data.listIterator();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ ImportDiagnoseVO next = it.next();
|
|
|
+ String type = next.getType();
|
|
|
+ String orderNo = next.getOrderNo();
|
|
|
+ Integer rowNum = next.getRowNum() - 1;
|
|
|
+ if (!diagtypes.contains(type) && StringUtil.isNotBlank(type) && StringUtil.isNotBlank(orderNo)) {
|
|
|
+ orderList.add(orderNo);
|
|
|
+ }
|
|
|
+ if ("拟诊".equals(type) && StringUtils.isNotBlank(orderNo)) {
|
|
|
+ if (typeCollect.containsKey(type)) {
|
|
|
+ List<String> gongsi = typeCollect.get(type);
|
|
|
+ gongsi.add(orderNo);
|
|
|
+ typeCollect.put(type, gongsi);
|
|
|
+ } else {
|
|
|
+ List<String> gongsi = Lists.newArrayList();
|
|
|
+ gongsi.add(orderNo);
|
|
|
+ typeCollect.put(type, gongsi);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ("确诊".equals(type) && StringUtils.isNotBlank(orderNo)) {
|
|
|
+ if (orderNo.contains("拟诊") && typeCollect.containsKey("拟诊")) {
|
|
|
+ it.remove();
|
|
|
+ for (String nizhen : typeCollect.get("拟诊")) {
|
|
|
+ ImportDiagnoseVO importDiagnoseVO = new ImportDiagnoseVO();
|
|
|
+ importDiagnoseVO.setParentRule(next.getOrderNo());
|
|
|
+ importDiagnoseVO.setType(type);
|
|
|
+ importDiagnoseVO.setRowNum(rowNum);
|
|
|
+ importDiagnoseVO.setOrderNo(orderNo.replace("拟诊", nizhen));
|
|
|
+ it.add(importDiagnoseVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取sheet名称和序号的对应关系
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Integer> dealExcel(MultipartFile file) {
|
|
|
+ Map<String, Integer> sheetNumName = Maps.newLinkedHashMap();
|
|
|
+ Workbook workBook = null;
|
|
|
+ try {
|
|
|
+ workBook = ExcelUtils.getWorkBook(file);
|
|
|
+ int numberOfSheets = workBook.getNumberOfSheets();
|
|
|
+ for (int i = 0; i < numberOfSheets; i++) {
|
|
|
+ String sheetName = workBook.getSheetName(i);
|
|
|
+ if (!"目录".equals(sheetName)) {
|
|
|
+ sheetNumName.put(sheetName, i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return sheetNumName;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给标准词设置conceptId
|
|
|
+ *
|
|
|
+ * @param diagtypes
|
|
|
+ * @param importDiagnoseVOS
|
|
|
+ * @param concept_map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<ImportDiagnoseVO> dealImportDiagnose(List<String> diagtypes, List<ImportDiagnoseVO> importDiagnoseVOS, Map<String, KlConcept> concept_map) {
|
|
|
+ for (ImportDiagnoseVO idv : importDiagnoseVOS) {
|
|
|
+ String type = idv.getType();
|
|
|
+ String orderNo = idv.getOrderNo();
|
|
|
+ String rule = idv.getRule();
|
|
|
+ if (StringUtil.isBlank(type) && StringUtil.isBlank(orderNo)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!type.contains("正则") && !diagtypes.contains(type)) {
|
|
|
+ KlConcept klConcept = concept_map.get(rule + "_" + String.valueOf(LexiconExtEnum.getEnum(type).getKey()));
|
|
|
+ if (klConcept != null) {
|
|
|
+ idv.setConceptId(klConcept.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return importDiagnoseVOS;
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据及格式校验
|
|
|
+ private void dealVerify(List<String> currentErrMsg, List<String> orderNums, List<String> diagtypes, List<ImportDiagnoseVO> data, Map<String, KlConcept> concept_map) {
|
|
|
+ //list元素计数
|
|
|
+ Map<String, Long> orderNumMap = orderNums.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
|
|
|
+ for (Map.Entry<String, Long> on : orderNumMap.entrySet()) {
|
|
|
+ if (on.getValue() > 1) {
|
|
|
+ currentErrMsg.add(String.format("%s序号重复", "【" + on.getKey() + "】"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(data)) {
|
|
|
+ for (ImportDiagnoseVO imd : data) {
|
|
|
+ Integer rowNum = imd.getRowNum();
|
|
|
+ String type = imd.getType();
|
|
|
+ String rule = imd.getRule();
|
|
|
+ String orderNo = imd.getOrderNo();
|
|
|
+ String eq = imd.getEq();
|
|
|
+ String maxSymbol = imd.getMaxSymbol();
|
|
|
+ String minSymbol = imd.getMinSymbol();
|
|
|
+ String parentRule = imd.getParentRule();
|
|
|
+ if (StringUtil.isBlank(type) && StringUtil.isBlank(orderNo)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtil.isNotBlank(type) && StringUtil.isNotBlank(rule) && StringUtil.isNotBlank(orderNo)) {
|
|
|
+ LexiconExtEnum anEnum = LexiconExtEnum.getEnum(type);
|
|
|
+ if (anEnum == null) {
|
|
|
+ currentErrMsg.add(String.format("第%d行【%s】类型错误", rowNum, type));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int key = anEnum.getKey();
|
|
|
+ if (!type.contains("正则") &&
|
|
|
+ !concept_map.containsKey(rule + "_" + String.valueOf(key))) {
|
|
|
+ currentErrMsg.add(String.format("第%d行【%s】不是标准词", rowNum, rule));
|
|
|
+ }
|
|
|
+ String name = DiagnoseLexiconTypeEnum.getName(key);
|
|
|
+ Boolean regexRes = RegexUtil.getRegexRes(orderNo, name + "\\d+");
|
|
|
+ if (!regexRes) {
|
|
|
+ currentErrMsg.add(String.format("第%d行类型【%s】和序号【%s】对应错误", rowNum, type, orderNo));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(maxSymbol) &&
|
|
|
+ !"<=".equals(maxSymbol) && !"<".equals(maxSymbol)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行%s的【最大值符号】不正确", rowNum, rule));
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(minSymbol) &&
|
|
|
+ !">=".equals(minSymbol) && !">".equals(minSymbol)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行%s的【最小值符号】不正确", rowNum, rule));
|
|
|
+ }
|
|
|
+ if (LexiconExtEnum.LisSubName.getName().equals(type) && StringUtils.isNotBlank(rule)
|
|
|
+ && StringUtils.isBlank(eq)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行%s的【等于值】不能为空", rowNum, rule));
|
|
|
+ }
|
|
|
+ if ((LexiconExtEnum.Vital.getName().equals(type) || LexiconExtEnum.Age.getName().equals(type))
|
|
|
+ && StringUtils.isNotBlank(rule)
|
|
|
+ && StringUtils.isBlank(imd.getMin()) && StringUtils.isBlank(imd.getMax())) {
|
|
|
+ currentErrMsg.add(String.format("第%d行%s【最大值】和【最小值】至少有一个不能为空", rowNum, rule));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(type)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行【类型】不能为空", rowNum));
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(orderNo)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行【序号】不能为空", rowNum));
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(type) && !diagtypes.contains(type) && StringUtils.isBlank(rule)) {
|
|
|
+ currentErrMsg.add(String.format("第%d行【规则】不能为空", rowNum));
|
|
|
+ }
|
|
|
+ if (diagtypes.contains(type) && StringUtil.isNotBlank(orderNo)) {
|
|
|
+ String s = VerifyUtil.verifyFormula(orderNums, orderNo);
|
|
|
+ if (StringUtil.isNotBlank(s)) {
|
|
|
+ if (StringUtil.isNotBlank(parentRule)) {
|
|
|
+ s = s.replace(orderNo, parentRule);
|
|
|
+ }
|
|
|
+ currentErrMsg.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //格式校验
|
|
|
+ /*if (ListUtil.isNotEmpty(verifies)) {
|
|
|
+ for (String vef : verifies) {
|
|
|
+ String s = VerifyUtil.verifyFormula(orderNums, vef);
|
|
|
+ if (StringUtil.isNotBlank(s)) {
|
|
|
+ currentErrMsg.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private Map<String, KlConcept> getConceptMap() {
|
|
|
+ List<KlConcept> klConcepts
|
|
|
+ = klConceptService.list(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ );
|
|
|
+ Map<String, KlConcept> map
|
|
|
+ = EntityUtil.makeEntityMapByKeys(klConcepts, "_", "libName", "libType");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存数据
|
|
|
+ *
|
|
|
+ * @param allData
|
|
|
+ */
|
|
|
+ public void saveData(List<ImportDiagnoseResVO> allData) {
|
|
|
+ for (ImportDiagnoseResVO importDiagnoseResVO : allData) {
|
|
|
+ Long diseaseId = importDiagnoseResVO.getDiseaseId();
|
|
|
+ String diseaseName = importDiagnoseResVO.getDiseaseName();
|
|
|
+ List<ImportDiagnoseVO> data = importDiagnoseResVO.getImportDiagnoseVOList();
|
|
|
+ // 获取序号对应的行数据
|
|
|
+ Map<String, List<ImportDiagnoseVO>> map = EntityUtil.makeEntityListMap(data, "orderNo");
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(data)) {
|
|
|
+ // 第一层
|
|
|
+ KlDiagnoseSaveVO klDiagnoseSaveVO = new KlDiagnoseSaveVO();
|
|
|
+ klDiagnoseSaveVO.setConceptId(diseaseId);
|
|
|
+ klDiagnoseSaveVO.setDescription(diseaseName);
|
|
|
+
|
|
|
+ // 第二层
|
|
|
+ List<KlDiagnoseTypeVO> klDiagnoseTypeVOList = Lists.newArrayList();
|
|
|
+
|
|
|
+ for (ImportDiagnoseVO importDiagnoseVO : data) {
|
|
|
+ String type = importDiagnoseVO.getType();
|
|
|
+ String getOrderNo = importDiagnoseVO.getOrderNo();
|
|
|
+ if (StringUtil.isNotBlank(type) && StringUtil.isNotBlank(getOrderNo)) {
|
|
|
+ if ("拟诊".equals(type) || "确诊".equals(type) || "警惕".equals(type)) {
|
|
|
+ String[] splitGroup = getOrderNo.split("\\+");
|
|
|
+
|
|
|
+ KlDiagnoseTypeVO klDiagnoseTypeVO = new KlDiagnoseTypeVO();
|
|
|
+ if ("拟诊".equals(type)) {
|
|
|
+ klDiagnoseTypeVO.setConditionType(2);
|
|
|
+ } else if ("确诊".equals(type)) {
|
|
|
+ klDiagnoseTypeVO.setConditionType(3);
|
|
|
+ } else if ("警惕".equals(type)) {
|
|
|
+ klDiagnoseTypeVO.setConditionType(4);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 第三层
|
|
|
+ List<KlDiagnoseGroupVO> groupVO = Lists.newArrayList();
|
|
|
+ for (String group : splitGroup) {
|
|
|
+ KlDiagnoseGroupVO klDiagnoseGroupVO = generateDiagnoseGroup(group, map);
|
|
|
+ groupVO.add(klDiagnoseGroupVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ klDiagnoseTypeVO.setGroupVO(groupVO);
|
|
|
+ klDiagnoseTypeVOList.add(klDiagnoseTypeVO);
|
|
|
+ klDiagnoseSaveVO.setKlDiagnoseTypeVO(klDiagnoseTypeVOList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取主表数据
|
|
|
+ KlDiagnose klDiagnose = klDiagnoseFacade.getOne(new QueryWrapper<KlDiagnose>().eq("concept_id", diseaseId), false);
|
|
|
+ if (klDiagnose != null) {
|
|
|
+ klDiagnoseSaveVO.setId(klDiagnose.getId());
|
|
|
+ klDiagnoseSaveVO.setModifier("0");
|
|
|
+ }
|
|
|
+ klDiagnoseFacade.saveDiagnoseAll(klDiagnoseSaveVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成KlDiagnoseGroupVO, 每一组+分隔后的内容
|
|
|
+ *
|
|
|
+ * @param map
|
|
|
+ * @param text
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public KlDiagnoseGroupVO generateDiagnoseGroup(String text, Map<String, List<ImportDiagnoseVO>> map) {
|
|
|
+ KlDiagnoseGroupVO klDiagnoseGroupVO = new KlDiagnoseGroupVO();
|
|
|
+
|
|
|
+ // list[0]:序号,list[1]:任几
|
|
|
+ List<String> list = Lists.newArrayList();
|
|
|
+ if (text.contains("[") || text.contains("]")) {
|
|
|
+ list.add(text.substring(text.indexOf("[") + 1, text.indexOf("]")));
|
|
|
+ String numStr = text.substring(text.indexOf("任") + 1);
|
|
|
+ String num = "1";
|
|
|
+ switch (numStr) {
|
|
|
+ case "一":
|
|
|
+ num = "1";
|
|
|
+ break;
|
|
|
+ case "二":
|
|
|
+ num = "2";
|
|
|
+ break;
|
|
|
+ case "三":
|
|
|
+ num = "3";
|
|
|
+ break;
|
|
|
+ case "四":
|
|
|
+ num = "4";
|
|
|
+ break;
|
|
|
+ case "五":
|
|
|
+ num = "5";
|
|
|
+ break;
|
|
|
+ case "六":
|
|
|
+ num = "6";
|
|
|
+ break;
|
|
|
+ case "七":
|
|
|
+ num = "7";
|
|
|
+ break;
|
|
|
+ case "八":
|
|
|
+ num = "8";
|
|
|
+ break;
|
|
|
+ case "九":
|
|
|
+ num = "9";
|
|
|
+ break;
|
|
|
+ case "十":
|
|
|
+ num = "10";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ list.add(num);
|
|
|
+ } else {
|
|
|
+ list.add(text);
|
|
|
+ list.add("1");
|
|
|
+ }
|
|
|
+ klDiagnoseGroupVO.setFitNo(Integer.valueOf(list.get(1))); // 任几
|
|
|
+
|
|
|
+ List<KlDiagnoseDetailVO> klDiagnoseDetail = Lists.newArrayList();
|
|
|
+ String[] orderArr = list.get(0).split("、");
|
|
|
+ for (String order : orderArr) {
|
|
|
+ KlDiagnoseDetailVO klDiagnoseDetailVO = new KlDiagnoseDetailVO();
|
|
|
+ ImportDiagnoseVO current = map.get(order).get(0);
|
|
|
+ LexiconExtEnum libTypeEnum = LexiconExtEnum.getEnum(current.getType());
|
|
|
+ if (libTypeEnum != null) {
|
|
|
+ klDiagnoseDetailVO.setBasLibName(current.getRule());
|
|
|
+ switch (libTypeEnum) {
|
|
|
+ case Symptom: // 症状
|
|
|
+ case VitalResult: // 体格检查结果
|
|
|
+ case PacsResult: // 辅助检查结果
|
|
|
+ case Group: // 人群
|
|
|
+ case Disease: // 疾病
|
|
|
+ klDiagnoseDetailVO.setBasConceptId(current.getConceptId());
|
|
|
+ klDiagnoseDetailVO.setBasType(1);
|
|
|
+ klDiagnoseDetailVO.setBasDescription(current.getRule());
|
|
|
+ break;
|
|
|
+ case zsxbszz: // 主诉现病史正则
|
|
|
+ klDiagnoseDetailVO.setBasType(3);
|
|
|
+ klDiagnoseDetailVO.setBasDescription(current.getRule());
|
|
|
+ klDiagnoseDetailVO.setEqValue(current.getRule());
|
|
|
+ break;
|
|
|
+ case jwzz: // 既往正则
|
|
|
+ klDiagnoseDetailVO.setBasType(4);
|
|
|
+ klDiagnoseDetailVO.setBasDescription(current.getRule());
|
|
|
+ klDiagnoseDetailVO.setEqValue(current.getRule());
|
|
|
+ break;
|
|
|
+ case Vital: // 体格检查项目
|
|
|
+ case Age: // 年龄
|
|
|
+ klDiagnoseDetailVO.setBasConceptId(current.getConceptId());
|
|
|
+ if (StringUtil.isNotBlank(current.getMin())) {
|
|
|
+ klDiagnoseDetailVO.setMinVal(current.getMin());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(current.getMinSymbol())) {
|
|
|
+ klDiagnoseDetailVO.setMinOperator(current.getMinSymbol());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(current.getUnit())) {
|
|
|
+ klDiagnoseDetailVO.setMinUnit(current.getUnit());
|
|
|
+ klDiagnoseDetailVO.setMaxUnit(current.getUnit());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(current.getMax())) {
|
|
|
+ klDiagnoseDetailVO.setMaxVal(current.getMax());
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(current.getMaxSymbol())) {
|
|
|
+ klDiagnoseDetailVO.setMaxOperator(String.valueOf(current.getMaxSymbol()));
|
|
|
+ }
|
|
|
+ klDiagnoseDetailVO.setBasDescription(current.getRule());
|
|
|
+ klDiagnoseDetailVO.setBasType(2);
|
|
|
+ break;
|
|
|
+ case LisSubName: // 实验室检查子项目
|
|
|
+ klDiagnoseDetailVO.setBasConceptId(current.getConceptId());
|
|
|
+ klDiagnoseDetailVO.setEqValue(current.getEq());
|
|
|
+ klDiagnoseDetailVO.setBasDescription(current.getRule() + current.getEq());
|
|
|
+ klDiagnoseDetailVO.setBasType(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ klDiagnoseDetail.add(klDiagnoseDetailVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ klDiagnoseGroupVO.setKlDiagnoseDetail(klDiagnoseDetail);
|
|
|
+ return klDiagnoseGroupVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String text = "[1、2、3]任一";
|
|
|
+ List<String> list = Lists.newArrayList();
|
|
|
+ if (text.contains("[") || text.contains("]")) {
|
|
|
+ list.add(text.substring(text.indexOf("[") + 1, text.indexOf("]")));
|
|
|
+ list.add(text.substring(text.indexOf("]") + 1));
|
|
|
+ }
|
|
|
+ System.out.println(list);
|
|
|
+ }
|
|
|
+}
|