ConceptMapper.xml 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291
  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="typesIn != null and typesIn.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="typesIn" 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="typesIn" 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="typesIn" 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="typesIn != null and typesIn.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. -- 量表匹配静态知识同时搜索诊断有关的量表;
  1065. <if test="hasGauge == true">
  1066. <if test="typesIn != null and typesIn.size() > 0 or hasLis == true">
  1067. union
  1068. </if>
  1069. (
  1070. SELECT
  1071. b1.selfId conceptId,
  1072. b1.selfName `name`,
  1073. 71 AS orderNo,
  1074. b1.retrievalName retrievalName,
  1075. b1.showType showType,
  1076. b1.libTypeId libTypeId,
  1077. b1.libTypeName libTypeName,
  1078. b1.selfId uniqueId,
  1079. b1.selfName uniqueName
  1080. FROM
  1081. (
  1082. SELECT
  1083. t1.id selfId,
  1084. t1.lib_name selfName,
  1085. t2.`name` retrievalName,
  1086. t2.is_concept showType,
  1087. t1.lib_type libTypeId,
  1088. t6.`name` libTypeName
  1089. FROM
  1090. kl_concept t1
  1091. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  1092. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  1093. WHERE
  1094. t1.is_deleted = 'N'
  1095. AND t2.is_deleted = 'N'
  1096. AND t6.is_deleted = 'N'
  1097. AND t1.lib_type = 48
  1098. AND (
  1099. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  1100. OR UPPER(t2. NAME) = UPPER(TRIM(#{InputStr}))
  1101. )
  1102. ) b1,
  1103. kl_scale b2
  1104. WHERE
  1105. b2.is_deleted = 'N'
  1106. AND b1.selfId = b2.concept_id
  1107. )
  1108. UNION
  1109. (
  1110. SELECT
  1111. b1.selfId conceptId,
  1112. b1.selfName `name`,
  1113. 72 AS orderNo,
  1114. b1.retrievalName retrievalName,
  1115. b1.showType showType,
  1116. b1.libTypeId libTypeId,
  1117. b1.libTypeName libTypeName,
  1118. b1.selfId uniqueId,
  1119. b1.selfName uniqueName
  1120. FROM
  1121. (
  1122. SELECT
  1123. t1.id selfId,
  1124. t1.lib_name selfName,
  1125. t2.`name` retrievalName,
  1126. t2.is_concept showType,
  1127. t1.lib_type libTypeId,
  1128. t6.`name` libTypeName
  1129. FROM
  1130. kl_concept t1
  1131. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  1132. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  1133. WHERE
  1134. t1.is_deleted = 'N'
  1135. AND t2.is_deleted = 'N'
  1136. AND t6.is_deleted = 'N'
  1137. AND t1.lib_type = 48
  1138. AND (
  1139. UPPER(t2.spell) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  1140. OR UPPER(t2. NAME) LIKE CONCAT(UPPER(TRIM(#{InputStr})), '%')
  1141. )
  1142. ) b1,
  1143. kl_scale b2
  1144. WHERE
  1145. b2.is_deleted = 'N'
  1146. AND b1.selfId = b2.concept_id
  1147. )
  1148. UNION
  1149. (
  1150. SELECT
  1151. b1.selfId conceptId,
  1152. b1.selfName `name`,
  1153. 73 AS orderNo,
  1154. b1.retrievalName retrievalName,
  1155. b1.showType showType,
  1156. b1.libTypeId libTypeId,
  1157. b1.libTypeName libTypeName,
  1158. b1.selfId uniqueId,
  1159. b1.selfName uniqueName
  1160. FROM
  1161. (
  1162. SELECT
  1163. t1.id selfId,
  1164. t1.lib_name selfName,
  1165. t2.`name` retrievalName,
  1166. t2.is_concept showType,
  1167. t1.lib_type libTypeId,
  1168. t6.`name` libTypeName
  1169. FROM
  1170. kl_concept t1
  1171. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  1172. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  1173. WHERE
  1174. t1.is_deleted = 'N'
  1175. AND t2.is_deleted = 'N'
  1176. AND t6.is_deleted = 'N'
  1177. AND t1.lib_type = 48
  1178. AND (
  1179. UPPER(t2.spell) LIKE CONCAT('%', UPPER(TRIM(#{InputStr})), '%')
  1180. OR UPPER(t2. NAME) LIKE CONCAT('%',UPPER(TRIM(#{InputStr})), '%')
  1181. )
  1182. ) b1
  1183. ,kl_scale b2
  1184. WHERE
  1185. b2.is_deleted = 'N'
  1186. AND b1.selfId = b2.concept_id
  1187. )
  1188. UNION
  1189. (
  1190. SELECT distinct
  1191. b2.id conceptId,
  1192. b2.lib_name `name`,
  1193. 74 AS orderNo,
  1194. b1.retrievalName retrievalName,
  1195. 0 showType,
  1196. b2.lib_type libTypeId,
  1197. '量表' libTypeName,
  1198. b2.id uniqueId,
  1199. b2.lib_name uniqueName
  1200. FROM
  1201. (
  1202. SELECT
  1203. t1.id selfId,
  1204. t1.lib_name selfName,
  1205. t2.`name` retrievalName,
  1206. t2.is_concept showType,
  1207. t1.lib_type libTypeId,
  1208. t6.`name` libTypeName
  1209. FROM
  1210. kl_concept t1
  1211. LEFT JOIN kl_library_info t2 ON t1.id = t2.concept_id
  1212. LEFT JOIN kl_lexicon t6 ON t6.id = t1.lib_type
  1213. WHERE
  1214. t1.is_deleted = 'N'
  1215. AND t2.is_deleted = 'N'
  1216. AND t6.is_deleted = 'N'
  1217. AND t1.lib_type = 18
  1218. AND (
  1219. UPPER(t2.spell) = UPPER(TRIM(#{InputStr}))
  1220. OR UPPER(t2. NAME) = UPPER(TRIM(#{InputStr}))
  1221. )
  1222. ) b1
  1223. , kl_concept b2, kl_relation b3, kl_scale b4
  1224. WHERE
  1225. b2.is_deleted = 'N'
  1226. AND b3.is_deleted = 'N'
  1227. AND b4.is_deleted = 'N'
  1228. AND b1.selfId = b3.start_id
  1229. AND b2.id = b3.end_id
  1230. AND b2.id = b4.concept_id
  1231. )
  1232. </if>
  1233. ) a1
  1234. ORDER BY
  1235. a1.orderNo ASC,
  1236. a1.showType DESC,
  1237. a1.conceptId ASC
  1238. </select>
  1239. <select id="getConceptConMap" resultType="com.diagbot.dto.ConceptBaseDTO" parameterType="com.diagbot.vo.ConceptFindVO">
  1240. SELECT
  1241. t1.id as conceptId,
  1242. t1.lib_name as name
  1243. FROM
  1244. kl_concept t1,
  1245. kl_concept_common t2
  1246. WHERE
  1247. t1.id = t2.concept_id
  1248. AND t1.is_deleted = 'N'
  1249. AND t2.is_deleted = 'N'
  1250. <if test="conceptIds != null and conceptIds.size > 0">
  1251. and t1.id in
  1252. <foreach item="id" collection="conceptIds" open="(" separator="," close=")">
  1253. #{id}
  1254. </foreach>
  1255. </if>
  1256. <if test="sexType == 3">
  1257. AND t2.sex_type IN ('1','2','3')
  1258. </if>
  1259. <if test="sexType != 3">
  1260. AND t2.sex_type IN ('3',#{sexType})
  1261. </if>
  1262. <if test="age != null and age != ''">
  1263. AND <![CDATA[ t2.min_age <= #{age} ]]>
  1264. AND <![CDATA[ t2.max_age >= #{age} ]]>
  1265. </if>
  1266. </select>
  1267. <select id="getStandWord" resultType="java.lang.String">
  1268. SELECT lib_name FROM kl_concept WHERE is_deleted = 'N' AND lib_type = 33
  1269. </select>
  1270. <select id="indexConcept" resultType="com.diagbot.dto.ConceptBaseDTO">
  1271. SELECT DISTINCT b.id concept_id,b.lib_name name FROM `kl_library_info` a, kl_concept b
  1272. where a.is_deleted = 'N' and b.is_deleted = 'N'
  1273. and a.concept_id = b.id
  1274. and (UPPER(TRIM(a.`name`)) like concat('%',UPPER(TRIM(#{name})),'%')
  1275. or UPPER(TRIM(a.`spell`)) like concat('%',UPPER(TRIM(#{name})),'%'))
  1276. and a.type_id = #{libType} and b.lib_type = #{libType}
  1277. </select>
  1278. </mapper>