zhaops před 4 roky
rodič
revize
54646a134a

+ 23 - 0
src/main/java/com/diagbot/dto/IndexDTO.java

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/2/22 9:49
+ */
+@Getter
+@Setter
+public class IndexDTO {
+    private Long id;
+    private String name;
+    private String icd10Code;
+    private String maxValue;
+    private String minValue;
+    private String units;
+    private Integer range;
+    private Long packId;
+    private String packName;
+}

+ 140 - 0
src/main/java/com/diagbot/facade/MedRetrievalFacade.java

@@ -0,0 +1,140 @@
+package com.diagbot.facade;
+
+import com.diagbot.dto.DiseaseInfoDTO;
+import com.diagbot.dto.DrugInfoDTO;
+import com.diagbot.dto.IndexDTO;
+import com.diagbot.dto.LisDetailDTO;
+import com.diagbot.dto.OperationInfoDTO;
+import com.diagbot.dto.RetrievalDTO;
+import com.diagbot.util.BeanUtil;
+import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
+import com.diagbot.vo.MedRetrievalVO;
+import com.diagbot.vo.RetrievalVO;
+import com.google.common.collect.Lists;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/2/22 10:35
+ */
+@Component
+public class MedRetrievalFacade {
+    @Autowired
+    private KlConceptFacade klConceptFacade;
+
+    /**
+     * 检索
+     *
+     * @param retrievalVO
+     * @return
+     */
+    public RetrievalDTO index(RetrievalVO retrievalVO) {
+        if (retrievalVO.getSize() == null) {
+            retrievalVO.setSize(100);
+        }
+        RetrievalDTO retrievalDTO = new RetrievalDTO();
+        MedRetrievalVO medRetrievalVO = new MedRetrievalVO();
+        BeanUtil.copyProperties(retrievalVO, medRetrievalVO);
+        medRetrievalVO.setTypeIds(new ArrayList<>());
+        List<IndexDTO> indexList = Lists.newLinkedList();
+
+        /**
+         * 类型:1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、9-症状
+         */
+        switch (retrievalVO.getType()) {
+            case 1:
+                medRetrievalVO.setTypeId(107L);
+                medRetrievalVO.getTypeIds().add(107L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setLisNames(indexList.stream().map(i -> i.getName()).collect(Collectors.toList()));
+                }
+                break;
+            case 2:
+                medRetrievalVO.setTypeId(108L);
+                medRetrievalVO.getTypeIds().add(108L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    List<LisDetailDTO> lisDetails = Lists.newLinkedList();
+                    indexList.forEach(item -> {
+                        LisDetailDTO lisDetail = new LisDetailDTO();
+                        BeanUtil.copyProperties(item, lisDetail);
+                        lisDetail.setName(item.getPackName());
+                        lisDetail.setUniqueName(item.getName());
+                        //默认套餐名称
+                        if (StringUtil.isBlank(lisDetail.getName())) {
+                            lisDetail.setName(lisDetail.getUniqueName());
+                        }
+                        lisDetails.add(lisDetail);
+                    });
+                    retrievalDTO.setLisDetailNames(lisDetails);
+                }
+                break;
+            case 3:
+                medRetrievalVO.setTypeId(109L);
+                medRetrievalVO.getTypeIds().addAll(Arrays.asList(new Long[] { 109L, 110L }));
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setPacsNames(indexList.stream().map(i -> i.getName()).collect(Collectors.toList()));
+                }
+                break;
+            case 4:
+                medRetrievalVO.setTypeId(100L);
+                medRetrievalVO.getTypeIds().add(100L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setDiseaseNames(BeanUtil.listCopyTo(indexList, DiseaseInfoDTO.class));
+                }
+                break;
+            case 5:
+                medRetrievalVO.setTypeId(101L);
+                medRetrievalVO.getTypeIds().add(101L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setDrugNames(BeanUtil.listCopyTo(indexList, DrugInfoDTO.class));
+                }
+                break;
+            case 6:
+                medRetrievalVO.setTypeId(106L);
+                medRetrievalVO.getTypeIds().add(106L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setOperationNames(BeanUtil.listCopyTo(indexList, OperationInfoDTO.class));
+                }
+                break;
+            case 7:
+                medRetrievalVO.setTypeId(115L);
+                medRetrievalVO.getTypeIds().add(115L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setDeptNames(indexList.stream().map(i -> i.getName()).collect(Collectors.toList()));
+                }
+                break;
+            case 8:
+                medRetrievalVO.setTypeId(113L);
+                medRetrievalVO.getTypeIds().add(113L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setTransfusionNames(indexList.stream().map(i -> i.getName()).collect(Collectors.toList()));
+                }
+                break;
+            case 9:
+                medRetrievalVO.setTypeId(103L);
+                medRetrievalVO.getTypeIds().add(103L);
+                indexList = klConceptFacade.index(medRetrievalVO);
+                if (ListUtil.isNotEmpty(indexList)) {
+                    retrievalDTO.setSymptomNames(indexList.stream().map(i -> i.getName()).collect(Collectors.toList()));
+                }
+                break;
+        }
+        return retrievalDTO;
+    }
+}

