KlConceptStaticMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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.KlConceptStaticMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.KlConceptStatic">
  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="concept_id" property="conceptId" />
  13. <result column="status" property="status" />
  14. <result column="clinical_pathway_name" property="clinicalPathwayName" />
  15. <result column="notice_name" property="noticeName" />
  16. </resultMap>
  17. <!-- 分页查询 -->
  18. <select id="getPage" resultType="com.diagbot.dto.KlConceptStaticDTO">
  19. SELECT
  20. t1.id,
  21. t1.NAME,
  22. t1.clinicalPathwayName,
  23. t1.noticeName,
  24. t1.type,
  25. t1.status,
  26. t1.title,
  27. t1.gmtModified,
  28. t1.modifier
  29. FROM
  30. (
  31. SELECT
  32. a.id,
  33. a.lib_name as NAME ,
  34. b.clinical_pathway_name AS clinicalPathwayName,
  35. b.notice_name AS noticeName,
  36. a.lib_type as type,
  37. b.status,
  38. "" AS title,
  39. b.gmt_modified AS gmtModified,
  40. b.modifier
  41. FROM
  42. kl_concept a,
  43. kl_concept_static b
  44. WHERE
  45. a.id = b.concept_id
  46. and a.is_deleted = 'N'
  47. and b.is_deleted = 'N'
  48. <if test="klConceptStaticPageVO.status!=null ">
  49. AND b.status = #{klConceptStaticPageVO.status}
  50. </if>
  51. <if test="klConceptStaticPageVO.name!=null and klConceptStaticPageVO.name!=''">
  52. AND a.lib_name like concat('%', #{klConceptStaticPageVO.name},'%')
  53. </if>
  54. <if test="klConceptStaticPageVO.type!=null and klConceptStaticPageVO.type!=''">
  55. AND a.lib_type = #{klConceptStaticPageVO.type}
  56. </if>
  57. ) t1
  58. ORDER BY
  59. t1.status DESC,
  60. t1.gmtModified DESC
  61. </select>
  62. <!-- 静态知识检索分页返回 -->
  63. <select id="staticIndexPage" resultType="com.diagbot.dto.StaticKnowledgeIndexPageDTO">
  64. SELECT
  65. f.*
  66. FROM
  67. (
  68. SELECT
  69. distinct
  70. s.*,
  71. s1.concept_id AS conceptId,
  72. s1.clinical_pathway_name AS clinicalPathwayName,
  73. s1.notice_name AS noticeName,
  74. s1.`status` AS status,
  75. IF( count( s2.id )> 0, 1, 0 ) AS hasInfo ,
  76. IF( sum( IF ( FIND_IN_SET( 1, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasStaticKnowledge,
  77. IF( sum( IF ( FIND_IN_SET( 2, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasNotice,
  78. IF( sum( IF ( FIND_IN_SET( 3, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasClinicalPathway,
  79. IF( sum( IF ( FIND_IN_SET( 4, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasTreatInfo,
  80. s2.content as abstractContent
  81. FROM
  82. (
  83. SELECT
  84. t.id,
  85. t.NAME,
  86. t.retrievalName,
  87. t.type,
  88. t.typeName,
  89. l1.icd10_code AS code
  90. FROM
  91. (
  92. SELECT
  93. a.NAME AS retrievalName,
  94. a.spell AS spell,
  95. b.id AS id,
  96. b.lib_name AS NAME,
  97. b.lib_type AS type,
  98. c.NAME AS typeName
  99. FROM
  100. kl_library_info a,
  101. kl_concept b,
  102. kl_lexicon c
  103. WHERE
  104. a.is_deleted = 'N'
  105. AND b.is_deleted = 'N'
  106. AND c.is_deleted = 'N'
  107. AND a.concept_id = b.id
  108. AND b.lib_type = c.code
  109. AND b.`status` = 1
  110. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  111. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  112. a.type_id =#{typeId}
  113. </foreach>
  114. </if>
  115. ) t
  116. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  117. AND l1.is_deleted = 'N'
  118. WHERE
  119. 1=1
  120. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  121. AND ( t.retrievalName = #{staticKnowledgeIndexPageVO.inputStr}
  122. OR LOWER(t.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr})
  123. OR LOWER(l1.icd10_code) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  124. </if>
  125. UNION
  126. SELECT
  127. t.id,
  128. t.NAME,
  129. t.retrievalName,
  130. t.type,
  131. t.typeName,
  132. l1.icd10_code AS code
  133. FROM
  134. (
  135. SELECT
  136. a.NAME AS retrievalName,
  137. a.spell AS spell,
  138. b.id AS id,
  139. b.lib_name AS NAME,
  140. b.lib_type AS type,
  141. c.NAME AS typeName
  142. FROM
  143. kl_library_info a,
  144. kl_concept b,
  145. kl_lexicon c
  146. WHERE
  147. a.is_deleted = 'N'
  148. AND b.is_deleted = 'N'
  149. AND c.is_deleted = 'N'
  150. AND a.concept_id = b.id
  151. AND b.lib_type = c.code
  152. AND b.`status` = 1
  153. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  154. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  155. a.type_id =#{typeId}
  156. </foreach>
  157. </if>
  158. ) t
  159. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  160. AND l1.is_deleted = 'N'
  161. WHERE
  162. 1=1
  163. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  164. AND ( t.retrievalName LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%')
  165. OR LOWER(t.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%'))
  166. OR LOWER(l1.icd10_code) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  167. </if>
  168. UNION
  169. SELECT
  170. t.id,
  171. t.NAME,
  172. t.retrievalName,
  173. t.type,
  174. t.typeName,
  175. l1.icd10_code AS code
  176. FROM
  177. (
  178. SELECT
  179. a.NAME AS retrievalName,
  180. a.spell AS spell,
  181. b.id AS id,
  182. b.lib_name AS NAME,
  183. b.lib_type AS type,
  184. c.NAME AS typeName
  185. FROM
  186. kl_library_info a,
  187. kl_concept b,
  188. kl_lexicon c
  189. WHERE
  190. a.is_deleted = 'N'
  191. AND b.is_deleted = 'N'
  192. AND c.is_deleted = 'N'
  193. AND a.concept_id = b.id
  194. AND b.lib_type = c.code
  195. AND b.`status` = 1
  196. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  197. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  198. a.type_id =#{typeId}
  199. </foreach>
  200. </if>
  201. ) t
  202. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  203. AND l1.is_deleted = 'N'
  204. WHERE
  205. 1=1
  206. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  207. AND ( t.retrievalName LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')
  208. OR LOWER(t.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%'))
  209. OR LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  210. </if>
  211. <if test="(staticKnowledgeIndexPageVO.types != null and staticKnowledgeIndexPageVO.types.size > 0 and (staticKnowledgeIndexPageVO.types.contains(0) or staticKnowledgeIndexPageVO.types.contains(3))) or staticKnowledgeIndexPageVO.types==null or staticKnowledgeIndexPageVO.types.size==0">
  212. UNION
  213. SELECT DISTINCT
  214. e.id AS id,
  215. e.lib_name AS NAME,
  216. b.lib_name AS retrievalName,
  217. e.lib_type AS type,
  218. c.name AS typeName,
  219. NULL AS code
  220. FROM
  221. kl_library_info a,
  222. kl_concept b,
  223. kl_lexicon c,
  224. kl_relation d,
  225. kl_concept e
  226. WHERE
  227. a.is_deleted = 'N'
  228. AND b.is_deleted = 'N'
  229. AND c.is_deleted = 'N'
  230. AND d.is_deleted = 'N'
  231. AND e.is_deleted = 'N'
  232. AND a.concept_id = b.id
  233. AND b.id = d.end_id
  234. AND e.id = d.start_id
  235. AND e.lib_type = c.code
  236. AND b.lib_type = 108
  237. AND e.lib_type = 107
  238. AND d.relation_id = 600
  239. AND b.`status` = 1
  240. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  241. AND ( a.name = #{staticKnowledgeIndexPageVO.inputStr} OR LOWER(a.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  242. </if>
  243. UNION
  244. SELECT DISTINCT
  245. e.id AS id,
  246. e.lib_name AS NAME,
  247. b.lib_name AS retrievalName,
  248. e.lib_type AS type,
  249. c.name AS typeName,
  250. NULL AS code
  251. FROM
  252. kl_library_info a,
  253. kl_concept b,
  254. kl_lexicon c,
  255. kl_relation d,
  256. kl_concept e
  257. WHERE
  258. a.is_deleted = 'N'
  259. AND b.is_deleted = 'N'
  260. AND c.is_deleted = 'N'
  261. AND d.is_deleted = 'N'
  262. AND e.is_deleted = 'N'
  263. AND a.concept_id = b.id
  264. AND b.id = d.end_id
  265. AND e.id = d.start_id
  266. AND e.lib_type = c.code
  267. AND b.lib_type = 108
  268. AND e.lib_type = 107
  269. AND d.relation_id = 600
  270. AND b.`status` = 1
  271. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  272. AND ( a.name LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  273. </if>
  274. UNION
  275. SELECT DISTINCT
  276. e.id AS id,
  277. e.lib_name AS NAME,
  278. b.lib_name AS retrievalName,
  279. e.lib_type AS type,
  280. c.name AS typeName,
  281. NULL AS code
  282. FROM
  283. kl_library_info a,
  284. kl_concept b,
  285. kl_lexicon c,
  286. kl_relation d,
  287. kl_concept e
  288. WHERE
  289. a.is_deleted = 'N'
  290. AND b.is_deleted = 'N'
  291. AND c.is_deleted = 'N'
  292. AND d.is_deleted = 'N'
  293. AND e.is_deleted = 'N'
  294. AND a.concept_id = b.id
  295. AND b.id = d.end_id
  296. AND e.id = d.start_id
  297. AND e.lib_type = c.code
  298. AND b.lib_type = 108
  299. AND e.lib_type = 107
  300. AND d.relation_id = 600
  301. AND b.`status` = 1
  302. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  303. AND ( a.name LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  304. </if>
  305. </if>
  306. ) s,
  307. kl_concept_static s1,
  308. kl_concept_detail s2
  309. WHERE s.id = s1.concept_id
  310. AND s.id = s2.concept_id
  311. AND s1.is_deleted = 'N'
  312. AND s2.is_deleted = 'N'
  313. AND (FIND_IN_SET( 1, s2.content_type ) OR FIND_IN_SET( 2, s2.content_type ) OR FIND_IN_SET( 3, s2.content_type ))
  314. GROUP BY s.id
  315. ORDER BY s.type ASC ,s2.order_no ASC
  316. ) f
  317. </select>
  318. </mapper>