ConceptMapper.xml 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116
  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.ConceptMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
  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. </resultMap>
  16. <select id="getConcept" resultType="com.diagbot.dto.ConceptRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  17. SELECT
  18. t1.id AS startId,
  19. t1.lib_name AS startName,
  20. t3.id AS endId,
  21. t3.lib_name AS endName
  22. FROM
  23. `kl_concept` t1,
  24. `kl_relation` t2,
  25. <if test="startSex != null or startAge != null">
  26. kl_concept_common c1,
  27. </if>
  28. <if test="endSex != null or endAge != null">
  29. kl_concept_common c2,
  30. </if>
  31. `kl_concept` t3
  32. WHERE
  33. t1.is_deleted = 'N'
  34. AND t2.is_deleted = 'N'
  35. AND t3.is_deleted = 'N'
  36. AND t1.id = t2.start_id
  37. AND t3.id = t2.end_id
  38. <if test="startId != null">
  39. AND t2.start_id = #{startId}
  40. </if>
  41. <if test="startName != null and startName != ''">
  42. AND t1.lib_name = #{startName}
  43. </if>
  44. <if test="startSex != null or startAge != null">
  45. AND c1.is_deleted = 'N'
  46. <if test="startSex != null">
  47. <if test="startSex == 3">
  48. and c1.sex_type in ('1','2','3')
  49. </if>
  50. <if test="startSex != 3">
  51. and c1.sex_type in ('3',#{startSex})
  52. </if>
  53. </if>
  54. <if test="startAge != null">
  55. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  56. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  57. </if>
  58. AND t2.start_id = c1.concept_id
  59. </if>
  60. <if test="startType != null">
  61. AND t1.lib_type = #{startType}
  62. </if>
  63. <if test="relationType != null">
  64. AND t2.relation_id = #{relationType}
  65. </if>
  66. <if test="endId != null">
  67. AND t2.end_id = #{endId}
  68. </if>
  69. <if test="endName != null and endName != ''">
  70. AND t3.lib_name = #{endName}
  71. </if>
  72. <if test="endSex != null or endAge != null">
  73. AND c2.is_deleted = 'N'
  74. <if test="endSex != null">
  75. <if test="endSex == 3">
  76. and c2.sex_type in ('1','2','3')
  77. </if>
  78. <if test="endSex != 3">
  79. and c2.sex_type in ('3',#{endSex})
  80. </if>
  81. </if>
  82. <if test="endAge != null">
  83. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  84. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  85. </if>
  86. AND t2.end_id = c2.concept_id
  87. </if>
  88. <if test="endType != null">
  89. AND t3.lib_type = #{endType}
  90. </if>
  91. </select>
  92. <select id="getConceptWithOrder" resultType="com.diagbot.dto.ConceptWithOrderRes" parameterType="com.diagbot.entity.wrapper.ConceptWrapper">
  93. SELECT
  94. t1.id AS startId,
  95. t1.lib_name AS startName,
  96. t3.id AS endId,
  97. t3.lib_name AS endName,
  98. t4.order_no AS orderNo
  99. FROM
  100. `kl_concept` t1,
  101. `kl_relation` t2,
  102. <if test="startSex != null or startAge != null">
  103. kl_concept_common c1,
  104. </if>
  105. <if test="endSex != null or endAge != null">
  106. kl_concept_common c2,
  107. </if>
  108. `kl_concept` t3,
  109. `kl_relation_order` t4
  110. WHERE
  111. t1.is_deleted = 'N'
  112. AND t2.is_deleted = 'N'
  113. AND t3.is_deleted = 'N'
  114. AND t4.is_deleted = 'N'
  115. AND t1.id = t2.start_id
  116. AND t3.id = t2.end_id
  117. AND t2.id = t4.t_relation_id
  118. <if test="startId != null">
  119. AND t2.start_id = #{startId}
  120. </if>
  121. <if test="startName != null and startName != ''">
  122. AND t1.lib_name = #{startName}
  123. </if>
  124. <if test="startSex != null or startAge != null">
  125. AND c1.is_deleted = 'N'
  126. <if test="startSex != null">
  127. <if test="startSex == 3">
  128. and c1.sex_type in ('1','2','3')
  129. </if>
  130. <if test="startSex != 3">
  131. and c1.sex_type in ('3',#{startSex})
  132. </if>
  133. </if>
  134. <if test="startAge != null">
  135. <![CDATA[ AND c1.min_age <= #{startAge} ]]>
  136. <![CDATA[ AND c1.max_age >= #{startAge} ]]>
  137. </if>
  138. AND t2.start_id = c1.concept_id
  139. </if>
  140. <if test="startNameList != null and startNameList.size() > 0">
  141. AND t1.lib_name in
  142. <foreach collection="startNameList" item="item" open="(" close=")" separator=",">
  143. #{item}
  144. </foreach>
  145. </if>
  146. <if test="startType != null">
  147. AND t1.lib_type = #{startType}
  148. </if>
  149. <if test="relationType != null">
  150. AND t2.relation_id = #{relationType}
  151. </if>
  152. <if test="endId != null">
  153. AND t2.end_id = #{endId}
  154. </if>
  155. <if test="endName != null and endName != ''">
  156. AND t3.lib_name = #{endName}
  157. </if>
  158. <if test="endSex != null or endAge != null">
  159. AND c2.is_deleted = 'N'
  160. <if test="endSex != null">
  161. <if test="endSex == 3">
  162. and c2.sex_type in ('1','2','3')
  163. </if>
  164. <if test="endSex != 3">
  165. and c2.sex_type in ('3',#{endSex})
  166. </if>
  167. </if>
  168. <if test="endAge != null">
  169. <![CDATA[ AND c2.min_age <= #{endAge} ]]>
  170. <![CDATA[ AND c2.max_age >= #{endAge} ]]>
  171. </if>
  172. AND t2.end_id = c2.concept_id
  173. </if>
  174. <if test="endNameList != null and endNameList.size() > 0">
  175. AND t3.lib_name in
  176. <foreach collection="endNameList" item="item" open="(" close=")" separator=",">
  177. #{item}
  178. </foreach>
  179. </if>
  180. <if test="endType != null">
  181. AND t3.lib_type = #{endType}
  182. </if>
  183. ORDER BY t4.order_no
  184. </select>
  185. <select id="retrievalConcept" resultType="com.diagbot.dto.ConceptRetrievalDTO">
  186. SELECT a1.* from (
  187. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  188. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  189. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  190. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  191. WHERE
  192. t1.is_deleted = 'N'
  193. AND t2.is_deleted = 'N'
  194. AND t3.is_deleted = 'N'
  195. AND t6.is_deleted = 'N'
  196. <if test="type != null">
  197. AND t1.lib_type = #{type}
  198. </if>
  199. <if test="otherType != null and otherType.size > 0">
  200. and t1.lib_type in
  201. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  202. #{type}
  203. </foreach>
  204. </if>
  205. <if test="sexType == 3">
  206. and t3.sex_type in ('1','2','3')
  207. </if>
  208. <if test="sexType != 3">
  209. and t3.sex_type in ('3',#{sexType})
  210. </if>
  211. <if test="age != null and age != ''">
  212. AND <![CDATA[ t3.min_age <= #{age} ]]>
  213. AND <![CDATA[ t3.max_age >= #{age} ]]>
  214. </if>
  215. <if test="inputIds != null and inputIds.size > 0">
  216. and t1.id not in
  217. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  218. #{id}
  219. </foreach>
  220. </if>
  221. AND (UPPER(t2.spell) = UPPER(TRIM(#{InputStr})) OR UPPER(t2.name) = UPPER(TRIM(#{InputStr})))
  222. LIMIT 100)
  223. UNION
  224. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  225. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  226. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  227. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  228. WHERE
  229. t1.is_deleted = 'N'
  230. AND t2.is_deleted = 'N'
  231. AND t3.is_deleted = 'N'
  232. AND t6.is_deleted = 'N'
  233. <if test="type != null">
  234. AND t1.lib_type = #{type}
  235. </if>
  236. <if test="otherType != null and otherType.size > 0">
  237. and t1.lib_type in
  238. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  239. #{type}
  240. </foreach>
  241. </if>
  242. <if test="sexType == 3">
  243. and t3.sex_type in ('1','2','3')
  244. </if>
  245. <if test="sexType != 3">
  246. and t3.sex_type in ('3',#{sexType})
  247. </if>
  248. <if test="age != null and age != ''">
  249. AND <![CDATA[ t3.min_age <= #{age} ]]>
  250. AND <![CDATA[ t3.max_age >= #{age} ]]>
  251. </if>
  252. <if test="inputIds != null and inputIds.size > 0">
  253. and t1.id not in
  254. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  255. #{id}
  256. </foreach>
  257. </if>
  258. AND (UPPER(t2.spell) LIKE CONCAT( UPPER(TRIM(#{InputStr})),'%') OR UPPER(t2.name) LIKE CONCAT( UPPER(TRIM(#{InputStr})),'%'))
  259. LIMIT 100)
  260. UNION
  261. (SELECT t1.id selfId,t1.lib_name selfName,0 parentId,null parentName,t2.`name` sameName,t2.is_concept showType,t1.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  262. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  263. LEFT JOIN kl_concept_common t3 ON t1.id = t3.concept_id
  264. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  265. WHERE
  266. t1.is_deleted = 'N'
  267. AND t2.is_deleted = 'N'
  268. AND t3.is_deleted = 'N'
  269. AND t6.is_deleted = 'N'
  270. <if test="type != null">
  271. AND t1.lib_type = #{type}
  272. </if>
  273. <if test="otherType != null and otherType.size > 0">
  274. and t1.lib_type in
  275. <foreach item="type" collection="otherType" open="(" separator="," close=")">
  276. #{type}
  277. </foreach>
  278. </if>
  279. <if test="sexType == 3">
  280. and t3.sex_type in ('1','2','3')
  281. </if>
  282. <if test="sexType != 3">
  283. and t3.sex_type in ('3',#{sexType})
  284. </if>
  285. <if test="age != null and age != ''">
  286. AND <![CDATA[ t3.min_age <= #{age} ]]>
  287. AND <![CDATA[ t3.max_age >= #{age} ]]>
  288. </if>
  289. <if test="inputIds != null and inputIds.size > 0">
  290. and t1.id not in
  291. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  292. #{id}
  293. </foreach>
  294. </if>
  295. AND (UPPER(t2.spell) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})),'%') OR UPPER(t2.name) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})),'%'))
  296. LIMIT 100)
  297. <if test="detailType != null and detailType != ''">
  298. UNION
  299. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  300. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  301. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  302. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  303. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  304. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  305. WHERE
  306. t1.is_deleted = 'N'
  307. AND t2.is_deleted = 'N'
  308. AND t3.is_deleted = 'N'
  309. AND t4.is_deleted = 'N'
  310. AND t5.is_deleted = 'N'
  311. AND t6.is_deleted = 'N'
  312. <if test="detailType != null">
  313. AND t1.lib_type = #{detailType}
  314. </if>
  315. <if test="sexType == 3">
  316. and t3.sex_type in ('1','2','3')
  317. </if>
  318. <if test="sexType != 3">
  319. and t3.sex_type in ('3',#{sexType})
  320. </if>
  321. <if test="age != null and age != ''">
  322. AND <![CDATA[ t3.min_age <= #{age} ]]>
  323. AND <![CDATA[ t3.max_age >= #{age} ]]>
  324. </if>
  325. AND (UPPER(t2.spell) = UPPER(TRIM(#{InputStr})) OR UPPER(t2.name) = UPPER(TRIM(#{InputStr})))
  326. <if test="inputIds != null and inputIds.size > 0">
  327. and t1.id not in
  328. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  329. #{id}
  330. </foreach>
  331. </if>
  332. AND t4.relation_id = 18
  333. LIMIT 100)
  334. UNION
  335. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  336. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  337. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  338. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  339. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  340. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  341. WHERE
  342. t1.is_deleted = 'N'
  343. AND t2.is_deleted = 'N'
  344. AND t3.is_deleted = 'N'
  345. AND t4.is_deleted = 'N'
  346. AND t5.is_deleted = 'N'
  347. AND t6.is_deleted = 'N'
  348. <if test="detailType != null">
  349. AND t1.lib_type = #{detailType}
  350. </if>
  351. <if test="sexType == 3">
  352. and t3.sex_type in ('1','2','3')
  353. </if>
  354. <if test="sexType != 3">
  355. and t3.sex_type in ('3',#{sexType})
  356. </if>
  357. <if test="age != null and age != ''">
  358. AND <![CDATA[ t3.min_age <= #{age} ]]>
  359. AND <![CDATA[ t3.max_age >= #{age} ]]>
  360. </if>
  361. AND (UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})),'%') OR UPPER(t2.name) LIKE CONCAT( UPPER(TRIM(#{InputStr})),'%'))
  362. <if test="inputIds != null and inputIds.size > 0">
  363. and t1.id not in
  364. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  365. #{id}
  366. </foreach>
  367. </if>
  368. <if test="isStatic != null and isStatic == 1">
  369. GROUP BY t5.id
  370. </if>
  371. AND t4.relation_id = 18
  372. LIMIT 100)
  373. UNION
  374. (SELECT t1.id selfId,t1.lib_name selfName,t5.id parentId,t5.lib_name parentName,null sameName,t2.is_concept showType,t5.lib_type libTypeId,t6.`name` libTypeName FROM kl_concept t1
  375. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  376. LEFT JOIN kl_relation t4 ON t4.end_id= t1.id
  377. LEFT JOIN kl_concept t5 on t5.id = t4.start_id
  378. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  379. LEFT JOIN kl_concept_common t3 ON t5.id = t3.concept_id
  380. WHERE
  381. t1.is_deleted = 'N'
  382. AND t2.is_deleted = 'N'
  383. AND t3.is_deleted = 'N'
  384. AND t4.is_deleted = 'N'
  385. AND t5.is_deleted = 'N'
  386. AND t6.is_deleted = 'N'
  387. <if test="detailType != null">
  388. AND t1.lib_type = #{detailType}
  389. </if>
  390. <if test="sexType == 3">
  391. and t3.sex_type in ('1','2','3')
  392. </if>
  393. <if test="sexType != 3">
  394. and t3.sex_type in ('3',#{sexType})
  395. </if>
  396. <if test="age != null and age != ''">
  397. AND <![CDATA[ t3.min_age <= #{age} ]]>
  398. AND <![CDATA[ t3.max_age >= #{age} ]]>
  399. </if>
  400. AND (UPPER(t2.spell) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})),'%') OR UPPER(t2.name) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})),'%'))
  401. <if test="inputIds != null and inputIds.size > 0">
  402. and t1.id not in
  403. <foreach item="id" collection="inputIds" open="(" separator="," close=")">
  404. #{id}
  405. </foreach>
  406. </if>
  407. AND t4.relation_id = 18
  408. LIMIT 100)
  409. </if>
  410. ) a1
  411. LIMIT 100
  412. </select>
  413. <select id="staticKnowledge" resultType="com.diagbot.dto.RetrievalDTO">
  414. SELECT
  415. a1.*
  416. FROM
  417. (
  418. -- 除化验外其他类型标签
  419. <if test="typesNoLis != null and typesNoLis.size() > 0">
  420. (
  421. SELECT
  422. b1.*, 0 uniqueId,
  423. NULL uniqueName
  424. FROM
  425. (
  426. SELECT
  427. t1.id conceptId,
  428. t1.lib_name `name`,
  429. (
  430. CASE t1.lib_type
  431. WHEN 18 THEN
  432. 10
  433. WHEN 10 THEN
  434. 20
  435. WHEN 1 THEN
  436. 25
  437. WHEN 16 THEN
  438. 50
  439. WHEN 25 THEN
  440. 60
  441. ELSE
  442. 100
  443. END
  444. ) + 1 AS orderNo,
  445. t2.`name` retrievalName,
  446. t2.is_concept showType,
  447. t1.lib_type libTypeId,
  448. CASE t6.`name`
  449. when '药品通用名' then '药品'
  450. when '辅检项目' then '辅检'
  451. ELSE t6.`name`
  452. END libTypeName
  453. FROM
  454. kl_concept t1
  455. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  456. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  457. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  458. WHERE
  459. t1.is_deleted = 'N'
  460. AND t2.is_deleted = 'N'
  461. AND t6.is_deleted = 'N'
  462. AND t7.is_deleted = 'N'
  463. AND t1.lib_type IN
  464. <foreach collection="typesNoLis" item="item" open="(" close=")"
  465. separator=",">
  466. #{item}
  467. </foreach>
  468. AND (
  469. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  470. OR UPPER(TRIM(t2. NAME)) = UPPER((TRIM(#{InputStr})))
  471. )
  472. ) b1
  473. )
  474. UNION
  475. (
  476. SELECT
  477. b1.*, 0 uniqueId,
  478. NULL uniqueName
  479. FROM
  480. (
  481. SELECT
  482. t1.id conceptId,
  483. t1.lib_name `name`,
  484. (
  485. CASE t1.lib_type
  486. WHEN 18 THEN
  487. 10
  488. WHEN 10 THEN
  489. 20
  490. WHEN 1 THEN
  491. 25
  492. WHEN 16 THEN
  493. 50
  494. WHEN 25 THEN
  495. 60
  496. ELSE
  497. 100
  498. END
  499. ) + 2 AS orderNo,
  500. t2.`name` retrievalName,
  501. t2.is_concept showType,
  502. t1.lib_type libTypeId,
  503. CASE t6.`name`
  504. when '药品通用名' then '药品'
  505. when '辅检项目' then '辅检'
  506. ELSE t6.`name`
  507. END libTypeName
  508. FROM
  509. kl_concept t1
  510. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  511. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  512. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  513. WHERE
  514. t1.is_deleted = 'N'
  515. AND t2.is_deleted = 'N'
  516. AND t6.is_deleted = 'N'
  517. AND t7.is_deleted = 'N'
  518. AND t1.lib_type IN
  519. <foreach collection="typesNoLis" item="item" open="(" close=")"
  520. separator=",">
  521. #{item}
  522. </foreach>
  523. AND (
  524. UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  525. OR UPPER(t2. NAME) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  526. )
  527. ) b1
  528. )
  529. UNION
  530. (
  531. SELECT
  532. b1.*, 0 uniqueId,
  533. NULL uniqueName
  534. FROM
  535. (
  536. SELECT
  537. t1.id conceptId,
  538. t1.lib_name `name`,
  539. (
  540. CASE t1.lib_type
  541. WHEN 18 THEN
  542. 10
  543. WHEN 10 THEN
  544. 20
  545. WHEN 1 THEN
  546. 25
  547. WHEN 16 THEN
  548. 50
  549. WHEN 25 THEN
  550. 60
  551. ELSE
  552. 100
  553. END
  554. ) + 3 AS orderNo,
  555. t2.`name` retrievalName,
  556. t2.is_concept showType,
  557. t1.lib_type libTypeId,
  558. CASE t6.`name`
  559. when '药品通用名' then '药品'
  560. when '辅检项目' then '辅检'
  561. ELSE t6.`name`
  562. END libTypeName
  563. FROM
  564. kl_concept t1
  565. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  566. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  567. LEFT JOIN kl_concept_detail t7 ON t7.concept_id = t1.id
  568. WHERE
  569. t1.is_deleted = 'N'
  570. AND t2.is_deleted = 'N'
  571. AND t6.is_deleted = 'N'
  572. AND t7.is_deleted = 'N'
  573. AND t1.lib_type IN
  574. <foreach collection="typesNoLis" item="item" open="(" close=")"
  575. separator=",">
  576. #{item}
  577. </foreach>
  578. AND (
  579. UPPER(t2.spell) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  580. OR UPPER(t2. NAME) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})), '%')
  581. )
  582. ) b1
  583. )
  584. </if>
  585. -- 化验本体标签公表项匹配静态知识
  586. <if test="typesNoLis != null and typesNoLis.size() > 0 and hasLis == true">
  587. UNION
  588. </if>
  589. <if test="hasLis == true">
  590. (
  591. SELECT
  592. b2.id conceptId,
  593. b1.selfName `name`,
  594. 31 AS orderNo,
  595. b1.retrievalName retrievalName,
  596. b1.showType showType,
  597. b1.libTypeId libTypeId,
  598. b1.libTypeName libTypeName,
  599. b2.id uniqueId,
  600. b2.lib_name uniqueName
  601. FROM
  602. (
  603. SELECT
  604. t1.id selfId,
  605. t1.lib_name selfName,
  606. t2.`name` retrievalName,
  607. t2.is_concept showType,
  608. t1.lib_type libTypeId,
  609. t6.`name` libTypeName
  610. FROM
  611. kl_concept t1
  612. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  613. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  614. WHERE
  615. t1.is_deleted = 'N'
  616. AND t2.is_deleted = 'N'
  617. AND t6.is_deleted = 'N'
  618. AND t1.lib_type = 12
  619. AND (
  620. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  621. OR UPPER(t2. NAME) = UPPER(TRIM(#{InputStr}))
  622. )
  623. ) b1,
  624. kl_concept b2,
  625. kl_concept_detail b3,
  626. kl_lis_mapping m
  627. WHERE
  628. b2.is_deleted = 'N'
  629. AND b3.is_deleted = 'N'
  630. AND m.is_deleted = 'N'
  631. AND m.item_id = 0
  632. AND m.meal_id = b1.selfId
  633. AND m.unique_id = b2.id
  634. AND b2.lib_type = 46
  635. AND b2.id = b3.concept_id
  636. )
  637. UNION
  638. (
  639. SELECT
  640. b2.id conceptId,
  641. b1.selfName `name`,
  642. 32 AS orderNo,
  643. b1.retrievalName retrievalName,
  644. b1.showType showType,
  645. b1.libTypeId libTypeId,
  646. b1.libTypeName libTypeName,
  647. b2.id uniqueId,
  648. b2.lib_name uniqueName
  649. FROM
  650. (
  651. SELECT
  652. t1.id selfId,
  653. t1.lib_name selfName,
  654. t2.`name` retrievalName,
  655. t2.is_concept showType,
  656. t1.lib_type libTypeId,
  657. t6.`name` libTypeName
  658. FROM
  659. kl_concept t1
  660. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  661. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  662. WHERE
  663. t1.is_deleted = 'N'
  664. AND t2.is_deleted = 'N'
  665. AND t6.is_deleted = 'N'
  666. AND t1.lib_type = 12
  667. AND (
  668. UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  669. OR UPPER(t2. NAME) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  670. )
  671. ) b1,
  672. kl_concept b2,
  673. kl_concept_detail b3,
  674. kl_lis_mapping m
  675. WHERE
  676. b2.is_deleted = 'N'
  677. AND b3.is_deleted = 'N'
  678. AND m.is_deleted = 'N'
  679. AND m.item_id = 0
  680. AND m.meal_id = b1.selfId
  681. AND m.unique_id = b2.id
  682. AND b2.lib_type = 46
  683. AND b2.id = b3.concept_id
  684. )
  685. UNION
  686. (
  687. SELECT
  688. b2.id conceptId,
  689. b1.selfName `name`,
  690. 33 AS orderNo,
  691. b1.retrievalName retrievalName,
  692. b1.showType showType,
  693. b1.libTypeId libTypeId,
  694. b1.libTypeName libTypeName,
  695. b2.id uniqueId,
  696. b2.lib_name uniqueName
  697. FROM
  698. (
  699. SELECT
  700. t1.id selfId,
  701. t1.lib_name selfName,
  702. t2.`name` retrievalName,
  703. t2.is_concept showType,
  704. t1.lib_type libTypeId,
  705. t6.`name` libTypeName
  706. FROM
  707. kl_concept t1
  708. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  709. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  710. WHERE
  711. t1.is_deleted = 'N'
  712. AND t2.is_deleted = 'N'
  713. AND t6.is_deleted = 'N'
  714. AND t1.lib_type = 12
  715. AND (
  716. UPPER(t2.spell) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  717. OR UPPER(t2. NAME) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})), '%')
  718. )
  719. ) b1,
  720. kl_concept b2,
  721. kl_concept_detail b3,
  722. kl_lis_mapping m
  723. WHERE
  724. b2.is_deleted = 'N'
  725. AND b3.is_deleted = 'N'
  726. AND m.is_deleted = 'N'
  727. AND m.item_id = 0
  728. AND m.meal_id = b1.selfId
  729. AND m.unique_id = b2.id
  730. AND b2.lib_type = 46
  731. AND b2.id = b3.concept_id
  732. ) -- 化验子项推父项,父项公表项匹配静态知识
  733. UNION
  734. (
  735. SELECT
  736. b2.id conceptId,
  737. b1.parentName `name`,
  738. 34 AS orderNo,
  739. b1.retrievalName retrievalName,
  740. b1.showType + 10 showType,
  741. b1.libTypeId libTypeId,
  742. b1.libTypeName libTypeName,
  743. b2.id uniqueId,
  744. b2.lib_name uniqueName
  745. FROM
  746. (
  747. SELECT
  748. t1.id selfId,
  749. t1.lib_name selfName,
  750. t5.id parentId,
  751. t5.lib_name parentName,
  752. t2.`name` retrievalName,
  753. t2.is_concept showType,
  754. t5.lib_type libTypeId,
  755. t6.`name` libTypeName
  756. FROM
  757. kl_concept t1
  758. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  759. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  760. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  761. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  762. WHERE
  763. t1.is_deleted = 'N'
  764. AND t2.is_deleted = 'N'
  765. AND t4.is_deleted = 'N'
  766. AND t5.is_deleted = 'N'
  767. AND t6.is_deleted = 'N'
  768. AND t1.lib_type = 13
  769. AND (
  770. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  771. OR UPPER(t2. NAME) = UPPER(TRIM(#{InputStr}))
  772. )
  773. AND t4.relation_id = 18
  774. ) b1,
  775. kl_concept b2,
  776. kl_concept_detail b3,
  777. kl_lis_mapping m
  778. WHERE
  779. b2.is_deleted = 'N'
  780. AND b3.is_deleted = 'N'
  781. AND m.is_deleted = 'N'
  782. AND m.meal_id = b1.parentId
  783. AND m.item_id = 0
  784. AND m.unique_id = b2.id
  785. AND b2.lib_type = 46
  786. AND b2.id = b3.concept_id
  787. )
  788. UNION
  789. (
  790. SELECT
  791. b2.id conceptId,
  792. b1.parentName `name`,
  793. 35 AS orderNo,
  794. b1.retrievalName retrievalName,
  795. b1.showType + 10 showType,
  796. b1.libTypeId libTypeId,
  797. b1.libTypeName libTypeName,
  798. b2.id uniqueId,
  799. b2.lib_name uniqueName
  800. FROM
  801. (
  802. SELECT
  803. t1.id selfId,
  804. t1.lib_name selfName,
  805. t5.id parentId,
  806. t5.lib_name parentName,
  807. t2.`name` retrievalName,
  808. t2.is_concept showType,
  809. t5.lib_type libTypeId,
  810. t6.`name` libTypeName
  811. FROM
  812. kl_concept t1
  813. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  814. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  815. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  816. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  817. WHERE
  818. t1.is_deleted = 'N'
  819. AND t2.is_deleted = 'N'
  820. AND t4.is_deleted = 'N'
  821. AND t5.is_deleted = 'N'
  822. AND t6.is_deleted = 'N'
  823. AND t1.lib_type = 13
  824. AND (
  825. UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  826. OR UPPER(t2. NAME) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  827. )
  828. AND t4.relation_id = 18
  829. ) b1,
  830. kl_concept b2,
  831. kl_concept_detail b3,
  832. kl_lis_mapping m
  833. WHERE
  834. b2.is_deleted = 'N'
  835. AND b3.is_deleted = 'N'
  836. AND m.is_deleted = 'N'
  837. AND m.meal_id = b1.parentId
  838. AND m.item_id = 0
  839. AND m.unique_id = b2.id
  840. AND b2.lib_type = 46
  841. AND b2.id = b3.concept_id
  842. )
  843. UNION
  844. (
  845. SELECT
  846. b2.id conceptId,
  847. b1.parentName `name`,
  848. 36 AS orderNo,
  849. b1.retrievalName retrievalName,
  850. b1.showType + 10 showType,
  851. b1.libTypeId libTypeId,
  852. b1.libTypeName libTypeName,
  853. b2.id uniqueId,
  854. b2.lib_name uniqueName
  855. FROM
  856. (
  857. SELECT
  858. t1.id selfId,
  859. t1.lib_name selfName,
  860. t5.id parentId,
  861. t5.lib_name parentName,
  862. t2.`name` retrievalName,
  863. t2.is_concept showType,
  864. t5.lib_type libTypeId,
  865. t6.`name` libTypeName
  866. FROM
  867. kl_concept t1
  868. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  869. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  870. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  871. LEFT JOIN kl_lexicon t6 ON t6.id = t5.lib_type
  872. WHERE
  873. t1.is_deleted = 'N'
  874. AND t2.is_deleted = 'N'
  875. AND t4.is_deleted = 'N'
  876. AND t5.is_deleted = 'N'
  877. AND t6.is_deleted = 'N'
  878. AND t1.lib_type = 13
  879. AND (
  880. UPPER(t2.spell) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  881. OR UPPER(t2. NAME) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  882. )
  883. AND t4.relation_id = 18
  884. ) b1,
  885. kl_concept b2,
  886. kl_concept_detail b3,
  887. kl_lis_mapping m
  888. WHERE
  889. b2.is_deleted = 'N'
  890. AND b3.is_deleted = 'N'
  891. AND m.is_deleted = 'N'
  892. AND m.meal_id = b1.parentId
  893. AND m.item_id = 0
  894. AND m.unique_id = b2.id
  895. AND b2.lib_type = 46
  896. AND b2.id = b3.concept_id
  897. ) -- 化验子项推父项,父项--子项组合公表项匹配静态知识
  898. UNION
  899. (
  900. SELECT
  901. b2.id conceptId,
  902. CONCAT(b1.parentName,'(',b1.selfName,')') `name`,
  903. 41 AS orderNo,
  904. b1.retrievalName retrievalName,
  905. b1.showType + 20 showType,
  906. b1.libTypeId libTypeId,
  907. b1.libTypeName libTypeName,
  908. b2.id uniqueId,
  909. b2.lib_name uniqueName
  910. FROM
  911. (
  912. SELECT
  913. t1.id selfId,
  914. t1.lib_name selfName,
  915. t5.id parentId,
  916. t5.lib_name parentName,
  917. t2.`name` retrievalName,
  918. t2.is_concept showType,
  919. t1.lib_type libTypeId,
  920. t6.`name` libTypeName
  921. FROM
  922. kl_concept t1
  923. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  924. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  925. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  926. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  927. WHERE
  928. t1.is_deleted = 'N'
  929. AND t2.is_deleted = 'N'
  930. AND t4.is_deleted = 'N'
  931. AND t5.is_deleted = 'N'
  932. AND t6.is_deleted = 'N'
  933. AND t1.lib_type = 13
  934. AND (
  935. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  936. OR UPPER(t2. NAME) = UPPER(TRIM(#{InputStr}))
  937. )
  938. AND t4.relation_id = 18
  939. ) b1,
  940. kl_concept b2,
  941. kl_concept_detail b3,
  942. kl_lis_mapping m
  943. WHERE
  944. b2.is_deleted = 'N'
  945. AND b3.is_deleted = 'N'
  946. AND m.is_deleted = 'N'
  947. AND m.meal_id = b1.parentId
  948. AND m.item_id = b1.selfId
  949. AND m.unique_id = b2.id
  950. AND b2.lib_type = 46
  951. AND b2.id = b3.concept_id
  952. )
  953. UNION
  954. (
  955. SELECT
  956. b2.id conceptId,
  957. CONCAT(b1.parentName,'(',b1.selfName,')') `name`,
  958. 42 AS orderNo,
  959. b1.retrievalName retrievalName,
  960. b1.showType + 20 showType,
  961. b1.libTypeId libTypeId,
  962. b1.libTypeName libTypeName,
  963. b2.id uniqueId,
  964. b2.lib_name uniqueName
  965. FROM
  966. (
  967. SELECT
  968. t1.id selfId,
  969. t1.lib_name selfName,
  970. t5.id parentId,
  971. t5.lib_name parentName,
  972. t2.`name` retrievalName,
  973. t2.is_concept showType,
  974. t1.lib_type libTypeId,
  975. t6.`name` libTypeName
  976. FROM
  977. kl_concept t1
  978. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  979. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  980. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  981. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  982. WHERE
  983. t1.is_deleted = 'N'
  984. AND t2.is_deleted = 'N'
  985. AND t4.is_deleted = 'N'
  986. AND t5.is_deleted = 'N'
  987. AND t6.is_deleted = 'N'
  988. AND t1.lib_type = 13
  989. AND (
  990. UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  991. OR UPPER(t2. NAME) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  992. )
  993. AND t4.relation_id = 18
  994. ) b1,
  995. kl_concept b2,
  996. kl_concept_detail b3,
  997. kl_lis_mapping m
  998. WHERE
  999. b2.is_deleted = 'N'
  1000. AND b3.is_deleted = 'N'
  1001. AND m.is_deleted = 'N'
  1002. AND m.meal_id = b1.parentId
  1003. AND m.item_id = b1.selfId
  1004. AND m.unique_id = b2.id
  1005. AND b2.lib_type = 46
  1006. AND b2.id = b3.concept_id
  1007. )
  1008. UNION
  1009. (
  1010. SELECT
  1011. b2.id conceptId,
  1012. CONCAT(b1.parentName,'(',b1.selfName,')') `name`,
  1013. 43 AS orderNo,
  1014. b1.retrievalName retrievalName,
  1015. b1.showType + 20 showType,
  1016. b1.libTypeId libTypeId,
  1017. b1.libTypeName libTypeName,
  1018. b2.id uniqueId,
  1019. b2.lib_name uniqueName
  1020. FROM
  1021. (
  1022. SELECT
  1023. t1.id selfId,
  1024. t1.lib_name selfName,
  1025. t5.id parentId,
  1026. t5.lib_name parentName,
  1027. t2.`name` retrievalName,
  1028. t2.is_concept showType,
  1029. t1.lib_type libTypeId,
  1030. t6.`name` libTypeName
  1031. FROM
  1032. kl_concept t1
  1033. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  1034. LEFT JOIN kl_relation t4 ON t4.end_id = t1.id
  1035. LEFT JOIN kl_concept t5 ON t5.id = t4.start_id
  1036. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  1037. WHERE
  1038. t1.is_deleted = 'N'
  1039. AND t2.is_deleted = 'N'
  1040. AND t4.is_deleted = 'N'
  1041. AND t5.is_deleted = 'N'
  1042. AND t6.is_deleted = 'N'
  1043. AND t1.lib_type = 13
  1044. AND (
  1045. UPPER(t2.spell) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  1046. OR UPPER(t2. NAME) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  1047. )
  1048. AND t4.relation_id = 18
  1049. ) b1,
  1050. kl_concept b2,
  1051. kl_concept_detail b3,
  1052. kl_lis_mapping m
  1053. WHERE
  1054. b2.is_deleted = 'N'
  1055. AND b3.is_deleted = 'N'
  1056. AND m.is_deleted = 'N'
  1057. AND m.meal_id = b1.parentId
  1058. AND m.item_id = b1.selfId
  1059. AND m.unique_id = b2.id
  1060. AND b2.lib_type = 46
  1061. AND b2.id = b3.concept_id
  1062. )
  1063. </if>
  1064. ) a1
  1065. ORDER BY
  1066. a1.orderNo ASC,
  1067. a1.showType DESC,
  1068. a1.conceptId ASC
  1069. </select>
  1070. <select id="getConceptConMap" resultType="com.diagbot.dto.ConceptBaseDTO" parameterType="com.diagbot.vo.ConceptFindVO">
  1071. SELECT
  1072. t1.id as conceptId,
  1073. t1.lib_name as name
  1074. FROM
  1075. kl_concept t1,
  1076. kl_concept_common t2
  1077. WHERE
  1078. t1.id = t2.concept_id
  1079. AND t1.is_deleted = 'N'
  1080. AND t2.is_deleted = 'N'
  1081. <if test="conceptIds != null and conceptIds.size > 0">
  1082. and t1.id in
  1083. <foreach item="id" collection="conceptIds" open="(" separator="," close=")">
  1084. #{id}
  1085. </foreach>
  1086. </if>
  1087. <if test="sexType == 3">
  1088. AND t2.sex_type IN ('1','2','3')
  1089. </if>
  1090. <if test="sexType != 3">
  1091. AND t2.sex_type IN ('3',#{sexType})
  1092. </if>
  1093. <if test="age != null and age != ''">
  1094. AND <![CDATA[ t2.min_age <= #{age} ]]>
  1095. AND <![CDATA[ t2.max_age >= #{age} ]]>
  1096. </if>
  1097. </select>
  1098. <select id="getStandWord" resultType="java.lang.String">
  1099. SELECT lib_name FROM kl_concept WHERE is_deleted = 'N' AND lib_type = 33
  1100. </select>
  1101. <select id="indexConcept" resultType="com.diagbot.dto.ConceptBaseDTO">
  1102. SELECT DISTINCT b.id concept_id,b.lib_name name FROM `kl_library_info` a, kl_concept b
  1103. where a.is_deleted = 'N' and b.is_deleted = 'N'
  1104. and a.concept_id = b.id
  1105. and UPPER(TRIM(a.`name`)) like concat('%',UPPER(TRIM(#{name})),'%') and a.type_id = #{libType} and b.lib_type = #{libType}
  1106. </select>
  1107. </mapper>