+ 6 - 1
src/main/java/com/diagbot/mapper/KlConceptMapper.java

@@ -1,7 +1,11 @@
 package com.diagbot.mapper;
 
-import com.diagbot.entity.KlConcept;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.diagbot.dto.IndexDTO;
+import com.diagbot.entity.KlConcept;
+import com.diagbot.vo.MedRetrievalVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +17,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface KlConceptMapper extends BaseMapper<KlConcept> {
 
+    List<IndexDTO> index(MedRetrievalVO medRetrievalVO);
 }

+ 5 - 1
src/main/java/com/diagbot/service/KlConceptService.java

@@ -1,8 +1,12 @@
 package com.diagbot.service;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
+import com.diagbot.dto.IndexDTO;
 import com.diagbot.entity.KlConcept;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.diagbot.vo.MedRetrievalVO;
+
+import java.util.List;
 
 /**
  * <p>
@@ -14,5 +18,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 @DS("med")
 public interface KlConceptService extends IService<KlConcept> {
-
+    List<IndexDTO> index(MedRetrievalVO medRetrievalVO);
 }

+ 8 - 2
src/main/java/com/diagbot/service/impl/KlConceptServiceImpl.java

@@ -1,11 +1,15 @@
 package com.diagbot.service.impl;
 
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.dto.IndexDTO;
 import com.diagbot.entity.KlConcept;
 import com.diagbot.mapper.KlConceptMapper;
 import com.diagbot.service.KlConceptService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.diagbot.vo.MedRetrievalVO;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 /**
  * <p>
  * 概念表 服务实现类
@@ -16,5 +20,7 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class KlConceptServiceImpl extends ServiceImpl<KlConceptMapper, KlConcept> implements KlConceptService {
-
+    public List<IndexDTO> index(MedRetrievalVO medRetrievalVO) {
+        return baseMapper.index(medRetrievalVO);
+    }
 }

+ 18 - 0
src/main/java/com/diagbot/vo/MedRetrievalVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2021/2/22 10:36
+ */
+@Getter
+@Setter
+public class MedRetrievalVO extends RetrievalVO {
+    private Long typeId;
+    private List<Long> typeIds;
+}

+ 6 - 1
src/main/java/com/diagbot/web/RetrievalController.java

@@ -4,6 +4,7 @@ import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RetrievalDTO;
 import com.diagbot.dto.StaticKnowledgeIndexDTO;
 import com.diagbot.facade.ConceptFacade;
+import com.diagbot.facade.MedRetrievalFacade;
 import com.diagbot.facade.RetrievalFacade;
 import com.diagbot.vo.ConceptVO;
 import com.diagbot.vo.RetrievalVO;
