123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.diagbot.mapper.ConceptMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
- <id column="id" property="id" />
- <result column="is_deleted" property="isDeleted" />
- <result column="gmt_create" property="gmtCreate" />
- <result column="gmt_modified" property="gmtModified" />
- <result column="creator" property="creator" />
- <result column="modifier" property="modifier" />
- <result column="lib_id" property="libId" />
- <result column="lib_name" property="libName" />
- <result column="lib_type" property="libType" />
- </resultMap>
-
- <select id="getAllLisConcept" parameterType="com.diagbot.vo.GetAllLisConceptVO" resultType="com.diagbot.dto.GetAllLisConceptDTO">
- SELECT
- conceptName
- FROM
- ((SELECT
- @rowNo:=@rowNo+1 as taocanNum,
- lib_name as conceptName,
- 0 AS zixiangNum
- FROM kl_concept,(select @rowNo:=0) num_tab
- WHERE is_deleted='N' AND lib_type=12
- ORDER BY gmt_modified DESC)
- UNION
- (SELECT
- t1.taocanNum,
- CONCAT(t1.conceptName,'-',t3.conceptName) as conceptName,
- @rowNo:=@rowNo+1 as zixiangNum
- FROM
- (SELECT
- id as conceptId,
- lib_name as conceptName,
- @rowNo:=@rowNo+1 as taocanNum
- FROM kl_concept,(select @rowNo:=0) num_tab
- WHERE is_deleted='N' AND lib_type=12
- ORDER BY gmt_modified DESC) t1
- JOIN kl_relation t2
- ON t1.conceptId=t2.end_id
- JOIN
- (SELECT
- id as conceptId,
- lib_name as conceptName
- FROM kl_concept
- WHERE is_deleted='N' AND lib_type=13) t3
- ON t2.start_id=t3.conceptId
- LEFT JOIN kl_relation_order t4
- ON t2.id=t4.t_relation_id,(select @rowNo:=0) num_tab
- WHERE t2.is_deleted='N' AND t2.relation_id=18
- ORDER BY t4.order_no DESC,t2.gmt_modified DESC)) tab
- WHERE 1=1
- <if test="conceptName!=null and conceptName!=''">
- and (conceptName LIKE CONCAT('%',#{conceptName},'%'))
- </if>
- <if test="excludedConceptNames!=null and excludedConceptNames.size>0">
- and (conceptName not in
- <foreach collection="excludedConceptNames" open="(" close=")" separator="," item="excludedConceptName">
- #{excludedConceptName}
- </foreach>
- )
- </if>
- ORDER BY taocanNum ASC,zixiangNum ASC
- </select>
-
- <select id="getAllInformation" resultType="com.diagbot.dto.GetAllInformationDTO">
- SELECT
- *
- FROM
- (SELECT
- a.id as conceptId,
- a.lib_name AS libName,
- c.`name` AS libType,
- GROUP_CONCAT(b.`name` ORDER BY b.id ASC SEPARATOR '、') as otherNames,
- a.modifier as operName,
- a.gmt_modified as operTime,
- a.is_deleted as isDeleted
- FROM kl_concept a JOIN kl_library_info b ON a.id=b.concept_id
- LEFT JOIN kl_lexicon c ON a.lib_type=c.id
- GROUP BY a.id) t
- where 1=1
- <if test="name!=null and name!=''">
- AND otherNames like concat('%',#{name},'%')
- </if>
- <if test="type!=null and type!=''">
- AND libType = #{type}
- </if>
- <if test="isDeleted!=null and isDeleted!=''">
- AND isDeleted=#{isDeleted}
- </if>
- ORDER BY isDeleted ASC,operTime DESC,conceptId DESC
- </select>
-
- <select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
- SELECT
- t1.id AS startId,
- t1.lib_name AS startName,
- t3.id AS endId,
- t3.lib_name AS endName
- FROM
- `kl_concept` t1,
- `kl_relation` t2,
- <if test="startSex != null or startAge != null">
- kl_concept_common c1,
- </if>
- <if test="endSex != null or endAge != null">
- kl_concept_common c2,
- </if>
- `kl_concept` t3
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t1.id = t2.start_id
- AND t3.id = t2.end_id
- <if test="startId != null">
- AND t2.start_id = #{startId}
- </if>
- <if test="startName != null and startName != ''">
- AND t1.lib_name = #{startName}
- </if>
- <if test="startSex != null or startAge != null">
- AND c1.is_deleted = 'N'
- <if test="startSex != null">
- <if test="startSex == 3">
- and c1.sex_type in ('1','2','3')
- </if>
- <if test="startSex != 3">
- and c1.sex_type in ('3',#{startSex})
- </if>
- </if>
- <if test="startAge != null">
- <![CDATA[ AND c1.min_age <= #{startAge} ]]>
- <![CDATA[ AND c1.max_age >= #{startAge} ]]>
- </if>
- AND t2.start_id = c1.concept_id
- </if>
- <if test="startType != null">
- AND t1.lib_type = #{startType}
- </if>
- <if test="relationType != null">
- AND t2.relation_id = #{relationType}
- </if>
- <if test="endId != null">
- AND t2.end_id = #{endId}
- </if>
- <if test="endName != null and endName != ''">
- AND t3.lib_name = #{endName}
- </if>
- <if test="endSex != null or endAge != null">
- AND c2.is_deleted = 'N'
- <if test="endSex != null">
- <if test="endSex == 3">
- and c2.sex_type in ('1','2','3')
- </if>
- <if test="endSex != 3">
- and c2.sex_type in ('3',#{endSex})
- </if>
- </if>
- <if test="endAge != null">
- <![CDATA[ AND c2.min_age <= #{endAge} ]]>
- <![CDATA[ AND c2.max_age >= #{endAge} ]]>
- </if>
- AND t2.end_id = c2.concept_id
- </if>
- <if test="endType != null">
- AND t3.lib_type = #{endType}
- </if>
- </select>
- <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
- SELECT
- t1.id AS startId,
- t1.lib_name AS startName,
- t3.id AS endId,
- t3.lib_name AS endName,
- t4.order_no AS orderNo
- FROM
- `kl_concept` t1,
- `kl_relation` t2,
- <if test="startSex != null or startAge != null">
- kl_concept_common c1,
- </if>
- <if test="endSex != null or endAge != null">
- kl_concept_common c2,
- </if>
- `kl_concept` t3,
- `kl_relation_order` t4
- WHERE
- t1.is_deleted = 'N'
- AND t2.is_deleted = 'N'
- AND t3.is_deleted = 'N'
- AND t4.is_deleted = 'N'
- AND t1.id = t2.start_id
- AND t3.id = t2.end_id
- AND t2.id = t4.t_relation_id
- <if test="startId != null">
- AND t2.start_id = #{startId}
- </if>
- <if test="startName != null and startName != ''">
- AND t1.lib_name = #{startName}
- </if>
- <if test="startSex != null or startAge != null">
- AND c1.is_deleted = 'N'
- <if test="startSex != null">
- <if test="startSex == 3">
- and c1.sex_type in ('1','2','3')
- </if>
- <if test="startSex != 3">
- and c1.sex_type in ('3',#{startSex})
- </if>
- </if>
- <if test="startAge != null">
- <![CDATA[ AND c1.min_age <= #{startAge} ]]>
- <![CDATA[ AND c1.max_age >= #{startAge} ]]>
- </if>
- AND t2.start_id = c1.concept_id
- </if>
- <if test="startNameList != null and startNameList.size() > 0">
- AND t1.lib_name in
- <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="startType != null">
- AND t1.lib_type = #{startType}
- </if>
- <if test="relationType != null">
- AND t2.relation_id = #{relationType}
- </if>
- <if test="endId != null">
- AND t2.end_id = #{endId}
- </if>
- <if test="endName != null and endName != ''">
- AND t3.lib_name = #{endName}
- </if>
- <if test="endSex != null or endAge != null">
- AND c2.is_deleted = 'N'
- <if test="endSex != null">
- <if test="endSex == 3">
- and c2.sex_type in ('1','2','3')
- </if>
- <if test="endSex != 3">
- and c2.sex_type in ('3',#{endSex})
- </if>
- </if>
- <if test="endAge != null">
- <![CDATA[ AND c2.min_age <= #{endAge} ]]>
- <![CDATA[ AND c2.max_age >= #{endAge} ]]>
- </if>
- AND t2.end_id = c2.concept_id
- </if>
- <if test="endNameList != null and endNameList.size() > 0">
- AND t3.lib_name in
- <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="endType != null">
- AND t3.lib_type = #{endType}
- </if>
- ORDER BY t4.order_no
- </select>
- <select id="index" resultType="com.diagbot.dto.ConceptBaseDTO">
- SELECT b.id conceptId, b.lib_name name
- FROM `kl_library_info` a, kl_concept b
- where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
- <if test="libType != null">
- and b.lib_type = #{libType}
- </if>
- and (a.name like concat('%',#{name},'%')
- or a.spell like concat('%',#{name},'%'))
- </select>
- <select id="indexByLexicon" resultType="com.diagbot.dto.ConceptBaseDTO">
- SELECT b.id conceptId, b.lib_name name
- FROM `kl_library_info` a, kl_concept b
- where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
- <if test="libType != null and libType.size() > 0">
- and b.lib_type in
- <foreach collection="libType" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- and (a.name like concat('%',#{name},'%')
- or a.spell like concat('%',#{name},'%'))
- </select>
- <select id="queryLibTypeCou" parameterType="list" resultType="com.diagbot.dto.BIItemDTO">
- SELECT
- a.moduleName,
- a.itemName,
- CASE WHEN b.lib_type IS NULL THEN 0 else b.count END AS count
- FROM
- (SELECT
- id,
- CASE WHEN id=18 then '疾病'
- WHEN id=1 THEN '症状'
- WHEN id=35 OR id=33 THEN '体征'
- WHEN id=12 OR id=13 THEN '化验'
- WHEN id=16 THEN '辅检'
- WHEN id=10 THEN '药品'
- WHEN id=25 THEN '手术'
- WHEN id=11 THEN '治疗'
- ELSE '' END AS moduleName,
- CASE WHEN id=18 THEN '疾病总数'
- WHEN id=1 THEN '症状标准词'
- WHEN id=25 THEN '手术项目'
- WHEN id=11 THEN '治疗数目'
- ELSE `name` END AS itemName
- FROM kl_lexicon
- WHERE id in (18,1,35,33,12,13,16,10,25,11)
- ) a
- LEFT JOIN
- (SELECT
- lib_type,COUNT(id) AS count
- FROM kl_concept
- WHERE lib_type in (18,1,35,33,12,13,16,10,25,11)
- AND is_deleted='N'
- GROUP BY lib_type) b
- ON a.id=b.lib_type
- </select>
-
- </mapper>
|