ConceptMapper.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.ConceptMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="lib_id" property="libId" />
  13. <result column="lib_name" property="libName" />
  14. <result column="lib_type" property="libType" />
  15. </resultMap>
  16. <select id="getAllLisConcept" parameterType="com.diagbot.vo.GetAllLisConceptVO" resultType="com.diagbot.dto.GetAllLisConceptDTO">
  17. SELECT
  18. conceptName
  19. FROM
  20. ((SELECT
  21. @rowNo:=@rowNo+1 as taocanNum,
  22. lib_name as conceptName,
  23. 0 AS zixiangNum
  24. FROM kl_concept,(select @rowNo:=0) num_tab
  25. WHERE is_deleted='N' AND lib_type=12
  26. ORDER BY gmt_modified DESC)
  27. UNION
  28. (SELECT
  29. t1.taocanNum,
  30. CONCAT(t1.conceptName,'-',t3.conceptName) as conceptName,
  31. @rowNo:=@rowNo+1 as zixiangNum
  32. FROM
  33. (SELECT
  34. id as conceptId,
  35. lib_name as conceptName,
  36. @rowNo:=@rowNo+1 as taocanNum
  37. FROM kl_concept,(select @rowNo:=0) num_tab
  38. WHERE is_deleted='N' AND lib_type=12
  39. ORDER BY gmt_modified DESC) t1
  40. JOIN kl_relation t2
  41. ON t1.conceptId=t2.end_id
  42. JOIN
  43. (SELECT
  44. id as conceptId,
  45. lib_name as conceptName
  46. FROM kl_concept
  47. WHERE is_deleted='N' AND lib_type=13) t3
  48. ON t2.start_id=t3.conceptId
  49. LEFT JOIN kl_relation_order t4
  50. ON t2.id=t4.t_relation_id,(select @rowNo:=0) num_tab
  51. WHERE t2.is_deleted='N' AND t2.relation_id=18
  52. ORDER BY t4.order_no DESC,t2.gmt_modified DESC)) tab
  53. WHERE 1=1
  54. <if test="conceptName!=null and conceptName!=''">
  55. and (conceptName LIKE CONCAT('%',#{conceptName},'%'))
  56. </if>
  57. <if test="excludedConceptNames!=null and excludedConceptNames.size>0">
  58. and (conceptName not in
  59. <foreach collection="excludedConceptNames" open="(" close=")" separator="," item="excludedConceptName">
  60. #{excludedConceptName}
  61. </foreach>
  62. )
  63. </if>
  64. ORDER BY taocanNum ASC,zixiangNum ASC
  65. </select>
  66. <select id="getAllInformation" resultType="com.diagbot.dto.GetAllInformationDTO">
  67. SELECT
  68. *
  69. FROM
  70. (SELECT
  71. a.id as conceptId,
  72. a.lib_name AS libName,
  73. c.`name` AS libType,
  74. GROUP_CONCAT(b.`name` ORDER BY b.id ASC SEPARATOR '、') as otherNames,
  75. a.modifier as operName,
  76. a.gmt_modified as operTime,
  77. a.is_deleted as isDeleted
  78. FROM kl_concept a JOIN kl_library_info b ON a.id=b.concept_id
  79. LEFT JOIN kl_lexicon c ON a.lib_type=c.id
  80. GROUP BY a.id) t
  81. where 1=1
  82. <if test="name!=null and name!=''">
  83. AND otherNames like concat('%',#{name},'%')
  84. </if>
  85. <if test="type!=null and type!=''">
  86. AND libType = #{type}
  87. </if>
  88. <if test="isDeleted!=null and isDeleted!=''">
  89. AND isDeleted=#{isDeleted}
  90. </if>
  91. ORDER BY isDeleted ASC,operTime DESC,conceptId DESC
  92. </select>
  93. <select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  94. SELECT
  95. t1.id AS startId,
  96. t1.lib_name AS startName,
  97. t3.id AS endId,
  98. t3.lib_name AS endName
  99. FROM
  100. `kl_concept` t1,
  101. `kl_relation` t2,
  102. <if test="startSex != null or startAge != null">
  103. kl_concept_common c1,
  104. </if>
  105. <if test="endSex != null or endAge != null">
  106. kl_concept_common c2,
  107. </if>
  108. `kl_concept` t3
  109. WHERE
  110. t1.is_deleted = 'N'
  111. AND t2.is_deleted = 'N'
  112. AND t3.is_deleted = 'N'
  113. AND t1.id = t2.start_id
  114. AND t3.id = t2.end_id
  115. <if test="startId != null">
  116. AND t2.start_id = #{startId}
  117. </if>
  118. <if test="startName != null and startName != ''">
  119. AND t1.lib_name = #{startName}
  120. </if>
  121. <if test="startSex != null or startAge != null">
  122. AND c1.is_deleted = 'N'
  123. <if test="startSex != null">
  124. <if test="startSex == 3">
  125. and c1.sex_type in ('1','2','3')
  126. </if>
  127. <if test="startSex != 3">
  128. and c1.sex_type in ('3',#{startSex})
  129. </if>
  130. </if>
  131. <if test="startAge != null">
  132. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  133. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  134. </if>
  135. AND t2.start_id = c1.concept_id
  136. </if>
  137. <if test="startType != null">
  138. AND t1.lib_type = #{startType}
  139. </if>
  140. <if test="relationType != null">
  141. AND t2.relation_id = #{relationType}
  142. </if>
  143. <if test="endId != null">
  144. AND t2.end_id = #{endId}
  145. </if>
  146. <if test="endName != null and endName != ''">
  147. AND t3.lib_name = #{endName}
  148. </if>
  149. <if test="endSex != null or endAge != null">
  150. AND c2.is_deleted = 'N'
  151. <if test="endSex != null">
  152. <if test="endSex == 3">
  153. and c2.sex_type in ('1','2','3')
  154. </if>
  155. <if test="endSex != 3">
  156. and c2.sex_type in ('3',#{endSex})
  157. </if>
  158. </if>
  159. <if test="endAge != null">
  160. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  161. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  162. </if>
  163. AND t2.end_id = c2.concept_id
  164. </if>
  165. <if test="endType != null">
  166. AND t3.lib_type = #{endType}
  167. </if>
  168. </select>
  169. <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  170. SELECT
  171. t1.id AS startId,
  172. t1.lib_name AS startName,
  173. t3.id AS endId,
  174. t3.lib_name AS endName,
  175. t4.order_no AS orderNo
  176. FROM
  177. `kl_concept` t1,
  178. `kl_relation` t2,
  179. <if test="startSex != null or startAge != null">
  180. kl_concept_common c1,
  181. </if>
  182. <if test="endSex != null or endAge != null">
  183. kl_concept_common c2,
  184. </if>
  185. `kl_concept` t3,
  186. `kl_relation_order` t4
  187. WHERE
  188. t1.is_deleted = 'N'
  189. AND t2.is_deleted = 'N'
  190. AND t3.is_deleted = 'N'
  191. AND t4.is_deleted = 'N'
  192. AND t1.id = t2.start_id
  193. AND t3.id = t2.end_id
  194. AND t2.id = t4.t_relation_id
  195. <if test="startId != null">
  196. AND t2.start_id = #{startId}
  197. </if>
  198. <if test="startName != null and startName != ''">
  199. AND t1.lib_name = #{startName}
  200. </if>
  201. <if test="startSex != null or startAge != null">
  202. AND c1.is_deleted = 'N'
  203. <if test="startSex != null">
  204. <if test="startSex == 3">
  205. and c1.sex_type in ('1','2','3')
  206. </if>
  207. <if test="startSex != 3">
  208. and c1.sex_type in ('3',#{startSex})
  209. </if>
  210. </if>
  211. <if test="startAge != null">
  212. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  213. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  214. </if>
  215. AND t2.start_id = c1.concept_id
  216. </if>
  217. <if test="startNameList != null and startNameList.size() > 0">
  218. AND t1.lib_name in
  219. <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
  220. #{item}
  221. </foreach>
  222. </if>
  223. <if test="startType != null">
  224. AND t1.lib_type = #{startType}
  225. </if>
  226. <if test="relationType != null">
  227. AND t2.relation_id = #{relationType}
  228. </if>
  229. <if test="endId != null">
  230. AND t2.end_id = #{endId}
  231. </if>
  232. <if test="endName != null and endName != ''">
  233. AND t3.lib_name = #{endName}
  234. </if>
  235. <if test="endSex != null or endAge != null">
  236. AND c2.is_deleted = 'N'
  237. <if test="endSex != null">
  238. <if test="endSex == 3">
  239. and c2.sex_type in ('1','2','3')
  240. </if>
  241. <if test="endSex != 3">
  242. and c2.sex_type in ('3',#{endSex})
  243. </if>
  244. </if>
  245. <if test="endAge != null">
  246. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  247. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  248. </if>
  249. AND t2.end_id = c2.concept_id
  250. </if>
  251. <if test="endNameList != null and endNameList.size() > 0">
  252. AND t3.lib_name in
  253. <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
  254. #{item}
  255. </foreach>
  256. </if>
  257. <if test="endType != null">
  258. AND t3.lib_type = #{endType}
  259. </if>
  260. ORDER BY t4.order_no
  261. </select>
  262. <select id="index" resultType="com.diagbot.dto.ConceptBaseDTO">
  263. SELECT b.id conceptId, b.lib_name name
  264. FROM `kl_library_info` a, kl_concept b
  265. where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
  266. <if test="libType != null">
  267. and b.lib_type = #{libType}
  268. </if>
  269. and (a.name like concat('%',#{name},'%')
  270. or a.spell like concat('%',#{name},'%'))
  271. </select>
  272. <select id="indexByLexicon" resultType="com.diagbot.dto.ConceptBaseDTO">
  273. SELECT b.id conceptId, b.lib_name name
  274. FROM `kl_library_info` a, kl_concept b
  275. where b.is_deleted = 'N' and a.is_deleted = 'N' and a.concept_id = b.id and a.is_concept = 1
  276. <if test="libType != null and libType.size() > 0">
  277. and b.lib_type in
  278. <foreach collection="libType" item="item" open="(" close=")" separator=",">
  279. #{item}
  280. </foreach>
  281. </if>
  282. and (a.name like concat('%',#{name},'%')
  283. or a.spell like concat('%',#{name},'%'))
  284. </select>
  285. <select id="queryLibTypeCou" parameterType="list" resultType="com.diagbot.dto.BIItemDTO">
  286. SELECT
  287. a.moduleName,
  288. a.itemName,
  289. CASE WHEN b.lib_type IS NULL THEN 0 else b.count END AS count
  290. FROM
  291. (SELECT
  292. id,
  293. CASE WHEN id=18 then '疾病'
  294. WHEN id=1 THEN '症状'
  295. WHEN id=35 OR id=33 THEN '体征'
  296. WHEN id=12 OR id=13 THEN '化验'
  297. WHEN id=16 THEN '辅检'
  298. WHEN id=10 THEN '药品'
  299. WHEN id=25 THEN '手术'
  300. WHEN id=11 THEN '治疗'
  301. ELSE '' END AS moduleName,
  302. CASE WHEN id=18 THEN '疾病总数'
  303. WHEN id=1 THEN '症状标准词'
  304. WHEN id=25 THEN '手术项目'
  305. WHEN id=11 THEN '治疗数目'
  306. ELSE `name` END AS itemName
  307. FROM kl_lexicon
  308. WHERE id in (18,1,35,33,12,13,16,10,25,11)
  309. ) a
  310. LEFT JOIN
  311. (SELECT
  312. lib_type,COUNT(id) AS count
  313. FROM kl_concept
  314. WHERE lib_type in (18,1,35,33,12,13,16,10,25,11)
  315. AND is_deleted='N'
  316. GROUP BY lib_type) b
  317. ON a.id=b.lib_type
  318. </select>
  319. </mapper>