HomePageMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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.HomePageMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.diagbot.entity.HomePage">
  6. <id column="home_page_id" property="homePageId" />
  7. <result column="hospital_id" property="hospitalId" />
  8. <result column="behospital_code" property="behospitalCode" />
  9. <result column="hospital_code" property="hospitalCode" />
  10. <result column="hospital_name" property="hospitalName" />
  11. <result column="org_code" property="orgCode" />
  12. <result column="pay_type" property="payType" />
  13. <result column="health_card" property="healthCard" />
  14. <result column="behospital_num" property="behospitalNum" />
  15. <result column="file_code" property="fileCode" />
  16. <result column="name" property="name" />
  17. <result column="sex" property="sex" />
  18. <result column="birthday" property="birthday" />
  19. <result column="age" property="age" />
  20. <result column="age_unit" property="ageUnit" />
  21. <result column="nationality" property="nationality" />
  22. <result column="newborn_month" property="newbornMonth" />
  23. <result column="newborn_day" property="newbornDay" />
  24. <result column="newborn_weight" property="newbornWeight" />
  25. <result column="newborn_behospital_weight" property="newbornBehospitalWeight" />
  26. <result column="born_address" property="bornAddress" />
  27. <result column="born_place" property="bornPlace" />
  28. <result column="nation" property="nation" />
  29. <result column="identity_card_no" property="identityCardNo" />
  30. <result column="job_type" property="jobType" />
  31. <result column="marriage" property="marriage" />
  32. <result column="cur_address" property="curAddress" />
  33. <result column="cur_phone" property="curPhone" />
  34. <result column="cur_post_code" property="curPostCode" />
  35. <result column="residence_address" property="residenceAddress" />
  36. <result column="residence_post_code" property="residencePostCode" />
  37. <result column="work_address" property="workAddress" />
  38. <result column="work_phone" property="workPhone" />
  39. <result column="work_post_code" property="workPostCode" />
  40. <result column="contact_name" property="contactName" />
  41. <result column="contact_relation" property="contactRelation" />
  42. <result column="contact_address" property="contactAddress" />
  43. <result column="contact_phone" property="contactPhone" />
  44. <result column="behospital_way" property="behospitalWay" />
  45. <result column="behospital_date" property="behospitalDate" />
  46. <result column="behospital_dept" property="behospitalDept" />
  47. <result column="behospital_ward" property="behospitalWard" />
  48. <result column="behospital_bed_id" property="behospitalBedId" />
  49. <result column="behospital_bed_code" property="behospitalBedCode" />
  50. <result column="change_dept" property="changeDept" />
  51. <result column="leave_hospital_date" property="leaveHospitalDate" />
  52. <result column="leave_hospital_dept" property="leaveHospitalDept" />
  53. <result column="leave_hospital_ward" property="leaveHospitalWard" />
  54. <result column="leave_hospital_bed_id" property="leaveHospitalBedId" />
  55. <result column="leave_hospital_bed_code" property="leaveHospitalBedCode" />
  56. <result column="behospital_day_num" property="behospitalDayNum" />
  57. <result column="outpatient_emr_diagnose" property="outpatientEmrDiagnose" />
  58. <result column="outpatient_emr_diagnose_code" property="outpatientEmrDiagnoseCode" />
  59. <result column="poison_factor" property="poisonFactor" />
  60. <result column="poison_factor_code" property="poisonFactorCode" />
  61. <result column="pathology_diagnose" property="pathologyDiagnose" />
  62. <result column="pathology_diagnose_code" property="pathologyDiagnoseCode" />
  63. <result column="pathology_diagnose_id" property="pathologyDiagnoseId" />
  64. <result column="is_med_allergy" property="isMedAllergy" />
  65. <result column="med_allergy_name" property="medAllergyName" />
  66. <result column="autopsy" property="autopsy" />
  67. <result column="blood_type" property="bloodType" />
  68. <result column="rh" property="rh" />
  69. <result column="dept_director" property="deptDirector" />
  70. <result column="director_doctor" property="directorDoctor" />
  71. <result column="attending_doctor" property="attendingDoctor" />
  72. <result column="behospital_doctor" property="behospitalDoctor" />
  73. <result column="response_nurse" property="responseNurse" />
  74. <result column="study_doctor" property="studyDoctor" />
  75. <result column="practice_doctor" property="practiceDoctor" />
  76. <result column="encode_man" property="encodeMan" />
  77. <result column="home_page_quality" property="homePageQuality" />
  78. <result column="qc_doctor" property="qcDoctor" />
  79. <result column="qc_nurse" property="qcNurse" />
  80. <result column="qc_date" property="qcDate" />
  81. <result column="leave_hospital_type" property="leaveHospitalType" />
  82. <result column="accept_org_code" property="acceptOrgCode" />
  83. <result column="again_behospital_plan" property="againBehospitalPlan" />
  84. <result column="again_behospital_goal" property="againBehospitalGoal" />
  85. <result column="tbi_before_day" property="tbiBeforeDay" />
  86. <result column="tbi_before_hour" property="tbiBeforeHour" />
  87. <result column="tbi_before_minute" property="tbiBeforeMinute" />
  88. <result column="tbi_after_day" property="tbiAfterDay" />
  89. <result column="tbi_after_hour" property="tbiAfterHour" />
  90. <result column="tbi_after_minute" property="tbiAfterMinute" />
  91. <result column="total_fee" property="totalFee" />
  92. <result column="own_fee" property="ownFee" />
  93. <result column="general_fee" property="generalFee" />
  94. <result column="service_fee" property="serviceFee" />
  95. <result column="nurse_fee" property="nurseFee" />
  96. <result column="other_fee" property="otherFee" />
  97. <result column="pathology_fee" property="pathologyFee" />
  98. <result column="lab_fee" property="labFee" />
  99. <result column="pacs_fee" property="pacsFee" />
  100. <result column="clinic_diagnose_fee" property="clinicDiagnoseFee" />
  101. <result column="not_operation_fee" property="notOperationFee" />
  102. <result column="clinic_physic_fee" property="clinicPhysicFee" />
  103. <result column="operation_treat_fee" property="operationTreatFee" />
  104. <result column="anaesthesia_fee" property="anaesthesiaFee" />
  105. <result column="operation_fee" property="operationFee" />
  106. <result column="health_type_fee" property="healthTypeFee" />
  107. <result column="chn_treat_fee" property="chnTreatFee" />
  108. <result column="western_med_fee" property="westernMedFee" />
  109. <result column="antibiosis_fee" property="antibiosisFee" />
  110. <result column="chn_med_fee" property="chnMedFee" />
  111. <result column="chn_herb_fee" property="chnHerbFee" />
  112. <result column="blood_fee" property="bloodFee" />
  113. <result column="albumen_fee" property="albumenFee" />
  114. <result column="globulin_fee" property="globulinFee" />
  115. <result column="blood_factor_fee" property="bloodFactorFee" />
  116. <result column="cell_factor_fee" property="cellFactorFee" />
  117. <result column="check_material_fee" property="checkMaterialFee" />
  118. <result column="treat_material_fee" property="treatMaterialFee" />
  119. <result column="operation_material_fee" property="operationMaterialFee" />
  120. <result column="other_type_fee" property="otherTypeFee" />
  121. <result column="single_diag_manage" property="singleDiagManage" />
  122. <result column="clinic_pathway_manage" property="clinicPathwayManage" />
  123. <result column="is_outpatient_behospital" property="isOutpatientBehospital" />
  124. <result column="is_leave_behospital" property="isLeaveBehospital" />
  125. <result column="is_operation_before_after" property="isOperationBeforeAfter" />
  126. <result column="is_clinic_pathology" property="isClinicPathology" />
  127. <result column="is_radiate_pathology" property="isRadiatePathology" />
  128. <result column="rescue_num" property="rescueNum" />
  129. <result column="rescue_success_num" property="rescueSuccessNum" />
  130. <result column="is_auto_leavehospital" property="isAutoLeavehospital" />
  131. <result column="return_to_type" property="returnToType" />
  132. <result column="is_deleted" property="isDeleted" />
  133. <result column="gmt_create" property="gmtCreate" />
  134. <result column="gmt_modified" property="gmtModified" />
  135. <result column="creator" property="creator" />
  136. <result column="modifier" property="modifier" />
  137. </resultMap>
  138. <!-- 按科室统计平均住院天数 -->
  139. <select id="getAverageDayNum" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
  140. SELECT
  141. a.beh_dept_id as id,
  142. a.beh_dept_name as name,
  143. count(*) AS num,
  144. round( sum( CAST(b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  145. round( sum( CAST(b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
  146. FROM
  147. med_behospital_info a,
  148. med_home_page b
  149. WHERE
  150. a.hospital_id = b.hospital_id
  151. AND a.behospital_code = b.behospital_code
  152. AND a.is_deleted = 'N'
  153. AND b.is_deleted = 'N'
  154. <![CDATA[AND a.qc_type_id <>0 ]]>
  155. <if test="hospitalId != null and hospitalId != ''">
  156. AND a.hospital_id = #{hospitalId}
  157. </if>
  158. <if test="startDate != null and startDate != ''">
  159. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  160. </if>
  161. <if test="endDate != null and endDate != ''">
  162. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  163. </if>
  164. GROUP BY
  165. a.beh_dept_id,
  166. a.beh_dept_name
  167. </select>
  168. <!-- 按科室统计平均费用 -->
  169. <select id="getAverageFee" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AverageStatisticsDTO">
  170. SELECT
  171. a.beh_dept_id as id,
  172. a.beh_dept_name as name,
  173. count(*) AS num,
  174. round( sum( CAST(b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  175. round( sum( CAST(b.total_fee AS DECIMAL )), 2 ) AS totleValue
  176. FROM
  177. med_behospital_info a,
  178. med_home_page b
  179. WHERE
  180. a.hospital_id = b.hospital_id
  181. AND a.behospital_code = b.behospital_code
  182. AND a.is_deleted = 'N'
  183. AND b.is_deleted = 'N'
  184. <![CDATA[AND a.qc_type_id <>0 ]]>
  185. <if test="hospitalId != null and hospitalId != ''">
  186. AND a.hospital_id = #{hospitalId}
  187. </if>
  188. <if test="startDate != null and startDate != ''">
  189. <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
  190. </if>
  191. <if test="endDate != null and endDate != ''">
  192. <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
  193. </if>
  194. GROUP BY
  195. a.beh_dept_id,
  196. a.beh_dept_name
  197. </select>
  198. <!-- 按科室统计平均住院天数 (分页)-->
  199. <select id="getAverageDayNumPage" resultType="com.diagbot.dto.AverageStatisticsDTO">
  200. SELECT
  201. id,
  202. NAME,
  203. averageValue,
  204. lastAverageValue,
  205. lastYearAverageValue
  206. FROM
  207. (
  208. SELECT
  209. dept.id,
  210. dept.NAME,
  211. t1.averageValue,
  212. t2.lastAverageValue,
  213. t3.lastYearAverageValue
  214. FROM
  215. (
  216. SELECT DISTINCT
  217. id,
  218. NAME
  219. FROM
  220. (
  221. (
  222. SELECT DISTINCT
  223. a.beh_dept_id AS id,
  224. a.beh_dept_name AS NAME
  225. FROM
  226. med_behospital_info a,
  227. med_home_page b
  228. WHERE
  229. a.hospital_id = b.hospital_id
  230. AND a.behospital_code = b.behospital_code
  231. AND a.is_deleted = 'N'
  232. AND b.is_deleted = 'N'
  233. <![CDATA[AND a.qc_type_id <>0 ]]>
  234. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  235. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  236. </if>
  237. <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
  238. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
  239. </if>
  240. <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
  241. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
  242. </if>
  243. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  244. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  245. </if>
  246. ) UNION
  247. (
  248. SELECT DISTINCT
  249. a.beh_dept_id AS id,
  250. a.beh_dept_name AS NAME
  251. FROM
  252. med_behospital_info a,
  253. med_home_page b
  254. WHERE
  255. a.hospital_id = b.hospital_id
  256. AND a.behospital_code = b.behospital_code
  257. AND a.is_deleted = 'N'
  258. AND b.is_deleted = 'N'
  259. <![CDATA[AND a.qc_type_id <>0 ]]>
  260. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  261. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  262. </if>
  263. <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
  264. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
  265. </if>
  266. <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
  267. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
  268. </if>
  269. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  270. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  271. </if>
  272. ) UNION
  273. (
  274. SELECT DISTINCT
  275. a.beh_dept_id AS id,
  276. a.beh_dept_name AS NAME
  277. FROM
  278. med_behospital_info a,
  279. med_home_page b
  280. WHERE
  281. a.hospital_id = b.hospital_id
  282. AND a.behospital_code = b.behospital_code
  283. AND a.is_deleted = 'N'
  284. AND b.is_deleted = 'N'
  285. <![CDATA[AND a.qc_type_id <>0 ]]>
  286. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  287. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  288. </if>
  289. <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
  290. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
  291. </if>
  292. <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
  293. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
  294. </if>
  295. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  296. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  297. </if>
  298. ))dept1
  299. ) dept
  300. LEFT JOIN (
  301. SELECT
  302. a.beh_dept_id AS id,
  303. a.beh_dept_name AS NAME,
  304. count(*) AS num,
  305. round( sum( CAST( b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  306. round( sum( CAST( b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
  307. FROM
  308. med_behospital_info a,
  309. med_home_page b
  310. WHERE
  311. a.hospital_id = b.hospital_id
  312. AND a.behospital_code = b.behospital_code
  313. AND a.is_deleted = 'N'
  314. AND b.is_deleted = 'N'
  315. <![CDATA[AND a.qc_type_id <>0 ]]>
  316. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  317. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  318. </if>
  319. <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
  320. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
  321. </if>
  322. <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
  323. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
  324. </if>
  325. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  326. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  327. </if>
  328. GROUP BY
  329. a.beh_dept_id,
  330. a.beh_dept_name
  331. ) t1 ON dept.id = t1.id
  332. AND dept.NAME = t1.
  333. NAME LEFT JOIN (
  334. SELECT
  335. a.beh_dept_id AS id,
  336. a.beh_dept_name AS NAME,
  337. count(*) AS num,
  338. round( sum( CAST( b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS lastAverageValue,
  339. round( sum( CAST( b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
  340. FROM
  341. med_behospital_info a,
  342. med_home_page b
  343. WHERE
  344. a.hospital_id = b.hospital_id
  345. AND a.behospital_code = b.behospital_code
  346. AND a.is_deleted = 'N'
  347. AND b.is_deleted = 'N'
  348. <![CDATA[AND a.qc_type_id <>0 ]]>
  349. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  350. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  351. </if>
  352. <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
  353. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
  354. </if>
  355. <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
  356. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
  357. </if>
  358. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  359. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  360. </if>
  361. GROUP BY
  362. a.beh_dept_id,
  363. a.beh_dept_name
  364. ) t2 ON dept.id = t2.id
  365. AND dept.NAME = t2.
  366. NAME LEFT JOIN (
  367. SELECT
  368. a.beh_dept_id AS id,
  369. a.beh_dept_name AS NAME,
  370. count(*) AS num,
  371. round( sum( CAST( b.behospital_day_num AS DECIMAL ))/ count(*), 2 ) AS lastYearAverageValue,
  372. round( sum( CAST( b.behospital_day_num AS DECIMAL )), 2 ) AS totleValue
  373. FROM
  374. med_behospital_info a,
  375. med_home_page b
  376. WHERE
  377. a.hospital_id = b.hospital_id
  378. AND a.behospital_code = b.behospital_code
  379. AND a.is_deleted = 'N'
  380. AND b.is_deleted = 'N'
  381. <![CDATA[AND a.qc_type_id <>0 ]]>
  382. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  383. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  384. </if>
  385. <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
  386. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
  387. </if>
  388. <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
  389. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
  390. </if>
  391. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  392. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  393. </if>
  394. GROUP BY
  395. a.beh_dept_id,
  396. a.beh_dept_name
  397. ) t3 ON dept.id = t3.id
  398. AND dept.NAME = t3.NAME
  399. ORDER BY
  400. t1.averageValue DESC,
  401. t2.lastAverageValue DESC,
  402. t3.lastYearAverageValue DESC
  403. )t
  404. </select>
  405. <!-- 按科室统计平均费用(分页) -->
  406. <select id="getAverageFeePage" resultType="com.diagbot.dto.AverageStatisticsDTO">
  407. SELECT
  408. id,
  409. NAME,
  410. averageValue,
  411. lastAverageValue,
  412. lastYearAverageValue
  413. FROM
  414. (
  415. SELECT
  416. dept.id,
  417. dept.NAME,
  418. t1.averageValue,
  419. t2.lastAverageValue,
  420. t3.lastYearAverageValue
  421. FROM
  422. (
  423. SELECT DISTINCT
  424. id,
  425. NAME
  426. FROM
  427. (
  428. (
  429. SELECT DISTINCT
  430. a.beh_dept_id AS id,
  431. a.beh_dept_name AS NAME
  432. FROM
  433. med_behospital_info a,
  434. med_home_page b
  435. WHERE
  436. a.hospital_id = b.hospital_id
  437. AND a.behospital_code = b.behospital_code
  438. AND a.is_deleted = 'N'
  439. AND b.is_deleted = 'N'
  440. <![CDATA[AND a.qc_type_id <>0 ]]>
  441. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  442. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  443. </if>
  444. <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
  445. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
  446. </if>
  447. <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
  448. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
  449. </if>
  450. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  451. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  452. </if>
  453. ) UNION
  454. (
  455. SELECT DISTINCT
  456. a.beh_dept_id AS id,
  457. a.beh_dept_name AS NAME
  458. FROM
  459. med_behospital_info a,
  460. med_home_page b
  461. WHERE
  462. a.hospital_id = b.hospital_id
  463. AND a.behospital_code = b.behospital_code
  464. AND a.is_deleted = 'N'
  465. AND b.is_deleted = 'N'
  466. <![CDATA[AND a.qc_type_id <>0 ]]>
  467. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  468. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  469. </if>
  470. <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
  471. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
  472. </if>
  473. <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
  474. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
  475. </if>
  476. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  477. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  478. </if>
  479. ) UNION
  480. (
  481. SELECT DISTINCT
  482. a.beh_dept_id AS id,
  483. a.beh_dept_name AS NAME
  484. FROM
  485. med_behospital_info a,
  486. med_home_page b
  487. WHERE
  488. a.hospital_id = b.hospital_id
  489. AND a.behospital_code = b.behospital_code
  490. AND a.is_deleted = 'N'
  491. AND b.is_deleted = 'N'
  492. <![CDATA[AND a.qc_type_id <>0 ]]>
  493. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  494. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  495. </if>
  496. <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
  497. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
  498. </if>
  499. <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
  500. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
  501. </if>
  502. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  503. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  504. </if>
  505. ))dept1
  506. ) dept
  507. LEFT JOIN (
  508. SELECT
  509. a.beh_dept_id AS id,
  510. a.beh_dept_name AS NAME,
  511. count(*) AS num,
  512. round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS averageValue,
  513. round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
  514. FROM
  515. med_behospital_info a,
  516. med_home_page b
  517. WHERE
  518. a.hospital_id = b.hospital_id
  519. AND a.behospital_code = b.behospital_code
  520. AND a.is_deleted = 'N'
  521. AND b.is_deleted = 'N'
  522. <![CDATA[AND a.qc_type_id <>0 ]]>
  523. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  524. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  525. </if>
  526. <if test="filterPageByAverageVO.startDate != null and filterPageByAverageVO.startDate != ''">
  527. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.startDate})]]>
  528. </if>
  529. <if test="filterPageByAverageVO.endDate != null and filterPageByAverageVO.endDate != ''">
  530. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.endDate})]]>
  531. </if>
  532. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  533. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  534. </if>
  535. GROUP BY
  536. a.beh_dept_id,
  537. a.beh_dept_name
  538. ) t1 ON dept.id = t1.id
  539. AND dept.NAME = t1.
  540. NAME LEFT JOIN (
  541. SELECT
  542. a.beh_dept_id AS id,
  543. a.beh_dept_name AS NAME,
  544. count(*) AS num,
  545. round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastAverageValue,
  546. round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
  547. FROM
  548. med_behospital_info a,
  549. med_home_page b
  550. WHERE
  551. a.hospital_id = b.hospital_id
  552. AND a.behospital_code = b.behospital_code
  553. AND a.is_deleted = 'N'
  554. AND b.is_deleted = 'N'
  555. <![CDATA[AND a.qc_type_id <>0 ]]>
  556. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  557. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  558. </if>
  559. <if test="filterPageByAverageVO.lastStartDate != null and filterPageByAverageVO.lastStartDate != ''">
  560. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastStartDate})]]>
  561. </if>
  562. <if test="filterPageByAverageVO.lastEndDate != null and filterPageByAverageVO.lastEndDate != ''">
  563. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastEndDate})]]>
  564. </if>
  565. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  566. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  567. </if>
  568. GROUP BY
  569. a.beh_dept_id,
  570. a.beh_dept_name
  571. ) t2 ON dept.id = t2.id
  572. AND dept.NAME = t2.
  573. NAME LEFT JOIN (
  574. SELECT
  575. a.beh_dept_id AS id,
  576. a.beh_dept_name AS NAME,
  577. count(*) AS num,
  578. round( sum( CAST( b.total_fee AS DECIMAL ))/ count(*), 2 ) AS lastYearAverageValue,
  579. round( sum( CAST( b.total_fee AS DECIMAL )), 2 ) AS totleValue
  580. FROM
  581. med_behospital_info a,
  582. med_home_page b
  583. WHERE
  584. a.hospital_id = b.hospital_id
  585. AND a.behospital_code = b.behospital_code
  586. AND a.is_deleted = 'N'
  587. AND b.is_deleted = 'N'
  588. <![CDATA[AND a.qc_type_id <>0 ]]>
  589. <if test="filterPageByAverageVO.hospitalId != null and filterPageByAverageVO.hospitalId != ''">
  590. AND a.hospital_id = #{filterPageByAverageVO.hospitalId}
  591. </if>
  592. <if test="filterPageByAverageVO.lastYearStartDate != null and filterPageByAverageVO.lastYearStartDate != ''">
  593. <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByAverageVO.lastYearStartDate})]]>
  594. </if>
  595. <if test="filterPageByAverageVO.lastYearEndDate != null and filterPageByAverageVO.lastYearEndDate != ''">
  596. <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByAverageVO.lastYearEndDate})]]>
  597. </if>
  598. <if test="filterPageByAverageVO.name != null and filterPageByAverageVO.name != ''">
  599. AND a.beh_dept_name like CONCAT('%', #{filterPageByAverageVO.name},'%')
  600. </if>
  601. GROUP BY
  602. a.beh_dept_id,
  603. a.beh_dept_name
  604. ) t3 ON dept.id = t3.id
  605. AND dept.NAME = t3.NAME
  606. ORDER BY
  607. t1.averageValue DESC,
  608. t2.lastAverageValue DESC,
  609. t3.lastYearAverageValue DESC
  610. )t
  611. </select>
  612. </mapper>