KlConceptStaticMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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.isConcept,
  88. t.type,
  89. t.typeName,
  90. l1.icd10_code AS code
  91. FROM
  92. (
  93. SELECT
  94. a.NAME AS retrievalName,
  95. a.spell AS spell,
  96. a.is_concept AS isConcept,
  97. b.id AS id,
  98. b.lib_name AS NAME,
  99. b.lib_type AS type,
  100. c.NAME AS typeName
  101. FROM
  102. kl_library_info a,
  103. kl_concept b,
  104. kl_lexicon c
  105. WHERE
  106. a.is_deleted = 'N'
  107. AND b.is_deleted = 'N'
  108. AND c.is_deleted = 'N'
  109. AND a.concept_id = b.id
  110. AND b.lib_type = c.code
  111. AND b.`status` = 1
  112. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  113. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  114. a.type_id =#{typeId}
  115. </foreach>
  116. </if>
  117. ) t
  118. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  119. AND l1.is_deleted = 'N'
  120. WHERE
  121. 1=1
  122. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  123. AND ( t.retrievalName = #{staticKnowledgeIndexPageVO.inputStr}
  124. OR LOWER(t.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr})
  125. OR LOWER(l1.icd10_code) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  126. </if>
  127. UNION
  128. SELECT
  129. t.id,
  130. t.NAME,
  131. t.retrievalName,
  132. t.isConcept,
  133. t.type,
  134. t.typeName,
  135. l1.icd10_code AS code
  136. FROM
  137. (
  138. SELECT
  139. a.NAME AS retrievalName,
  140. a.spell AS spell,
  141. a.is_concept AS isConcept,
  142. b.id AS id,
  143. b.lib_name AS NAME,
  144. b.lib_type AS type,
  145. c.NAME AS typeName
  146. FROM
  147. kl_library_info a,
  148. kl_concept b,
  149. kl_lexicon c
  150. WHERE
  151. a.is_deleted = 'N'
  152. AND b.is_deleted = 'N'
  153. AND c.is_deleted = 'N'
  154. AND a.concept_id = b.id
  155. AND b.lib_type = c.code
  156. AND b.`status` = 1
  157. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  158. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  159. a.type_id =#{typeId}
  160. </foreach>
  161. </if>
  162. ) t
  163. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  164. AND l1.is_deleted = 'N'
  165. WHERE
  166. 1=1
  167. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  168. AND ( t.retrievalName LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%')
  169. OR LOWER(t.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%'))
  170. OR LOWER(l1.icd10_code) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  171. </if>
  172. UNION
  173. SELECT
  174. t.id,
  175. t.NAME,
  176. t.retrievalName,
  177. t.isConcept,
  178. t.type,
  179. t.typeName,
  180. l1.icd10_code AS code
  181. FROM
  182. (
  183. SELECT
  184. a.NAME AS retrievalName,
  185. a.spell AS spell,
  186. a.is_concept AS isConcept,
  187. b.id AS id,
  188. b.lib_name AS NAME,
  189. b.lib_type AS type,
  190. c.NAME AS typeName
  191. FROM
  192. kl_library_info a,
  193. kl_concept b,
  194. kl_lexicon c
  195. WHERE
  196. a.is_deleted = 'N'
  197. AND b.is_deleted = 'N'
  198. AND c.is_deleted = 'N'
  199. AND a.concept_id = b.id
  200. AND b.lib_type = c.code
  201. AND b.`status` = 1
  202. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  203. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  204. a.type_id =#{typeId}
  205. </foreach>
  206. </if>
  207. ) t
  208. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  209. AND l1.is_deleted = 'N'
  210. WHERE
  211. 1=1
  212. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  213. AND ( t.retrievalName LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')
  214. OR LOWER(t.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%'))
  215. OR LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  216. </if>
  217. <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">
  218. UNION
  219. SELECT DISTINCT
  220. e.id AS id,
  221. e.lib_name AS NAME,
  222. b.lib_name AS retrievalName,
  223. 1 AS isConcept,
  224. e.lib_type AS type,
  225. c.name AS typeName,
  226. NULL AS code
  227. FROM
  228. kl_library_info a,
  229. kl_concept b,
  230. kl_lexicon c,
  231. kl_relation d,
  232. kl_concept e
  233. WHERE
  234. a.is_deleted = 'N'
  235. AND b.is_deleted = 'N'
  236. AND c.is_deleted = 'N'
  237. AND d.is_deleted = 'N'
  238. AND e.is_deleted = 'N'
  239. AND a.concept_id = b.id
  240. AND b.id = d.end_id
  241. AND e.id = d.start_id
  242. AND e.lib_type = c.code
  243. AND b.lib_type = 108
  244. AND e.lib_type = 107
  245. AND d.relation_id = 600
  246. AND b.`status` = 1
  247. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  248. AND ( a.name = #{staticKnowledgeIndexPageVO.inputStr} OR LOWER(a.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  249. </if>
  250. UNION
  251. SELECT DISTINCT
  252. e.id AS id,
  253. e.lib_name AS NAME,
  254. b.lib_name AS retrievalName,
  255. 1 AS isConcept,
  256. e.lib_type AS type,
  257. c.name AS typeName,
  258. NULL AS code
  259. FROM
  260. kl_library_info a,
  261. kl_concept b,
  262. kl_lexicon c,
  263. kl_relation d,
  264. kl_concept e
  265. WHERE
  266. a.is_deleted = 'N'
  267. AND b.is_deleted = 'N'
  268. AND c.is_deleted = 'N'
  269. AND d.is_deleted = 'N'
  270. AND e.is_deleted = 'N'
  271. AND a.concept_id = b.id
  272. AND b.id = d.end_id
  273. AND e.id = d.start_id
  274. AND e.lib_type = c.code
  275. AND b.lib_type = 108
  276. AND e.lib_type = 107
  277. AND d.relation_id = 600
  278. AND b.`status` = 1
  279. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  280. AND ( a.name LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  281. </if>
  282. UNION
  283. SELECT DISTINCT
  284. e.id AS id,
  285. e.lib_name AS NAME,
  286. b.lib_name AS retrievalName,
  287. 1 AS isConcept,
  288. e.lib_type AS type,
  289. c.name AS typeName,
  290. NULL AS code
  291. FROM
  292. kl_library_info a,
  293. kl_concept b,
  294. kl_lexicon c,
  295. kl_relation d,
  296. kl_concept e
  297. WHERE
  298. a.is_deleted = 'N'
  299. AND b.is_deleted = 'N'
  300. AND c.is_deleted = 'N'
  301. AND d.is_deleted = 'N'
  302. AND e.is_deleted = 'N'
  303. AND a.concept_id = b.id
  304. AND b.id = d.end_id
  305. AND e.id = d.start_id
  306. AND e.lib_type = c.code
  307. AND b.lib_type = 108
  308. AND e.lib_type = 107
  309. AND d.relation_id = 600
  310. AND b.`status` = 1
  311. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  312. AND ( a.name LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  313. </if>
  314. </if>
  315. ) s,
  316. kl_concept_static s1,
  317. kl_concept_detail s2
  318. WHERE s.id = s1.concept_id
  319. AND s.id = s2.concept_id
  320. AND s1.is_deleted = 'N'
  321. AND s2.is_deleted = 'N'
  322. AND (FIND_IN_SET( 1, s2.content_type ) OR FIND_IN_SET( 2, s2.content_type ) OR FIND_IN_SET( 3, s2.content_type ))
  323. GROUP BY s.id
  324. ORDER BY s.type ASC,
  325. s.isConcept DESC,
  326. s2.order_no ASC
  327. ) f
  328. </select>
  329. </mapper>