BehospitalInfoMapper.xml 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592
  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.BehospitalInfoMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  6. <id column="behospital_code" property="behospitalCode" />
  7. <result column="hospital_id" property="hospitalId" />
  8. <result column="name" property="name" />
  9. <result column="sex" property="sex" />
  10. <result column="birthday" property="birthday" />
  11. <result column="file_code" property="fileCode" />
  12. <result column="qc_type_id" property="qcTypeId" />
  13. <result column="ward_code" property="wardCode" />
  14. <result column="ward_name" property="wardName" />
  15. <result column="beh_dept_id" property="behDeptId" />
  16. <result column="beh_dept_name" property="behDeptName" />
  17. <result column="bed_code" property="bedCode" />
  18. <result column="bed_name" property="bedName" />
  19. <result column="insurance_name" property="insuranceName" />
  20. <result column="job_type" property="jobType" />
  21. <result column="behospital_date" property="behospitalDate" />
  22. <result column="leave_hospital_date" property="leaveHospitalDate" />
  23. <result column="diagnose_icd" property="diagnoseIcd" />
  24. <result column="diagnose" property="diagnose" />
  25. <result column="beh_doctor_id" property="behDoctorId" />
  26. <result column="beh_doctor_name" property="behDoctorName" />
  27. <result column="doctor_id" property="doctorId" />
  28. <result column="doctor_name" property="doctorName" />
  29. <result column="director_doctor_id" property="directorDoctorId" />
  30. <result column="director_doctor_name" property="directorDoctorName" />
  31. <result column="is_placefile" property="isPlacefile" />
  32. <result column="is_deleted" property="isDeleted" />
  33. <result column="gmt_create" property="gmtCreate" />
  34. <result column="gmt_modified" property="gmtModified" />
  35. <result column="creator" property="creator" />
  36. <result column="modifier" property="modifier" />
  37. </resultMap>
  38. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  39. select * from (
  40. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as grade_time, c.age from med_behospital_info a
  41. LEFT JOIN med_qcresult_info b
  42. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  43. left join med_home_page c
  44. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  45. ) t
  46. where t.is_deleted = 'N'
  47. <if test="deptId != null and deptId != ''">
  48. and t.beh_dept_id = #{deptId}
  49. </if>
  50. <if test="doctorName != null and doctorName != ''">
  51. and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
  52. </if>
  53. <if test="name != null and name != ''">
  54. and t.name like CONCAT('%',#{name},'%')
  55. </if>
  56. <if test="doctorCode != null and doctorCode != ''">
  57. and (t.doctor_id = #{doctorCode}
  58. or t.beh_doctor_id = #{doctorCode}
  59. or t.director_doctor_id = #{doctorCode})
  60. </if>
  61. <if test="fileCode != null and fileCode != ''">
  62. and t.file_code like CONCAT('%',#{fileCode},'%')
  63. </if>
  64. <if test="hospitalId != null">
  65. and t.hospital_id = #{hospitalId}
  66. </if>
  67. <if test="behospitalCode != null and behospitalCode != ''">
  68. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  69. </if>
  70. <if test="behosDateStart != null">
  71. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  72. </if>
  73. <if test="behosDateEnd != null">
  74. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  75. </if>
  76. <if test="leaveHosDateStart != null">
  77. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  78. </if>
  79. <if test="leaveHosDateEnd != null">
  80. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  81. </if>
  82. <if test="level != null and level != ''">
  83. and t.level = #{level}
  84. </if>
  85. <if test="isPlacefile != null and isPlacefile != ''">
  86. and t.is_placefile = #{isPlacefile}
  87. </if>
  88. and t.qc_type_id != 0
  89. </select>
  90. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  91. SELECT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  92. a.cases_id cases_id, d.score cases_score,b.id model_id, a.name standard_msg,
  93. c.opt_type, c.grade_type
  94. FROM `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  95. where a.is_deleted = 'N' and b.is_deleted = 'N' and c.is_deleted = 'N' and d.is_deleted = 'N'
  96. and a.id = c.cases_entry_id
  97. and a.mode_id = b.id
  98. AND c.cases_id = d.cases_id
  99. and c.hospital_id = d.hospital_id
  100. and c.hospital_id = #{hospitalId}
  101. and c.behospital_code = #{behospitalCode}
  102. order by b.order_no, a.order_no
  103. </select>
  104. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  105. SELECT b.id model_id,b.`name` model_name,
  106. d.score,d.msg,d.cases_entry_id,d.is_reject,
  107. a.cases_id cases_id, a.name standard_msg,a.code
  108. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  109. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  110. and a.mode_id = b.id
  111. and a.id = d.cases_entry_id
  112. and d.is_used = 1
  113. and d.hospital_id = #{hospitalId}
  114. and a.code in
  115. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  116. #{item}
  117. </foreach>
  118. <if test="modeId != null">
  119. and a.mode_id = #{modeId}
  120. </if>
  121. order by b.order_no, a.order_no;
  122. </select>
  123. <!-- 缺陷排行列表 -->
  124. <select id="resultStatistics" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  125. SELECT
  126. t1.msg AS name,
  127. t1.num AS num,
  128. round( t1.num / t2.totle, 4) AS percent
  129. FROM
  130. (
  131. (
  132. SELECT
  133. d.msg,
  134. count(*) AS num
  135. FROM
  136. med_behospital_info a,
  137. med_home_page b,
  138. med_qcresult_info c,
  139. med_qcresult_detail d
  140. WHERE
  141. a.behospital_code = b.behospital_code
  142. AND a.hospital_id = b.hospital_id
  143. AND a.behospital_code = c.behospital_code
  144. AND a.hospital_id = c.hospital_id
  145. AND a.behospital_code = d.behospital_code
  146. AND a.hospital_id = d.hospital_id
  147. AND a.is_deleted = 'N'
  148. AND b.is_deleted = 'N'
  149. AND c.is_deleted = 'N'
  150. AND d.is_deleted = 'N'
  151. <![CDATA[AND a.qc_type_id <>0 ]]>
  152. <if test="hospitalId != null and hospitalId != ''">
  153. AND a.hospital_id = #{hospitalId}
  154. </if>
  155. <if test="startDate != null and startDate != ''">
  156. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  157. </if>
  158. <if test="endDate != null and endDate != ''">
  159. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  160. </if>
  161. GROUP BY
  162. d.msg
  163. ORDER BY
  164. count(*) DESC
  165. ) t1,
  166. (
  167. SELECT
  168. count(*) AS totle
  169. FROM
  170. med_behospital_info a,
  171. med_home_page b,
  172. med_qcresult_info c,
  173. med_qcresult_detail d
  174. WHERE
  175. a.behospital_code = b.behospital_code
  176. AND a.hospital_id = b.hospital_id
  177. AND a.behospital_code = c.behospital_code
  178. AND a.hospital_id = c.hospital_id
  179. AND a.behospital_code = d.behospital_code
  180. AND a.hospital_id = d.hospital_id
  181. AND a.is_deleted = 'N'
  182. AND b.is_deleted = 'N'
  183. AND c.is_deleted = 'N'
  184. AND d.is_deleted = 'N'
  185. <![CDATA[AND a.qc_type_id <>0 ]]>
  186. <if test="hospitalId != null and hospitalId != ''">
  187. AND a.hospital_id = #{hospitalId}
  188. </if>
  189. <if test="startDate != null and startDate != ''">
  190. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  191. </if>
  192. <if test="endDate != null and endDate != ''">
  193. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  194. </if>
  195. ) t2
  196. )
  197. <if test="limitCount != null and limitCount != ''">
  198. limit 0,#{limitCount}
  199. </if>
  200. </select>
  201. <!-- 各科室缺陷占比 -->
  202. <select id="resultStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  203. SELECT
  204. t1.beh_dept_name AS name,
  205. t1.num AS num,
  206. round( t1.num / t2.totle, 4 ) AS percent
  207. FROM
  208. (
  209. (
  210. SELECT
  211. a.beh_dept_id,
  212. a.beh_dept_name,
  213. count(*) AS num
  214. FROM
  215. med_behospital_info a,
  216. med_home_page b,
  217. med_qcresult_info c,
  218. med_qcresult_detail d
  219. WHERE
  220. a.behospital_code = b.behospital_code
  221. AND a.hospital_id = b.hospital_id
  222. AND a.behospital_code = c.behospital_code
  223. AND a.hospital_id = c.hospital_id
  224. AND a.behospital_code = d.behospital_code
  225. AND a.hospital_id = d.hospital_id
  226. AND a.is_deleted = 'N'
  227. AND b.is_deleted = 'N'
  228. AND c.is_deleted = 'N'
  229. AND d.is_deleted = 'N'
  230. <![CDATA[AND a.qc_type_id <>0 ]]>
  231. <if test="hospitalId != null and hospitalId != ''">
  232. AND a.hospital_id = #{hospitalId}
  233. </if>
  234. <if test="startDate != null and startDate != ''">
  235. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  236. </if>
  237. <if test="endDate != null and endDate != ''">
  238. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  239. </if>
  240. GROUP BY
  241. a.beh_dept_id,
  242. a.beh_dept_name
  243. ORDER BY
  244. count(*) DESC
  245. ) t1,
  246. (
  247. SELECT
  248. count(*) AS totle
  249. FROM
  250. med_behospital_info a,
  251. med_home_page b,
  252. med_qcresult_info c,
  253. med_qcresult_detail d
  254. WHERE
  255. a.behospital_code = b.behospital_code
  256. AND a.hospital_id = b.hospital_id
  257. AND a.behospital_code = c.behospital_code
  258. AND a.hospital_id = c.hospital_id
  259. AND a.behospital_code = d.behospital_code
  260. AND a.hospital_id = d.hospital_id
  261. AND a.is_deleted = 'N'
  262. AND b.is_deleted = 'N'
  263. AND c.is_deleted = 'N'
  264. AND d.is_deleted = 'N'
  265. <![CDATA[AND a.qc_type_id <>0 ]]>
  266. <if test="hospitalId != null and hospitalId != ''">
  267. AND a.hospital_id = #{hospitalId}
  268. </if>
  269. <if test="startDate != null and startDate != ''">
  270. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  271. </if>
  272. <if test="endDate != null and endDate != ''">
  273. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  274. </if>
  275. ) t2
  276. )
  277. </select>
  278. <!-- 缺陷排行列表 -->
  279. <select id="resultStatistics2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  280. SELECT
  281. d.msg as name,
  282. count(*) AS num
  283. FROM
  284. FROM
  285. med_behospital_info a,
  286. med_home_page b,
  287. med_qcresult_info c,
  288. med_qcresult_detail d
  289. WHERE
  290. a.behospital_code = b.behospital_code
  291. AND a.hospital_id = b.hospital_id
  292. AND a.behospital_code = c.behospital_code
  293. AND a.hospital_id = c.hospital_id
  294. AND a.behospital_code = d.behospital_code
  295. AND a.hospital_id = d.hospital_id
  296. AND a.is_deleted = 'N'
  297. AND b.is_deleted = 'N'
  298. AND c.is_deleted = 'N'
  299. AND d.is_deleted = 'N'
  300. <![CDATA[AND a.qc_type_id <>0 ]]>
  301. <if test="hospitalId != null and hospitalId != ''">
  302. AND a.hospital_id = #{hospitalId}
  303. </if>
  304. <if test="startDate != null and startDate != ''">
  305. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  306. </if>
  307. <if test="endDate != null and endDate != ''">
  308. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  309. </if>
  310. GROUP BY
  311. d.msg
  312. ORDER BY
  313. count(*) DESC
  314. <if test="limitCount != null and limitCount != ''">
  315. limit 0,#{limitCount}
  316. </if>
  317. </select>
  318. <!-- 各科室缺陷占比 -->
  319. <select id="resultStatisticsByDept2" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  320. SELECT
  321. a.beh_dept_id,
  322. a.beh_dept_name as name,
  323. count(*) AS num
  324. FROM
  325. med_behospital_info a,
  326. med_home_page b,
  327. med_qcresult_info c,
  328. med_qcresult_detail d
  329. WHERE
  330. a.behospital_code = b.behospital_code
  331. AND a.hospital_id = b.hospital_id
  332. AND a.behospital_code = c.behospital_code
  333. AND a.hospital_id = c.hospital_id
  334. AND a.behospital_code = d.behospital_code
  335. AND a.hospital_id = d.hospital_id
  336. AND a.is_deleted = 'N'
  337. AND b.is_deleted = 'N'
  338. AND c.is_deleted = 'N'
  339. AND d.is_deleted = 'N'
  340. <![CDATA[AND a.qc_type_id <>0 ]]>
  341. <if test="hospitalId != null and hospitalId != ''">
  342. AND a.hospital_id = #{hospitalId}
  343. </if>
  344. <if test="startDate != null and startDate != ''">
  345. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  346. </if>
  347. <if test="endDate != null and endDate != ''">
  348. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  349. </if>
  350. GROUP BY
  351. a.beh_dept_id,
  352. a.beh_dept_name
  353. ORDER BY
  354. count(*) DESC
  355. </select>
  356. <!-- 缺陷总数查询-->
  357. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  358. SELECT
  359. count(*) AS totle
  360. FROM
  361. med_behospital_info a,
  362. med_home_page b,
  363. med_qcresult_info c,
  364. med_qcresult_detail d
  365. WHERE
  366. a.behospital_code = b.behospital_code
  367. AND a.hospital_id = b.hospital_id
  368. AND a.behospital_code = c.behospital_code
  369. AND a.hospital_id = c.hospital_id
  370. AND a.behospital_code = d.behospital_code
  371. AND a.hospital_id = d.hospital_id
  372. AND a.is_deleted = 'N'
  373. AND b.is_deleted = 'N'
  374. AND c.is_deleted = 'N'
  375. AND d.is_deleted = 'N'
  376. <![CDATA[AND a.qc_type_id <>0 ]]>
  377. <if test="hospitalId != null and hospitalId != ''">
  378. AND a.hospital_id = #{hospitalId}
  379. </if>
  380. <if test="startDate != null and startDate != ''">
  381. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  382. </if>
  383. <if test="endDate != null and endDate != ''">
  384. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  385. </if>
  386. </select>
  387. <!--获取未评分病历-->
  388. <select id="getNoGrade" resultMap="BaseResultMap">
  389. select * from med_behospital_info a
  390. where a.is_deleted = 'N'
  391. and
  392. not EXISTS (
  393. SELECT
  394. 1
  395. FROM
  396. med_qcresult_info b
  397. WHERE
  398. b.is_deleted = 'N'
  399. AND a.hospital_id = b.hospital_id
  400. AND a.behospital_code = b.behospital_code
  401. )
  402. and a.qc_type_id != 0
  403. <if test="leaveDate != null">
  404. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  405. </if>
  406. </select>
  407. <!--质控评分(科室)分页-->
  408. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  409. SELECT
  410. *
  411. FROM
  412. ( SELECT
  413. a.*,
  414. IFNULL(b.level, '未评分') AS `level`,
  415. b.grade_type,
  416. b.score_res,
  417. b.gmt_create AS grade_time,
  418. c.age
  419. FROM
  420. med_behospital_info a
  421. JOIN sys_user_dept d
  422. ON a.hospital_id = d.hospital_id
  423. AND a.beh_dept_id = d.dept_id
  424. LEFT JOIN med_qcresult_info b
  425. ON a.behospital_code = b.behospital_code
  426. AND b.is_deleted = 'N'
  427. LEFT JOIN med_home_page c
  428. ON a.behospital_code = c.behospital_code
  429. AND c.is_deleted = 'N'
  430. WHERE d.is_deleted = 'N'
  431. AND d.user_id = #{userId}
  432. ) t
  433. where t.is_deleted = 'N'
  434. <if test="deptId != null and deptId != ''">
  435. and t.beh_dept_id = #{deptId}
  436. </if>
  437. <if test="doctorName != null and doctorName != ''">
  438. and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
  439. </if>
  440. <if test="doctorCode != null and doctorCode != ''">
  441. and (t.doctor_id = #{doctorCode}
  442. or t.beh_doctor_id = #{doctorCode}
  443. or t.director_doctor_id = #{doctorCode})
  444. </if>
  445. <if test="name != null and name != ''">
  446. and t.name like CONCAT('%',#{name},'%')
  447. </if>
  448. <if test="fileCode != null and fileCode != ''">
  449. and t.file_code like CONCAT('%',#{fileCode},'%')
  450. </if>
  451. <if test="hospitalId != null">
  452. and t.hospital_id = #{hospitalId}
  453. </if>
  454. <if test="behospitalCode != null and behospitalCode != ''">
  455. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  456. </if>
  457. <if test="behosDateStart != null">
  458. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  459. </if>
  460. <if test="behosDateEnd != null">
  461. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  462. </if>
  463. <if test="leaveHosDateStart != null">
  464. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  465. </if>
  466. <if test="leaveHosDateEnd != null">
  467. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  468. </if>
  469. <if test="level != null and level != ''">
  470. and t.level = #{level}
  471. </if>
  472. <if test="isPlacefile != null and isPlacefile != ''">
  473. and t.is_placefile = #{isPlacefile}
  474. </if>
  475. and t.qc_type_id != 0
  476. </select>
  477. <!--质控评分(个人)分页-->
  478. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  479. select * from (SELECT
  480. a.*,
  481. IFNULL(b.level, '未评分') AS `level`,
  482. b.grade_type,
  483. b.score_res,
  484. b.gmt_create AS grade_time,
  485. c.age
  486. FROM
  487. med_behospital_info a
  488. JOIN
  489. (SELECT
  490. u.id,
  491. u.linkman AS linkman,
  492. uh.hospital_id
  493. FROM
  494. sys_user u
  495. JOIN sys_user_hospital uh
  496. ON u.id = uh.user_id
  497. WHERE u.is_deleted = "N"
  498. AND u.id = #{userId}
  499. AND uh.hospital_id = #{hospitalId}) u1
  500. ON a.hospital_id = u1.hospital_id
  501. LEFT JOIN med_qcresult_info b
  502. ON a.behospital_code = b.behospital_code
  503. AND b.is_deleted = 'N'
  504. LEFT JOIN med_home_page c
  505. ON a.behospital_code = c.behospital_code
  506. AND c.is_deleted = 'N'
  507. WHERE CONCAT(
  508. IFNULL(a.doctor_name, ''),
  509. IFNULL(a.beh_doctor_name, ''),
  510. IFNULL(a.director_doctor_name, '')
  511. ) LIKE CONCAT('%', u1.linkman, '%')
  512. ) t
  513. where t.is_deleted = 'N'
  514. <if test="deptId != null and deptId != ''">
  515. and t.beh_dept_id = #{deptId}
  516. </if>
  517. <if test="name != null and name != ''">
  518. and t.name like CONCAT('%',#{name},'%')
  519. </if>
  520. <if test="fileCode != null and fileCode != ''">
  521. and t.file_code like CONCAT('%',#{fileCode},'%')
  522. </if>
  523. <if test="behospitalCode != null and behospitalCode != ''">
  524. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  525. </if>
  526. <if test="behosDateStart != null">
  527. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  528. </if>
  529. <if test="behosDateEnd != null">
  530. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  531. </if>
  532. <if test="leaveHosDateStart != null">
  533. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  534. </if>
  535. <if test="leaveHosDateEnd != null">
  536. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  537. </if>
  538. <if test="level != null and level != ''">
  539. and t.level = #{level}
  540. </if>
  541. <if test="isPlacefile != null and isPlacefile != ''">
  542. and t.is_placefile = #{isPlacefile}
  543. </if>
  544. and t.qc_type_id != 0
  545. </select>
  546. <!-- 病案首页病历数统计 -->
  547. <select id="homePageCount" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="int">
  548. SELECT
  549. COUNT(*)
  550. FROM
  551. med_behospital_info a,
  552. med_home_page b
  553. WHERE
  554. a.is_deleted = 'N'
  555. AND b.is_deleted = 'N'
  556. AND a.hospital_id = b.hospital_id
  557. AND a.behospital_code = b.behospital_code
  558. <![CDATA[AND a.qc_type_id <>0 ]]>
  559. <if test="hospitalId != null and hospitalId != ''">
  560. AND a.hospital_id = #{hospitalId}
  561. </if>
  562. <if test="startDate != null and startDate != ''">
  563. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  564. </if>
  565. <if test="endDate != null and endDate != ''">
  566. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  567. </if>
  568. <if test="death!=null and death==1">
  569. AND b.leave_hospital_type = '死亡'
  570. </if>
  571. <if test="newBorn!=null and newBorn==1">
  572. AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
  573. <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
  574. </if>
  575. </select>
  576. <!-- 病案首页手术病历数统计 -->
  577. <select id="homePageCountForOperation" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  578. SELECT
  579. COUNT( DISTINCT a.behospital_code )
  580. FROM
  581. med_behospital_info a,
  582. med_home_page b,
  583. med_medical_record c,
  584. qc_mode d
  585. WHERE
  586. a.is_deleted = 'N'
  587. AND b.is_deleted = 'N'
  588. AND c.is_deleted = 'N'
  589. AND d.is_deleted = 'N'
  590. AND a.hospital_id = b.hospital_id
  591. AND a.hospital_id = c.hospital_id
  592. AND a.behospital_code = b.behospital_code
  593. AND a.behospital_code = c.behospital_code
  594. AND c.mode_id = d.id
  595. AND d.`name` = '手术记录'
  596. <![CDATA[AND a.qc_type_id <>0 ]]>
  597. <if test="hospitalId != null and hospitalId != ''">
  598. AND a.hospital_id = #{hospitalId}
  599. </if>
  600. <if test="startDate != null and startDate != ''">
  601. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  602. </if>
  603. <if test="endDate != null and endDate != ''">
  604. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  605. </if>
  606. </select>
  607. <!-- 按科室统计病案首页病历数 -->
  608. <select id="homePageCountByDept" parameterType="com.diagbot.vo.HomePageFilterVO" resultType="com.diagbot.dto.NumDTO">
  609. SELECT
  610. a.beh_dept_id AS id,
  611. a.beh_dept_name AS NAME,
  612. COUNT(*) AS num
  613. FROM
  614. med_behospital_info a,
  615. med_home_page b,
  616. sys_user_dept c
  617. WHERE
  618. a.is_deleted = 'N'
  619. AND b.is_deleted = 'N'
  620. AND c.is_deleted = 'N'
  621. AND a.hospital_id = b.hospital_id
  622. AND a.hospital_id = c.hospital_id
  623. AND a.behospital_code = b.behospital_code
  624. AND a.beh_dept_id = c.dept_id
  625. <![CDATA[AND a.qc_type_id <>0 ]]>
  626. <if test="death!=null and death==1">
  627. AND b.leave_hospital_type = '死亡'
  628. </if>
  629. <if test="userId!=null">
  630. AND c.user_id = #{userId}
  631. </if>
  632. <if test="hospitalId != null and hospitalId != ''">
  633. AND a.hospital_id = #{hospitalId}
  634. </if>
  635. <if test="startDate != null and startDate != ''">
  636. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  637. </if>
  638. <if test="endDate != null and endDate != ''">
  639. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  640. </if>
  641. GROUP BY
  642. a.beh_dept_id,
  643. a.beh_dept_name
  644. </select>
  645. <!-- 按科室病案首页手术病历数 -->
  646. <select id="homePageCountForOperationByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  647. SELECT
  648. a.beh_dept_id AS id,
  649. a.beh_dept_name AS NAME,
  650. COUNT( DISTINCT a.behospital_code ) AS num
  651. FROM
  652. med_behospital_info a,
  653. med_home_page b,
  654. sys_user_dept c,
  655. med_medical_record d,
  656. qc_mode e
  657. WHERE
  658. a.is_deleted = 'N'
  659. AND b.is_deleted = 'N'
  660. AND c.is_deleted = 'N'
  661. AND d.is_deleted = 'N'
  662. AND e.is_deleted = 'N'
  663. AND a.hospital_id = b.hospital_id
  664. AND a.hospital_id = c.hospital_id
  665. AND a.hospital_id = d.hospital_id
  666. AND a.behospital_code = b.behospital_code
  667. AND b.behospital_code = d.behospital_code
  668. AND a.beh_dept_id = c.dept_id
  669. AND d.mode_id = e.id
  670. AND e.`name` = '手术记录'
  671. <![CDATA[AND a.qc_type_id <>0 ]]>
  672. <if test="userId!=null">
  673. AND c.user_id = #{userId}
  674. </if>
  675. <if test="hospitalId != null and hospitalId != ''">
  676. AND a.hospital_id = #{hospitalId}
  677. </if>
  678. <if test="startDate != null and startDate != ''">
  679. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  680. </if>
  681. <if test="endDate != null and endDate != ''">
  682. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  683. </if>
  684. GROUP BY
  685. a.beh_dept_id,
  686. a.beh_dept_name
  687. </select>
  688. <!-- 各科室缺陷占比排行(分页) -->
  689. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  690. SELECT t.*
  691. FROM
  692. (SELECT
  693. t1.beh_dept_name AS NAME,
  694. t1.num AS num,
  695. t2.totle AS totleNum,
  696. round( t1.num / t2.totle, 4 ) AS percent,
  697. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  698. FROM
  699. (
  700. SELECT
  701. a.beh_dept_id,
  702. a.beh_dept_name,
  703. count(*) AS num
  704. FROM
  705. med_behospital_info a,
  706. med_home_page b,
  707. med_qcresult_info c,
  708. med_qcresult_detail d
  709. WHERE
  710. a.behospital_code = b.behospital_code
  711. AND a.hospital_id = b.hospital_id
  712. AND a.behospital_code = c.behospital_code
  713. AND a.hospital_id = c.hospital_id
  714. AND a.behospital_code = d.behospital_code
  715. AND a.hospital_id = d.hospital_id
  716. AND a.is_deleted = 'N'
  717. AND b.is_deleted = 'N'
  718. AND c.is_deleted = 'N'
  719. AND d.is_deleted = 'N'
  720. <![CDATA[AND a.qc_type_id <>0 ]]>
  721. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  722. AND a.hospital_id = #{filterPageVO.hospitalId}
  723. </if>
  724. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  725. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  726. </if>
  727. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  728. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  729. </if>
  730. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  731. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  732. </if>
  733. GROUP BY
  734. a.beh_dept_id,
  735. a.beh_dept_name
  736. ORDER BY
  737. count(*) DESC
  738. ) t1,
  739. (
  740. SELECT
  741. count(*) AS totle
  742. FROM
  743. med_behospital_info a,
  744. med_home_page b,
  745. med_qcresult_info c,
  746. med_qcresult_detail d
  747. WHERE
  748. a.behospital_code = b.behospital_code
  749. AND a.hospital_id = b.hospital_id
  750. AND a.behospital_code = c.behospital_code
  751. AND a.hospital_id = c.hospital_id
  752. AND a.behospital_code = d.behospital_code
  753. AND a.hospital_id = d.hospital_id
  754. AND a.is_deleted = 'N'
  755. AND b.is_deleted = 'N'
  756. AND c.is_deleted = 'N'
  757. AND d.is_deleted = 'N'
  758. <![CDATA[AND a.qc_type_id <>0 ]]>
  759. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  760. AND a.hospital_id = #{filterPageVO.hospitalId}
  761. </if>
  762. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  763. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
  764. </if>
  765. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  766. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
  767. </if>
  768. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  769. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  770. </if>
  771. ) t2
  772. )t
  773. </select>
  774. <!-- 科室缺陷占比(主任医生) -->
  775. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  776. SELECT
  777. t.*
  778. FROM
  779. (
  780. SELECT
  781. t1.NAME,
  782. t1.num AS num,
  783. t2.totle AS totleNum,
  784. round( t1.num / t2.totle, 4 ) AS percent,
  785. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  786. FROM
  787. (
  788. SELECT
  789. d.msg as name,
  790. count(*) AS num
  791. FROM
  792. med_behospital_info a,
  793. med_home_page b,
  794. med_qcresult_info c,
  795. med_qcresult_detail d,
  796. sys_user_dept e
  797. WHERE
  798. a.behospital_code = b.behospital_code
  799. AND a.hospital_id = b.hospital_id
  800. AND a.behospital_code = c.behospital_code
  801. AND a.hospital_id = c.hospital_id
  802. AND a.behospital_code = d.behospital_code
  803. AND a.hospital_id = d.hospital_id
  804. AND a.is_deleted = 'N'
  805. AND b.is_deleted = 'N'
  806. AND c.is_deleted = 'N'
  807. AND d.is_deleted = 'N'
  808. AND e.is_deleted = 'N'
  809. AND a.beh_dept_id = e.dept_id
  810. <![CDATA[AND a.qc_type_id <>0 ]]>
  811. <if test="filterPageByDeptVO.userId!=null">
  812. AND e.user_id = #{filterPageByDeptVO.userId}
  813. </if>
  814. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  815. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  816. </if>
  817. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  818. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  819. </if>
  820. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  821. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  822. </if>
  823. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  824. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  825. </if>
  826. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  827. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  828. </if>
  829. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  830. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  831. </if>
  832. GROUP BY
  833. d.msg
  834. ORDER BY
  835. count(*) DESC
  836. ) t1,
  837. (
  838. SELECT
  839. count(*) AS totle
  840. FROM
  841. med_behospital_info a,
  842. med_home_page b,
  843. med_qcresult_info c,
  844. med_qcresult_detail d,
  845. sys_user_dept e
  846. WHERE
  847. a.behospital_code = b.behospital_code
  848. AND a.hospital_id = b.hospital_id
  849. AND a.behospital_code = c.behospital_code
  850. AND a.hospital_id = c.hospital_id
  851. AND a.behospital_code = d.behospital_code
  852. AND a.hospital_id = d.hospital_id
  853. AND a.is_deleted = 'N'
  854. AND b.is_deleted = 'N'
  855. AND c.is_deleted = 'N'
  856. AND d.is_deleted = 'N'
  857. AND e.is_deleted = 'N'
  858. AND a.beh_dept_id = e.dept_id
  859. <![CDATA[AND a.qc_type_id <>0 ]]>
  860. <if test="filterPageByDeptVO.userId!=null">
  861. AND e.user_id = #{filterPageByDeptVO.userId}
  862. </if>
  863. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  864. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  865. </if>
  866. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  867. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
  868. </if>
  869. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  870. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
  871. </if>
  872. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  873. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  874. </if>
  875. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  876. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  877. </if>
  878. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  879. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  880. </if>
  881. ) t2
  882. )t
  883. </select>
  884. <!-- 各科室缺陷占比(组合)-全院 -->
  885. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  886. SELECT
  887. t1.deptId,
  888. t1.deptName,
  889. t2.entryNum,
  890. t1.mrNum,
  891. t1.totleValue,
  892. t1.averageValue,
  893. t1.firstLevelNum,
  894. t1.secondLevelNum,
  895. t1.thirdLevelNum,
  896. t1.firstLevelPercent,
  897. t1.secondLevelPercent,
  898. t1.thirdLevelPercent,
  899. t1.firstLevelPercentStr,
  900. t1.secondLevelPercentStr,
  901. t1.thirdLevelPercentStr
  902. FROM
  903. (
  904. SELECT
  905. a.beh_dept_id AS deptId,
  906. a.beh_dept_name AS deptName,
  907. count( DISTINCT c.id ) AS mrNum,
  908. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  909. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  910. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  911. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  912. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  913. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  914. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  915. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS thirdLevelPercent,
  916. concat(
  917. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  918. '%'
  919. ) AS firstLevelPercentStr,
  920. concat(
  921. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  922. '%'
  923. ) AS secondLevelPercentStr,
  924. concat(
  925. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  926. '%'
  927. ) AS thirdLevelPercentStr
  928. FROM
  929. med_behospital_info a,
  930. med_home_page b,
  931. med_qcresult_info c
  932. WHERE
  933. a.is_deleted = 'N'
  934. AND b.is_deleted = 'N'
  935. AND c.is_deleted = 'N'
  936. AND a.hospital_id = b.hospital_id
  937. AND a.hospital_id = c.hospital_id
  938. AND a.behospital_code = b.behospital_code
  939. AND a.behospital_code = c.behospital_code
  940. <![CDATA[AND a.qc_type_id <>0 ]]>
  941. <if test="hospitalId != null and hospitalId != ''">
  942. AND a.hospital_id = #{hospitalId}
  943. </if>
  944. <if test="startDate != null and startDate != ''">
  945. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  946. </if>
  947. <if test="endDate != null and endDate != ''">
  948. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  949. </if>
  950. <if test="level != null and level != ''">
  951. and c.level = #{level}
  952. </if>
  953. <if test="name != null and name != ''">
  954. and a.beh_dept_name like CONCAT('%',#{name},'%')
  955. </if>
  956. GROUP BY
  957. a.beh_dept_id,
  958. a.beh_dept_name
  959. ) t1,
  960. (
  961. SELECT
  962. a.beh_dept_id AS deptId,
  963. a.beh_dept_name AS deptName,
  964. count( * ) AS entryNum
  965. FROM
  966. med_behospital_info a,
  967. med_home_page b,
  968. med_qcresult_info c,
  969. med_qcresult_detail d,
  970. qc_cases_entry e
  971. WHERE
  972. a.is_deleted = 'N'
  973. AND b.is_deleted = 'N'
  974. AND c.is_deleted = 'N'
  975. AND d.is_deleted = 'N'
  976. AND e.is_deleted = 'N'
  977. AND a.hospital_id = b.hospital_id
  978. AND a.hospital_id = c.hospital_id
  979. AND a.hospital_id = d.hospital_id
  980. AND a.behospital_code = b.behospital_code
  981. AND a.behospital_code = c.behospital_code
  982. AND a.behospital_code = d.behospital_code
  983. AND d.cases_id = e.cases_id
  984. AND d.cases_entry_id = e.id
  985. <![CDATA[AND a.qc_type_id <>0 ]]>
  986. <if test="hospitalId != null and hospitalId != ''">
  987. AND a.hospital_id = #{hospitalId}
  988. </if>
  989. <if test="startDate != null and startDate != ''">
  990. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  991. </if>
  992. <if test="endDate != null and endDate != ''">
  993. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  994. </if>
  995. <if test="level != null and level != ''">
  996. and c.level = #{level}
  997. </if>
  998. <if test="name != null and name != ''">
  999. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1000. </if>
  1001. GROUP BY
  1002. a.beh_dept_id,
  1003. a.beh_dept_name
  1004. ) t2
  1005. WHERE
  1006. t1.deptId = t2.deptId
  1007. AND t1.deptName = t2.deptName
  1008. <if test="asc != null and asc !=''">
  1009. order by
  1010. <choose>
  1011. <when test='asc=="deptId"'>deptId asc</when>
  1012. <when test='asc=="deptName"'>deptName asc</when>
  1013. <when test='asc=="entryNum"'>entryNum asc</when>
  1014. <when test='asc=="mrNum"'>mrNum asc</when>
  1015. <when test='asc=="totleValue"'>totleValue asc</when>
  1016. <when test='asc=="averageValue"'>averageValue asc</when>
  1017. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1018. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1019. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1020. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1021. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1022. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1023. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1024. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1025. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1026. <otherwise> deptName asc </otherwise>
  1027. </choose>
  1028. </if>
  1029. <if test="desc != null and desc!=''">
  1030. order by
  1031. <choose>
  1032. <when test='desc=="deptId"'>deptId desc</when>
  1033. <when test='desc=="deptName"'>deptName desc</when>
  1034. <when test='desc=="entryNum"'>entryNum desc</when>
  1035. <when test='desc=="mrNum"'>mrNum desc</when>
  1036. <when test='desc=="totleValue"'>totleValue desc</when>
  1037. <when test='desc=="averageValue"'>averageValue desc</when>
  1038. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1039. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1040. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1041. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1042. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1043. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1044. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1045. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1046. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1047. <otherwise> deptName desc </otherwise>
  1048. </choose>
  1049. </if>
  1050. </select>
  1051. <!-- 病案首页合格率占比 -全院-->
  1052. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1053. SELECT
  1054. t1.deptId,
  1055. t1.deptName,
  1056. t2.entryNum,
  1057. t1.mrNum,
  1058. t1.totleValue,
  1059. t1.averageValue,
  1060. t1.firstLevelNum,
  1061. t1.secondLevelNum,
  1062. t1.firstLevelPercent,
  1063. t1.secondLevelPercent,
  1064. t1.firstLevelPercentStr,
  1065. t1.secondLevelPercentStr
  1066. FROM
  1067. (
  1068. SELECT
  1069. a.beh_dept_id AS deptId,
  1070. a.beh_dept_name AS deptName,
  1071. count( DISTINCT c.id ) AS mrNum,
  1072. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1073. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1074. COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
  1075. COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
  1076. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1077. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1078. concat(
  1079. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1080. '%'
  1081. ) AS firstLevelPercentStr,
  1082. concat(
  1083. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1084. '%'
  1085. ) AS secondLevelPercentStr
  1086. FROM
  1087. med_behospital_info a,
  1088. med_home_page b,
  1089. med_qcresult_cases c
  1090. WHERE
  1091. a.is_deleted = 'N'
  1092. AND b.is_deleted = 'N'
  1093. AND c.is_deleted = 'N'
  1094. AND a.hospital_id = b.hospital_id
  1095. AND a.hospital_id = c.hospital_id
  1096. AND a.behospital_code = b.behospital_code
  1097. AND a.behospital_code = c.behospital_code
  1098. AND c.cases_id = 243
  1099. <![CDATA[AND a.qc_type_id <>0 ]]>
  1100. <if test="hospitalId != null and hospitalId != ''">
  1101. AND a.hospital_id = #{hospitalId}
  1102. </if>
  1103. <if test="startDate != null and startDate != ''">
  1104. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1105. </if>
  1106. <if test="endDate != null and endDate != ''">
  1107. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1108. </if>
  1109. <if test="level != null and level != ''">
  1110. and c.level = #{level}
  1111. </if>
  1112. <if test="name != null and name != ''">
  1113. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1114. </if>
  1115. GROUP BY
  1116. a.beh_dept_id,
  1117. a.beh_dept_name
  1118. ) t1,
  1119. (
  1120. SELECT
  1121. a.beh_dept_id AS deptId,
  1122. a.beh_dept_name AS deptName,
  1123. count( * ) AS entryNum
  1124. FROM
  1125. med_behospital_info a,
  1126. med_home_page b,
  1127. med_qcresult_cases c,
  1128. med_qcresult_detail d,
  1129. qc_cases_entry e
  1130. WHERE
  1131. a.is_deleted = 'N'
  1132. AND b.is_deleted = 'N'
  1133. AND c.is_deleted = 'N'
  1134. AND d.is_deleted = 'N'
  1135. AND e.is_deleted = 'N'
  1136. AND a.hospital_id = b.hospital_id
  1137. AND a.hospital_id = c.hospital_id
  1138. AND a.hospital_id = d.hospital_id
  1139. AND a.behospital_code = b.behospital_code
  1140. AND a.behospital_code = c.behospital_code
  1141. AND a.behospital_code = d.behospital_code
  1142. AND c.cases_id = d.cases_id
  1143. AND d.cases_id = e.cases_id
  1144. AND d.cases_entry_id = e.id
  1145. AND d.cases_id = 243
  1146. <![CDATA[AND a.qc_type_id <>0 ]]>
  1147. <if test="hospitalId != null and hospitalId != ''">
  1148. AND a.hospital_id = #{hospitalId}
  1149. </if>
  1150. <if test="startDate != null and startDate != ''">
  1151. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1152. </if>
  1153. <if test="endDate != null and endDate != ''">
  1154. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1155. </if>
  1156. <if test="level != null and level != ''">
  1157. and c.level = #{level}
  1158. </if>
  1159. <if test="name != null and name != ''">
  1160. and a.beh_dept_name like CONCAT('%',#{name},'%')
  1161. </if>
  1162. GROUP BY
  1163. a.beh_dept_id,
  1164. a.beh_dept_name
  1165. ) t2
  1166. WHERE
  1167. t1.deptId = t2.deptId
  1168. AND t1.deptName = t2.deptName
  1169. <if test="asc != null and asc !=''">
  1170. order by
  1171. <choose>
  1172. <when test='asc=="deptId"'>deptId asc</when>
  1173. <when test='asc=="deptName"'>deptName asc</when>
  1174. <when test='asc=="entryNum"'>entryNum asc</when>
  1175. <when test='asc=="mrNum"'>mrNum asc</when>
  1176. <when test='asc=="totleValue"'>totleValue asc</when>
  1177. <when test='asc=="averageValue"'>averageValue asc</when>
  1178. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1179. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1180. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1181. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1182. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1183. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1184. <otherwise> deptName asc </otherwise>
  1185. </choose>
  1186. </if>
  1187. <if test="desc != null and desc!=''">
  1188. order by
  1189. <choose>
  1190. <when test='desc=="deptId"'>deptId desc</when>
  1191. <when test='desc=="deptName"'>deptName desc</when>
  1192. <when test='desc=="entryNum"'>entryNum desc</when>
  1193. <when test='desc=="mrNum"'>mrNum desc</when>
  1194. <when test='desc=="totleValue"'>totleValue desc</when>
  1195. <when test='desc=="averageValue"'>averageValue desc</when>
  1196. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1197. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1198. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1199. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1200. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1201. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1202. <otherwise> deptName desc </otherwise>
  1203. </choose>
  1204. </if>
  1205. </select>
  1206. <!-- 各科室缺陷占比-科室 -->
  1207. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1208. SELECT
  1209. t1.doctorId,
  1210. t1.doctorName,
  1211. t2.entryNum,
  1212. t1.mrNum,
  1213. t1.totleValue,
  1214. t1.averageValue,
  1215. t1.firstLevelNum,
  1216. t1.secondLevelNum,
  1217. t1.thirdLevelNum,
  1218. t1.firstLevelPercent,
  1219. t1.secondLevelPercent,
  1220. t1.thirdLevelPercent,
  1221. t1.firstLevelPercentStr,
  1222. t1.secondLevelPercentStr,
  1223. t1.thirdLevelPercentStr
  1224. FROM
  1225. (
  1226. SELECT
  1227. a.doctor_id AS doctorId,
  1228. a.doctor_name AS doctorName,
  1229. count( DISTINCT c.id ) AS mrNum,
  1230. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1231. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1232. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1233. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1234. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1235. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1236. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1237. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS thirdLevelPercent,
  1238. concat(
  1239. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1240. '%'
  1241. ) AS firstLevelPercentStr,
  1242. concat(
  1243. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1244. '%'
  1245. ) AS secondLevelPercentStr,
  1246. concat(
  1247. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1248. '%'
  1249. ) AS thirdLevelPercentStr
  1250. FROM
  1251. med_behospital_info a,
  1252. med_home_page b,
  1253. med_qcresult_info c,
  1254. sys_user_dept e
  1255. WHERE
  1256. a.is_deleted = 'N'
  1257. AND b.is_deleted = 'N'
  1258. AND c.is_deleted = 'N'
  1259. AND e.is_deleted = 'N'
  1260. AND a.hospital_id = b.hospital_id
  1261. AND a.hospital_id = c.hospital_id
  1262. AND a.behospital_code = b.behospital_code
  1263. AND a.behospital_code = c.behospital_code
  1264. AND a.beh_dept_id = e.dept_id
  1265. <![CDATA[AND a.qc_type_id <>0 ]]>
  1266. <if test="hospitalId != null and hospitalId != ''">
  1267. AND a.hospital_id = #{hospitalId}
  1268. </if>
  1269. <if test="startDate != null and startDate != ''">
  1270. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1271. </if>
  1272. <if test="endDate != null and endDate != ''">
  1273. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1274. </if>
  1275. <if test="level != null and level != ''">
  1276. and c.level = #{level}
  1277. </if>
  1278. <if test="name != null and name != ''">
  1279. and a.doctor_name like CONCAT('%',#{name},'%')
  1280. </if>
  1281. <if test="userId!=null and userId !=''">
  1282. AND e.user_id = #{userId}
  1283. </if>
  1284. <if test="deptName!=null and deptName !=''">
  1285. AND a.beh_dept_name = #{deptName}
  1286. </if>
  1287. GROUP BY
  1288. a.doctor_id,
  1289. a.doctor_name
  1290. ) t1,
  1291. (
  1292. SELECT
  1293. a.doctor_id AS doctorId,
  1294. a.doctor_name AS doctorName,
  1295. count( * ) AS entryNum
  1296. FROM
  1297. med_behospital_info a,
  1298. med_home_page b,
  1299. med_qcresult_info c,
  1300. med_qcresult_detail d,
  1301. qc_cases_entry e,
  1302. sys_user_dept f
  1303. WHERE
  1304. a.is_deleted = 'N'
  1305. AND b.is_deleted = 'N'
  1306. AND c.is_deleted = 'N'
  1307. AND d.is_deleted = 'N'
  1308. AND e.is_deleted = 'N'
  1309. AND f.is_deleted = 'N'
  1310. AND a.hospital_id = b.hospital_id
  1311. AND a.hospital_id = c.hospital_id
  1312. AND a.hospital_id = d.hospital_id
  1313. AND a.behospital_code = b.behospital_code
  1314. AND a.behospital_code = c.behospital_code
  1315. AND a.behospital_code = d.behospital_code
  1316. AND d.cases_id = e.cases_id
  1317. AND d.cases_entry_id = e.id
  1318. AND a.beh_dept_id = f.dept_id
  1319. <![CDATA[AND a.qc_type_id <>0 ]]>
  1320. <if test="hospitalId != null and hospitalId != ''">
  1321. AND a.hospital_id = #{hospitalId}
  1322. </if>
  1323. <if test="startDate != null and startDate != ''">
  1324. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1325. </if>
  1326. <if test="endDate != null and endDate != ''">
  1327. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1328. </if>
  1329. <if test="level != null and level != ''">
  1330. and c.level = #{level}
  1331. </if>
  1332. <if test="name != null and name != ''">
  1333. and a.doctor_name like CONCAT('%',#{name},'%')
  1334. </if>
  1335. <if test="userId!=null and userId !=''">
  1336. AND f.user_id = #{userId}
  1337. </if>
  1338. <if test="deptName!=null and deptName !=''">
  1339. AND a.beh_dept_name = #{deptName}
  1340. </if>
  1341. GROUP BY
  1342. a.doctor_id,
  1343. a.doctor_name
  1344. ) t2
  1345. WHERE
  1346. t1.doctorId = t2.doctorId
  1347. AND t1.doctorName = t2.doctorName
  1348. <if test="asc != null and asc !=''">
  1349. order by
  1350. <choose>
  1351. <when test='asc=="doctorId"'>doctorId asc</when>
  1352. <when test='asc=="doctorName"'>doctorName asc</when>
  1353. <when test='asc=="entryNum"'>entryNum asc</when>
  1354. <when test='asc=="mrNum"'>mrNum asc</when>
  1355. <when test='asc=="totleValue"'>totleValue asc</when>
  1356. <when test='asc=="averageValue"'>averageValue asc</when>
  1357. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1358. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1359. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1360. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1361. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1362. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1363. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1364. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1365. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1366. <otherwise> doctorName asc </otherwise>
  1367. </choose>
  1368. </if>
  1369. <if test="desc != null and desc!=''">
  1370. order by
  1371. <choose>
  1372. <when test='desc=="doctorId"'>doctorId desc</when>
  1373. <when test='desc=="doctorName"'>doctorName desc</when>
  1374. <when test='desc=="entryNum"'>entryNum desc</when>
  1375. <when test='desc=="mrNum"'>mrNum desc</when>
  1376. <when test='desc=="totleValue"'>totleValue desc</when>
  1377. <when test='desc=="averageValue"'>averageValue desc</when>
  1378. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1379. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1380. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1381. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1382. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1383. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1384. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1385. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1386. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1387. <otherwise> doctorName desc </otherwise>
  1388. </choose>
  1389. </if>
  1390. </select>
  1391. <!-- 病案首页合格率占比-科室 -->
  1392. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
  1393. SELECT
  1394. t1.doctorId,
  1395. t1.doctorName,
  1396. t2.entryNum,
  1397. t1.mrNum,
  1398. t1.totleValue,
  1399. t1.averageValue,
  1400. t1.firstLevelNum,
  1401. t1.secondLevelNum,
  1402. t1.firstLevelPercent,
  1403. t1.secondLevelPercent,
  1404. t1.firstLevelPercentStr,
  1405. t1.secondLevelPercentStr
  1406. FROM
  1407. (
  1408. SELECT
  1409. a.doctor_id AS doctorId,
  1410. a.doctor_name AS doctorName,
  1411. count( DISTINCT c.id ) AS mrNum,
  1412. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1413. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1414. COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
  1415. COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
  1416. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
  1417. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
  1418. concat(
  1419. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1420. '%'
  1421. ) AS firstLevelPercentStr,
  1422. concat(
  1423. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
  1424. '%'
  1425. ) AS secondLevelPercentStr
  1426. FROM
  1427. med_behospital_info a,
  1428. med_home_page b,
  1429. med_qcresult_cases c,
  1430. sys_user_dept f
  1431. WHERE
  1432. a.is_deleted = 'N'
  1433. AND b.is_deleted = 'N'
  1434. AND c.is_deleted = 'N'
  1435. AND f.is_deleted = 'N'
  1436. AND a.hospital_id = b.hospital_id
  1437. AND a.hospital_id = c.hospital_id
  1438. AND a.behospital_code = b.behospital_code
  1439. AND a.behospital_code = c.behospital_code
  1440. AND a.beh_dept_id = f.dept_id
  1441. AND c.cases_id = 243
  1442. <![CDATA[AND a.qc_type_id <>0 ]]>
  1443. <if test="hospitalId != null and hospitalId != ''">
  1444. AND a.hospital_id = #{hospitalId}
  1445. </if>
  1446. <if test="startDate != null and startDate != ''">
  1447. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1448. </if>
  1449. <if test="endDate != null and endDate != ''">
  1450. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1451. </if>
  1452. <if test="level != null and level != ''">
  1453. and c.level = #{level}
  1454. </if>
  1455. <if test="name != null and name != ''">
  1456. and a.doctor_name like CONCAT('%',#{name},'%')
  1457. </if>
  1458. <if test="userId!=null and userId !=''">
  1459. AND f.user_id = #{userId}
  1460. </if>
  1461. <if test="deptName!=null and deptName !=''">
  1462. AND a.beh_dept_name = #{deptName}
  1463. </if>
  1464. GROUP BY
  1465. a.doctor_id,
  1466. a.doctor_name
  1467. ) t1,
  1468. (
  1469. SELECT
  1470. a.doctor_id AS doctorId,
  1471. a.doctor_name AS doctorName,
  1472. count( * ) AS entryNum
  1473. FROM
  1474. med_behospital_info a,
  1475. med_home_page b,
  1476. med_qcresult_cases c,
  1477. med_qcresult_detail d,
  1478. qc_cases_entry e,
  1479. sys_user_dept f
  1480. WHERE
  1481. a.is_deleted = 'N'
  1482. AND b.is_deleted = 'N'
  1483. AND c.is_deleted = 'N'
  1484. AND d.is_deleted = 'N'
  1485. AND e.is_deleted = 'N'
  1486. AND f.is_deleted = 'N'
  1487. AND a.hospital_id = b.hospital_id
  1488. AND a.hospital_id = c.hospital_id
  1489. AND a.hospital_id = d.hospital_id
  1490. AND a.behospital_code = b.behospital_code
  1491. AND a.behospital_code = c.behospital_code
  1492. AND a.behospital_code = d.behospital_code
  1493. AND a.beh_dept_id = f.dept_id
  1494. AND c.cases_id = d.cases_id
  1495. AND d.cases_id = e.cases_id
  1496. AND d.cases_entry_id = e.id
  1497. AND c.cases_id = 243
  1498. <![CDATA[AND a.qc_type_id <>0 ]]>
  1499. <if test="hospitalId != null and hospitalId != ''">
  1500. AND a.hospital_id = #{hospitalId}
  1501. </if>
  1502. <if test="startDate != null and startDate != ''">
  1503. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  1504. </if>
  1505. <if test="endDate != null and endDate != ''">
  1506. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  1507. </if>
  1508. <if test="level != null and level != ''">
  1509. and c.level = #{level}
  1510. </if>
  1511. <if test="name != null and name != ''">
  1512. and a.doctor_name like CONCAT('%',#{name},'%')
  1513. </if>
  1514. <if test="userId!=null and userId !=''">
  1515. AND f.user_id = #{userId}
  1516. </if>
  1517. <if test="deptName!=null and deptName !=''">
  1518. AND a.beh_dept_name = #{deptName}
  1519. </if>
  1520. GROUP BY
  1521. a.doctor_id,
  1522. a.doctor_name
  1523. ) t2
  1524. WHERE
  1525. t1.doctorId = t2.doctorId
  1526. AND t1.doctorName = t2.doctorName
  1527. <if test="asc != null and asc !=''">
  1528. order by
  1529. <choose>
  1530. <when test='asc=="doctorId"'>doctorId asc</when>
  1531. <when test='asc=="doctorName"'>doctorName asc</when>
  1532. <when test='asc=="entryNum"'>entryNum asc</when>
  1533. <when test='asc=="mrNum"'>mrNum asc</when>
  1534. <when test='asc=="totleValue"'>totleValue asc</when>
  1535. <when test='asc=="averageValue"'>averageValue asc</when>
  1536. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1537. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1538. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1539. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1540. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1541. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1542. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1543. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1544. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1545. <otherwise> doctorName asc </otherwise>
  1546. </choose>
  1547. </if>
  1548. <if test="desc != null and desc!=''">
  1549. order by
  1550. <choose>
  1551. <when test='desc=="doctorId"'>doctorId desc</when>
  1552. <when test='desc=="doctorName"'>doctorName desc</when>
  1553. <when test='desc=="entryNum"'>entryNum desc</when>
  1554. <when test='desc=="mrNum"'>mrNum desc</when>
  1555. <when test='desc=="totleValue"'>totleValue desc</when>
  1556. <when test='desc=="averageValue"'>averageValue desc</when>
  1557. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1558. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1559. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1560. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1561. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1562. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1563. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1564. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1565. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1566. <otherwise> doctorName desc </otherwise>
  1567. </choose>
  1568. </if>
  1569. </select>
  1570. </mapper>