|
@@ -1,8 +1,31 @@
|
|
|
package com.diagbot.facade;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.diagbot.dto.StaticKnowledgeDTO;
|
|
|
+import com.diagbot.dto.StaticKnowledgeDetailDTO;
|
|
|
+import com.diagbot.entity.KlConcept;
|
|
|
+import com.diagbot.entity.KlConceptDetail;
|
|
|
+import com.diagbot.entity.KlConceptStatic;
|
|
|
+import com.diagbot.entity.KlRelation;
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.enums.LexiconEnum;
|
|
|
+import com.diagbot.enums.StatusEnum;
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.service.impl.KlConceptStaticServiceImpl;
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
+import com.diagbot.vo.StaticKnowledgeVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @Description:
|
|
|
* @Author:zhaops
|
|
@@ -10,4 +33,175 @@ import org.springframework.stereotype.Component;
|
|
|
*/
|
|
|
@Component
|
|
|
public class KlConceptStaticFacade extends KlConceptStaticServiceImpl {
|
|
|
+ @Autowired
|
|
|
+ private KlConceptFacade klConceptFacade;
|
|
|
+ @Autowired
|
|
|
+ private KlRelationFacade klRelationFacade;
|
|
|
+ @Autowired
|
|
|
+ private KlConceptDetailFacade klConceptDetailFacade;
|
|
|
+ @Autowired
|
|
|
+ private DictionaryFacade dictionaryFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 页面获取静态知识
|
|
|
+ *
|
|
|
+ * @param staticKnowledgeVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public StaticKnowledgeDTO getStaticKnowledge(StaticKnowledgeVO staticKnowledgeVO) {
|
|
|
+ StaticKnowledgeDTO staticKnowledgeDTO = new StaticKnowledgeDTO();
|
|
|
+ Integer type = convertType(staticKnowledgeVO.getType());
|
|
|
+ if (type == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "请输入正确类型(1-诊断、2-药品、3-检验套餐、4-检验细项、5-检查、6-检查子项、7-手术和操作)");
|
|
|
+ }
|
|
|
+ staticKnowledgeVO.setType(type);
|
|
|
+
|
|
|
+ KlConcept concept = klConceptFacade.getOne(new QueryWrapper<KlConcept>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("lib_name", staticKnowledgeVO.getName())
|
|
|
+ .eq("lib_type", type), false);
|
|
|
+ if (concept == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "标准词不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ KlConceptStatic staticInfo = this.getOne(new QueryWrapper<KlConceptStatic>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("concept_id", concept.getId())
|
|
|
+ .eq("status", StatusEnum.Enable.getKey()), false);
|
|
|
+
|
|
|
+ if (staticInfo == null) {
|
|
|
+ //检验子项或检查子项向上级取静态知识
|
|
|
+ if (type.equals(LexiconEnum.LisSubName.getKey())
|
|
|
+ || type.equals(LexiconEnum.PacsSubName.getKey())) {
|
|
|
+ List<KlRelation> relations = klRelationFacade.list(new QueryWrapper<KlRelation>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("end_id", concept.getId())
|
|
|
+ .eq("relation_id", 600));
|
|
|
+ if (ListUtil.isNotEmpty(relations)) {
|
|
|
+ staticInfo = this.getOne(new QueryWrapper<KlConceptStatic>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("concept_id", relations.stream().map(i -> i.getStartId()).collect(Collectors.toList()))
|
|
|
+ .eq("status", StatusEnum.Enable.getKey()), false);
|
|
|
+ if (staticInfo == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "缺少静态信息");
|
|
|
+ }
|
|
|
+ concept = klConceptFacade.getById(staticInfo.getConceptId());
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "缺少静态信息");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS, "缺少静态信息");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //详情信息
|
|
|
+ String sql = "";
|
|
|
+ if (ListUtil.isNotEmpty(staticKnowledgeVO.getContentTypes())) {
|
|
|
+
|
|
|
+ for (Integer contentType : staticKnowledgeVO.getContentTypes()) {
|
|
|
+ if (contentType.equals(0)) {
|
|
|
+ sql = "";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(sql)) {
|
|
|
+ sql += " or ";
|
|
|
+ }
|
|
|
+ sql += "find_in_set(" + contentType + ",content_type)";
|
|
|
+ }
|
|
|
+ if (StringUtil.isNotBlank(sql)) {
|
|
|
+ sql = "(" + sql + ")";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KlConceptDetail> details = klConceptDetailFacade.list(new QueryWrapper<KlConceptDetail>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("concept_id", concept.getId())
|
|
|
+ .apply(sql)
|
|
|
+ .orderByAsc("order_no"));
|
|
|
+
|
|
|
+ List<StaticKnowledgeDetailDTO> detailList
|
|
|
+ = BeanUtil.listCopyTo(details, StaticKnowledgeDetailDTO.class);
|
|
|
+ List<StaticKnowledgeDetailDTO> introduceList = detailList
|
|
|
+ .stream()
|
|
|
+ .filter(i -> Arrays.asList(i.getContentType().split(",")).contains("1"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StaticKnowledgeDetailDTO> noticeList = detailList
|
|
|
+ .stream()
|
|
|
+ .filter(i -> Arrays.asList(i.getContentType().split(",")).contains("2"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StaticKnowledgeDetailDTO> clinicalPathwayList = detailList
|
|
|
+ .stream()
|
|
|
+ .filter(i -> Arrays.asList(i.getContentType().split(",")).contains("3"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<StaticKnowledgeDetailDTO> treatInfoList = detailList
|
|
|
+ .stream()
|
|
|
+ .filter(i -> Arrays.asList(i.getContentType().split(",")).contains("4"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<String, List<StaticKnowledgeDetailDTO>> detailMap = new HashMap<>();
|
|
|
+ if (ListUtil.isEmpty(staticKnowledgeVO.getContentTypes()) || staticKnowledgeVO.getContentTypes().contains(0)) {
|
|
|
+ if (ListUtil.isNotEmpty(introduceList)) {
|
|
|
+ detailMap.put("静态知识", introduceList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(noticeList)) {
|
|
|
+ detailMap.put("注意事项", noticeList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(clinicalPathwayList)) {
|
|
|
+ detailMap.put("临床路径", clinicalPathwayList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(treatInfoList)) {
|
|
|
+ detailMap.put("治疗方案", treatInfoList);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (ListUtil.isNotEmpty(introduceList) && staticKnowledgeVO.getContentTypes().contains(1)) {
|
|
|
+ detailMap.put("静态知识", introduceList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(noticeList) && staticKnowledgeVO.getContentTypes().contains(2)) {
|
|
|
+ detailMap.put("注意事项", noticeList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(clinicalPathwayList) && staticKnowledgeVO.getContentTypes().contains(3)) {
|
|
|
+ detailMap.put("临床路径", clinicalPathwayList);
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(treatInfoList) && staticKnowledgeVO.getContentTypes().contains(4)) {
|
|
|
+ detailMap.put("治疗方案", treatInfoList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ staticKnowledgeDTO.setId(concept.getId());
|
|
|
+ staticKnowledgeDTO.setName(concept.getLibName());
|
|
|
+ staticKnowledgeDTO.setType(concept.getLibType().toString());
|
|
|
+ staticKnowledgeDTO.setClinicalPathwayName(staticInfo.getClinicalPathwayName());
|
|
|
+ staticKnowledgeDTO.setNoticeName(staticInfo.getNoticeName());
|
|
|
+ staticKnowledgeDTO.setDetails(detailMap);
|
|
|
+ return staticKnowledgeDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Integer convertType(Integer type) {
|
|
|
+ Integer retType = null;
|
|
|
+ //1-诊断、2-药品、3-检验套餐、4-检验细项、5-检查、6-检查子项、7-手术和操作
|
|
|
+ switch (type) {
|
|
|
+ case 1:
|
|
|
+ retType = LexiconEnum.Disease.getKey();
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ retType = LexiconEnum.Medicine.getKey();
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ retType = LexiconEnum.LisName.getKey();
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ retType = LexiconEnum.LisSubName.getKey();
|
|
|
+ break;
|
|
|
+ case 5:
|
|
|
+ retType = LexiconEnum.PacsName.getKey();
|
|
|
+ break;
|
|
|
+ case 6:
|
|
|
+ retType = LexiconEnum.PacsSubName.getKey();
|
|
|
+ break;
|
|
|
+ case 7:
|
|
|
+ retType = LexiconEnum.Operation.getKey();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return retType;
|
|
|
+ }
|
|
|
}
|