@@ -32,8 +33,11 @@ public class RetrievalController {
     @Autowired
     private RetrievalFacade retrievalFacade;
     @Autowired
+    private MedRetrievalFacade medRetrievalFacade;
+    @Autowired
     private ConceptFacade conceptFacade;
 
+
     @ApiOperation(value = "术语检索[zhaops]",
             notes = "type: 类型:1-化验大项、2-化验小项、3-辅检、4-诊断、5-药品、6-手术和操作、7-科室、8-输血、9-症状 <br>" +
                     "inputStr: 检索内容<br>" +
@@ -41,7 +45,8 @@ public class RetrievalController {
                     "age: 年龄<br>")
     @PostMapping("/index")
     public RespDTO<RetrievalDTO> index(@Valid @RequestBody RetrievalVO retrievalVO) {
-        RetrievalDTO data = retrievalFacade.index(retrievalVO);
+        //RetrievalDTO data = retrievalFacade.index(retrievalVO);
+        RetrievalDTO data = medRetrievalFacade.index(retrievalVO);
         return RespDTO.onSuc(data);
     }
 

+ 128 - 0
src/main/resources/mapper/KlConceptMapper.xml

@@ -16,4 +16,132 @@
         <result column="status" property="status" />
     </resultMap>
 
+    <select id="index" resultType="com.diagbot.dto.IndexDTO">
+		SELECT DISTINCT
+		t.id as id,
+		t.lib_name as name
+		<if test="typeId!=null and typeId=100">
+			,t.icd10Code as icd10Code
+		</if>
+		<if test="typeId!=null and typeId=108">
+			,
+			t1.max_value as `maxValue`,
+			t1.min_value as minValue,
+			t1.unit as units,
+			t1.type as `range`,
+			t4.lib_name AS packName,
+			t4.id as packId
+		</if>
+		FROM
+		(
+		SELECT DISTINCT
+		b.id,
+		b.lib_name
+		<if test="typeId!=null and typeId=100">
+			,c.icd10_code as icd10Code
+		</if>
+		FROM
+		kl_library_info a,
+		kl_concept b
+		<if test="typeId!=null and typeId=100">
+			left join kl_disease c
+			on c.is_deleted = 'N'
+			and b.id = c.concept_id
+		</if>
+		WHERE
+		a.is_deleted = 'N'
+		AND b.is_deleted = 'N'
+		AND a.concept_id = b.id
+		AND a.id = b.lib_id
+		<if test="inputStr!=null and inputStr!=''">
+			AND ( a.`name` = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr})
+			<if test="typeId!=null and typeId=100">
+				OR LOWER(c.icd10_code) = LOWER(#{inputStr})
+			</if>
+			)
+		</if>
+		<if test="typeIds != null and typeIds.size > 0">
+			<foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
+				a.type_id =#{typeId}
+			</foreach>
+		</if>
+		UNION
+		SELECT DISTINCT
+		b.id,
+		b.lib_name
+		<if test="typeId!=null and typeId=100">
+			,c.icd10_code as icd10Code
+		</if>
+		FROM
+		kl_library_info a,
+		kl_concept b
+		<if test="typeId!=null and typeId=100">
+			left join kl_disease c
+			on c.is_deleted = 'N'
+			and b.id = c.concept_id
+		</if>
+		WHERE
+		a.is_deleted = 'N'
+		AND b.is_deleted = 'N'
+		AND a.concept_id = b.id
+		AND a.id = b.lib_id
+		<if test="inputStr!=null and inputStr!=''">
+			AND ( a.`name` LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER(concat(#{inputStr},'%'))
+			<if test="typeId!=null and typeId=100">
+				OR LOWER(c.icd10_code) LIKE LOWER(concat(#{inputStr},'%'))
+			</if>
+			)
+		</if>
+		<if test="typeIds != null and typeIds.size > 0">
+			<foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
+				a.type_id =#{typeId}
+			</foreach>
+		</if>
+		UNION
+		SELECT DISTINCT
+		b.id,
+		b.lib_name
+		<if test="typeId!=null and typeId=100">
+			,c.icd10_code as icd10Code
+		</if>
+		FROM
+		kl_library_info a,
+		kl_concept b
+		<if test="typeId!=null and typeId=100">
+			left join kl_disease c
+			on c.is_deleted = 'N'
+			and b.id = c.concept_id
+		</if>
+		WHERE
+		a.is_deleted = 'N'
+		AND b.is_deleted = 'N'
+		AND a.concept_id = b.id
+		AND a.id = b.lib_id
+		<if test="inputStr!=null and inputStr!=''">
+			AND ( a.`name` LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
+			<if test="typeId!=null and typeId=100">
+				OR LOWER(c.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
+			</if>
+			)
+		</if>
+		<if test="typeIds != null and typeIds.size > 0">
+			<foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
+				a.type_id =#{typeId}
+			</foreach>
+		</if>
+		) t
+		<if test="typeId!=null and typeId=108">
+			LEFT JOIN kl_lis t1 ON t.id = t1.concept_id
+			AND t1.is_deleted = 'N'
+			LEFT JOIN kl_relation t3 ON t.id = t3.end_id
+			AND t3.relation_id = 600
+			AND t3.is_deleted = 'N'
+			LEFT JOIN kl_concept t4 ON t3.start_id = t4.id
+			AND t4.lib_type = 107
+			AND t4.is_deleted = 'N'
+		</if>
+		<if test="size!=null">
+			LIMIT #{size}
+		</if>
+    </select>
 </mapper>