KlConceptMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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.code as code
  23. </if>
  24. <if test="typeId!=null and typeId==127">
  25. ,t.code as code
  26. </if>
  27. <if test="typeId!=null and typeId==128">
  28. ,t.code as code
  29. </if>
  30. <if test="typeId!=null and typeId==106">
  31. ,t.code as code
  32. </if>
  33. <if test="typeId!=null and typeId==108">
  34. ,
  35. t1.max_value as `maxValue`,
  36. t1.min_value as minValue,
  37. t1.unit as units,
  38. t1.type as `range`,
  39. t4.lib_name AS packName,
  40. t4.id as packId
  41. </if>
  42. FROM
  43. (
  44. SELECT DISTINCT
  45. b.id,
  46. b.lib_name
  47. <if test="typeId!=null and typeId==100">
  48. ,c.icd10_code as code
  49. </if>
  50. <if test="typeId!=null and typeId==127">
  51. ,c.code as code
  52. </if>
  53. <if test="typeId!=null and typeId==128">
  54. ,c.code as code
  55. </if>
  56. <if test="typeId!=null and typeId==106">
  57. ,c.operation_code as code
  58. </if>
  59. FROM
  60. kl_library_info a,
  61. kl_concept b
  62. <if test="typeId!=null and typeId==100">
  63. left join kl_disease c
  64. on c.is_deleted = 'N'
  65. and b.id = c.concept_id
  66. </if>
  67. <if test="typeId!=null and typeId==127">
  68. left join kl_tcm_disease c
  69. on c.is_deleted = 'N'
  70. and b.id = c.concept_id
  71. </if>
  72. <if test="typeId!=null and typeId==128">
  73. left join kl_tcm_syndrome c
  74. on c.is_deleted = 'N'
  75. and b.id = c.concept_id
  76. </if>
  77. <if test="typeId!=null and typeId==106">
  78. LEFT JOIN `kl_operation` c
  79. ON c.is_deleted = 'N'
  80. AND b.id = c.concept_id
  81. </if>
  82. WHERE
  83. a.is_deleted = 'N'
  84. AND b.is_deleted = 'N'
  85. AND a.concept_id = b.id
  86. AND a.id = b.lib_id
  87. AND b.status = 1
  88. <if test="inputStr!=null and inputStr!=''">
  89. AND ( a.`name` = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr})
  90. <if test="typeId!=null and typeId==100">
  91. OR LOWER(c.icd10_code) = LOWER(#{inputStr})
  92. </if>
  93. <if test="typeId!=null and typeId==127">
  94. OR LOWER(c.code) = LOWER(#{inputStr})
  95. </if>
  96. <if test="typeId!=null and typeId==128">
  97. OR LOWER(c.code) = LOWER(#{inputStr})
  98. </if>
  99. <if test="typeId!=null and typeId==106">
  100. OR LOWER(c.operation_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  101. </if>
  102. )
  103. </if>
  104. <if test="typeIds != null and typeIds.size > 0">
  105. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  106. a.type_id =#{typeId}
  107. </foreach>
  108. </if>
  109. UNION
  110. SELECT DISTINCT
  111. b.id,
  112. b.lib_name
  113. <if test="typeId!=null and typeId==100">
  114. ,c.icd10_code as code
  115. </if>
  116. <if test="typeId!=null and typeId==127">
  117. ,c.code as code
  118. </if>
  119. <if test="typeId!=null and typeId==128">
  120. ,c.code as code
  121. </if>
  122. <if test="typeId!=null and typeId==106">
  123. ,c.operation_code as code
  124. </if>
  125. FROM
  126. kl_library_info a,
  127. kl_concept b
  128. <if test="typeId!=null and typeId==100">
  129. left join kl_disease c
  130. on c.is_deleted = 'N'
  131. and b.id = c.concept_id
  132. </if>
  133. <if test="typeId!=null and typeId==127">
  134. left join kl_tcm_disease c
  135. on c.is_deleted = 'N'
  136. and b.id = c.concept_id
  137. </if>
  138. <if test="typeId!=null and typeId==128">
  139. left join kl_tcm_syndrome c
  140. on c.is_deleted = 'N'
  141. and b.id = c.concept_id
  142. </if>
  143. <if test="typeId!=null and typeId==106">
  144. LEFT JOIN `kl_operation` c
  145. ON c.is_deleted = 'N'
  146. AND b.id = c.concept_id
  147. </if>
  148. WHERE
  149. a.is_deleted = 'N'
  150. AND b.is_deleted = 'N'
  151. AND a.concept_id = b.id
  152. AND a.id = b.lib_id
  153. AND b.status = 1
  154. <if test="inputStr!=null and inputStr!=''">
  155. AND ( a.`name` LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER(concat(#{inputStr},'%'))
  156. <if test="typeId!=null and typeId==100">
  157. OR LOWER(c.icd10_code) LIKE LOWER(concat(#{inputStr},'%'))
  158. </if>
  159. <if test="typeId!=null and typeId==127">
  160. OR LOWER(c.code) LIKE LOWER(concat(#{inputStr},'%'))
  161. </if>
  162. <if test="typeId!=null and typeId==128">
  163. OR LOWER(c.code) LIKE LOWER(concat(#{inputStr},'%'))
  164. </if>
  165. <if test="typeId!=null and typeId==106">
  166. OR LOWER(c.operation_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  167. </if>
  168. )
  169. </if>
  170. <if test="typeIds != null and typeIds.size > 0">
  171. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  172. a.type_id =#{typeId}
  173. </foreach>
  174. </if>
  175. UNION
  176. SELECT DISTINCT
  177. b.id,
  178. b.lib_name
  179. <if test="typeId!=null and typeId==100">
  180. ,c.icd10_code as code
  181. </if>
  182. <if test="typeId!=null and typeId==127">
  183. ,c.code as code
  184. </if>
  185. <if test="typeId!=null and typeId==128">
  186. ,c.code as code
  187. </if>
  188. <if test="typeId!=null and typeId==106">
  189. ,c.operation_code as code
  190. </if>
  191. FROM
  192. kl_library_info a,
  193. kl_concept b
  194. <if test="typeId!=null and typeId==100">
  195. left join kl_disease c
  196. on c.is_deleted = 'N'
  197. and b.id = c.concept_id
  198. </if>
  199. <if test="typeId!=null and typeId==127">
  200. left join kl_tcm_disease c
  201. on c.is_deleted = 'N'
  202. and b.id = c.concept_id
  203. </if>
  204. <if test="typeId!=null and typeId==128">
  205. left join kl_tcm_syndrome c
  206. on c.is_deleted = 'N'
  207. and b.id = c.concept_id
  208. </if>
  209. <if test="typeId!=null and typeId==106">
  210. LEFT JOIN `kl_operation` c
  211. ON c.is_deleted = 'N'
  212. AND b.id = c.concept_id
  213. </if>
  214. WHERE
  215. a.is_deleted = 'N'
  216. AND b.is_deleted = 'N'
  217. AND a.concept_id = b.id
  218. AND a.id = b.lib_id
  219. AND b.status = 1
  220. <if test="inputStr!=null and inputStr!=''">
  221. AND ( a.`name` LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
  222. <if test="typeId!=null and typeId==100">
  223. OR LOWER(c.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  224. </if>
  225. <if test="typeId!=null and typeId==127">
  226. OR LOWER(c.code) LIKE LOWER( concat('%',#{inputStr},'%'))
  227. </if>
  228. <if test="typeId!=null and typeId==128">
  229. OR LOWER(c.code) LIKE LOWER( concat('%',#{inputStr},'%'))
  230. </if>
  231. <if test="typeId!=null and typeId==106">
  232. OR LOWER(c.operation_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  233. </if>
  234. )
  235. </if>
  236. <if test="typeIds != null and typeIds.size > 0">
  237. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  238. a.type_id =#{typeId}
  239. </foreach>
  240. </if>
  241. ) t
  242. <if test="typeId!=null and typeId==108">
  243. LEFT JOIN kl_lis t1 ON t.id = t1.concept_id
  244. AND t1.is_deleted = 'N'
  245. LEFT JOIN kl_relation t3 ON t.id = t3.end_id
  246. AND t3.relation_id = 600
  247. AND t3.is_deleted = 'N'
  248. LEFT JOIN kl_concept t4 ON t3.start_id = t4.id
  249. AND t4.lib_type = 107
  250. AND t4.is_deleted = 'N'
  251. </if>
  252. <if test="size!=null">
  253. LIMIT #{size}
  254. </if>
  255. </select>
  256. <select id="staticIndex" resultType="com.diagbot.dto.StaticKnowledgeIndexDTO">
  257. SELECT
  258. f.*
  259. FROM
  260. (
  261. SELECT
  262. s.moduleNo,
  263. s.id,
  264. s.name,
  265. s.retrievalName,
  266. s.isConcept,
  267. s.type,
  268. s.typeName,
  269. s.code,
  270. IF( s2.concept_id IS NOT NULL, s2.concept_id, s3.concept_id ) AS conceptId,
  271. s1.clinical_pathway_name,
  272. s1.notice_name,
  273. s1.`status` AS status,
  274. IF( count( s2.id )> 0, 1, IF( count( s3.id )>0 ,1 ,0 ) ) AS hasInfo ,
  275. IF( sum( IF ( FIND_IN_SET( 1, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasStaticKnowledge,
  276. IF( sum( IF ( FIND_IN_SET( 2, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasNotice,
  277. IF( sum( IF ( FIND_IN_SET( 3, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasClinicalPathway,
  278. IF( sum( IF ( FIND_IN_SET( 4, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasTreatInfo
  279. FROM
  280. (SELECT
  281. o1.*
  282. FROM
  283. (
  284. SELECT
  285. t.moduleNo,
  286. t.id,
  287. t.NAME,
  288. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  289. t.isConcept,
  290. t.type,
  291. t.typeName,
  292. t1.icd10_code AS code
  293. FROM
  294. (
  295. SELECT
  296. concat( '1', b.lib_type ) AS moduleNo,
  297. a.NAME AS retrievalName,
  298. a.spell AS spell,
  299. a.is_concept AS isConcept,
  300. b.id AS id,
  301. b.lib_name AS NAME,
  302. b.lib_type AS type,
  303. c.NAME AS typeName
  304. FROM
  305. kl_library_info a,
  306. kl_concept b,
  307. kl_lexicon c
  308. WHERE
  309. a.is_deleted = 'N'
  310. AND b.is_deleted = 'N'
  311. AND c.is_deleted = 'N'
  312. AND a.concept_id = b.id
  313. AND b.lib_type = c.code
  314. AND b.`status` = 1
  315. <if test="typeIds != null and typeIds.size > 0">
  316. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  317. a.type_id =#{typeId}
  318. </foreach>AND ( a.name = #{inputStr}
  319. </if>
  320. <if test="inputStr!=null and inputStr!=''">OR LOWER(a.spell
  321. ) = LOWER(#{inputStr}))
  322. </if>
  323. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  324. UNION
  325. SELECT
  326. t.moduleNo,
  327. t.id,
  328. t.NAME,
  329. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  330. t.isConcept,
  331. t.type,
  332. t.typeName,
  333. t1.icd10_code AS code
  334. FROM
  335. (
  336. SELECT
  337. concat( '2', b.lib_type ) AS moduleNo,
  338. a.NAME AS retrievalName,
  339. a.spell AS spell,
  340. a.is_concept AS isConcept,
  341. b.id AS id,
  342. b.lib_name AS NAME,
  343. b.lib_type AS type,
  344. c.NAME AS typeName
  345. FROM
  346. kl_library_info a,
  347. kl_concept b,
  348. kl_lexicon c
  349. WHERE
  350. a.is_deleted = 'N'
  351. AND b.is_deleted = 'N'
  352. AND c.is_deleted = 'N'
  353. AND a.concept_id = b.id
  354. AND b.lib_type = c.code
  355. AND b.`status` = 1
  356. <if test="typeIds != null and typeIds.size > 0">
  357. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  358. a.type_id =#{typeId}
  359. </foreach>
  360. </if>
  361. <if test="inputStr!=null and inputStr!=''">
  362. AND ( a.name LIKE concat(#{inputStr},'%')
  363. OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
  364. </if>
  365. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  366. UNION
  367. SELECT
  368. t.moduleNo,
  369. t.id,
  370. t.NAME,
  371. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  372. t.isConcept,
  373. t.type,
  374. t.typeName,
  375. t1.icd10_code AS code
  376. FROM
  377. (
  378. SELECT
  379. concat( '3', b.lib_type ) AS moduleNo,
  380. a.NAME AS retrievalName,
  381. a.spell AS spell,
  382. a.is_concept AS isConcept,
  383. b.id AS id,
  384. b.lib_name AS NAME,
  385. b.lib_type AS type,
  386. c.NAME AS typeName
  387. FROM
  388. kl_library_info a,
  389. kl_concept b,
  390. kl_lexicon c
  391. WHERE
  392. a.is_deleted = 'N'
  393. AND b.is_deleted = 'N'
  394. AND c.is_deleted = 'N'
  395. AND a.concept_id = b.id
  396. AND b.lib_type = c.code
  397. AND b.`status` = 1
  398. <if test="typeIds != null and typeIds.size > 0">
  399. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  400. a.type_id =#{typeId}
  401. </foreach>
  402. </if>
  403. <if test="inputStr!=null and inputStr!=''">
  404. AND ( a.name LIKE concat('%',#{inputStr},'%')
  405. OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
  406. </if>
  407. ) t left join kl_disease t1 on t.id = t1.concept_id and t1.is_deleted='N'
  408. <if test="typeIds.contains(107) or typeIds.contains(108)">
  409. UNION
  410. SELECT DISTINCT
  411. concat( '1', e.lib_type ) AS moduleNo,
  412. e.id AS id,
  413. e.lib_name AS NAME,
  414. b.lib_name AS retrievalName,
  415. 1 AS isConcept,
  416. e.lib_type AS type,
  417. c.name AS typeName,
  418. NULL AS code
  419. FROM
  420. kl_library_info a,
  421. kl_concept b,
  422. kl_lexicon c,
  423. kl_relation d,
  424. kl_concept e
  425. WHERE
  426. a.is_deleted = 'N'
  427. AND b.is_deleted = 'N'
  428. AND c.is_deleted = 'N'
  429. AND d.is_deleted = 'N'
  430. AND e.is_deleted = 'N'
  431. AND a.concept_id = b.id
  432. AND b.id = d.end_id
  433. AND e.id = d.start_id
  434. AND e.lib_type = c.code
  435. AND b.lib_type = 108
  436. AND e.lib_type = 107
  437. AND d.relation_id = 600
  438. AND b.`status` = 1
  439. <if test="inputStr!=null and inputStr!=''">
  440. AND ( a.name = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr}))
  441. </if>
  442. UNION
  443. SELECT DISTINCT
  444. concat( '2', e.lib_type ) AS moduleNo,
  445. e.id AS id,
  446. e.lib_name AS NAME,
  447. b.lib_name AS retrievalName,
  448. 1 AS isConcept,
  449. e.lib_type AS type,
  450. c.name AS typeName,
  451. NULL AS code
  452. FROM
  453. kl_library_info a,
  454. kl_concept b,
  455. kl_lexicon c,
  456. kl_relation d,
  457. kl_concept e
  458. WHERE
  459. a.is_deleted = 'N'
  460. AND b.is_deleted = 'N'
  461. AND c.is_deleted = 'N'
  462. AND d.is_deleted = 'N'
  463. AND e.is_deleted = 'N'
  464. AND a.concept_id = b.id
  465. AND b.id = d.end_id
  466. AND e.id = d.start_id
  467. AND e.lib_type = c.code
  468. AND b.lib_type = 108
  469. AND e.lib_type = 107
  470. AND d.relation_id = 600
  471. AND b.`status` = 1
  472. <if test="inputStr!=null and inputStr!=''">
  473. AND ( a.name LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
  474. </if>
  475. UNION
  476. SELECT DISTINCT
  477. concat( '3', e.lib_type ) AS moduleNo,
  478. e.id AS id,
  479. e.lib_name AS NAME,
  480. b.lib_name AS retrievalName,
  481. 1 AS isConcept,
  482. e.lib_type AS type,
  483. c.name AS typeName,
  484. NULL AS code
  485. FROM
  486. kl_library_info a,
  487. kl_concept b,
  488. kl_lexicon c,
  489. kl_relation d,
  490. kl_concept e
  491. WHERE
  492. a.is_deleted = 'N'
  493. AND b.is_deleted = 'N'
  494. AND c.is_deleted = 'N'
  495. AND d.is_deleted = 'N'
  496. AND e.is_deleted = 'N'
  497. AND a.concept_id = b.id
  498. AND b.id = d.end_id
  499. AND e.id = d.start_id
  500. AND e.lib_type = c.code
  501. AND b.lib_type = 108
  502. AND e.lib_type = 107
  503. AND d.relation_id = 600
  504. AND b.`status` = 1
  505. <if test="inputStr!=null and inputStr!=''">
  506. AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE
  507. LOWER( concat('%',#{inputStr},'%')))
  508. </if>
  509. </if>
  510. <if test="typeIds.contains(100) ">
  511. UNION
  512. SELECT
  513. t.moduleNo,
  514. t.id,
  515. t.NAME,
  516. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  517. t.isConcept,
  518. t.type,
  519. t.typeName,
  520. l1.icd10_code AS code
  521. FROM
  522. (
  523. SELECT
  524. concat( '1', b.lib_type ) AS moduleNo,
  525. a.NAME AS retrievalName,
  526. a.spell AS spell,
  527. a.is_concept AS isConcept,
  528. b.id AS id,
  529. b.lib_name AS NAME,
  530. b.lib_type AS type,
  531. c.NAME AS typeName
  532. FROM
  533. kl_library_info a,
  534. kl_concept b,
  535. kl_lexicon c
  536. WHERE
  537. a.is_deleted = 'N'
  538. AND b.is_deleted = 'N'
  539. AND c.is_deleted = 'N'
  540. AND a.concept_id = b.id
  541. AND b.lib_type = c.code
  542. AND b.`status` = 1
  543. AND a.type_id =100
  544. ) t
  545. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  546. AND l1.is_deleted = 'N'
  547. <where>
  548. <if test="inputStr!=null and inputStr!=''">
  549. AND LOWER(l1.icd10_code) = LOWER(#{inputStr})
  550. </if>
  551. </where>
  552. UNION
  553. SELECT
  554. t.moduleNo,
  555. t.id,
  556. t.NAME,
  557. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  558. t.isConcept,
  559. t.type,
  560. t.typeName,
  561. l1.icd10_code AS code
  562. FROM
  563. (
  564. SELECT
  565. concat( '2', b.lib_type ) AS moduleNo,
  566. a.NAME AS retrievalName,
  567. a.spell AS spell,
  568. a.is_concept AS isConcept,
  569. b.id AS id,
  570. b.lib_name AS NAME,
  571. b.lib_type AS type,
  572. c.NAME AS typeName
  573. FROM
  574. kl_library_info a,
  575. kl_concept b,
  576. kl_lexicon c
  577. WHERE
  578. a.is_deleted = 'N'
  579. AND b.is_deleted = 'N'
  580. AND c.is_deleted = 'N'
  581. AND a.concept_id = b.id
  582. AND b.lib_type = c.code
  583. AND b.`status` = 1
  584. AND a.type_id =100
  585. ) t
  586. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  587. AND l1.is_deleted = 'N'
  588. <where>
  589. <if test="inputStr!=null and inputStr!=''">
  590. AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
  591. </if>
  592. </where>
  593. UNION
  594. SELECT
  595. t.moduleNo,
  596. t.id,
  597. t.NAME,
  598. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  599. t.isConcept,
  600. t.type,
  601. t.typeName,
  602. l1.icd10_code AS code
  603. FROM
  604. (
  605. SELECT
  606. concat( '3', b.lib_type ) AS moduleNo,
  607. a.NAME AS retrievalName,
  608. a.spell AS spell,
  609. a.is_concept AS isConcept,
  610. b.id AS id,
  611. b.lib_name AS NAME,
  612. b.lib_type AS type,
  613. c.NAME AS typeName
  614. FROM
  615. kl_library_info a,
  616. kl_concept b,
  617. kl_lexicon c
  618. WHERE
  619. a.is_deleted = 'N'
  620. AND b.is_deleted = 'N'
  621. AND c.is_deleted = 'N'
  622. AND a.concept_id = b.id
  623. AND b.lib_type = c.code
  624. AND b.`status` = 1
  625. AND a.type_id =100
  626. ) t
  627. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  628. AND l1.is_deleted = 'N'
  629. <where>
  630. <if test="inputStr!=null and inputStr!=''">
  631. AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  632. </if>
  633. </where>
  634. </if>
  635. )o1
  636. order by o1.type asc,o1.moduleNo ASC,o1.isConcept DESC
  637. Limit 1000
  638. ) s
  639. LEFT JOIN kl_concept_static s1 ON s.id = s1.concept_id
  640. AND s1.is_deleted = 'N'
  641. LEFT JOIN kl_concept_detail s2 ON s.id = s2.concept_id
  642. AND s2.is_deleted = 'N'
  643. LEFT JOIN kl_concept_scale s3 ON s.id = s3.concept_id
  644. AND s3.is_deleted = 'N'
  645. GROUP BY s.id
  646. ) f
  647. WHERE
  648. 1 = 1
  649. <if test="hasInfo!=null ">
  650. <choose>
  651. <when test="hasInfo==0">
  652. AND f.conceptId IS NULL
  653. </when>
  654. <when test="hasInfo==1">
  655. AND f.conceptId IS NOT NULL
  656. </when>
  657. </choose>
  658. </if>
  659. <if test="size!=null">
  660. LIMIT #{size}
  661. </if>
  662. </select>
  663. <select id="getLisDetaisByNames" parameterType="com.diagbot.vo.KllisDetailVO"
  664. resultType="com.diagbot.dto.KllisDetailDTO">
  665. SELECT
  666. t1.lib_name,
  667. t1.id,
  668. t2.min_value,
  669. t2.max_value,
  670. t2.type,
  671. t2.unit
  672. FROM
  673. `kl_concept` t1,
  674. kl_lis t2
  675. WHERE
  676. t1.is_deleted = "N"
  677. AND t2.is_deleted = "N"
  678. AND t1.id = t2.concept_id
  679. AND t1.lib_type = 108
  680. AND t1.`status` = 1
  681. <if test="names != null and names.size > 0">
  682. and t1.lib_name in
  683. <foreach item="name" collection="names" open="(" separator="," close=")">
  684. #{name}
  685. </foreach>
  686. </if>
  687. </select>
  688. <select id="searchByTypeAndName" parameterType="com.diagbot.vo.SearchConceptVO"
  689. resultType="com.diagbot.dto.GetAllForRelationDTO">
  690. <!-- SELECT-->
  691. <!-- kc.id AS conceptId,-->
  692. <!-- kc.lib_name AS conceptName,-->
  693. <!-- kc.lib_type AS libType,-->
  694. <!-- kc.lib_name AS conceptNameType-->
  695. <!-- FROM-->
  696. <!-- `kl_concept` kc-->
  697. <!-- WHERE-->
  698. <!-- kc.`status` = 1-->
  699. <!-- <if test="libType!=null">-->
  700. <!-- AND kc.lib_type = #{libType}-->
  701. <!-- </if>-->
  702. <!-- <if test="name != null and name != ''">-->
  703. <!-- AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')-->
  704. <!-- </if>-->
  705. <!-- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">-->
  706. <!-- AND kc.id not in-->
  707. <!-- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">-->
  708. <!-- #{id}-->
  709. <!-- </foreach>-->
  710. <!-- </if>-->
  711. <!-- AND kc.is_deleted = 'N'-->
  712. <!-- AND kc.id NOT IN (1)-->
  713. <!-- AND kc.id IN (-->
  714. <!-- SELECT DISTINCT-->
  715. <!-- start_id-->
  716. <!-- FROM-->
  717. <!-- kl_relation-->
  718. <!-- WHERE-->
  719. <!-- is_deleted = 'N'-->
  720. <!-- AND relation_id = 600-->
  721. <!-- )-->
  722. select kc.id AS conceptId,
  723. kc.lib_name AS conceptName,
  724. kc.lib_type AS libType,
  725. kc.lib_name AS conceptNameType
  726. from (SELECT
  727. a.*,
  728. <choose>
  729. <when test="libType gte 308 and libType lte 328"> b.id as tRelationId</when>
  730. <otherwise>null as tRelationId</otherwise>
  731. </choose>
  732. FROM
  733. kl_concept a
  734. <choose>
  735. <when test="libType gte 308 and libType lte 328"> LEFT JOIN kl_relation b ON a.id = b.start_id
  736. AND a.lib_type = #{libType} AND b.relation_id = 600 and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</when>
  737. <otherwise>where a.lib_type = #{libType} and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</otherwise>
  738. </choose>
  739. GROUP BY
  740. a.id)kc
  741. where
  742. <choose>
  743. <when test="libType gte 308 and libType lte 328"> kc.tRelationId is not null</when>
  744. <otherwise>kc.tRelationId is null</otherwise>
  745. </choose>
  746. limit 100
  747. </select>
  748. <select id="searchByTypeAndNameAdd" parameterType="com.diagbot.vo.SearchConceptVO"
  749. resultType="com.diagbot.dto.GetAllForRelationDTO">
  750. SELECT
  751. kc.id AS conceptId,
  752. kc.lib_name AS conceptName,
  753. kc.lib_type AS libType,
  754. kc.lib_name AS conceptNameType,
  755. kli.remark
  756. FROM
  757. `kl_concept` kc,
  758. kl_library_info kli
  759. WHERE
  760. <if test="libType!=null">
  761. kc.lib_type = #{libType}
  762. </if>
  763. AND kc.`status` = 1
  764. AND kc.is_deleted = 'N'
  765. <if test="name != null and name != ''">
  766. AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
  767. </if>
  768. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  769. AND kc.id not in
  770. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  771. #{id}
  772. </foreach>
  773. </if>
  774. AND kc.id NOT IN (
  775. SELECT DISTINCT
  776. start_id
  777. FROM
  778. kl_relation
  779. WHERE
  780. is_deleted = 'N'
  781. AND relation_id = 600
  782. )
  783. AND kc.id = kli.concept_id
  784. AND kli.is_deleted = 'N'
  785. AND kli.is_concept = 1
  786. limit 100
  787. </select>
  788. <select id="searchCollectionConcept" parameterType="com.diagbot.vo.SearchCollectionConceptVO"
  789. resultType="com.diagbot.dto.GetAllForRelationDTO">
  790. select kc.id AS conceptId,
  791. kc.lib_name AS conceptName,
  792. kc.lib_type AS libType,
  793. kc.lib_name AS conceptNameType
  794. from kl_concept kc
  795. where
  796. <if test="libType!=null">
  797. kc.lib_type = #{libType}
  798. </if>
  799. AND kc.status = 1
  800. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  801. AND kc.id not in
  802. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  803. #{id}
  804. </foreach>
  805. </if>
  806. <if test="names != null and names.size > 0">
  807. and
  808. <choose>
  809. <when test="logicalOperator != null and logicalOperator eq 0">
  810. <foreach collection="names" item="id" open="(" separator="and" close=")">
  811. <if test="id != null and id != ''">
  812. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  813. </if>
  814. </foreach>
  815. </when>
  816. <when test="logicalOperator != null and logicalOperator eq 1">
  817. <foreach collection="names" item="id" open="(" separator="or" close=")">
  818. <if test="id != null and id != ''">
  819. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  820. </if>
  821. </foreach>
  822. </when>
  823. </choose>
  824. </if>
  825. LIMIT 100
  826. </select>
  827. </mapper>