|
@@ -1,13 +1,25 @@
|
|
|
package com.diagbot.rule;
|
|
|
|
|
|
+import com.diagbot.biz.push.entity.Item;
|
|
|
+import com.diagbot.biz.push.entity.Lis;
|
|
|
+import com.diagbot.biz.push.entity.Pacs;
|
|
|
import com.diagbot.dto.BillMsg;
|
|
|
import com.diagbot.dto.BillNeoMaxDTO;
|
|
|
import com.diagbot.dto.NodeNeoDTO;
|
|
|
+import com.diagbot.dto.WordCrfDTO;
|
|
|
+import com.diagbot.enums.TypeEnum;
|
|
|
import com.diagbot.model.entity.Negative;
|
|
|
+import com.diagbot.util.CatalogueUtil;
|
|
|
import com.diagbot.util.CoreUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.Comparator;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -51,4 +63,189 @@ public class CommonRule {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 24小时重复开单总入口
|
|
|
+ *
|
|
|
+ * @param wordCrfDTO
|
|
|
+ * @param billMsgList
|
|
|
+ */
|
|
|
+ public static void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
|
|
|
+ // repeat24BillWithLisType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName()); // 化验重复开单
|
|
|
+ repeat24BillWithPacsType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName()); // 辅检重复开单
|
|
|
+ repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName()); // 药品重复开单
|
|
|
+ repeat24BillWithType(billMsgList, wordCrfDTO.getOperationOrder(), TypeEnum.operation.getName()); // 手术重复开单
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 24小时重复开单入口(化验)
|
|
|
+ *
|
|
|
+ * @param billMsgList
|
|
|
+ * @param itemList
|
|
|
+ * @param type
|
|
|
+ */
|
|
|
+ public static <T> void repeat24BillWithPacsType(List<BillMsg> billMsgList, List<Pacs> itemList, String type) {
|
|
|
+ if (ListUtil.isEmpty(itemList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ List<Pacs> items = map.get(key);
|
|
|
+
|
|
|
+ // 个数大于2个才比较
|
|
|
+ if (ListUtil.isNotEmpty(items) && items.size() > 1) {
|
|
|
+ // items 按照时间排序
|
|
|
+ Collections.sort(items, new Comparator<Pacs>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Pacs o1, Pacs o2) {
|
|
|
+ if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return o1.getDateValue().compareTo(o2.getDateValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 比较时间是否在24小时内
|
|
|
+ List<Date> dateList = new ArrayList<>();
|
|
|
+ for (Pacs it : items) {
|
|
|
+ if (StringUtil.isNotBlank(it.getDateValue())) {
|
|
|
+ Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
|
|
|
+ // 如果为null,说明日期格式出错,不比较
|
|
|
+ if (cur != null) {
|
|
|
+ if (ListUtil.isNotEmpty(dateList)) {
|
|
|
+ Date last = dateList.get(dateList.size() - 1);
|
|
|
+ if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
|
|
|
+ BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
|
|
|
+ it.getName(), it.getUniqueName(),
|
|
|
+ it.getName(), type);
|
|
|
+ billMsgList.add(commonBillMsg);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 24小时重复开单入口(化验)
|
|
|
+ *
|
|
|
+ * @param billMsgList
|
|
|
+ * @param itemList
|
|
|
+ * @param type
|
|
|
+ */
|
|
|
+ public static <T> void repeat24BillWithLisType(List<BillMsg> billMsgList, List<Lis> itemList, String type) {
|
|
|
+ if (ListUtil.isEmpty(itemList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ Map<String, List<Lis>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ List<Lis> items = map.get(key);
|
|
|
+
|
|
|
+ // 个数大于2个才比较
|
|
|
+ if (ListUtil.isNotEmpty(items) && items.size() > 1) {
|
|
|
+ // items 按照时间排序
|
|
|
+ Collections.sort(items, new Comparator<Lis>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Lis o1, Lis o2) {
|
|
|
+ if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return o1.getDateValue().compareTo(o2.getDateValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 比较时间是否在24小时内
|
|
|
+ List<Date> dateList = new ArrayList<>();
|
|
|
+ for (Lis it : items) {
|
|
|
+ if (StringUtil.isNotBlank(it.getDateValue())) {
|
|
|
+ Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
|
|
|
+ // 如果为null,说明日期格式出错,不比较
|
|
|
+ if (cur != null) {
|
|
|
+ if (ListUtil.isNotEmpty(dateList)) {
|
|
|
+ Date last = dateList.get(dateList.size() - 1);
|
|
|
+ if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
|
|
|
+ BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
|
|
|
+ it.getName(), it.getUniqueName(),
|
|
|
+ it.getName(), type);
|
|
|
+ billMsgList.add(commonBillMsg);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 24小时重复开单入口
|
|
|
+ *
|
|
|
+ * @param billMsgList
|
|
|
+ * @param itemList
|
|
|
+ * @param type
|
|
|
+ */
|
|
|
+ public static void repeat24BillWithType(List<BillMsg> billMsgList, List<Item> itemList, String type) {
|
|
|
+ if (ListUtil.isEmpty(itemList)) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ Map<String, List<Item>> map = EntityUtil.makeEntityListMap(itemList, "uniqueName");
|
|
|
+ for (String key : map.keySet()) {
|
|
|
+ List<Item> items = map.get(key);
|
|
|
+
|
|
|
+ // 个数大于2个才比较
|
|
|
+ if (ListUtil.isNotEmpty(items) && items.size() > 1) {
|
|
|
+ // items 按照时间排序
|
|
|
+ Collections.sort(items, new Comparator<Item>() {
|
|
|
+ @Override
|
|
|
+ public int compare(Item o1, Item o2) {
|
|
|
+ if (StringUtil.isBlank(o1.getDateValue()) || StringUtil.isBlank(o2.getDateValue())) {
|
|
|
+ return -1;
|
|
|
+ } else {
|
|
|
+ return o1.getDateValue().compareTo(o2.getDateValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 比较时间是否在24小时内
|
|
|
+ List<Date> dateList = new ArrayList<>();
|
|
|
+ for (Item it : items) {
|
|
|
+ if (StringUtil.isNotBlank(it.getDateValue())) {
|
|
|
+ Date cur = CatalogueUtil.parseStringDate(it.getDateValue());
|
|
|
+ // 如果为null,说明日期格式出错,不比较
|
|
|
+ if (cur != null) {
|
|
|
+ if (ListUtil.isNotEmpty(dateList)) {
|
|
|
+ Date last = dateList.get(dateList.size() - 1);
|
|
|
+ if (!CatalogueUtil.compareTime(last, cur, 60L * 24)) {
|
|
|
+ BillMsg commonBillMsg = CoreUtil.getBillMsg24Repeat(
|
|
|
+ it.getName(), it.getUniqueName(),
|
|
|
+ it.getName(), type);
|
|
|
+ billMsgList.add(commonBillMsg);
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dateList.add(cur);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|