KlConceptMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.diagbot.mapper.KlConceptMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.KlConcept">
  6. <id column="id" property="id" />
  7. <result column="is_deleted" property="isDeleted" />
  8. <result column="gmt_create" property="gmtCreate" />
  9. <result column="gmt_modified" property="gmtModified" />
  10. <result column="creator" property="creator" />
  11. <result column="modifier" property="modifier" />
  12. <result column="lib_id" property="libId" />
  13. <result column="lib_name" property="libName" />
  14. <result column="lib_type" property="libType" />
  15. <result column="status" property="status" />
  16. </resultMap>
  17. <select id="index" resultType="com.diagbot.dto.IndexDTO">
  18. SELECT DISTINCT
  19. t.id as id,
  20. t.lib_name as name
  21. <if test="typeId!=null and typeId==100">
  22. ,t.icd10Code as icd10Code
  23. </if>
  24. <if test="typeId!=null and typeId==108">
  25. ,
  26. t1.max_value as `maxValue`,
  27. t1.min_value as minValue,
  28. t1.unit as units,
  29. t1.type as `range`,
  30. t4.lib_name AS packName,
  31. t4.id as packId
  32. </if>
  33. FROM
  34. (
  35. SELECT DISTINCT
  36. b.id,
  37. b.lib_name
  38. <if test="typeId!=null and typeId==100">
  39. ,c.icd10_code as icd10Code
  40. </if>
  41. FROM
  42. kl_library_info a,
  43. kl_concept b
  44. <if test="typeId!=null and typeId==100">
  45. left join kl_disease c
  46. on c.is_deleted = 'N'
  47. and b.id = c.concept_id
  48. </if>
  49. WHERE
  50. a.is_deleted = 'N'
  51. AND b.is_deleted = 'N'
  52. AND a.concept_id = b.id
  53. AND a.id = b.lib_id
  54. <if test="inputStr!=null and inputStr!=''">
  55. AND ( a.`name` = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr})
  56. <if test="typeId!=null and typeId==100">
  57. OR LOWER(c.icd10_code) = LOWER(#{inputStr})
  58. </if>
  59. )
  60. </if>
  61. <if test="typeIds != null and typeIds.size > 0">
  62. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  63. a.type_id =#{typeId}
  64. </foreach>
  65. </if>
  66. UNION
  67. SELECT DISTINCT
  68. b.id,
  69. b.lib_name
  70. <if test="typeId!=null and typeId==100">
  71. ,c.icd10_code as icd10Code
  72. </if>
  73. FROM
  74. kl_library_info a,
  75. kl_concept b
  76. <if test="typeId!=null and typeId==100">
  77. left join kl_disease c
  78. on c.is_deleted = 'N'
  79. and b.id = c.concept_id
  80. </if>
  81. WHERE
  82. a.is_deleted = 'N'
  83. AND b.is_deleted = 'N'
  84. AND a.concept_id = b.id
  85. AND a.id = b.lib_id
  86. <if test="inputStr!=null and inputStr!=''">
  87. AND ( a.`name` LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER(concat(#{inputStr},'%'))
  88. <if test="typeId!=null and typeId==100">
  89. OR LOWER(c.icd10_code) LIKE LOWER(concat(#{inputStr},'%'))
  90. </if>
  91. )
  92. </if>
  93. <if test="typeIds != null and typeIds.size > 0">
  94. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  95. a.type_id =#{typeId}
  96. </foreach>
  97. </if>
  98. UNION
  99. SELECT DISTINCT
  100. b.id,
  101. b.lib_name
  102. <if test="typeId!=null and typeId==100">
  103. ,c.icd10_code as icd10Code
  104. </if>
  105. FROM
  106. kl_library_info a,
  107. kl_concept b
  108. <if test="typeId!=null and typeId==100">
  109. left join kl_disease c
  110. on c.is_deleted = 'N'
  111. and b.id = c.concept_id
  112. </if>
  113. WHERE
  114. a.is_deleted = 'N'
  115. AND b.is_deleted = 'N'
  116. AND a.concept_id = b.id
  117. AND a.id = b.lib_id
  118. <if test="inputStr!=null and inputStr!=''">
  119. AND ( a.`name` LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
  120. <if test="typeId!=null and typeId==100">
  121. OR LOWER(c.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%'))
  122. </if>
  123. )
  124. </if>
  125. <if test="typeIds != null and typeIds.size > 0">
  126. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  127. a.type_id =#{typeId}
  128. </foreach>
  129. </if>
  130. ) t
  131. <if test="typeId!=null and typeId==108">
  132. LEFT JOIN kl_lis t1 ON t.id = t1.concept_id
  133. AND t1.is_deleted = 'N'
  134. LEFT JOIN kl_relation t3 ON t.id = t3.end_id
  135. AND t3.relation_id = 600
  136. AND t3.is_deleted = 'N'
  137. LEFT JOIN kl_concept t4 ON t3.start_id = t4.id
  138. AND t4.lib_type = 107
  139. AND t4.is_deleted = 'N'
  140. </if>
  141. <if test="size!=null">
  142. LIMIT #{size}
  143. </if>
  144. </select>
  145. <select id="staticIndex" resultType="com.diagbot.dto.StaticKnowledgeIndexDTO">
  146. SELECT
  147. f.*
  148. FROM
  149. (
  150. SELECT
  151. distinct
  152. s.*,
  153. s1.concept_id AS conceptId,
  154. s1.clinical_pathway_name,
  155. s1.notice_name,
  156. s1.`status` AS status,
  157. IF( count( s2.id )> 0, 1, 0 ) AS hasInfo ,
  158. IF( sum( IF ( FIND_IN_SET( 1, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasStaticKnowledge,
  159. IF( sum( IF ( FIND_IN_SET( 2, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasNotice,
  160. IF( sum( IF ( FIND_IN_SET( 3, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasClinicalPathway,
  161. IF( sum( IF ( FIND_IN_SET( 4, s2.content_type )> 0, 1, 0 ))> 0, 1, 0 ) AS hasTreatInfo
  162. FROM
  163. (
  164. SELECT
  165. t.id,
  166. t.NAME,
  167. t.retrievalName,
  168. t.type,
  169. t.typeName,
  170. l1.icd10_code AS code
  171. FROM
  172. (
  173. SELECT
  174. a.NAME AS retrievalName,
  175. a.spell AS spell,
  176. b.id AS id,
  177. b.lib_name AS NAME,
  178. b.lib_type AS type,
  179. c.NAME AS typeName
  180. FROM
  181. kl_library_info a,
  182. kl_concept b,
  183. kl_lexicon c
  184. WHERE
  185. a.is_deleted = 'N'
  186. AND b.is_deleted = 'N'
  187. AND c.is_deleted = 'N'
  188. AND a.id = b.lib_id
  189. AND b.lib_type = c.code
  190. <if test="typeIds != null and typeIds.size > 0">
  191. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  192. a.type_id =#{typeId}
  193. </foreach>
  194. </if>
  195. ) t
  196. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  197. AND l1.is_deleted = 'N'
  198. WHERE
  199. 1=1
  200. <if test="inputStr!=null and inputStr!=''">
  201. AND ( t.name = #{inputStr}
  202. OR LOWER(t.spell) = LOWER(#{inputStr})
  203. OR LOWER(l1.icd10_code) = LOWER(#{inputStr}))
  204. </if>
  205. UNION
  206. SELECT
  207. t.id,
  208. t.NAME,
  209. t.retrievalName,
  210. t.type,
  211. t.typeName,
  212. l1.icd10_code AS code
  213. FROM
  214. (
  215. SELECT
  216. a.NAME AS retrievalName,
  217. a.spell AS spell,
  218. b.id AS id,
  219. b.lib_name AS NAME,
  220. b.lib_type AS type,
  221. c.NAME AS typeName
  222. FROM
  223. kl_library_info a,
  224. kl_concept b,
  225. kl_lexicon c
  226. WHERE
  227. a.is_deleted = 'N'
  228. AND b.is_deleted = 'N'
  229. AND c.is_deleted = 'N'
  230. AND a.id = b.lib_id
  231. AND b.lib_type = c.code
  232. <if test="typeIds != null and typeIds.size > 0">
  233. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  234. a.type_id =#{typeId}
  235. </foreach>
  236. </if>
  237. ) t
  238. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  239. AND l1.is_deleted = 'N'
  240. WHERE
  241. 1=1
  242. <if test="inputStr!=null and inputStr!=''">
  243. AND ( t.name LIKE concat(#{inputStr},'%')
  244. OR LOWER(t.spell) LIKE LOWER( concat(#{inputStr},'%'))
  245. OR LOWER(l1.icd10_code) LIKE LOWER( concat(#{inputStr},'%')))
  246. </if>
  247. UNION
  248. SELECT
  249. t.id,
  250. t.NAME,
  251. t.retrievalName,
  252. t.type,
  253. t.typeName,
  254. l1.icd10_code AS code
  255. FROM
  256. (
  257. SELECT
  258. a.NAME AS retrievalName,
  259. a.spell AS spell,
  260. b.id AS id,
  261. b.lib_name AS NAME,
  262. b.lib_type AS type,
  263. c.NAME AS typeName
  264. FROM
  265. kl_library_info a,
  266. kl_concept b,
  267. kl_lexicon c
  268. WHERE
  269. a.is_deleted = 'N'
  270. AND b.is_deleted = 'N'
  271. AND c.is_deleted = 'N'
  272. AND a.id = b.lib_id
  273. AND b.lib_type = c.code
  274. <if test="typeIds != null and typeIds.size > 0">
  275. <foreach item="typeId" collection="typeIds" open="and(" separator="or" close=")" >
  276. a.type_id =#{typeId}
  277. </foreach>
  278. </if>
  279. ) t
  280. LEFT JOIN kl_disease l1 ON t.id = l1.concept_id
  281. AND l1.is_deleted = 'N'
  282. WHERE
  283. 1=1
  284. <if test="inputStr!=null and inputStr!=''">
  285. AND ( t.name LIKE concat('%',#{inputStr},'%')
  286. OR LOWER(t.spell) LIKE LOWER( concat('%',#{inputStr},'%'))
  287. OR LOWER(l1.icd10_code) LIKE LOWER( concat('%',#{inputStr},'%')))
  288. </if>
  289. <if test="(types != null and types.size > 0 and (types.contains(0) or types.contains(3))) or types==null or types.size==0">
  290. UNION
  291. SELECT DISTINCT
  292. e.id AS id,
  293. e.lib_name AS NAME,
  294. b.lib_name AS retrievalName,
  295. e.lib_type AS type,
  296. c.name AS typeName,
  297. NULL AS code
  298. FROM
  299. kl_library_info a,
  300. kl_concept b,
  301. kl_lexicon c,
  302. kl_relation d,
  303. kl_concept e
  304. WHERE
  305. a.is_deleted = 'N'
  306. AND b.is_deleted = 'N'
  307. AND c.is_deleted = 'N'
  308. AND d.is_deleted = 'N'
  309. AND e.is_deleted = 'N'
  310. AND a.id = b.lib_id
  311. AND b.id = d.end_id
  312. AND e.id = d.start_id
  313. AND e.lib_type = c.code
  314. AND b.lib_type = 108
  315. AND e.lib_type = 107
  316. AND d.relation_id = 600
  317. <if test="inputStr!=null and inputStr!=''">
  318. AND ( a.name = #{inputStr} OR LOWER(a.spell) = LOWER(#{inputStr}))
  319. </if>
  320. UNION
  321. SELECT DISTINCT
  322. e.id AS id,
  323. e.lib_name AS NAME,
  324. b.lib_name AS retrievalName,
  325. e.lib_type AS type,
  326. c.name AS typeName,
  327. NULL AS code
  328. FROM
  329. kl_library_info a,
  330. kl_concept b,
  331. kl_lexicon c,
  332. kl_relation d,
  333. kl_concept e
  334. WHERE
  335. a.is_deleted = 'N'
  336. AND b.is_deleted = 'N'
  337. AND c.is_deleted = 'N'
  338. AND d.is_deleted = 'N'
  339. AND e.is_deleted = 'N'
  340. AND a.id = b.lib_id
  341. AND b.id = d.end_id
  342. AND e.id = d.start_id
  343. AND e.lib_type = c.code
  344. AND b.lib_type = 108
  345. AND e.lib_type = 107
  346. AND d.relation_id = 600
  347. <if test="inputStr!=null and inputStr!=''">
  348. AND ( a.name LIKE concat(#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat(#{inputStr},'%')))
  349. </if>
  350. UNION
  351. SELECT DISTINCT
  352. e.id AS id,
  353. e.lib_name AS NAME,
  354. b.lib_name AS retrievalName,
  355. e.lib_type AS type,
  356. c.name AS typeName,
  357. NULL AS code
  358. FROM
  359. kl_library_info a,
  360. kl_concept b,
  361. kl_lexicon c,
  362. kl_relation d,
  363. kl_concept e
  364. WHERE
  365. a.is_deleted = 'N'
  366. AND b.is_deleted = 'N'
  367. AND c.is_deleted = 'N'
  368. AND d.is_deleted = 'N'
  369. AND e.is_deleted = 'N'
  370. AND a.id = b.lib_id
  371. AND b.id = d.end_id
  372. AND e.id = d.start_id
  373. AND e.lib_type = c.code
  374. AND b.lib_type = 108
  375. AND e.lib_type = 107
  376. AND d.relation_id = 600
  377. <if test="inputStr!=null and inputStr!=''">
  378. AND ( a.name LIKE concat('%',#{inputStr},'%') OR LOWER(a.spell) LIKE LOWER( concat('%',#{inputStr},'%')))
  379. </if>
  380. </if>
  381. ) s
  382. LEFT JOIN kl_concept_static s1 ON s.id = s1.concept_id
  383. AND s1.is_deleted = 'N'
  384. LEFT JOIN kl_concept_detail s2 ON s.id = s2.concept_id
  385. AND s2.is_deleted = 'N'
  386. GROUP BY s.id
  387. ) f
  388. WHERE
  389. 1 = 1
  390. <if test="hasInfo!=null ">
  391. <choose>
  392. <when test="hasInfo==0">
  393. AND f.conceptId IS NULL
  394. </when>
  395. <when test="hasInfo==1">
  396. AND f.conceptId IS NOT NULL
  397. </when>
  398. </choose>
  399. </if>
  400. order by f.type asc
  401. <if test="size!=null">
  402. LIMIT #{size}
  403. </if>
  404. </select>
  405. </mapper>