KlConceptMapper.xml 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287
  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="caseIndex" resultType="com.diagbot.dto.ClassicCaseIndexDTO">
  766. SELECT DISTINCT t.*
  767. FROM
  768. (SELECT
  769. t1.id AS id,
  770. t1.lib_name AS NAME,
  771. -- t2.NAME AS retrievalName,
  772. t1.lib_type AS type,
  773. t3.name AS typeName,
  774. t1.status AS status
  775. FROM
  776. kl_concept t1
  777. INNER JOIN kl_library_info t2 ON t1.id = t2.concept_id
  778. INNER JOIN kl_lexicon t3 ON t1.lib_type = t3.code
  779. WHERE
  780. t1.is_deleted = 'N'
  781. AND t2.is_deleted = 'N'
  782. AND t3.is_deleted = 'N'
  783. AND t1.status = 1
  784. <if test="inputStr!=null and inputStr!=''">
  785. AND ( t2.name LIKE concat('%',#{inputStr},'%')
  786. OR
  787. LOWER(t2.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
  788. </if>
  789. ) t
  790. LEFT JOIN kl_classic_case t4 ON t.id = t4.concept_id and t4.status = 1
  791. WHERE
  792. <if test="hasInfo!=null ">
  793. <choose>
  794. <when test="hasInfo==0">
  795. t4.concept_id IS NULL
  796. </when>
  797. <when test="hasInfo==1">
  798. t4.concept_id IS NOT NULL
  799. </when>
  800. </choose>
  801. </if>
  802. <if test="typeIds != null and typeIds.size > 0">
  803. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")">
  804. t.type =#{typeId}
  805. </foreach>
  806. </if>
  807. <if test="size!=null">
  808. LIMIT #{size}
  809. </if>
  810. </select>
  811. <select id="getLisDetaisByNames" parameterType="com.diagbot.vo.KllisDetailVO"
  812. resultType="com.diagbot.dto.KllisDetailDTO">
  813. SELECT
  814. t1.lib_name,
  815. t1.id,
  816. t2.min_value,
  817. t2.max_value,
  818. t2.type,
  819. t2.unit
  820. FROM
  821. `kl_concept` t1,
  822. kl_lis t2
  823. WHERE
  824. t1.is_deleted = "N"
  825. AND t2.is_deleted = "N"
  826. AND t1.id = t2.concept_id
  827. AND t1.lib_type = 108
  828. AND t1.`status` = 1
  829. <if test="names != null and names.size > 0">
  830. and t1.lib_name in
  831. <foreach item="name" collection="names" open="(" separator="," close=")">
  832. #{name}
  833. </foreach>
  834. </if>
  835. </select>
  836. <select id="searchByTypeAndName" parameterType="com.diagbot.vo.SearchConceptVO"
  837. resultType="com.diagbot.dto.GetAllForRelationDTO">
  838. <!-- SELECT-->
  839. <!-- kc.id AS conceptId,-->
  840. <!-- kc.lib_name AS conceptName,-->
  841. <!-- kc.lib_type AS libType,-->
  842. <!-- kc.lib_name AS conceptNameType-->
  843. <!-- FROM-->
  844. <!-- `kl_concept` kc-->
  845. <!-- WHERE-->
  846. <!-- kc.`status` = 1-->
  847. <!-- <if test="libType!=null">-->
  848. <!-- AND kc.lib_type = #{libType}-->
  849. <!-- </if>-->
  850. <!-- <if test="name != null and name != ''">-->
  851. <!-- AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')-->
  852. <!-- </if>-->
  853. <!-- <if test="excludedConceptIds != null and excludedConceptIds.size > 0">-->
  854. <!-- AND kc.id not in-->
  855. <!-- <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">-->
  856. <!-- #{id}-->
  857. <!-- </foreach>-->
  858. <!-- </if>-->
  859. <!-- AND kc.is_deleted = 'N'-->
  860. <!-- AND kc.id NOT IN (1)-->
  861. <!-- AND kc.id IN (-->
  862. <!-- SELECT DISTINCT-->
  863. <!-- start_id-->
  864. <!-- FROM-->
  865. <!-- kl_relation-->
  866. <!-- WHERE-->
  867. <!-- is_deleted = 'N'-->
  868. <!-- AND relation_id = 600-->
  869. <!-- )-->
  870. select kc.id AS conceptId,
  871. kc.lib_name AS conceptName,
  872. kc.lib_type AS libType,
  873. kc.lib_name AS conceptNameType
  874. from (SELECT
  875. a.*,
  876. <choose>
  877. <when test="libType gte 308 and libType lte 328"> b.id as tRelationId</when>
  878. <otherwise>null as tRelationId</otherwise>
  879. </choose>
  880. FROM
  881. kl_concept a
  882. <choose>
  883. <when test="libType gte 308 and libType lte 328"> LEFT JOIN kl_relation b ON a.id = b.start_id
  884. AND a.lib_type = #{libType} AND b.relation_id = 600 and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</when>
  885. <otherwise>where a.lib_type = #{libType} and UPPER(a.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')</otherwise>
  886. </choose>
  887. GROUP BY
  888. a.id)kc
  889. where
  890. <choose>
  891. <when test="libType gte 308 and libType lte 328"> kc.tRelationId is not null</when>
  892. <otherwise>kc.tRelationId is null</otherwise>
  893. </choose>
  894. limit 100
  895. </select>
  896. <select id="searchByTypeAndNameAdd" parameterType="com.diagbot.vo.SearchConceptVO"
  897. resultType="com.diagbot.dto.GetAllForRelationDTO">
  898. SELECT
  899. kc.id AS conceptId,
  900. kc.lib_name AS conceptName,
  901. kc.lib_type AS libType,
  902. kc.lib_name AS conceptNameType,
  903. kli.remark
  904. FROM
  905. `kl_concept` kc,
  906. kl_library_info kli
  907. WHERE
  908. <if test="libType!=null">
  909. kc.lib_type = #{libType}
  910. </if>
  911. AND kc.`status` = 1
  912. AND kc.is_deleted = 'N'
  913. <if test="name != null and name != ''">
  914. AND UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
  915. </if>
  916. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  917. AND kc.id not in
  918. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  919. #{id}
  920. </foreach>
  921. </if>
  922. AND kc.id NOT IN (
  923. SELECT DISTINCT
  924. start_id
  925. FROM
  926. kl_relation
  927. WHERE
  928. is_deleted = 'N'
  929. AND relation_id = 600
  930. )
  931. AND kc.id = kli.concept_id
  932. AND kli.is_deleted = 'N'
  933. AND kli.is_concept = 1
  934. limit 100
  935. </select>
  936. <select id="searchCollectionConcept" parameterType="com.diagbot.vo.SearchCollectionConceptVO"
  937. resultType="com.diagbot.dto.GetAllForRelationDTO">
  938. select kc.id AS conceptId,
  939. kc.lib_name AS conceptName,
  940. kc.lib_type AS libType,
  941. kc.lib_name AS conceptNameType
  942. from kl_concept kc
  943. where
  944. <if test="libType!=null">
  945. kc.lib_type = #{libType}
  946. </if>
  947. AND kc.status = 1
  948. <if test="excludedConceptIds != null and excludedConceptIds.size > 0">
  949. AND kc.id not in
  950. <foreach item="id" collection="excludedConceptIds" open="(" separator="," close=")">
  951. #{id}
  952. </foreach>
  953. </if>
  954. <if test="names != null and names.size > 0">
  955. and
  956. <choose>
  957. <when test="logicalOperator != null and logicalOperator eq 0">
  958. <foreach collection="names" item="id" open="(" separator="and" close=")">
  959. <if test="id != null and id != ''">
  960. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  961. </if>
  962. </foreach>
  963. </when>
  964. <when test="logicalOperator != null and logicalOperator eq 1">
  965. <foreach collection="names" item="id" open="(" separator="or" close=")">
  966. <if test="id != null and id != ''">
  967. UPPER(kc.lib_name) LIKE CONCAT('%', UPPER(trim(#{id})), '%')
  968. </if>
  969. </foreach>
  970. </when>
  971. </choose>
  972. </if>
  973. LIMIT 100
  974. </select>
  975. <select id="searchCollectionConceptNew" parameterType="com.diagbot.vo.SearchCollectionConceptVO"
  976. resultType="com.diagbot.dto.GetAllForRelationDTO">
  977. select kc.id AS conceptId,
  978. kc.lib_name AS conceptName,
  979. kc.lib_type AS libType,
  980. kc.lib_name AS conceptNameType
  981. from kl_concept kc
  982. where kc.status = 1
  983. and kc.lib_name in
  984. <foreach collection="names" item="name" open="(" separator="," close=")">
  985. #{name}
  986. </foreach>
  987. </select>
  988. <select id="indexByApproval" resultType="com.diagbot.dto.IndexBatchDTO">
  989. SELECT
  990. t1.approvalNum,
  991. t1.approval,
  992. t1.id,
  993. t1.NAME,
  994. t1.regName,
  995. t1.form,
  996. t1.status,
  997. t2.id AS formConceptId
  998. FROM
  999. (
  1000. SELECT
  1001. REPLACE ( a.approval, '国药准字', '' ) AS approvalNum,
  1002. a.approval AS approval,
  1003. c.id AS id,
  1004. c.lib_name AS NAME,
  1005. a.NAME AS regName,
  1006. a.form AS form,
  1007. c.status AS status
  1008. FROM
  1009. kl_drug_register a,
  1010. `kl_drug_mapping` b,
  1011. kl_concept c
  1012. WHERE
  1013. a.id = b.register_id
  1014. AND b.drug_concept = c.id
  1015. AND a.is_deleted = 'N'
  1016. AND b.is_deleted = 'N'
  1017. AND c.is_deleted = 'N'
  1018. <if test="status != null">
  1019. AND c.STATUS = #{status}
  1020. </if>
  1021. <if test="approvalList != null and approvalList.size > 0">
  1022. <foreach item="approval" collection="approvalList" open="and(" separator="or" close=")">
  1023. a.approval = #{approval}
  1024. </foreach>
  1025. </if>
  1026. ) t1
  1027. LEFT JOIN ( SELECT * FROM kl_concept WHERE is_deleted = 'N' AND STATUS = 1 AND lib_type = 102 ) t2 ON t1.form = t2.lib_name
  1028. <!--GROUP BY
  1029. t1.approval-->
  1030. </select>
  1031. <!--ICD编码查询-->
  1032. <select id="findDiseaeByCode" resultType="com.diagbot.dto.DiseaseIndexDTO">
  1033. SELECT
  1034. t.id,
  1035. <if test="diseaseIndexPageVO.type != null">
  1036. <choose>
  1037. <when test="diseaseIndexPageVO.type == 1">
  1038. t.lib_name AS NAME,
  1039. t.icd10_code AS CODE,
  1040. </when>
  1041. <when test="diseaseIndexPageVO.type == 2">
  1042. t.guoname AS NAME,
  1043. t.guocode AS CODE,
  1044. </when>
  1045. <otherwise>
  1046. </otherwise>
  1047. </choose>
  1048. </if>
  1049. t.partId
  1050. FROM
  1051. (
  1052. SELECT
  1053. a.id,
  1054. a.lib_name,
  1055. b.spell,
  1056. c.icd10_code,
  1057. c.guoname,
  1058. c.guocode,
  1059. c.guospell,
  1060. CONCAT( '1', a.lib_type ) AS partId
  1061. FROM
  1062. kl_concept a,
  1063. kl_library_info b,
  1064. kl_disease c
  1065. WHERE
  1066. a.is_deleted = 'N'
  1067. AND b.is_deleted = 'N'
  1068. AND c.is_deleted = 'N'
  1069. AND a.id = b.concept_id
  1070. AND a.id = c.concept_id
  1071. AND b.is_concept = 1
  1072. AND a.lib_type = 100
  1073. AND a.`status` = 1
  1074. <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
  1075. <choose>
  1076. <when test="diseaseIndexPageVO.type == 1">
  1077. AND c.icd10_code != ''
  1078. AND ( a.lib_name = #{diseaseIndexPageVO.inputStr}
  1079. OR b.spell = #{diseaseIndexPageVO.inputStr}
  1080. OR c.icd10_code = #{diseaseIndexPageVO.inputStr} )
  1081. </when>
  1082. <when test="diseaseIndexPageVO.type == 2">
  1083. AND c.guocode != ''
  1084. AND ( c.guoname = #{diseaseIndexPageVO.inputStr}
  1085. OR c.guospell = #{diseaseIndexPageVO.inputStr}
  1086. OR c.guocode = #{diseaseIndexPageVO.inputStr} )
  1087. </when>
  1088. <otherwise></otherwise>
  1089. </choose>
  1090. </if>
  1091. UNION
  1092. SELECT
  1093. a.id,
  1094. a.lib_name,
  1095. b.spell,
  1096. c.icd10_code,
  1097. c.guoname,
  1098. c.guocode,
  1099. c.guospell,
  1100. CONCAT( '2', a.lib_type ) AS partId
  1101. FROM
  1102. kl_concept a,
  1103. kl_library_info b,
  1104. kl_disease c
  1105. WHERE
  1106. a.is_deleted = 'N'
  1107. AND b.is_deleted = 'N'
  1108. AND c.is_deleted = 'N'
  1109. AND a.id = b.concept_id
  1110. AND a.id = c.concept_id
  1111. AND b.is_concept = 1
  1112. AND a.lib_type = 100
  1113. AND a.`status` = 1
  1114. <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
  1115. <choose>
  1116. <when test="diseaseIndexPageVO.type == 1">
  1117. AND c.icd10_code != ''
  1118. AND ( a.lib_name LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1119. OR b.spell LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1120. OR c.icd10_code LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' ) )
  1121. </when>
  1122. <when test="diseaseIndexPageVO.type == 2">
  1123. AND c.guocode != ''
  1124. AND ( c.guoname LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1125. OR c.guospell LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1126. OR c.guocode LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' ) )
  1127. </when>
  1128. <otherwise></otherwise>
  1129. </choose>
  1130. </if>
  1131. UNION
  1132. SELECT
  1133. a.id,
  1134. a.lib_name,
  1135. b.spell,
  1136. c.icd10_code,
  1137. c.guoname,
  1138. c.guocode,
  1139. c.guospell,
  1140. CONCAT( '3', a.lib_type ) AS partId
  1141. FROM
  1142. kl_concept a,
  1143. kl_library_info b,
  1144. kl_disease c
  1145. WHERE
  1146. a.is_deleted = 'N'
  1147. AND b.is_deleted = 'N'
  1148. AND c.is_deleted = 'N'
  1149. AND a.id = b.concept_id
  1150. AND a.id = c.concept_id
  1151. AND b.is_concept = 1
  1152. AND a.lib_type = 100
  1153. AND a.`status` = 1
  1154. <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
  1155. <choose>
  1156. <when test="diseaseIndexPageVO.type == 1">
  1157. AND c.icd10_code != ''
  1158. AND ( a.lib_name LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1159. OR b.spell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1160. OR c.icd10_code LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
  1161. AND (
  1162. a.lib_name NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1163. AND b.spell NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1164. AND c.icd10_code NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1165. )
  1166. </when>
  1167. <when test="diseaseIndexPageVO.type == 2">
  1168. AND c.guocode != ''
  1169. AND ( c.guoname LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1170. OR c.guospell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1171. OR c.guocode LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
  1172. AND (
  1173. c.guoname NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1174. AND c.guospell NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1175. AND c.guocode NOT LIKE CONCAT( #{diseaseIndexPageVO.inputStr}, '%' )
  1176. )
  1177. </when>
  1178. <otherwise></otherwise>
  1179. </choose>
  1180. </if>
  1181. ) t
  1182. ORDER BY
  1183. t.partId
  1184. </select>
  1185. <!--ICD编码查询-->
  1186. <select id="diseaseIndex" resultType="com.diagbot.dto.DiseaseIndexDTO">
  1187. SELECT
  1188. k.id,
  1189. k.name,
  1190. k.code,
  1191. k.spell,
  1192. k.pos,
  1193. least( k.nameLen, k.spellLen, k.codeLen ) AS len
  1194. FROM
  1195. (
  1196. SELECT
  1197. t.*,
  1198. LEAST( t.namePos, t.spellPos, t.codePos ) AS pos,
  1199. IF( LEAST( t.namePos, t.spellPos, t.codePos )= namePos, CHAR_LENGTH( t.name ), 999 ) AS nameLen,
  1200. IF( LEAST( t.namePos, t.spellPos, t.codePos )= spellPos, CHAR_LENGTH( t.spell ), 999 ) AS spellLen,
  1201. IF( LEAST( t.namePos, t.spellPos, t.codePos )= codePos, CHAR_LENGTH( t.code ), 999 ) AS codeLen
  1202. FROM
  1203. (
  1204. SELECT
  1205. <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
  1206. <choose>
  1207. <when test="diseaseIndexPageVO.type == 1">
  1208. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN a.lib_name )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN a.lib_name ), 999 ) AS namePos,
  1209. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN b.spell )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN b.spell ), 999 ) AS spellPos,
  1210. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.icd10_code )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.icd10_code ), 999 ) AS codePos,
  1211. </when>
  1212. <when test="diseaseIndexPageVO.type == 2">
  1213. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guoname )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guoname ), 999 ) AS namePos,
  1214. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guospell )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guospell ), 999 ) AS spellPos,
  1215. IF( POSITION( #{diseaseIndexPageVO.inputStr} IN c.guocode )> 0, POSITION( #{diseaseIndexPageVO.inputStr} IN c.guocode ), 999 ) AS codePos,
  1216. </when>
  1217. <otherwise></otherwise>
  1218. </choose>
  1219. </if>
  1220. <if test="diseaseIndexPageVO.type != null">
  1221. <choose>
  1222. <when test="diseaseIndexPageVO.type == 1">
  1223. a.lib_name AS NAME,
  1224. c.icd10_code AS CODE,
  1225. b.spell AS spell,
  1226. </when>
  1227. <when test="diseaseIndexPageVO.type == 2">
  1228. c.guoname AS NAME,
  1229. c.guocode AS CODE,
  1230. c.guospell AS spell,
  1231. </when>
  1232. <otherwise>
  1233. </otherwise>
  1234. </choose>
  1235. </if>
  1236. a.id
  1237. FROM
  1238. kl_concept a,
  1239. kl_library_info b,
  1240. kl_disease c
  1241. WHERE
  1242. a.is_deleted = 'N'
  1243. AND b.is_deleted = 'N'
  1244. AND c.is_deleted = 'N'
  1245. AND a.id = b.concept_id
  1246. AND a.id = c.concept_id
  1247. AND b.is_concept = 1
  1248. AND a.lib_type = 100
  1249. AND a.`status` = 1
  1250. <if test="diseaseIndexPageVO.inputStr != null and diseaseIndexPageVO.inputStr != '' and diseaseIndexPageVO.type != null">
  1251. <choose>
  1252. <when test="diseaseIndexPageVO.type == 1">
  1253. AND c.icd10_code != ''
  1254. AND ( a.lib_name LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1255. OR b.spell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1256. OR c.icd10_code LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
  1257. </when>
  1258. <when test="diseaseIndexPageVO.type == 2">
  1259. AND c.guocode != ''
  1260. AND ( c.guoname LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1261. OR c.guospell LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' )
  1262. OR c.guocode LIKE CONCAT( '%', #{diseaseIndexPageVO.inputStr}, '%' ) )
  1263. </when>
  1264. <otherwise></otherwise>
  1265. </choose>
  1266. </if>
  1267. ) t
  1268. ) k
  1269. ORDER BY
  1270. k.pos,
  1271. len
  1272. </select>
  1273. </mapper>