KlConceptStaticMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. s.moduleNo,
  70. s.id,
  71. s.name,
  72. s.retrievalName,
  73. s.isConcept,
  74. s.type,
  75. s.typeName,
  76. s.code,
  77. s1.concept_id AS conceptId,
  78. s1.clinical_pathway_name AS clinicalPathwayName,
  79. s1.notice_name AS noticeName,
  80. s1.`status` AS status
  81. FROM
  82. (
  83. SELECT
  84. t.moduleNo,
  85. t.id,
  86. t.NAME,
  87. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  88. t.isConcept,
  89. t.type,
  90. t.typeName,
  91. t1.icd10_code AS code
  92. FROM
  93. (
  94. SELECT
  95. concat( '1', b.lib_type ) AS moduleNo,
  96. a.NAME AS retrievalName,
  97. a.spell AS spell,
  98. a.is_concept AS isConcept,
  99. b.id AS id,
  100. b.lib_name AS NAME,
  101. b.lib_type AS type,
  102. c.NAME AS typeName
  103. FROM
  104. kl_library_info a,
  105. kl_concept b,
  106. kl_lexicon c
  107. WHERE
  108. a.is_deleted = 'N'
  109. AND b.is_deleted = 'N'
  110. AND c.is_deleted = 'N'
  111. AND a.concept_id = b.id
  112. AND b.lib_type = c.code
  113. AND b.`status` = 1
  114. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  115. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  116. a.type_id =#{typeId}
  117. </foreach>
  118. </if>
  119. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  120. AND ( a.name = #{staticKnowledgeIndexPageVO.inputStr}
  121. OR LOWER(a.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  122. </if>
  123. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  124. UNION
  125. SELECT
  126. t.moduleNo,
  127. t.id,
  128. t.NAME,
  129. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  130. t.isConcept,
  131. t.type,
  132. t.typeName,
  133. t1.icd10_code AS code
  134. FROM
  135. (
  136. SELECT
  137. concat( '2', b.lib_type ) AS moduleNo,
  138. a.NAME AS retrievalName,
  139. a.spell AS spell,
  140. a.is_concept AS isConcept,
  141. b.id AS id,
  142. b.lib_name AS NAME,
  143. b.lib_type AS type,
  144. c.NAME AS typeName
  145. FROM
  146. kl_library_info a,
  147. kl_concept b,
  148. kl_lexicon c
  149. WHERE
  150. a.is_deleted = 'N'
  151. AND b.is_deleted = 'N'
  152. AND c.is_deleted = 'N'
  153. AND a.concept_id = b.id
  154. AND b.lib_type = c.code
  155. AND b.`status` = 1
  156. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  157. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  158. a.type_id =#{typeId}
  159. </foreach>
  160. </if>
  161. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  162. AND ( a.name LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%')
  163. OR LOWER(a.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  164. </if>
  165. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  166. UNION
  167. SELECT
  168. t.moduleNo,
  169. t.id,
  170. t.NAME,
  171. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  172. t.isConcept,
  173. t.type,
  174. t.typeName,
  175. t1.icd10_code AS code
  176. FROM
  177. (
  178. SELECT
  179. concat( '3', b.lib_type ) AS moduleNo,
  180. a.NAME AS retrievalName,
  181. a.spell AS spell,
  182. a.is_concept AS isConcept,
  183. b.id AS id,
  184. b.lib_name AS NAME,
  185. b.lib_type AS type,
  186. c.NAME AS typeName
  187. FROM
  188. kl_library_info a,
  189. kl_concept b,
  190. kl_lexicon c
  191. WHERE
  192. a.is_deleted = 'N'
  193. AND b.is_deleted = 'N'
  194. AND c.is_deleted = 'N'
  195. AND a.concept_id = b.id
  196. AND b.lib_type = c.code
  197. AND b.`status` = 1
  198. <if test="staticKnowledgeIndexPageVO.typeIds != null and staticKnowledgeIndexPageVO.typeIds.size > 0">
  199. <foreach item="typeId" collection="staticKnowledgeIndexPageVO.typeIds" open="and(" separator="or" close=")" >
  200. a.type_id =#{typeId}
  201. </foreach>
  202. </if>
  203. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  204. AND ( a.name LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')
  205. OR LOWER(a.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  206. </if>
  207. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  208. <if test="staticKnowledgeIndexPageVO.typeIds.contains(107) or staticKnowledgeIndexPageVO.typeIds.contains(108)">
  209. UNION
  210. SELECT DISTINCT
  211. concat( '1', e.lib_type ) AS moduleNo,
  212. e.id AS id,
  213. e.lib_name AS NAME,
  214. b.lib_name AS retrievalName,
  215. 1 AS isConcept,
  216. e.lib_type AS type,
  217. c.name AS typeName,
  218. NULL AS code
  219. FROM
  220. kl_library_info a,
  221. kl_concept b,
  222. kl_lexicon c,
  223. kl_relation d,
  224. kl_concept e
  225. WHERE
  226. a.is_deleted = 'N'
  227. AND b.is_deleted = 'N'
  228. AND c.is_deleted = 'N'
  229. AND d.is_deleted = 'N'
  230. AND e.is_deleted = 'N'
  231. AND a.concept_id = b.id
  232. AND b.id = d.end_id
  233. AND e.id = d.start_id
  234. AND e.lib_type = c.code
  235. AND b.lib_type = 108
  236. AND e.lib_type = 107
  237. AND d.relation_id = 600
  238. AND b.`status` = 1
  239. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  240. AND ( a.name = #{staticKnowledgeIndexPageVO.inputStr} OR LOWER(a.spell) = LOWER(#{staticKnowledgeIndexPageVO.inputStr}))
  241. </if>
  242. UNION
  243. SELECT DISTINCT
  244. concat( '2', e.lib_type ) AS moduleNo,
  245. e.id AS id,
  246. e.lib_name AS NAME,
  247. b.lib_name AS retrievalName,
  248. 1 AS isConcept,
  249. e.lib_type AS type,
  250. c.name AS typeName,
  251. NULL AS code
  252. FROM
  253. kl_library_info a,
  254. kl_concept b,
  255. kl_lexicon c,
  256. kl_relation d,
  257. kl_concept e
  258. WHERE
  259. a.is_deleted = 'N'
  260. AND b.is_deleted = 'N'
  261. AND c.is_deleted = 'N'
  262. AND d.is_deleted = 'N'
  263. AND e.is_deleted = 'N'
  264. AND a.concept_id = b.id
  265. AND b.id = d.end_id
  266. AND e.id = d.start_id
  267. AND e.lib_type = c.code
  268. AND b.lib_type = 108
  269. AND e.lib_type = 107
  270. AND d.relation_id = 600
  271. AND b.`status` = 1
  272. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  273. AND ( a.name LIKE concat(#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%')))
  274. </if>
  275. UNION
  276. SELECT DISTINCT
  277. concat( '3', e.lib_type ) AS moduleNo,
  278. e.id AS id,
  279. e.lib_name AS NAME,
  280. b.lib_name AS retrievalName,
  281. 1 AS isConcept,
  282. e.lib_type AS type,
  283. c.name AS typeName,
  284. NULL AS code
  285. FROM
  286. kl_library_info a,
  287. kl_concept b,
  288. kl_lexicon c,
  289. kl_relation d,
  290. kl_concept e
  291. WHERE
  292. a.is_deleted = 'N'
  293. AND b.is_deleted = 'N'
  294. AND c.is_deleted = 'N'
  295. AND d.is_deleted = 'N'
  296. AND e.is_deleted = 'N'
  297. AND a.concept_id = b.id
  298. AND b.id = d.end_id
  299. AND e.id = d.start_id
  300. AND e.lib_type = c.code
  301. AND b.lib_type = 108
  302. AND e.lib_type = 107
  303. AND d.relation_id = 600
  304. AND b.`status` = 1
  305. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  306. AND ( a.name LIKE concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%')))
  307. </if>
  308. </if>
  309. <if test="staticKnowledgeIndexPageVO.typeIds.contains(100) ">
  310. UNION
  311. SELECT
  312. t.moduleNo,
  313. t.id,
  314. t.NAME,
  315. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  316. t.isConcept,
  317. t.type,
  318. t.typeName,
  319. l1.icd10_code AS code
  320. FROM
  321. (
  322. SELECT
  323. concat( '1', b.lib_type ) AS moduleNo,
  324. a.NAME AS retrievalName,
  325. a.spell AS spell,
  326. a.is_concept AS isConcept,
  327. b.id AS id,
  328. b.lib_name AS NAME,
  329. b.lib_type AS type,
  330. c.NAME AS typeName
  331. FROM
  332. kl_library_info a,
  333. kl_concept b,
  334. kl_lexicon c
  335. WHERE
  336. a.is_deleted = 'N'
  337. AND b.is_deleted = 'N'
  338. AND c.is_deleted = 'N'
  339. AND a.concept_id = b.id
  340. AND b.lib_type = c.code
  341. AND b.`status` = 1
  342. AND a.type_id =100
  343. ) t
  344. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  345. AND l1.is_deleted = 'N'
  346. WHERE
  347. 1=1
  348. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  349. AND LOWER(l1.icd10_code) = LOWER(#{staticKnowledgeIndexPageVO.inputStr})
  350. </if>
  351. UNION
  352. SELECT
  353. t.moduleNo,
  354. t.id,
  355. t.NAME,
  356. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  357. t.isConcept,
  358. t.type,
  359. t.typeName,
  360. l1.icd10_code AS code
  361. FROM
  362. (
  363. SELECT
  364. concat( '2', b.lib_type ) AS moduleNo,
  365. a.NAME AS retrievalName,
  366. a.spell AS spell,
  367. a.is_concept AS isConcept,
  368. b.id AS id,
  369. b.lib_name AS NAME,
  370. b.lib_type AS type,
  371. c.NAME AS typeName
  372. FROM
  373. kl_library_info a,
  374. kl_concept b,
  375. kl_lexicon c
  376. WHERE
  377. a.is_deleted = 'N'
  378. AND b.is_deleted = 'N'
  379. AND c.is_deleted = 'N'
  380. AND a.concept_id = b.id
  381. AND b.lib_type = c.code
  382. AND b.`status` = 1
  383. AND a.type_id =100
  384. ) t
  385. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  386. AND l1.is_deleted = 'N'
  387. WHERE
  388. 1=1
  389. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  390. AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{staticKnowledgeIndexPageVO.inputStr},'%'))
  391. </if>
  392. UNION
  393. SELECT
  394. t.moduleNo,
  395. t.id,
  396. t.NAME,
  397. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  398. t.isConcept,
  399. t.type,
  400. t.typeName,
  401. l1.icd10_code AS code
  402. FROM
  403. (
  404. SELECT
  405. concat( '3', b.lib_type ) AS moduleNo,
  406. a.NAME AS retrievalName,
  407. a.spell AS spell,
  408. a.is_concept AS isConcept,
  409. b.id AS id,
  410. b.lib_name AS NAME,
  411. b.lib_type AS type,
  412. c.NAME AS typeName
  413. FROM
  414. kl_library_info a,
  415. kl_concept b,
  416. kl_lexicon c
  417. WHERE
  418. a.is_deleted = 'N'
  419. AND b.is_deleted = 'N'
  420. AND c.is_deleted = 'N'
  421. AND a.concept_id = b.id
  422. AND b.lib_type = c.code
  423. AND b.`status` = 1
  424. AND a.type_id =100
  425. ) t
  426. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  427. AND l1.is_deleted = 'N'
  428. WHERE
  429. 1=1
  430. <if test="staticKnowledgeIndexPageVO.inputStr!=null and staticKnowledgeIndexPageVO.inputStr!=''">
  431. AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{staticKnowledgeIndexPageVO.inputStr},'%'))
  432. </if>
  433. </if>
  434. ) s,
  435. kl_concept_static s1
  436. WHERE s.id = s1.concept_id
  437. AND s1.is_deleted = 'N'
  438. GROUP BY s.id
  439. ORDER BY s.type ASC,
  440. s.moduleNo ASC,
  441. s.isConcept DESC
  442. ) f
  443. </select>
  444. </mapper>