KlConceptMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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.KlConceptMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.KlConcept">
  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. <result column="status" property="status" />
  16. </resultMap>
  17. <select id="index" resultType="com.diagbot.dto.IndexDTO">
  18. SELECT DISTINCT
  19. t.id as id,
  20. t.lib_name as name
  21. <if test="typeId!=null and typeId==100">
  22. ,t.icd10Code as icd10Code
  23. </if>
  24. <if test="typeId!=null and typeId==108">
  25. ,
  26. t1.max_value as `maxValue`,
  27. t1.min_value as minValue,
  28. t1.unit as units,
  29. t1.type as `range`,
  30. t4.lib_name AS packName,
  31. t4.id as packId
  32. </if>
  33. FROM
  34. (
  35. SELECT DISTINCT
  36. b.id,
  37. b.lib_name
  38. <if test="typeId!=null and typeId==100">
  39. ,c.icd10_code as icd10Code
  40. </if>
  41. FROM
  42. kl_library_info a,
  43. kl_concept b
  44. <if test="typeId!=null and typeId==100">
  45. left join kl_disease c
  46. on c.is_deleted = 'N'
  47. and b.id = c.concept_id
  48. </if>
  49. WHERE
  50. a.is_deleted = 'N'
  51. AND b.is_deleted = 'N'
  52. AND a.concept_id = b.id
  53. AND a.id = b.lib_id
  54. <if test="inputStr!=null and inputStr!=''">
  55. AND ( a.`name` = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr})
  56. <if test="typeId!=null and typeId==100">
  57. OR LOWER(c.icd10_code) = LOWER(#{inputStr})
  58. </if>
  59. )
  60. </if>
  61. <if test="typeIds != null and typeIds.size > 0">
  62. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  63. a.type_id =#{typeId}
  64. </foreach>
  65. </if>
  66. UNION
  67. SELECT DISTINCT
  68. b.id,
  69. b.lib_name
  70. <if test="typeId!=null and typeId==100">
  71. ,c.icd10_code as icd10Code
  72. </if>
  73. FROM
  74. kl_library_info a,
  75. kl_concept b
  76. <if test="typeId!=null and typeId==100">
  77. left join kl_disease c
  78. on c.is_deleted = 'N'
  79. and b.id = c.concept_id
  80. </if>
  81. WHERE
  82. a.is_deleted = 'N'
  83. AND b.is_deleted = 'N'
  84. AND a.concept_id = b.id
  85. AND a.id = b.lib_id
  86. <if test="inputStr!=null and inputStr!=''">
  87. AND ( a.`name` LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER(concat(#{inputStr},'%'))
  88. <if test="typeId!=null and typeId==100">
  89. OR LOWER(c.icd10_code) LIKE LOWER(concat(#{inputStr},'%'))
  90. </if>
  91. )
  92. </if>
  93. <if test="typeIds != null and typeIds.size > 0">
  94. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  95. a.type_id =#{typeId}
  96. </foreach>
  97. </if>
  98. UNION
  99. SELECT DISTINCT
  100. b.id,
  101. b.lib_name
  102. <if test="typeId!=null and typeId==100">
  103. ,c.icd10_code as icd10Code
  104. </if>
  105. FROM
  106. kl_library_info a,
  107. kl_concept b
  108. <if test="typeId!=null and typeId==100">
  109. left join kl_disease c
  110. on c.is_deleted = 'N'
  111. and b.id = c.concept_id
  112. </if>
  113. WHERE
  114. a.is_deleted = 'N'
  115. AND b.is_deleted = 'N'
  116. AND a.concept_id = b.id
  117. AND a.id = b.lib_id
  118. <if test="inputStr!=null and inputStr!=''">
  119. AND ( a.`name` LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
  120. <if test="typeId!=null and typeId==100">
  121. OR LOWER(c.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  122. </if>
  123. )
  124. </if>
  125. <if test="typeIds != null and typeIds.size > 0">
  126. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  127. a.type_id =#{typeId}
  128. </foreach>
  129. </if>
  130. ) t
  131. <if test="typeId!=null and typeId==108">
  132. LEFT JOIN kl_lis t1 ON t.id = t1.concept_id
  133. AND t1.is_deleted = 'N'
  134. LEFT JOIN kl_relation t3 ON t.id = t3.end_id
  135. AND t3.relation_id = 600
  136. AND t3.is_deleted = 'N'
  137. LEFT JOIN kl_concept t4 ON t3.start_id = t4.id
  138. AND t4.lib_type = 107
  139. AND t4.is_deleted = 'N'
  140. </if>
  141. <if test="size!=null">
  142. LIMIT #{size}
  143. </if>
  144. </select>
  145. <select id="staticIndex" resultType="com.diagbot.dto.StaticKnowledgeIndexDTO">
  146. SELECT
  147. f.*
  148. FROM
  149. (
  150. SELECT
  151. s.id,
  152. s.name,
  153. s.retrievalName,
  154. s.isConcept,
  155. s.type,
  156. s.typeName,
  157. group_concat(distinct s.code SEPARATOR '') as code,
  158. s1.concept_id AS conceptId,
  159. s1.clinical_pathway_name,
  160. s1.notice_name,
  161. s1.`status` AS status,
  162. IF( count( s2.id )> 0, 1, 0 ) AS hasInfo ,
  163. IF( sum( IF ( FIND_IN_SET( 1, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasStaticKnowledge,
  164. IF( sum( IF ( FIND_IN_SET( 2, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasNotice,
  165. IF( sum( IF ( FIND_IN_SET( 3, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasClinicalPathway,
  166. IF( sum( IF ( FIND_IN_SET( 4, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasTreatInfo
  167. FROM
  168. (
  169. SELECT
  170. t.id,
  171. t.NAME,
  172. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  173. t.isConcept,
  174. t.type,
  175. t.typeName,
  176. '' AS code
  177. FROM
  178. (
  179. SELECT
  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="typeIds != null and typeIds.size > 0">
  199. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  200. a.type_id =#{typeId}
  201. </foreach>
  202. </if>
  203. ) t
  204. WHERE
  205. 1=1
  206. <if test="inputStr!=null and inputStr!=''">
  207. AND ( t.retrievalName = #{inputStr}
  208. OR LOWER(t.spell) = LOWER(#{inputStr}))
  209. </if>
  210. UNION
  211. SELECT
  212. t.id,
  213. t.NAME,
  214. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  215. t.isConcept,
  216. t.type,
  217. t.typeName,
  218. '' AS code
  219. FROM
  220. (
  221. SELECT
  222. a.NAME AS retrievalName,
  223. a.spell AS spell,
  224. a.is_concept AS isConcept,
  225. b.id AS id,
  226. b.lib_name AS NAME,
  227. b.lib_type AS type,
  228. c.NAME AS typeName
  229. FROM
  230. kl_library_info a,
  231. kl_concept b,
  232. kl_lexicon c
  233. WHERE
  234. a.is_deleted = 'N'
  235. AND b.is_deleted = 'N'
  236. AND c.is_deleted = 'N'
  237. AND a.concept_id = b.id
  238. AND b.lib_type = c.code
  239. AND b.`status` = 1
  240. <if test="typeIds != null and typeIds.size > 0">
  241. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  242. a.type_id =#{typeId}
  243. </foreach>
  244. </if>
  245. ) t
  246. WHERE
  247. 1=1
  248. <if test="inputStr!=null and inputStr!=''">
  249. AND ( t.retrievalName LIKE concat(#{inputStr},'%')
  250. OR LOWER(t.spell) LIKE LOWER( concat(#{inputStr},'%')))
  251. </if>
  252. UNION
  253. SELECT
  254. t.id,
  255. t.NAME,
  256. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  257. t.isConcept,
  258. t.type,
  259. t.typeName,
  260. '' AS code
  261. FROM
  262. (
  263. SELECT
  264. a.NAME AS retrievalName,
  265. a.spell AS spell,
  266. a.is_concept AS isConcept,
  267. b.id AS id,
  268. b.lib_name AS NAME,
  269. b.lib_type AS type,
  270. c.NAME AS typeName
  271. FROM
  272. kl_library_info a,
  273. kl_concept b,
  274. kl_lexicon c
  275. WHERE
  276. a.is_deleted = 'N'
  277. AND b.is_deleted = 'N'
  278. AND c.is_deleted = 'N'
  279. AND a.concept_id = b.id
  280. AND b.lib_type = c.code
  281. AND b.`status` = 1
  282. <if test="typeIds != null and typeIds.size > 0">
  283. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  284. a.type_id =#{typeId}
  285. </foreach>
  286. </if>
  287. ) t
  288. WHERE
  289. 1=1
  290. <if test="inputStr!=null and inputStr!=''">
  291. AND ( t.retrievalName LIKE concat('%',#{inputStr},'%')
  292. OR LOWER(t.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
  293. </if>
  294. <if test="typeIds.contains(107) or typeIds.contains(108)">
  295. UNION
  296. SELECT DISTINCT
  297. e.id AS id,
  298. e.lib_name AS NAME,
  299. b.lib_name AS retrievalName,
  300. 1 AS isConcept,
  301. e.lib_type AS type,
  302. c.name AS typeName,
  303. NULL AS code
  304. FROM
  305. kl_library_info a,
  306. kl_concept b,
  307. kl_lexicon c,
  308. kl_relation d,
  309. kl_concept e
  310. WHERE
  311. a.is_deleted = 'N'
  312. AND b.is_deleted = 'N'
  313. AND c.is_deleted = 'N'
  314. AND d.is_deleted = 'N'
  315. AND e.is_deleted = 'N'
  316. AND a.concept_id = b.id
  317. AND b.id = d.end_id
  318. AND e.id = d.start_id
  319. AND e.lib_type = c.code
  320. AND b.lib_type = 108
  321. AND e.lib_type = 107
  322. AND d.relation_id = 600
  323. AND b.`status` = 1
  324. <if test="inputStr!=null and inputStr!=''">
  325. AND ( a.name = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr}))
  326. </if>
  327. UNION
  328. SELECT DISTINCT
  329. e.id AS id,
  330. e.lib_name AS NAME,
  331. b.lib_name AS retrievalName,
  332. 1 AS isConcept,
  333. e.lib_type AS type,
  334. c.name AS typeName,
  335. NULL AS code
  336. FROM
  337. kl_library_info a,
  338. kl_concept b,
  339. kl_lexicon c,
  340. kl_relation d,
  341. kl_concept e
  342. WHERE
  343. a.is_deleted = 'N'
  344. AND b.is_deleted = 'N'
  345. AND c.is_deleted = 'N'
  346. AND d.is_deleted = 'N'
  347. AND e.is_deleted = 'N'
  348. AND a.concept_id = b.id
  349. AND b.id = d.end_id
  350. AND e.id = d.start_id
  351. AND e.lib_type = c.code
  352. AND b.lib_type = 108
  353. AND e.lib_type = 107
  354. AND d.relation_id = 600
  355. AND b.`status` = 1
  356. <if test="inputStr!=null and inputStr!=''">
  357. AND ( a.name LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
  358. </if>
  359. UNION
  360. SELECT DISTINCT
  361. e.id AS id,
  362. e.lib_name AS NAME,
  363. b.lib_name AS retrievalName,
  364. 1 AS isConcept,
  365. e.lib_type AS type,
  366. c.name AS typeName,
  367. NULL AS code
  368. FROM
  369. kl_library_info a,
  370. kl_concept b,
  371. kl_lexicon c,
  372. kl_relation d,
  373. kl_concept e
  374. WHERE
  375. a.is_deleted = 'N'
  376. AND b.is_deleted = 'N'
  377. AND c.is_deleted = 'N'
  378. AND d.is_deleted = 'N'
  379. AND e.is_deleted = 'N'
  380. AND a.concept_id = b.id
  381. AND b.id = d.end_id
  382. AND e.id = d.start_id
  383. AND e.lib_type = c.code
  384. AND b.lib_type = 108
  385. AND e.lib_type = 107
  386. AND d.relation_id = 600
  387. AND b.`status` = 1
  388. <if test="inputStr!=null and inputStr!=''">
  389. AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
  390. </if>
  391. </if>
  392. <if test="typeIds.contains(100) ">
  393. UNION
  394. SELECT
  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. a.NAME AS retrievalName,
  406. a.spell AS spell,
  407. a.is_concept AS isConcept,
  408. b.id AS id,
  409. b.lib_name AS NAME,
  410. b.lib_type AS type,
  411. c.NAME AS typeName
  412. FROM
  413. kl_library_info a,
  414. kl_concept b,
  415. kl_lexicon c
  416. WHERE
  417. a.is_deleted = 'N'
  418. AND b.is_deleted = 'N'
  419. AND c.is_deleted = 'N'
  420. AND a.concept_id = b.id
  421. AND b.lib_type = c.code
  422. AND b.`status` = 1
  423. AND a.type_id =100
  424. ) t
  425. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  426. AND l1.is_deleted = 'N'
  427. WHERE
  428. 1=1
  429. <if test="inputStr!=null and inputStr!=''">
  430. AND LOWER(l1.icd10_code) = LOWER(#{inputStr})
  431. </if>
  432. UNION
  433. SELECT
  434. t.id,
  435. t.NAME,
  436. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  437. t.isConcept,
  438. t.type,
  439. t.typeName,
  440. l1.icd10_code AS code
  441. FROM
  442. (
  443. SELECT
  444. a.NAME AS retrievalName,
  445. a.spell AS spell,
  446. a.is_concept AS isConcept,
  447. b.id AS id,
  448. b.lib_name AS NAME,
  449. b.lib_type AS type,
  450. c.NAME AS typeName
  451. FROM
  452. kl_library_info a,
  453. kl_concept b,
  454. kl_lexicon c
  455. WHERE
  456. a.is_deleted = 'N'
  457. AND b.is_deleted = 'N'
  458. AND c.is_deleted = 'N'
  459. AND a.concept_id = b.id
  460. AND b.lib_type = c.code
  461. AND b.`status` = 1
  462. AND a.type_id =100
  463. ) t
  464. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  465. AND l1.is_deleted = 'N'
  466. WHERE
  467. 1=1
  468. <if test="inputStr!=null and inputStr!=''">
  469. AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
  470. </if>
  471. UNION
  472. SELECT
  473. t.id,
  474. t.NAME,
  475. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  476. t.isConcept,
  477. t.type,
  478. t.typeName,
  479. l1.icd10_code AS code
  480. FROM
  481. (
  482. SELECT
  483. a.NAME AS retrievalName,
  484. a.spell AS spell,
  485. a.is_concept AS isConcept,
  486. b.id AS id,
  487. b.lib_name AS NAME,
  488. b.lib_type AS type,
  489. c.NAME AS typeName
  490. FROM
  491. kl_library_info a,
  492. kl_concept b,
  493. kl_lexicon c
  494. WHERE
  495. a.is_deleted = 'N'
  496. AND b.is_deleted = 'N'
  497. AND c.is_deleted = 'N'
  498. AND a.concept_id = b.id
  499. AND b.lib_type = c.code
  500. AND b.`status` = 1
  501. AND a.type_id =100
  502. ) t
  503. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  504. AND l1.is_deleted = 'N'
  505. WHERE
  506. 1=1
  507. <if test="inputStr!=null and inputStr!=''">
  508. AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  509. </if>
  510. </if>
  511. ) s
  512. LEFT JOIN kl_concept_static s1 ON s.id = s1.concept_id
  513. AND s1.is_deleted = 'N'
  514. LEFT JOIN kl_concept_detail s2 ON s.id = s2.concept_id
  515. AND s2.is_deleted = 'N'
  516. GROUP BY s.id
  517. ) f
  518. WHERE
  519. 1 = 1
  520. <if test="hasInfo!=null ">
  521. <choose>
  522. <when test="hasInfo==0">
  523. AND f.conceptId IS NULL
  524. </when>
  525. <when test="hasInfo==1">
  526. AND f.conceptId IS NOT NULL
  527. </when>
  528. </choose>
  529. </if>
  530. order by f.type asc,f.isConcept DESC
  531. <if test="size!=null">
  532. LIMIT #{size}
  533. </if>
  534. </select>
  535. </mapper>