CommonRule.java 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. package com.diagbot.rule;
  2. import com.diagbot.biz.push.entity.Lis;
  3. import com.diagbot.biz.push.entity.Pacs;
  4. import com.diagbot.dto.BaseDiagnoseDTO;
  5. import com.diagbot.dto.BillMsg;
  6. import com.diagbot.dto.DictionaryInfoDTO;
  7. import com.diagbot.dto.RuleBaseDTO;
  8. import com.diagbot.dto.RuleSimpleDTO;
  9. import com.diagbot.dto.WordCrfDTO;
  10. import com.diagbot.enums.BaseDiagnoseTypeEnum;
  11. import com.diagbot.enums.ConEnum;
  12. import com.diagbot.enums.LexiconEnum;
  13. import com.diagbot.enums.RedisEnum;
  14. import com.diagbot.enums.TypeEnum;
  15. import com.diagbot.facade.CommonFacade;
  16. import com.diagbot.facade.KlDictionaryInfoFacade;
  17. import com.diagbot.model.entity.Clinical;
  18. import com.diagbot.model.entity.Negative;
  19. import com.diagbot.util.BeanUtil;
  20. import com.diagbot.util.CatalogueUtil;
  21. import com.diagbot.util.CoreUtil;
  22. import com.diagbot.util.EntityUtil;
  23. import com.diagbot.util.ListUtil;
  24. import com.diagbot.util.MsgNewUtil;
  25. import com.diagbot.util.MsgUtil;
  26. import com.diagbot.util.RedisUtil;
  27. import com.diagbot.util.ReflectUtil;
  28. import com.diagbot.util.RegexUtil;
  29. import com.diagbot.util.StringUtil;
  30. import org.apache.commons.lang3.StringUtils;
  31. import org.springframework.beans.factory.annotation.Autowired;
  32. import org.springframework.stereotype.Component;
  33. import java.util.ArrayList;
  34. import java.util.Collections;
  35. import java.util.Comparator;
  36. import java.util.Date;
  37. import java.util.LinkedHashMap;
  38. import java.util.List;
  39. import java.util.Map;
  40. import java.util.Set;
  41. import java.util.stream.Collectors;
  42. /**
  43. * @description: 通用规则提取
  44. * @author: kwz
  45. * @time: 2020/8/3 14:47
  46. */
  47. @Component
  48. public class CommonRule {
  49. @Autowired
  50. CommonFacade commonFacade;
  51. @Autowired
  52. GroupRule groupRule;
  53. @Autowired
  54. VitalRule vitalRule;
  55. @Autowired
  56. AgeRule ageRule;
  57. @Autowired
  58. LisRule lisRule;
  59. @Autowired
  60. KlDictionaryInfoFacade klDictionaryInfoFacade;
  61. @Autowired
  62. RedisUtil redisUtil;
  63. @Autowired
  64. MsgNewUtil msgNewUtil;
  65. /**
  66. * 比较阳性属性是否匹配
  67. *
  68. * @param input
  69. * @param ruleBaseDTO
  70. * @param billMsgList
  71. * @param conType
  72. * @param ruleSimpleDTO
  73. * @param <T>
  74. */
  75. public <T> void compareNameWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
  76. String conType, RuleSimpleDTO ruleSimpleDTO) {
  77. if (ListUtil.isNotEmpty(input)) {
  78. for (T d : input) {
  79. Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
  80. if (val == null) {
  81. String standName = (String) CoreUtil.getFieldValue(d, "standName");
  82. String name = (String) CoreUtil.getFieldValue(d, "name");
  83. if (StringUtils.isNotBlank(standName) && CoreUtil.compareName(ruleBaseDTO, standName)) {
  84. ruleSimpleDTO.setContent(name);
  85. ruleSimpleDTO.setConType(conType);
  86. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  87. CoreUtil.addBeanToList(billMsgList, billMsg);
  88. }
  89. }
  90. }
  91. }
  92. }
  93. /**
  94. * 比较阳性属性是否匹配
  95. *
  96. * @param input
  97. * @param ruleBaseDTO
  98. * @param baseIdList
  99. * @param ids
  100. * @param <T>
  101. */
  102. public <T> void compareNameWithPush(List<T> input, RuleBaseDTO ruleBaseDTO, List<Long> baseIdList, String ids) {
  103. if (ListUtil.isNotEmpty(input)) {
  104. for (T d : input) {
  105. Negative val = (Negative) CoreUtil.getFieldValue(d, "negative");
  106. if (val == null) {
  107. String c = (String) CoreUtil.getFieldValue(d, "standName");
  108. if (StringUtils.isNotBlank(c) && CoreUtil.compareNameMulti(ruleBaseDTO, c)) {
  109. CoreUtil.addSplitString(baseIdList, ids);
  110. }
  111. }
  112. }
  113. }
  114. }
  115. /**
  116. * 比较是否包含
  117. *
  118. * @param input
  119. * @param name
  120. * @return
  121. */
  122. public <T> Boolean containsItem(List<T> input, String name) {
  123. if (ListUtil.isNotEmpty(input) && StringUtil.isNotBlank(name)) {
  124. for (T t : input) {
  125. String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
  126. if (c.contains(name)) {
  127. return true;
  128. }
  129. }
  130. }
  131. return false;
  132. }
  133. /**
  134. * 比较名称是否匹配
  135. *
  136. * @param input
  137. * @param ruleBaseDTO
  138. * @param <T>
  139. */
  140. public <T> Map compareItem(List<T> input, RuleBaseDTO ruleBaseDTO) {
  141. Map<String, Object> map = new LinkedHashMap<>();
  142. boolean flag = false;
  143. if (ruleBaseDTO == null || ListUtil.isEmpty(input)) {
  144. map.put("flag", flag);
  145. return map;
  146. }
  147. List<String> msgList = new ArrayList<>();
  148. for (T t : input) {
  149. String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
  150. String c_name = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
  151. if (CoreUtil.compareName(ruleBaseDTO, c)) {
  152. msgList.add(c_name);
  153. flag = true;
  154. }
  155. }
  156. map.put("flag", flag);
  157. map.put("msgList", msgList);
  158. return map;
  159. }
  160. /**
  161. * 比较名称是否匹配——开单
  162. *
  163. * @param input
  164. * @param ruleBaseDTO
  165. * @param billMsgList
  166. * @param conType
  167. * @param ruleSimpleDTO
  168. * @param <T>
  169. */
  170. public <T> void compareItemWithBill(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList,
  171. String conType, RuleSimpleDTO ruleSimpleDTO) {
  172. if (ListUtil.isNotEmpty(input)) {
  173. for (T t : input) {
  174. String uniqueName = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
  175. String inputName = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
  176. if (CoreUtil.compareName(ruleBaseDTO, uniqueName)) {
  177. ruleSimpleDTO.setContent(inputName);
  178. ruleSimpleDTO.setConType(conType);
  179. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  180. CoreUtil.addBeanToList(billMsgList, billMsg);
  181. }
  182. }
  183. }
  184. }
  185. /**
  186. * 比较名称是否匹配——推理
  187. *
  188. * @param input
  189. * @param ruleBaseDTO
  190. * @param baseIdList
  191. * @param ids
  192. * @param <T>
  193. */
  194. public <T> void compareItemWithPush(List<T> input, RuleBaseDTO ruleBaseDTO, List<Long> baseIdList, String ids) {
  195. if (ListUtil.isNotEmpty(input)) {
  196. for (T t : input) {
  197. String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
  198. if (CoreUtil.compareNameMulti(ruleBaseDTO, c)) {
  199. CoreUtil.addSplitString(baseIdList, ids);
  200. }
  201. }
  202. }
  203. }
  204. /**
  205. * 比较名称是否匹配
  206. *
  207. * @param input
  208. * @param ruleBaseDTO
  209. * @param highRiskList
  210. * @param ruleSimpleDTO
  211. * @param <T>
  212. */
  213. public <T> void compareItemWithHighRisk(List<T> input, RuleBaseDTO ruleBaseDTO, List<BillMsg> highRiskList, RuleSimpleDTO ruleSimpleDTO) {
  214. if (ListUtil.isNotEmpty(input)) {
  215. for (T t : input) {
  216. String c = (String) CoreUtil.getFieldValue(t, "uniqueName"); // 标准名称
  217. String c_name = (String) CoreUtil.getFieldValue(t, "name"); // 界面名称
  218. if (CoreUtil.compareName(ruleBaseDTO, c)) {
  219. BillMsg billMsg = MsgUtil.getCommonHighRiskMsg(c_name, ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
  220. highRiskList.add(billMsg);
  221. }
  222. }
  223. }
  224. }
  225. /**
  226. * 正常结果,无需重复开单项——辅检
  227. *
  228. * @param wordCrfDTO
  229. * @param ruleBaseDTO
  230. * @param billMsgList
  231. * @param ruleSimpleDTO
  232. */
  233. public void needlessRepeatOrderPacs(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
  234. String orderStandName = ruleBaseDTO.getBaseLibName();
  235. Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(wordCrfDTO.getPacs(), "uniqueName");
  236. List<Pacs> pacsList = map.get(orderStandName);
  237. if (ListUtil.isNotEmpty(pacsList)) {
  238. sortByProperty(pacsList, "dateValue");
  239. Pacs pacs = pacsList.get(pacsList.size() - 1); // 按时间排序,取最后一条
  240. String result = pacs.getResult();
  241. if (StringUtil.isNotBlank(result) && StringUtil.isNotBlank(ruleBaseDTO.getBaseEqValue())
  242. && RegexUtil.getRegexRes(result, ruleBaseDTO.getBaseEqValue())) {
  243. String dateValue = pacs.getDateValue(); // 结果日期
  244. String orderDateValue = ruleSimpleDTO.getDateValue(); // 开单项日期
  245. int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false);
  246. if (flag == 1) {
  247. ruleSimpleDTO.setContent(result);
  248. ruleSimpleDTO.setConType(conType);
  249. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  250. CoreUtil.addBeanToList(billMsgList, billMsg);
  251. }
  252. }
  253. }
  254. }
  255. /**
  256. * 正常结果,无需重复开单项——化验
  257. *
  258. * @param wordCrfDTO
  259. * @param ruleBaseDTO
  260. * @param billMsgList
  261. * @param ruleSimpleDTO
  262. */
  263. public void needlessRepeatOrderLis(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO) {
  264. String orderStandName = ruleBaseDTO.getBaseLibName();
  265. Map<String, List<Lis>> map = EntityUtil.makeEntityListMap(wordCrfDTO.getLis(), "uniqueName");
  266. List<Lis> lisList = map.get(orderStandName);
  267. if (ListUtil.isNotEmpty(lisList)) {
  268. sortByProperty(lisList, "dateValue");
  269. Lis lis = lisList.get(lisList.size() - 1); // 按时间排序,取最后一条
  270. Map<String, Object> lisMap = CoreUtil.compareLis(ruleBaseDTO, lis);
  271. if (CoreUtil.getMapFlag(lisMap)) {
  272. String dateValue = lis.getDateValue(); // 结果日期
  273. String orderDateValue = ruleSimpleDTO.getDateValue(); // 开单项日期
  274. int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false);
  275. if (flag == 1) { // 有效期范围内
  276. ruleSimpleDTO.setContent(CoreUtil.getMapMsg(lisMap));
  277. ruleSimpleDTO.setConType(conType);
  278. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  279. CoreUtil.addBeanToList(billMsgList, billMsg);
  280. }
  281. }
  282. }
  283. }
  284. /**
  285. * 正则匹配——推送
  286. *
  287. * @param content 文本内容
  288. * @param regex 表达式
  289. * @return
  290. */
  291. public void getRegexResPush(String content, String regex, List<Long> baseIdList, String ids) {
  292. // 是否有符合的数据
  293. boolean flag = RegexUtil.getRegexRes(content, regex);
  294. if (flag) {
  295. CoreUtil.addSplitString(baseIdList, ids);
  296. }
  297. }
  298. /**
  299. * 根据指定字段按照字符串排序
  300. *
  301. * @param tList
  302. * @param property
  303. * @param <T>
  304. */
  305. public <T> void sortByProperty(List<T> tList, String property) {
  306. if (ListUtil.isNotEmpty(tList) && tList.size() > 1) {
  307. // items 按照时间排序
  308. Collections.sort(tList, new Comparator<T>() {
  309. @Override
  310. public int compare(T o1, T o2) {
  311. String o1Str = (String) CoreUtil.getFieldValue(o1, property);
  312. String o2Str = (String) CoreUtil.getFieldValue(o2, property);
  313. if (StringUtil.isBlank(o1Str)) {
  314. return -1;
  315. }
  316. if (StringUtil.isBlank(o2Str)) {
  317. return 1;
  318. }
  319. return o1Str.compareTo(o2Str);
  320. }
  321. });
  322. }
  323. }
  324. /**
  325. * 24小时重复开单总入口
  326. *
  327. * @param wordCrfDTO
  328. * @param billMsgList
  329. */
  330. public void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
  331. repeat24BillWithType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName(), ConEnum.repeat24.getName()); // 化验重复开单
  332. repeat24BillWithType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName(), ConEnum.repeat24.getName()); // 辅检重复开单
  333. // repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName(), ConEnum.repeat24.getName()); // 药品重复开单
  334. // repeat24BillWithType(billMsgList, wordCrfDTO.getOperationOrder(), TypeEnum.operation.getName(), ConEnum.repeat24.getName()); // 手术重复开单
  335. // repeat24BillWithType(billMsgList, wordCrfDTO.getTransfusionOrder(), TypeEnum.transfusion.getName(), ConEnum.repeat24.getName()); // 输血重复开单
  336. }
  337. // /**
  338. // * 互斥开单项——辅检
  339. // *
  340. // * @param wordCrfDTO
  341. // * @param ruleBaseDTO
  342. // * @param billMsgList
  343. // * @param ruleSimpleDTO
  344. // * @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
  345. // */
  346. // public void exclusionBill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
  347. // // 辅检开单项互斥
  348. // List<Pacs> pacsOrder = wordCrfDTO.getPacsOrder();
  349. // if (ListUtil.isNotEmpty(pacsOrder) && pacsOrder.size() > 1) {
  350. // // 不同的辅检项目可能对应同一个uniqueName,提示显示多条
  351. // Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(pacsOrder, "uniqueName");
  352. // List<Pacs> orginNameList = map.get(ruleBaseDTO.getBaseLibName()); // 互斥名称
  353. // if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
  354. // for (Pacs pacs : orginNameList) {
  355. // String orginName = pacs.getName();
  356. // // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
  357. // if (!set.contains(ruleSimpleDTO.getLibName() + "******" + orginName)) {
  358. // set.add(ruleSimpleDTO.getLibName() + "******" + orginName);
  359. // set.add(orginName + "******" + ruleSimpleDTO.getLibName());
  360. // ruleSimpleDTO.setContent(orginName);
  361. // ruleSimpleDTO.setConType(conType);
  362. // BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  363. // CoreUtil.addBeanToList(billMsgList, billMsg);
  364. // }
  365. // }
  366. // }
  367. // }
  368. // }
  369. /**
  370. * 互斥开单项
  371. *
  372. * @param orderList 开单列表
  373. * @param ruleBaseDTO
  374. * @param billMsgList
  375. * @param ruleSimpleDTO
  376. * @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
  377. */
  378. public <T> void exclusionBill(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
  379. if (ListUtil.isNotEmpty(orderList) && orderList.size() > 1) {
  380. // 不同的项目可能对应同一个uniqueName,提示显示多条
  381. Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
  382. List<T> orginNameList = map.get(ruleBaseDTO.getBaseLibName());
  383. if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
  384. for (T bean : orginNameList) {
  385. String orginName = ReflectUtil.getProperty(bean, "name");
  386. // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
  387. if (!set.contains(ruleSimpleDTO.getLibName() + "******" + orginName)) {
  388. set.add(ruleSimpleDTO.getLibName() + "******" + orginName);
  389. set.add(orginName + "******" + ruleSimpleDTO.getLibName());
  390. ruleSimpleDTO.setContent(orginName);
  391. ruleSimpleDTO.setConType(conType);
  392. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  393. CoreUtil.addBeanToList(billMsgList, billMsg);
  394. }
  395. }
  396. }
  397. }
  398. }
  399. /**
  400. * 获取频次分组
  401. *
  402. * @param frequency
  403. * @return
  404. */
  405. public String getFrquenceType(String frequency) {
  406. if (StringUtil.isEmpty(frequency)) {
  407. frequency = "空";
  408. }
  409. List<DictionaryInfoDTO> listByGroupType = redisUtil.get(RedisEnum.frequency.getName());
  410. for (DictionaryInfoDTO dic : listByGroupType) {
  411. if (RegexUtil.getRegexRes(frequency, dic.getVal())) {
  412. return dic.getName();
  413. }
  414. }
  415. return "单次";
  416. }
  417. /**
  418. * 24小时重复开单入口
  419. *
  420. * @param billMsgList
  421. * @param itemList
  422. * @param type
  423. * @param conType 禁忌条件
  424. * @param <T>
  425. */
  426. public <T> void repeat24BillWithType(List<BillMsg> billMsgList, List<T> itemList, String type, String conType) {
  427. if (ListUtil.isEmpty(itemList)) {
  428. return;
  429. }
  430. Map<String, List<T>> map = CoreUtil.makeEntityListMap(itemList, "name", "uniqueName");
  431. for (String key : map.keySet()) {
  432. List<T> items = map.get(key);
  433. if (ListUtil.isNotEmpty(items) && items.size() > 1) {
  434. for (int i = 0; i < items.size() - 1; i++) {
  435. T it = items.get(i);
  436. String curDateValue = ReflectUtil.getProperty(it, "dateValue");
  437. if (StringUtil.isNotBlank(curDateValue)) {
  438. Date curDate = CatalogueUtil.parseStringDate(curDateValue);
  439. for (int j = i + 1; j < items.size(); j++) {
  440. T itNext = items.get(j);
  441. String nextDateValue = ReflectUtil.getProperty(itNext, "dateValue");
  442. if (StringUtil.isNotBlank(nextDateValue)) {
  443. Date nextDate = CatalogueUtil.parseStringDate(nextDateValue);
  444. if (!CatalogueUtil.compareTime(curDate, nextDate, 60L * 24, true)
  445. && getFrquenceType(ReflectUtil.getProperty(it, "frequency"))
  446. .equals(getFrquenceType(ReflectUtil.getProperty(itNext, "frequency")))) {
  447. String name = (String) CoreUtil.getFieldValue(it, "name");
  448. String uniqueName = (String) CoreUtil.getFieldValue(it, "uniqueName");
  449. RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO();
  450. ruleSimpleDTO.setInputName(name);
  451. ruleSimpleDTO.setLibName(uniqueName);
  452. ruleSimpleDTO.setLibTypeName(type);
  453. ruleSimpleDTO.setContent(name);
  454. ruleSimpleDTO.setConType(ConEnum.repeat24.getName());
  455. BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
  456. CoreUtil.addBeanToList(billMsgList, billMsg);
  457. break;
  458. }
  459. }
  460. }
  461. }
  462. }
  463. }
  464. }
  465. }
  466. /**
  467. * 高风险药品、手术
  468. *
  469. * @param ruleSimpleDTO
  470. * @param highRiskList
  471. */
  472. public void highRisk(RuleSimpleDTO ruleSimpleDTO, List<BillMsg> highRiskList) {
  473. BillMsg billMsg = MsgUtil.getCommonHighRiskMsg(ruleSimpleDTO.getMsg(),
  474. ruleSimpleDTO.getInputName(), ruleSimpleDTO.getLibTypeName());
  475. highRiskList.add(billMsg);
  476. }
  477. /**
  478. * 根据基础规则,通用
  479. *
  480. * @param wordCrfDTO
  481. */
  482. public List<Long> matchBase(WordCrfDTO wordCrfDTO, List<BaseDiagnoseDTO> baseList) {
  483. List<Long> baseIdList = new ArrayList<>();
  484. /**---------------------------数据统一处理开始--------------------------------- */
  485. // 【临床表现数据来源】(主诉、现病史)
  486. List<Clinical> clinicals = commonFacade.getClinicalSource(wordCrfDTO);
  487. /**---------------------------数据统一处理结束--------------------------------- */
  488. // 规则处理
  489. for (BaseDiagnoseDTO base : baseList) {
  490. RuleBaseDTO ruleBaseDTO = new RuleBaseDTO();
  491. BeanUtil.copyProperties(base, ruleBaseDTO);
  492. String baseIds = base.getIds();
  493. BaseDiagnoseTypeEnum baseEnum = BaseDiagnoseTypeEnum.getEnum(base.getBaseType());
  494. if (baseEnum == null) { // 防止报空指针
  495. continue;
  496. }
  497. switch (baseEnum) {
  498. case equals: // 等于术语本身
  499. switch (LexiconEnum.getEnum(base.getBaseLibType())) {
  500. case Symptom: // 症状
  501. compareNameWithPush(clinicals, ruleBaseDTO, baseIdList, baseIds);
  502. break;
  503. case Disease: // 疾病【病史】
  504. compareNameWithPush(wordCrfDTO.getPastLabel().getDiags(), ruleBaseDTO, baseIdList, baseIds);
  505. break;
  506. case VitalResult: // 体格检查结果
  507. vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
  508. break;
  509. case Group: // 人群
  510. groupRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
  511. break;
  512. case PacsResult: // 辅助检查结果
  513. compareItemWithPush(wordCrfDTO.getPacsLabel().getRes(), ruleBaseDTO, baseIdList, baseIds);
  514. break;
  515. }
  516. break;
  517. case compare: // 比较
  518. switch (LexiconEnum.getEnum(base.getBaseLibType())) {
  519. case LisSubName: // 化验
  520. lisRule.push(wordCrfDTO.getLis(), ruleBaseDTO, baseIdList, baseIds);
  521. break;
  522. case Age: // 年龄
  523. ageRule.push(wordCrfDTO, ruleBaseDTO, baseIdList, baseIds);
  524. break;
  525. case Vital: // 体格检查项目
  526. vitalRule.push(wordCrfDTO.getVitalLabel(), ruleBaseDTO, baseIdList, baseIds);
  527. break;
  528. }
  529. break;
  530. case regexChiefSymptom: // 主诉现病史正则
  531. getRegexResPush(wordCrfDTO.getChief() + wordCrfDTO.getSymptom(),
  532. base.getBaseEqValue(), baseIdList, baseIds);
  533. break;
  534. case regexPast: // 既往史正则
  535. getRegexResPush(wordCrfDTO.getPasts() + wordCrfDTO.getPersonal() + wordCrfDTO.getMenstrual() + wordCrfDTO.getMarital() + wordCrfDTO.getFamily(),
  536. base.getBaseEqValue(), baseIdList, baseIds);
  537. case regexVital: // 查体正则
  538. getRegexResPush(wordCrfDTO.getVital(),
  539. base.getBaseEqValue(), baseIdList, baseIds);
  540. case regexPacs: // 辅检正则
  541. if (ListUtil.isNotEmpty(wordCrfDTO.getPacs())) {
  542. String content = wordCrfDTO.getPacs().stream().map(r -> r.getResult())
  543. .filter(r -> StringUtil.isNotBlank(r)).collect(Collectors.joining("。"));
  544. getRegexResPush(content, base.getBaseEqValue(), baseIdList, baseIds);
  545. }
  546. break;
  547. }
  548. }
  549. Collections.sort(baseIdList); // id排序,方便调试查看
  550. return baseIdList;
  551. }
  552. public static void main(String[] args) {
  553. CommonRule commonRule = new CommonRule();
  554. System.out.println(commonRule.getFrquenceType(null));
  555. }
  556. }