QcCasesEntryMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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.QcCasesEntryMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.QcCasesEntry">
  6. <id column="id" property="id" />
  7. <result column="cases_id" property="casesId" />
  8. <result column="cases_name" property="casesName" />
  9. <result column="mode_id" property="modeId" />
  10. <result column="code" property="code" />
  11. <result column="name" property="name" />
  12. <result column="rule_type" property="ruleType" />
  13. <result column="dev_type" property="devType" />
  14. <result column="accuracy_type" property="accuracyType" />
  15. <result column="drgs" property="drgs" />
  16. <result column="type" property="type" />
  17. <result column="precond" property="precond" />
  18. <result column="order_no" property="orderNo" />
  19. <result column="remark" property="remark" />
  20. <result column="is_deleted" property="isDeleted" />
  21. <result column="gmt_create" property="gmtCreate" />
  22. <result column="gmt_modified" property="gmtModified" />
  23. <result column="creator" property="creator" />
  24. <result column="modifier" property="modifier" />
  25. </resultMap>
  26. <select id="getAllQcCasesEntry" parameterType="com.diagbot.vo.QcCasesEntryAllVO" resultType="com.diagbot.dto.QcCasesEntryAllDTO">
  27. SELECT a.*,b.name as modeName FROM qc_cases_entry a
  28. LEFT JOIN qc_mode b ON b.id= a.mode_id
  29. WHERE a.is_deleted = 'N'
  30. <if test="casesId != null and casesId != ''">
  31. AND a.cases_id = #{casesId}
  32. </if>
  33. <if test="modeId != null and modeId != ''">
  34. AND b.id = #{modeId}
  35. </if>
  36. <if test="ruleType != null">
  37. AND a.rule_type = #{ruleType}
  38. </if>
  39. <if test="devType != null">
  40. AND a.dev_type = #{devType}
  41. </if>
  42. <if test="accuracyType != null">
  43. AND a.accuracy_type = #{accuracyType}
  44. </if>
  45. <if test="drgs != null">
  46. AND a.drgs = #{drgs}
  47. </if>
  48. <if test="type != null">
  49. AND a.type = #{type}
  50. </if>
  51. <if test="name != null and name != ''">
  52. AND UPPER(a.name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
  53. </if>
  54. <if test="code != null and code != ''">
  55. AND UPPER(a.code) LIKE CONCAT('%', UPPER(trim(#{code})), '%')
  56. </if>
  57. ORDER BY a.gmt_modified DESC
  58. </select>
  59. <select id="getQcCasesEntryIndex" resultType="com.diagbot.dto.QcCasesEntryAllDTO">
  60. SELECT distinct a.*,b.name as modeName
  61. FROM qc_cases_entry a, qc_mode b, qc_cases_entry_hospital c
  62. WHERE a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N '
  63. and b.id= a.mode_id and a.id = c.cases_entry_id
  64. <if test="hospitalId != null">
  65. AND c.hospital_id = #{hospitalId}
  66. </if>
  67. <if test="casesId != null and casesId != ''">
  68. AND a.cases_id = #{casesId}
  69. </if>
  70. <if test="modeId != null and modeId != ''">
  71. AND b.id = #{modeId}
  72. </if>
  73. <if test="name != null and name != ''">
  74. AND UPPER(a.name) LIKE CONCAT('%', UPPER(trim(#{name})), '%')
  75. </if>
  76. <if test="code != null and code != ''">
  77. AND a.code = #{code}
  78. </if>
  79. <if test="ids != null and ids.size() > 0 ">
  80. and a.id in
  81. <foreach collection="ids" item="item" open="(" separator="," close=")">
  82. #{item}
  83. </foreach>
  84. </if>
  85. <if test="notIds != null and notIds.size() > 0 ">
  86. and a.id not in
  87. <foreach collection="notIds" item="item" open="(" separator="," close=")">
  88. #{item}
  89. </foreach>
  90. </if>
  91. <if test="filter != null and filter == 1">
  92. and a.id not in
  93. (
  94. select DISTINCT q2.cases_entry_id from qc_question_info q1, qc_question_entry q2
  95. where q1.is_deleted = 'N' and q2.is_deleted = 'N' and q1.id = q2.question_id
  96. <if test="hospitalId != null">
  97. and q1.hospital_id = #{hospitalId}
  98. </if>
  99. <if test="modeId != null and modeId != ''">
  100. AND q1.mode_id = #{modeId}
  101. </if>
  102. )
  103. </if>
  104. ORDER BY a.cases_id,a.id
  105. </select>
  106. <select id="getByCasesEntryId" resultType="com.diagbot.dto.QcCasesEntryDTO">
  107. SELECT a.*,b.name as modeName FROM qc_cases_entry a
  108. LEFT JOIN qc_mode b ON b.id= a.mode_id
  109. WHERE a.is_deleted = 'N' AND a.id
  110. IN
  111. <foreach collection="ids" item="ids" open="(" close=")" separator=",">
  112. #{ids}
  113. </foreach>
  114. </select>
  115. <select id ="getQcCasesEntryAll" resultType="com.diagbot.dto.QcCasesEntryAllDTO">
  116. SELECT a.id,a.cases_id,a.cases_name,a.mode_id,a.code,a.name,a.drgs,a.type,a.rule_type,a.dev_type,a.accuracy_type,a.precond,a.is_deleted,a.order_no,a.gmt_create,a.gmt_modified,a.creator,a.modifier,
  117. b.name as modeName FROM qc_cases_entry a
  118. LEFT JOIN qc_mode b ON b.id= a.mode_id
  119. WHERE a.is_deleted = 'N'
  120. ORDER BY a.cases_id,a.id
  121. </select>
  122. <select id="index" resultType="com.diagbot.dto.QcCasesEntrySimpleDTO">
  123. SELECT distinct t3.msg name, t2.id
  124. FROM
  125. qc_cases_entry t2,
  126. qc_cases_entry_hospital t3
  127. where t2.is_deleted = 'N'
  128. and t3.is_deleted = 'N'
  129. and t2.id = t3.cases_entry_id
  130. and t3.is_used = 1
  131. <if test="hospitalId != null">
  132. and t3.hospital_id = #{hospitalId}
  133. </if>
  134. <if test="input != null and input != ''">
  135. and t2.name like concat('%', #{input}, '%')
  136. </if>
  137. <if test="notIds != null and notIds.size > 0">
  138. and t2.id not in
  139. <foreach item="item" collection="notIds" open="(" separator="," close=")" >
  140. #{item}
  141. </foreach>
  142. </if>
  143. order by t2.order_no
  144. </select>
  145. <select id="getEntryByHospital" resultType="com.diagbot.dto.QcCasesEntrySimpleDTO">
  146. SELECT
  147. t1.`name`, t1.id, t3.`name` mode_name, t2.is_used, 1 as sel
  148. FROM
  149. qc_cases_entry t1,
  150. qc_cases_entry_hospital t2,
  151. qc_mode t3
  152. WHERE
  153. t1.is_deleted = 'N'
  154. AND t2.is_deleted = 'N'
  155. AND t3.is_deleted = 'N'
  156. AND t1.id = t2.cases_entry_id
  157. AND t1.mode_id = t3.id
  158. AND t2.hospital_id = #{hospitalId}
  159. ORDER BY t3.order_no,t1.order_no
  160. </select>
  161. <select id="entryTypePage" resultType="com.diagbot.dto.QcEntryTypeDTO">
  162. SELECT
  163. t.*, qc.cases_id,
  164. qc.cases_name,
  165. qc.`code`,
  166. qc.`name` entry_name
  167. FROM
  168. (
  169. SELECT
  170. a1.entry_id,
  171. a1.hospital_id,
  172. GROUP_CONCAT(b1. NAME) type_str
  173. FROM
  174. (
  175. SELECT
  176. t1.id entry_id,
  177. t2.hospital_id
  178. FROM
  179. qc_cases_entry t1,
  180. qc_cases_entry_hospital t2
  181. WHERE
  182. t1.is_deleted = 'N'
  183. AND t2.is_deleted = 'N'
  184. AND t1.id = t2.cases_entry_id
  185. ) a1
  186. LEFT JOIN (
  187. SELECT
  188. a1. NAME,
  189. a2.case_entry_id,
  190. a1.hospital_id
  191. FROM
  192. qc_type a1,
  193. qc_type_cases_entry a2
  194. WHERE
  195. a1.is_deleted = 'N'
  196. AND a2.is_deleted = 'N'
  197. AND a1.id = a2.type_id
  198. ) b1 ON a1.entry_id = b1.case_entry_id
  199. AND a1.hospital_id = b1.hospital_id
  200. GROUP BY
  201. a1.entry_id,
  202. a1.hospital_id
  203. ) t,
  204. qc_cases_entry qc
  205. WHERE
  206. t.entry_id = qc.id
  207. <if test="hospitalId != null">
  208. and t.hospital_id = #{hospitalId}
  209. </if>
  210. <if test="entryName != null and entryName != ''">
  211. and qc.name like concat('%', #{entryName}, '%')
  212. </if>
  213. <if test="code != null and code != ''">
  214. and qc.code like concat('%', #{code}, '%')
  215. </if>
  216. <if test="casesId != null and casesId != ''">
  217. and qc.cases_id = #{casesId}
  218. </if>
  219. <if test="typeName != null and typeName != ''">
  220. and t.type_str like concat('%', #{typeName}, '%')
  221. </if>
  222. <if test="typeIsNull != null and typeIsNull == 1">
  223. and t.type_str is null
  224. </if>
  225. </select>
  226. <select id="entryTypeDetail" resultType="com.diagbot.dto.QcTypeByEntryDTO">
  227. SELECT
  228. t1.id entry_id,
  229. t1.`name` entry_name,
  230. t2.hospital_id,
  231. t4.NAME type_name,
  232. t4.id type_id,
  233. t1.cases_name
  234. FROM
  235. qc_cases_entry t1,
  236. qc_cases_entry_hospital t2,
  237. qc_type_cases_entry t3,
  238. qc_type t4
  239. WHERE
  240. t1.is_deleted = 'N'
  241. AND t2.is_deleted = 'N'
  242. AND t3.is_deleted = 'N'
  243. AND t4.is_deleted = 'N'
  244. AND t1.id = t2.cases_entry_id
  245. AND t1.id = t3.case_entry_id
  246. AND t3.type_id = t4.id
  247. AND t2.hospital_id = t4.hospital_id
  248. AND t2.hospital_id = #{hospitalId}
  249. AND t1.id = #{entryId}
  250. ORDER BY
  251. t4.id
  252. </select>
  253. <select id="indexQcType" resultType="com.diagbot.dto.QcTypeSimpDTO">
  254. SELECT
  255. *
  256. FROM
  257. `qc_type` t1
  258. WHERE
  259. t1.is_deleted = 'N'
  260. AND t1.hospital_id = #{hospitalId}
  261. AND t1.id NOT IN (
  262. SELECT DISTINCT
  263. type_id
  264. FROM
  265. qc_type_cases_entry t2
  266. WHERE
  267. t2.is_deleted = 'N'
  268. AND t2.case_entry_id = #{entryId}
  269. )
  270. </select>
  271. <delete id="deleteQcTypeEntry">
  272. DELETE t2
  273. FROM
  274. qc_type t1,
  275. qc_type_cases_entry t2
  276. WHERE
  277. t1.hospital_id = #{hospitalId}
  278. AND t1.id = t2.type_id
  279. AND t2.case_entry_id = #{entryId}
  280. </delete>
  281. <select id="getTypeByHospital" resultType="com.diagbot.dto.QcTypeSimpDTO">
  282. SELECT DISTINCT
  283. NAME
  284. FROM
  285. `qc_type`
  286. WHERE
  287. is_deleted = 'N'
  288. <if test="hospitalId != null">
  289. and hospital_id = #{hospitalId}
  290. </if>
  291. ORDER BY
  292. id
  293. </select>
  294. </mapper>