|
@@ -9,6 +9,7 @@ import com.diagbot.dto.RuleBaseDTO;
|
|
|
import com.diagbot.dto.RuleSimpleDTO;
|
|
|
import com.diagbot.dto.WordCrfDTO;
|
|
|
import com.diagbot.enums.BaseDiagnoseTypeEnum;
|
|
|
+import com.diagbot.enums.CommonEnum;
|
|
|
import com.diagbot.enums.ConEnum;
|
|
|
import com.diagbot.enums.LexiconEnum;
|
|
|
import com.diagbot.enums.RedisEnum;
|
|
@@ -18,7 +19,6 @@ import com.diagbot.facade.KlDictionaryInfoFacade;
|
|
|
import com.diagbot.model.entity.Clinical;
|
|
|
import com.diagbot.model.entity.Negative;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
-import com.diagbot.util.CatalogueUtil;
|
|
|
import com.diagbot.util.CoreUtil;
|
|
|
import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
@@ -28,6 +28,7 @@ import com.diagbot.util.RedisUtil;
|
|
|
import com.diagbot.util.ReflectUtil;
|
|
|
import com.diagbot.util.RegexUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -35,7 +36,6 @@ import org.springframework.stereotype.Component;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
-import java.util.Date;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -250,12 +250,15 @@ public class CommonRule {
|
|
|
if (ListUtil.isNotEmpty(pacsList)) {
|
|
|
sortByProperty(pacsList, "dateValue");
|
|
|
Pacs pacs = pacsList.get(pacsList.size() - 1); // 按时间排序,取最后一条
|
|
|
+ if (StringUtil.isNotBlank(pacs.getName())) {
|
|
|
+ ruleSimpleDTO.setStructName(pacs.getName());
|
|
|
+ }
|
|
|
String result = pacs.getResult();
|
|
|
if (StringUtil.isNotBlank(result) && StringUtil.isNotBlank(ruleBaseDTO.getBaseEqValue())
|
|
|
&& RegexUtil.getRegexRes(result, ruleBaseDTO.getBaseEqValue())) {
|
|
|
String dateValue = pacs.getDateValue(); // 结果日期
|
|
|
String orderDateValue = ruleSimpleDTO.getDateValue(); // 开单项日期
|
|
|
- int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false);
|
|
|
+ int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false, false);
|
|
|
if (flag == 1) {
|
|
|
ruleSimpleDTO.setContent(result);
|
|
|
ruleSimpleDTO.setConType(conType);
|
|
@@ -285,7 +288,7 @@ public class CommonRule {
|
|
|
if (CoreUtil.getMapFlag(lisMap)) {
|
|
|
String dateValue = lis.getDateValue(); // 结果日期
|
|
|
String orderDateValue = ruleSimpleDTO.getDateValue(); // 开单项日期
|
|
|
- int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false);
|
|
|
+ int flag = CoreUtil.compareTime(dateValue, orderDateValue, 60L * 24 * 7, false, false);
|
|
|
if (flag == 1) { // 有效期范围内
|
|
|
ruleSimpleDTO.setContent(CoreUtil.getMapMsg(lisMap));
|
|
|
ruleSimpleDTO.setConType(conType);
|
|
@@ -345,76 +348,103 @@ public class CommonRule {
|
|
|
* @param billMsgList
|
|
|
*/
|
|
|
public void repeat24Bill(WordCrfDTO wordCrfDTO, List<BillMsg> billMsgList) {
|
|
|
- repeat24BillWithType(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName(), ConEnum.repeat24.getName()); // 化验重复开单
|
|
|
- repeat24BillWithType(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName(), ConEnum.repeat24.getName()); // 辅检重复开单
|
|
|
+ // 当前开单项与当前开单项重复开立
|
|
|
+ repeat24BillWithOrder(billMsgList, wordCrfDTO.getLisOrder(), TypeEnum.lis.getName(), ConEnum.repeat24.getName()); // 化验重复开单
|
|
|
+ repeat24BillWithOrder(billMsgList, wordCrfDTO.getPacsOrder(), TypeEnum.pacs.getName(), ConEnum.repeat24.getName()); // 辅检重复开单
|
|
|
// repeat24BillWithType(billMsgList, wordCrfDTO.getDrugOrder(), TypeEnum.drug.getName(), ConEnum.repeat24.getName()); // 药品重复开单
|
|
|
// repeat24BillWithType(billMsgList, wordCrfDTO.getOperationOrder(), TypeEnum.operation.getName(), ConEnum.repeat24.getName()); // 手术重复开单
|
|
|
// repeat24BillWithType(billMsgList, wordCrfDTO.getTransfusionOrder(), TypeEnum.transfusion.getName(), ConEnum.repeat24.getName()); // 输血重复开单
|
|
|
- }
|
|
|
|
|
|
- // /**
|
|
|
- // * 互斥开单项——辅检
|
|
|
- // *
|
|
|
- // * @param wordCrfDTO
|
|
|
- // * @param ruleBaseDTO
|
|
|
- // * @param billMsgList
|
|
|
- // * @param ruleSimpleDTO
|
|
|
- // * @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
|
|
|
- // */
|
|
|
- // public void exclusionBill(WordCrfDTO wordCrfDTO, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
|
|
|
- // // 辅检开单项互斥
|
|
|
- // List<Pacs> pacsOrder = wordCrfDTO.getPacsOrder();
|
|
|
- // if (ListUtil.isNotEmpty(pacsOrder) && pacsOrder.size() > 1) {
|
|
|
- // // 不同的辅检项目可能对应同一个uniqueName,提示显示多条
|
|
|
- // Map<String, List<Pacs>> map = EntityUtil.makeEntityListMap(pacsOrder, "uniqueName");
|
|
|
- // List<Pacs> orginNameList = map.get(ruleBaseDTO.getBaseLibName()); // 互斥名称
|
|
|
- // if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
|
|
|
- // for (Pacs pacs : orginNameList) {
|
|
|
- // String orginName = pacs.getName();
|
|
|
- // // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
|
|
|
- // if (!set.contains(ruleSimpleDTO.getLibName() + "******" + orginName)) {
|
|
|
- // set.add(ruleSimpleDTO.getLibName() + "******" + orginName);
|
|
|
- // set.add(orginName + "******" + ruleSimpleDTO.getLibName());
|
|
|
- // ruleSimpleDTO.setContent(orginName);
|
|
|
- // ruleSimpleDTO.setConType(conType);
|
|
|
- // BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
- // CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
+ // 当前开单项和结构化开单项重复开立
|
|
|
+ repeat24BillWithStruct(billMsgList, wordCrfDTO.getLisOrder(), wordCrfDTO.getLis(), TypeEnum.lis.getName(), ConEnum.repeat24.getName()); // 化验重复开单
|
|
|
+ repeat24BillWithStruct(billMsgList, wordCrfDTO.getPacsOrder(), wordCrfDTO.getPacs(), TypeEnum.pacs.getName(), ConEnum.repeat24.getName()); // 辅检重复开单
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
- * 互斥开单项
|
|
|
+ * 互斥开单项(结构化)
|
|
|
*
|
|
|
- * @param orderList 开单列表
|
|
|
+ * @param orderList 开单列表
|
|
|
* @param ruleBaseDTO
|
|
|
* @param billMsgList
|
|
|
* @param ruleSimpleDTO
|
|
|
* @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
|
|
|
*/
|
|
|
- public <T> void exclusionBill(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
|
|
|
+ public <T> void exclusionBillOrder(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
|
|
|
if (ListUtil.isNotEmpty(orderList) && orderList.size() > 1) {
|
|
|
+ String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
|
|
|
+ String libName = ruleSimpleDTO.getLibName(); // 标准名称
|
|
|
+ String inputName = ruleSimpleDTO.getInputName(); // 医院名称
|
|
|
+ // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
|
|
|
+ if (libName.equals(baseLibName)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 不同的项目可能对应同一个uniqueName,提示显示多条
|
|
|
+ Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
|
|
|
+ List<T> orginNameList = map.get(baseLibName);
|
|
|
+ if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
|
|
|
+ for (T bean : orginNameList) {
|
|
|
+ String orginName = ReflectUtil.getProperty(bean, "name");
|
|
|
+ // A与B不宜同时进行, B与A不宜同时进行,只能提示一个
|
|
|
+ if (!set.contains(inputName + CommonEnum.splitSymbol.getName() + orginName)) {
|
|
|
+ set.add(inputName + CommonEnum.splitSymbol.getName() + orginName);
|
|
|
+ set.add(orginName + CommonEnum.splitSymbol.getName() + inputName);
|
|
|
+ ruleSimpleDTO.setContent(orginName);
|
|
|
+ ruleSimpleDTO.setConType(conType);
|
|
|
+ BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
+ CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 互斥开单项(结构化)
|
|
|
+ *
|
|
|
+ * @param orderList 开单列表
|
|
|
+ * @param ruleBaseDTO
|
|
|
+ * @param billMsgList
|
|
|
+ * @param ruleSimpleDTO
|
|
|
+ * @param set 用于记录:A与B不宜同时进行, B与A不宜同时进行 只能提示一个
|
|
|
+ */
|
|
|
+ public <T> void exclusionBillStruct(List<T> orderList, RuleBaseDTO ruleBaseDTO, List<BillMsg> billMsgList, String conType, RuleSimpleDTO ruleSimpleDTO, Set<String> set) {
|
|
|
+ if (ListUtil.isNotEmpty(orderList)) {
|
|
|
+ String baseLibName = ruleBaseDTO.getBaseLibName(); // 互斥名称
|
|
|
+ String libName = ruleSimpleDTO.getLibName(); // 标准名称
|
|
|
+ // 加入集合后,会出现自己与自己互斥的数据,这些数据不提示
|
|
|
+ if (libName.equals(baseLibName)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 不同的项目可能对应同一个uniqueName,提示显示多条
|
|
|
Map<String, List<T>> map = EntityUtil.makeEntityListMap(orderList, "uniqueName");
|
|
|
List<T> orginNameList = map.get(ruleBaseDTO.getBaseLibName());
|
|
|
if (map.get(ruleBaseDTO.getBaseLibName()) != null) {
|
|
|
for (T bean : orginNameList) {
|
|
|
- String orderDateValue = ReflectUtil.getProperty(ruleSimpleDTO, "dateValue");
|
|
|
- String beanDateValue = ReflectUtil.getProperty(bean, "dateValue");
|
|
|
- int dateFlag = CoreUtil.compareTime(beanDateValue, orderDateValue);
|
|
|
- if (dateFlag == 1) {
|
|
|
- String orginName = ReflectUtil.getProperty(bean, "name");
|
|
|
- // A与B不宜同时进行, B与A不宜同时进行 只能提示一个
|
|
|
- // if (!set.contains(ruleSimpleDTO.getLibName() + "******" + orginName)) {
|
|
|
- // set.add(ruleSimpleDTO.getLibName() + "******" + orginName);
|
|
|
- // set.add(orginName + "******" + ruleSimpleDTO.getLibName());
|
|
|
- ruleSimpleDTO.setContent(orginName);
|
|
|
- ruleSimpleDTO.setConType(conType);
|
|
|
- BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
- CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
- // }
|
|
|
+ // 化验明细项不为空的数据,说明是细项,舍弃
|
|
|
+ if (TypeEnum.lis.getName().equals(ruleSimpleDTO.getLibTypeName())) {
|
|
|
+ String detailName = ReflectUtil.getProperty(bean, "detailName");
|
|
|
+ if (StringUtil.isNotBlank(detailName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String finishDateValue = ReflectUtil.getProperty(bean, "finishDateValue");
|
|
|
+ // 报告时间为空,再比较时间间隔
|
|
|
+ if (StringUtil.isBlank(finishDateValue)) {
|
|
|
+ String orderDateValue = ReflectUtil.getProperty(ruleSimpleDTO, "dateValue");
|
|
|
+ String beanDateValue = ReflectUtil.getProperty(bean, "dateValue");
|
|
|
+ int dateFlag = CoreUtil.compareTime(beanDateValue, orderDateValue, 60L * 24, false, false);
|
|
|
+ if (dateFlag == 1) {
|
|
|
+ String orginName = ReflectUtil.getProperty(bean, "name");
|
|
|
+ // A与B不宜同时进行, B与A不宜同时进行,只能提示一个
|
|
|
+ if (!set.contains(libName + CommonEnum.splitSymbol.getName() + orginName)) {
|
|
|
+ set.add(libName + CommonEnum.splitSymbol.getName() + orginName);
|
|
|
+ set.add(orginName + CommonEnum.splitSymbol.getName() + libName);
|
|
|
+ ruleSimpleDTO.setContent(orginName);
|
|
|
+ ruleSimpleDTO.setConType(conType);
|
|
|
+ BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
+ CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -441,7 +471,7 @@ public class CommonRule {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 24小时重复开单入口
|
|
|
+ * 24小时重复开单入口——与开单项比较
|
|
|
*
|
|
|
* @param billMsgList
|
|
|
* @param itemList
|
|
@@ -449,10 +479,11 @@ public class CommonRule {
|
|
|
* @param conType 禁忌条件
|
|
|
* @param <T>
|
|
|
*/
|
|
|
- public <T> void repeat24BillWithType(List<BillMsg> billMsgList, List<T> itemList, String type, String conType) {
|
|
|
+ public <T> void repeat24BillWithOrder(List<BillMsg> billMsgList, List<T> itemList, String type, String conType) {
|
|
|
if (ListUtil.isEmpty(itemList)) {
|
|
|
return;
|
|
|
}
|
|
|
+ // name+uniqueName 作为key(备注:标准名称相同,医院名称不同,认为是不同的开单项)
|
|
|
Map<String, List<T>> map = CoreUtil.makeEntityListMap(itemList, "name", "uniqueName");
|
|
|
for (String key : map.keySet()) {
|
|
|
List<T> items = map.get(key);
|
|
@@ -462,23 +493,17 @@ public class CommonRule {
|
|
|
T it = items.get(i);
|
|
|
String curDateValue = ReflectUtil.getProperty(it, "dateValue");
|
|
|
if (StringUtil.isNotBlank(curDateValue)) {
|
|
|
- Date curDate = CatalogueUtil.parseStringDate(curDateValue);
|
|
|
for (int j = i + 1; j < items.size(); j++) {
|
|
|
T itNext = items.get(j);
|
|
|
String nextDateValue = ReflectUtil.getProperty(itNext, "dateValue");
|
|
|
if (StringUtil.isNotBlank(nextDateValue)) {
|
|
|
- Date nextDate = CatalogueUtil.parseStringDate(nextDateValue);
|
|
|
- if (!CatalogueUtil.compareTime(curDate, nextDate, 60L * 24, true)
|
|
|
+ int dateFlag = CoreUtil.compareTime(curDateValue, nextDateValue, 60L * 24, false, true);
|
|
|
+ if (dateFlag == 1
|
|
|
&& getFrquenceType(ReflectUtil.getProperty(it, "frequency"))
|
|
|
.equals(getFrquenceType(ReflectUtil.getProperty(itNext, "frequency")))) {
|
|
|
String name = (String) CoreUtil.getFieldValue(it, "name");
|
|
|
String uniqueName = (String) CoreUtil.getFieldValue(it, "uniqueName");
|
|
|
- RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO();
|
|
|
- ruleSimpleDTO.setInputName(name);
|
|
|
- ruleSimpleDTO.setLibName(uniqueName);
|
|
|
- ruleSimpleDTO.setLibTypeName(type);
|
|
|
- ruleSimpleDTO.setContent(name);
|
|
|
- ruleSimpleDTO.setConType(ConEnum.repeat24.getName());
|
|
|
+ RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(name, uniqueName, type, name, conType);
|
|
|
BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
break;
|
|
@@ -491,6 +516,56 @@ public class CommonRule {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 24小时重复开单——与结构化比较
|
|
|
+ *
|
|
|
+ * @param billMsgList
|
|
|
+ * @param orderList
|
|
|
+ * @param itemList
|
|
|
+ * @param type
|
|
|
+ * @param conType
|
|
|
+ * @param <T>
|
|
|
+ */
|
|
|
+ public <T> void repeat24BillWithStruct(List<BillMsg> billMsgList, List<T> orderList, List<T> itemList, String type, String conType) {
|
|
|
+ if (ListUtil.isEmpty(itemList) || ListUtil.isEmpty(orderList)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // name+uniqueName 作为key(备注:标准名称相同,医院名称不同,认为是不同的开单项)
|
|
|
+ Map<String, List<T>> map = CoreUtil.makeEntityListMap(itemList, "name", "uniqueName");
|
|
|
+ for (T order : orderList) {
|
|
|
+ String orderName = ReflectUtil.getProperty(order, "name");
|
|
|
+ String orderUniqueName = ReflectUtil.getProperty(order, "uniqueName");
|
|
|
+ List<T> items = map.get(orderName + CommonEnum.splitSymbol.getName() + orderUniqueName);
|
|
|
+ if (ListUtil.isNotEmpty(items)) {
|
|
|
+ for (T it : items) {
|
|
|
+ // 化验明细项不为空的数据,说明是细项,舍弃
|
|
|
+ if (TypeEnum.lis.getName().equals(type)) {
|
|
|
+ String detailName = ReflectUtil.getProperty(order, "detailName");
|
|
|
+ if (StringUtil.isNotBlank(detailName)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String finishDateValue = ReflectUtil.getProperty(it, "finishDateValue");
|
|
|
+ // 报告时间为空,再比较时间间隔
|
|
|
+ if (StringUtil.isBlank(finishDateValue)) {
|
|
|
+ String curDateValue = ReflectUtil.getProperty(order, "dateValue"); // 当前开单时间
|
|
|
+ String pastDateValue = ReflectUtil.getProperty(it, "dateValue"); // 历史开单时间
|
|
|
+ int dateFlag = CoreUtil.compareTime(pastDateValue, curDateValue, 60L * 24, false, false);
|
|
|
+ // 规定时间内,并且频次相同
|
|
|
+ if (dateFlag == 1 &&
|
|
|
+ getFrquenceType(ReflectUtil.getProperty(it, "frequency"))
|
|
|
+ .equals(getFrquenceType(ReflectUtil.getProperty(it, "frequency")))) {
|
|
|
+ RuleSimpleDTO ruleSimpleDTO = new RuleSimpleDTO(orderName, orderUniqueName, type, orderName, conType);
|
|
|
+ BillMsg billMsg = msgNewUtil.getCommonBillMsg(ruleSimpleDTO);
|
|
|
+ CoreUtil.addBeanToList(billMsgList, billMsg);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 高风险药品、手术
|
|
|
*
|
|
@@ -581,7 +656,14 @@ public class CommonRule {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- CommonRule commonRule = new CommonRule();
|
|
|
- System.out.println(commonRule.getFrquenceType(null));
|
|
|
+ List<Lis> lisList = Lists.newArrayList();
|
|
|
+ Lis lis = new Lis();
|
|
|
+ lis.setName("血常规");
|
|
|
+ lis.setUniqueName(null);
|
|
|
+ lisList.add(lis);
|
|
|
+ Map<String, List<Lis>> map = lisList.stream().collect(Collectors.groupingBy(r -> {
|
|
|
+ return "333";
|
|
|
+ }));
|
|
|
+ System.out.println(map);
|
|
|
}
|
|
|
}
|