|
@@ -1,15 +1,20 @@
|
|
package com.diagbot.facade;
|
|
package com.diagbot.facade;
|
|
|
|
|
|
import com.diagbot.dto.DictionaryInfoDTO;
|
|
import com.diagbot.dto.DictionaryInfoDTO;
|
|
-import com.diagbot.entity.node.BillItem;
|
|
|
|
import com.diagbot.entity.node.BillConcept;
|
|
import com.diagbot.entity.node.BillConcept;
|
|
import com.diagbot.entity.node.BillCondition;
|
|
import com.diagbot.entity.node.BillCondition;
|
|
|
|
+import com.diagbot.entity.node.BillItem;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
import com.diagbot.repository.BillManRepository;
|
|
import com.diagbot.repository.BillManRepository;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.EntityUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
|
+import com.diagbot.vo.BillPageVO;
|
|
|
|
+import com.diagbot.vo.BillSaveVO;
|
|
import com.diagbot.vo.ConceptIndexVO;
|
|
import com.diagbot.vo.ConceptIndexVO;
|
|
import com.diagbot.vo.ConditionIndexVO;
|
|
import com.diagbot.vo.ConditionIndexVO;
|
|
-import com.diagbot.vo.BillPageVO;
|
|
|
|
|
|
+import com.diagbot.vo.RelationIdVO;
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
@@ -62,6 +67,10 @@ public class BillManFacade {
|
|
billPageVO.getConditionName(),
|
|
billPageVO.getConditionName(),
|
|
billPageVO.getRelationStatus(),
|
|
billPageVO.getRelationStatus(),
|
|
pageable);
|
|
pageable);
|
|
|
|
+
|
|
|
|
+ for(BillItem billItem:page.getContent()){
|
|
|
|
+ billItem.setRuleName(billItem.getRuleName()+"test");
|
|
|
|
+ }
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -74,6 +83,7 @@ public class BillManFacade {
|
|
public List<BillCondition> conditionIndex(ConditionIndexVO conditionIndexVO) {
|
|
public List<BillCondition> conditionIndex(ConditionIndexVO conditionIndexVO) {
|
|
List<DictionaryInfoDTO> dicTypeConvert = dictionaryFacade.getListByGroupType(8);
|
|
List<DictionaryInfoDTO> dicTypeConvert = dictionaryFacade.getListByGroupType(8);
|
|
List<DictionaryInfoDTO> dicIndicationManType = dictionaryFacade.getListByGroupType(11);
|
|
List<DictionaryInfoDTO> dicIndicationManType = dictionaryFacade.getListByGroupType(11);
|
|
|
|
+ List<DictionaryInfoDTO> dicBillConditionType = dictionaryFacade.getListByGroupType(12);
|
|
Map<String, String> dicTypeConvertMap
|
|
Map<String, String> dicTypeConvertMap
|
|
= EntityUtil.makeMapWithKeyValue(dicTypeConvert, "name", "val");
|
|
= EntityUtil.makeMapWithKeyValue(dicTypeConvert, "name", "val");
|
|
Map<String, String> dicIndicationManTypeMap
|
|
Map<String, String> dicIndicationManTypeMap
|
|
@@ -82,9 +92,15 @@ public class BillManFacade {
|
|
&& dicTypeConvertMap.containsKey(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString()))) {
|
|
&& dicTypeConvertMap.containsKey(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString()))) {
|
|
conditionIndexVO.setConceptLabel(dicTypeConvertMap.get(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString())));
|
|
conditionIndexVO.setConceptLabel(dicTypeConvertMap.get(dicIndicationManTypeMap.get(conditionIndexVO.getType().toString())));
|
|
}
|
|
}
|
|
- List<String> relationTypes = billManRepository.getRelationTypes(conditionIndexVO.getConceptLabel());
|
|
|
|
- List<String> conditionLabels = Lists.newArrayList();
|
|
|
|
//条件明细筛选范围
|
|
//条件明细筛选范围
|
|
|
|
+ List<String> conditionLabels = Lists.newArrayList();
|
|
|
|
+ /*if (ListUtil.isNotEmpty(dicBillConditionType)) {
|
|
|
|
+ conditionLabels = dicBillConditionType.stream()
|
|
|
|
+ .map(i -> i.getName())
|
|
|
|
+ .distinct()
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ }*/
|
|
|
|
+ List<String> relationTypes = billManRepository.getRelationTypes(conditionIndexVO.getConceptLabel());
|
|
if (ListUtil.isNotEmpty(relationTypes)) {
|
|
if (ListUtil.isNotEmpty(relationTypes)) {
|
|
for (String relationType : relationTypes) {
|
|
for (String relationType : relationTypes) {
|
|
int index = relationType.indexOf("禁忌");
|
|
int index = relationType.indexOf("禁忌");
|
|
@@ -97,7 +113,7 @@ public class BillManFacade {
|
|
List<BillCondition> notInConditions
|
|
List<BillCondition> notInConditions
|
|
= billManRepository.getNotInConditions(conditionIndexVO.getConceptName(), conditionIndexVO.getConceptLabel());
|
|
= billManRepository.getNotInConditions(conditionIndexVO.getConceptName(), conditionIndexVO.getConceptLabel());
|
|
List<Long> notInIds = Lists.newArrayList();
|
|
List<Long> notInIds = Lists.newArrayList();
|
|
- if (ListUtil.isNotEmpty(notInConditions) && conditionIndexVO.getRuleType().equals("文本类型")) {
|
|
|
|
|
|
+ if (ListUtil.isNotEmpty(notInConditions)) {
|
|
notInIds = notInConditions.stream().map(i -> i.getId()).distinct().collect(Collectors.toList());
|
|
notInIds = notInConditions.stream().map(i -> i.getId()).distinct().collect(Collectors.toList());
|
|
}
|
|
}
|
|
List<BillCondition> conditions = billManRepository.conditionIndex(conditionLabels,
|
|
List<BillCondition> conditions = billManRepository.conditionIndex(conditionLabels,
|
|
@@ -135,4 +151,121 @@ public class BillManFacade {
|
|
|
|
|
|
return concepts;
|
|
return concepts;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询单条规则
|
|
|
|
+ *
|
|
|
|
+ * @param relationIdVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public BillSaveVO getRecordByRelationId(RelationIdVO relationIdVO) {
|
|
|
|
+ BillSaveVO billSaveVO = new BillSaveVO();
|
|
|
|
+ BillConcept billConcept = new BillConcept();
|
|
|
|
+ BillCondition billCondition = new BillCondition();
|
|
|
|
+
|
|
|
|
+ List<DictionaryInfoDTO> dicTypeConvert = dictionaryFacade.getListByGroupType(8);
|
|
|
|
+ List<DictionaryInfoDTO> dicIndicationManType = dictionaryFacade.getListByGroupType(11);
|
|
|
|
+ Map<String, String> dicTypeConvertMap
|
|
|
|
+ = EntityUtil.makeMapWithKeyValue(dicTypeConvert, "val", "name");
|
|
|
|
+ Map<String, String> dicIndicationManTypeMap
|
|
|
|
+ = EntityUtil.makeMapWithKeyValue(dicIndicationManType, "name", "val");
|
|
|
|
+ BillItem billItem = billManRepository.getRecordByRelationId(relationIdVO.getRelationId());
|
|
|
|
+ if (billItem != null) {
|
|
|
|
+ billConcept.setId(billItem.getConceptId());
|
|
|
|
+ billConcept.setName(billItem.getConceptName());
|
|
|
|
+ billConcept.setConceptLabel(billItem.getConceptLabel());
|
|
|
|
+ billConcept.setStatus(billItem.getConceptStatus());
|
|
|
|
+
|
|
|
|
+ billCondition.setId(billItem.getConditionId());
|
|
|
|
+ billCondition.setName(billItem.getConditionName());
|
|
|
|
+ billCondition.setConditionLabel(billItem.getConditionLabel());
|
|
|
|
+ billCondition.setMaxValue(billItem.getConditionMaxValue());
|
|
|
|
+ billCondition.setMinValue(billItem.getConditionMinValue());
|
|
|
|
+ billCondition.setUnit(billItem.getConditionUnit());
|
|
|
|
+ billCondition.setRange(billItem.getConditionRange());
|
|
|
|
+ billCondition.setStatus(billItem.getConditionStatus());
|
|
|
|
+
|
|
|
|
+ if (dicTypeConvertMap.containsKey(billItem.getConceptLabel())
|
|
|
|
+ && dicIndicationManTypeMap.containsKey(dicTypeConvertMap.get(billItem.getConceptLabel()))) {
|
|
|
|
+ billSaveVO.setType(Integer.valueOf(dicIndicationManTypeMap.get(dicTypeConvertMap.get(billItem.getConceptLabel()))));
|
|
|
|
+ }
|
|
|
|
+ billSaveVO.setRuleType(billItem.getRuleType());
|
|
|
|
+ billSaveVO.setRuleName(billCondition.getName() + "开单" + billConcept.getName());
|
|
|
|
+ billSaveVO.setRelationId(billItem.getRelationId());
|
|
|
|
+ billSaveVO.setRelationName(billItem.getRelationName());
|
|
|
|
+ billSaveVO.setRelationStatus(billItem.getRelationStatus());
|
|
|
|
+ billSaveVO.setConcept(billConcept);
|
|
|
|
+ billSaveVO.setCondition(billCondition);
|
|
|
|
+ }
|
|
|
|
+ return billSaveVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Boolean saveRecord(BillSaveVO billSaveVO) {
|
|
|
|
+ //验证关系是否已存在
|
|
|
|
+ //开单项-[]->条件明细
|
|
|
|
+ //开单项-[]->开单项+禁忌+条件明细
|
|
|
|
+ String relationType = billSaveVO.getConcept().getConceptLabel() + "禁忌" + billSaveVO.getCondition().getConditionLabel();
|
|
|
|
+ BillItem existRelation = billManRepository.isExistRelation(billSaveVO.getConcept().getName(),
|
|
|
|
+ billSaveVO.getCondition().getName(),
|
|
|
|
+ relationType);
|
|
|
|
+ BillCondition existCondition = billManRepository.isExistCondition(billSaveVO.getConcept().getName(),
|
|
|
|
+ billSaveVO.getConcept().getConceptLabel(),
|
|
|
|
+ relationType,
|
|
|
|
+ billSaveVO.getCondition().getName(),
|
|
|
|
+ billSaveVO.getCondition().getConditionLabel());
|
|
|
|
+ //新增已存在
|
|
|
|
+ if (billSaveVO.getRelationId() == null
|
|
|
|
+ && existRelation != null) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在,不允许重复添加");
|
|
|
|
+ }
|
|
|
|
+ //修改成已存在规则
|
|
|
|
+ if (billSaveVO.getRelationId() != null
|
|
|
|
+ && !billSaveVO.getRelationId().equals(existRelation.getRelationId())) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.IS_EXISTS, "规则已存在,不允许修改");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //数值类型
|
|
|
|
+ if (StringUtil.isNotBlank(billSaveVO.getRuleType())
|
|
|
|
+ && billSaveVO.getRuleType().equals("2")) {
|
|
|
|
+ BillCondition condition = billSaveVO.getCondition();
|
|
|
|
+ if (condition.getMinValue() != null
|
|
|
|
+ && condition.getMaxValue() != null
|
|
|
|
+ && condition.getMinValue() > condition.getMaxValue()) {
|
|
|
|
+ Double minValue = condition.getMinValue();
|
|
|
|
+ condition.setMinValue(condition.getMaxValue());
|
|
|
|
+ condition.setMaxValue(minValue);
|
|
|
|
+ condition.setRange(1);
|
|
|
|
+ } else {
|
|
|
|
+ condition.setRange(0);
|
|
|
|
+ }
|
|
|
|
+ billSaveVO.setCondition(condition);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (billSaveVO.getRelationId() == null) {
|
|
|
|
+ //新增
|
|
|
|
+ if(billSaveVO.getRuleType().equals("1")){
|
|
|
|
+ //文本类型,新建关系
|
|
|
|
+ Long relationId=billManRepository.createRelation(billSaveVO.getConcept().getName(),
|
|
|
|
+ billSaveVO.getConcept().getConceptLabel(),
|
|
|
|
+ billSaveVO.getCondition().getName(),
|
|
|
|
+ billSaveVO.getCondition().getConditionLabel(),
|
|
|
|
+ relationType,
|
|
|
|
+ billSaveVO.getRuleType());
|
|
|
|
+
|
|
|
|
+ }else if(billSaveVO.getRuleType().equals("2")){
|
|
|
|
+ //数值类型
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //修改
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //体征和实验室检查、实验室检查名称新增一个节点
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|