KlConceptMapper.xml 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007
  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(109) or typeIds.contains(110)">
  511. UNION
  512. SELECT DISTINCT
  513. concat( '1', e.lib_type ) AS moduleNo,
  514. e.id AS id,
  515. e.lib_name AS NAME,
  516. b.lib_name AS retrievalName,
  517. 1 AS isConcept,
  518. e.lib_type AS type,
  519. c.name AS typeName,
  520. NULL AS code
  521. FROM
  522. kl_library_info a,
  523. kl_concept b,
  524. kl_lexicon c,
  525. kl_relation d,
  526. kl_concept e
  527. WHERE
  528. a.is_deleted = 'N'
  529. AND b.is_deleted = 'N'
  530. AND c.is_deleted = 'N'
  531. AND d.is_deleted = 'N'
  532. AND e.is_deleted = 'N'
  533. AND a.concept_id = b.id
  534. AND b.id = d.end_id
  535. AND e.id = d.start_id
  536. AND e.lib_type = c.code
  537. AND b.lib_type = 110
  538. AND e.lib_type = 109
  539. AND d.relation_id = 600
  540. AND b.`status` = 1
  541. <if test="inputStr!=null and inputStr!=''">
  542. AND ( a.name = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr}))
  543. </if>
  544. UNION
  545. SELECT DISTINCT
  546. concat( '2', e.lib_type ) AS moduleNo,
  547. e.id AS id,
  548. e.lib_name AS NAME,
  549. b.lib_name AS retrievalName,
  550. 1 AS isConcept,
  551. e.lib_type AS type,
  552. c.name AS typeName,
  553. NULL AS code
  554. FROM
  555. kl_library_info a,
  556. kl_concept b,
  557. kl_lexicon c,
  558. kl_relation d,
  559. kl_concept e
  560. WHERE
  561. a.is_deleted = 'N'
  562. AND b.is_deleted = 'N'
  563. AND c.is_deleted = 'N'
  564. AND d.is_deleted = 'N'
  565. AND e.is_deleted = 'N'
  566. AND a.concept_id = b.id
  567. AND b.id = d.end_id
  568. AND e.id = d.start_id
  569. AND e.lib_type = c.code
  570. AND b.lib_type = 110
  571. AND e.lib_type = 109
  572. AND d.relation_id = 600
  573. AND b.`status` = 1
  574. <if test="inputStr!=null and inputStr!=''">
  575. AND ( a.name LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
  576. </if>
  577. UNION
  578. SELECT DISTINCT
  579. concat( '3', e.lib_type ) AS moduleNo,
  580. e.id AS id,
  581. e.lib_name AS NAME,
  582. b.lib_name AS retrievalName,
  583. 1 AS isConcept,
  584. e.lib_type AS type,
  585. c.name AS typeName,
  586. NULL AS code
  587. FROM
  588. kl_library_info a,
  589. kl_concept b,
  590. kl_lexicon c,
  591. kl_relation d,
  592. kl_concept e
  593. WHERE
  594. a.is_deleted = 'N'
  595. AND b.is_deleted = 'N'
  596. AND c.is_deleted = 'N'
  597. AND d.is_deleted = 'N'
  598. AND e.is_deleted = 'N'
  599. AND a.concept_id = b.id
  600. AND b.id = d.end_id
  601. AND e.id = d.start_id
  602. AND e.lib_type = c.code
  603. AND b.lib_type = 110
  604. AND e.lib_type = 109
  605. AND d.relation_id = 600
  606. AND b.`status` = 1
  607. <if test="inputStr!=null and inputStr!=''">
  608. AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE
  609. LOWER( concat('%',#{inputStr},'%')))
  610. </if>
  611. </if>
  612. <if test="typeIds.contains(100) ">
  613. UNION
  614. SELECT
  615. t.moduleNo,
  616. t.id,
  617. t.NAME,
  618. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  619. t.isConcept,
  620. t.type,
  621. t.typeName,
  622. l1.icd10_code AS code
  623. FROM
  624. (
  625. SELECT
  626. concat( '1', b.lib_type ) AS moduleNo,
  627. a.NAME AS retrievalName,
  628. a.spell AS spell,
  629. a.is_concept AS isConcept,
  630. b.id AS id,
  631. b.lib_name AS NAME,
  632. b.lib_type AS type,
  633. c.NAME AS typeName
  634. FROM
  635. kl_library_info a,
  636. kl_concept b,
  637. kl_lexicon c
  638. WHERE
  639. a.is_deleted = 'N'
  640. AND b.is_deleted = 'N'
  641. AND c.is_deleted = 'N'
  642. AND a.concept_id = b.id
  643. AND b.lib_type = c.code
  644. AND b.`status` = 1
  645. AND a.type_id =100
  646. ) t
  647. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  648. AND l1.is_deleted = 'N'
  649. <where>
  650. <if test="inputStr!=null and inputStr!=''">
  651. AND LOWER(l1.icd10_code) = LOWER(#{inputStr})
  652. </if>
  653. </where>
  654. UNION
  655. SELECT
  656. t.moduleNo,
  657. t.id,
  658. t.NAME,
  659. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  660. t.isConcept,
  661. t.type,
  662. t.typeName,
  663. l1.icd10_code AS code
  664. FROM
  665. (
  666. SELECT
  667. concat( '2', b.lib_type ) AS moduleNo,
  668. a.NAME AS retrievalName,
  669. a.spell AS spell,
  670. a.is_concept AS isConcept,
  671. b.id AS id,
  672. b.lib_name AS NAME,
  673. b.lib_type AS type,
  674. c.NAME AS typeName
  675. FROM
  676. kl_library_info a,
  677. kl_concept b,
  678. kl_lexicon c
  679. WHERE
  680. a.is_deleted = 'N'
  681. AND b.is_deleted = 'N'
  682. AND c.is_deleted = 'N'
  683. AND a.concept_id = b.id
  684. AND b.lib_type = c.code
  685. AND b.`status` = 1
  686. AND a.type_id =100
  687. ) t
  688. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  689. AND l1.is_deleted = 'N'
  690. <where>
  691. <if test="inputStr!=null and inputStr!=''">
  692. AND LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%'))
  693. </if>
  694. </where>
  695. UNION
  696. SELECT
  697. t.moduleNo,
  698. t.id,
  699. t.NAME,
  700. IF ( t.isConcept = 0, t.retrievalName, '' ) AS retrievalName,
  701. t.isConcept,
  702. t.type,
  703. t.typeName,
  704. l1.icd10_code AS code
  705. FROM
  706. (
  707. SELECT
  708. concat( '3', b.lib_type ) AS moduleNo,
  709. a.NAME AS retrievalName,
  710. a.spell AS spell,
  711. a.is_concept AS isConcept,
  712. b.id AS id,
  713. b.lib_name AS NAME,
  714. b.lib_type AS type,
  715. c.NAME AS typeName
  716. FROM
  717. kl_library_info a,
  718. kl_concept b,
  719. kl_lexicon c
  720. WHERE
  721. a.is_deleted = 'N'
  722. AND b.is_deleted = 'N'
  723. AND c.is_deleted = 'N'
  724. AND a.concept_id = b.id
  725. AND b.lib_type = c.code
  726. AND b.`status` = 1
  727. AND a.type_id =100
  728. ) t
  729. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  730. AND l1.is_deleted = 'N'
  731. <where>
  732. <if test="inputStr!=null and inputStr!=''">
  733. AND LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  734. </if>
  735. </where>
  736. </if>
  737. )o1
  738. order by o1.type asc,o1.moduleNo ASC,o1.isConcept DESC
  739. Limit 1000
  740. ) s
  741. LEFT JOIN kl_concept_static s1 ON s.id = s1.concept_id
  742. AND s1.is_deleted = 'N'
  743. LEFT JOIN kl_concept_detail s2 ON s.id = s2.concept_id
  744. AND s2.is_deleted = 'N'
  745. LEFT JOIN kl_concept_scale s3 ON s.id = s3.concept_id
  746. AND s3.is_deleted = 'N'
  747. GROUP BY s.id
  748. ) f
  749. WHERE
  750. 1 = 1
  751. <if test="hasInfo!=null ">
  752. <choose>
  753. <when test="hasInfo==0">
  754. AND f.conceptId IS NULL
  755. </when>
  756. <when test="hasInfo==1">
  757. AND f.conceptId IS NOT NULL
  758. </when>
  759. </choose>
  760. </if>
  761. <if test="size!=null">
  762. LIMIT #{size}
  763. </if>
  764. </select>
  765. <select id="getLisDetaisByNames" parameterType="com.diagbot.vo.KllisDetailVO"
  766. resultType="com.diagbot.dto.KllisDetailDTO">
  767. SELECT
  768. t1.lib_name,
  769. t1.id,
  770. t2.min_value,
  771. t2.max_value,
  772. t2.type,
  773. t2.unit
  774. FROM
  775. `kl_concept` t1,
  776. kl_lis t2
  777. WHERE
  778. t1.is_deleted = "N"
  779. AND t2.is_deleted = "N"
  780. AND t1.id = t2.concept_id
  781. AND t1.lib_type = 108
  782. AND t1.`status` = 1
  783. <if test="names != null and names.size > 0">
  784. and t1.lib_name in
  785. <foreach item="name" collection="names" open="(" separator="," close=")">
  786. #{name}
  787. </foreach>
  788. </if>
  789. </select>
  790. <select id="searchByTypeAndName" parameterType="com.diagbot.vo.SearchConceptVO"
  791. resultType="com.diagbot.dto.GetAllForRelationDTO">
  792. <!-- SELECT-->
  793. <!-- kc.id AS conceptId,-->
  794. <!-- kc.lib_name AS conceptName,-->
  795. <!-- kc.lib_type AS libType,-->
  796. <!-- kc.lib_name AS conceptNameType-->
  797. <!-- FROM-->
  798. <!-- `kl_concept` kc-->
  799. <!-- WHERE-->
  800. <!-- kc.`status` = 1-->
  801. <!-- <if test="libType!=null">-->
  802. <!-- AND kc.lib_type = #{libType}-->
  803. <!-- </if>-->
  804. <!-- <if test="name != null and name != ''">-->
  805. <!-- AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')-->
  806. <!-- </if>-->
  807. <!-- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">-->
  808. <!-- AND kc.id not in-->
  809. <!-- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">-->
  810. <!-- #{id}-->
  811. <!-- </foreach>-->
  812. <!-- </if>-->
  813. <!-- AND kc.is_deleted = 'N'-->
  814. <!-- AND kc.id NOT IN (1)-->
  815. <!-- AND kc.id IN (-->
  816. <!-- SELECT DISTINCT-->
  817. <!-- start_id-->
  818. <!-- FROM-->
  819. <!-- kl_relation-->
  820. <!-- WHERE-->
  821. <!-- is_deleted = 'N'-->
  822. <!-- AND relation_id = 600-->
  823. <!-- )-->
  824. select kc.id AS conceptId,
  825. kc.lib_name AS conceptName,
  826. kc.lib_type AS libType,
  827. kc.lib_name AS conceptNameType
  828. from (SELECT
  829. a.*,
  830. <choose>
  831. <when test="libType gte 308 and libType lte 328"> b.id as tRelationId</when>
  832. <otherwise>null as tRelationId</otherwise>
  833. </choose>
  834. FROM
  835. kl_concept a
  836. <choose>
  837. <when test="libType gte 308 and libType lte 328"> LEFT JOIN kl_relation b ON a.id = b.start_id
  838. AND a.lib_type = #{libType} AND b.relation_id = 600 and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</when>
  839. <otherwise>where a.lib_type = #{libType} and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</otherwise>
  840. </choose>
  841. GROUP BY
  842. a.id)kc
  843. where
  844. <choose>
  845. <when test="libType gte 308 and libType lte 328"> kc.tRelationId is not null</when>
  846. <otherwise>kc.tRelationId is null</otherwise>
  847. </choose>
  848. limit 100
  849. </select>
  850. <select id="searchByTypeAndNameAdd" parameterType="com.diagbot.vo.SearchConceptVO"
  851. resultType="com.diagbot.dto.GetAllForRelationDTO">
  852. SELECT
  853. kc.id AS conceptId,
  854. kc.lib_name AS conceptName,
  855. kc.lib_type AS libType,
  856. kc.lib_name AS conceptNameType,
  857. kli.remark
  858. FROM
  859. `kl_concept` kc,
  860. kl_library_info kli
  861. WHERE
  862. <if test="libType!=null">
  863. kc.lib_type = #{libType}
  864. </if>
  865. AND kc.`status` = 1
  866. AND kc.is_deleted = 'N'
  867. <if test="name != null and name != ''">
  868. AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
  869. </if>
  870. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  871. AND kc.id not in
  872. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  873. #{id}
  874. </foreach>
  875. </if>
  876. AND kc.id NOT IN (
  877. SELECT DISTINCT
  878. start_id
  879. FROM
  880. kl_relation
  881. WHERE
  882. is_deleted = 'N'
  883. AND relation_id = 600
  884. )
  885. AND kc.id = kli.concept_id
  886. AND kli.is_deleted = 'N'
  887. AND kli.is_concept = 1
  888. limit 100
  889. </select>
  890. <select id="searchCollectionConcept" parameterType="com.diagbot.vo.SearchCollectionConceptVO"
  891. resultType="com.diagbot.dto.GetAllForRelationDTO">
  892. select kc.id AS conceptId,
  893. kc.lib_name AS conceptName,
  894. kc.lib_type AS libType,
  895. kc.lib_name AS conceptNameType
  896. from kl_concept kc
  897. where
  898. <if test="libType!=null">
  899. kc.lib_type = #{libType}
  900. </if>
  901. AND kc.status = 1
  902. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  903. AND kc.id not in
  904. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  905. #{id}
  906. </foreach>
  907. </if>
  908. <if test="names != null and names.size > 0">
  909. and
  910. <choose>
  911. <when test="logicalOperator != null and logicalOperator eq 0">
  912. <foreach collection="names" item="id" open="(" separator="and" close=")">
  913. <if test="id != null and id != ''">
  914. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  915. </if>
  916. </foreach>
  917. </when>
  918. <when test="logicalOperator != null and logicalOperator eq 1">
  919. <foreach collection="names" item="id" open="(" separator="or" close=")">
  920. <if test="id != null and id != ''">
  921. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  922. </if>
  923. </foreach>
  924. </when>
  925. </choose>
  926. </if>
  927. LIMIT 100
  928. </select>
  929. <select id="indexByApproval" resultType="com.diagbot.dto.IndexBatchDTO">
  930. SELECT
  931. t1.approvalNum,
  932. t1.approval,
  933. t1.id,
  934. t1.NAME,
  935. t1.regName,
  936. t1.form,
  937. t1.status,
  938. t2.id AS formConceptId
  939. FROM
  940. (
  941. SELECT
  942. REPLACE ( a.approval, '国药准字', '' ) AS approvalNum,
  943. a.approval AS approval,
  944. c.id AS id,
  945. c.lib_name AS NAME,
  946. a.NAME AS regName,
  947. a.form AS form,
  948. c.status AS status
  949. FROM
  950. kl_drug_register a,
  951. `kl_drug_mapping` b,
  952. kl_concept c
  953. WHERE
  954. a.id = b.register_id
  955. AND b.drug_concept = c.id
  956. AND a.is_deleted = 'N'
  957. AND b.is_deleted = 'N'
  958. AND c.is_deleted = 'N'
  959. <if test="status != null">
  960. AND c.STATUS = #{status}
  961. </if>
  962. <if test="approvalList != null and approvalList.size > 0">
  963. <foreach item="approval" collection="approvalList" open="and(" separator="or" close=")">
  964. a.approval = #{approval}
  965. </foreach>
  966. </if>
  967. ) t1
  968. LEFT JOIN ( SELECT * FROM kl_concept WHERE is_deleted = 'N' AND STATUS = 1 AND lib_type = 102 ) t2 ON t1.form = t2.lib_name
  969. <!--GROUP BY
  970. t1.approval-->
  971. </select>
  972. <select id="getGather" resultType="com.diagbot.dto.GatherDTO">
  973. SELECT
  974. a.lib_name par_name,
  975. a.lib_type par_lib_type,
  976. c.lib_name son_name
  977. FROM
  978. `kl_concept` a,
  979. kl_relation b,
  980. kl_concept c
  981. WHERE
  982. a.is_deleted = 'N'
  983. AND b.is_deleted = 'N'
  984. AND c.is_deleted = 'N'
  985. AND a.`status` = 1
  986. AND c.`status` = 1
  987. AND a.id = b.start_id
  988. AND b.end_id = c.id
  989. AND b.relation_id = 600
  990. AND CONCAT(a.lib_name, '#', a.lib_type) IN
  991. <foreach collection="gatherNameList" item="item" open="(" close=")" separator=",">
  992. #{item}
  993. </foreach>
  994. </select>
  995. </mapper>