YbStatDao.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. package thyyxxk.webserver.dao.his.ybkf;
  2. import org.apache.ibatis.annotations.Mapper;
  3. import org.apache.ibatis.annotations.Param;
  4. import org.apache.ibatis.annotations.Select;
  5. import thyyxxk.webserver.entity.medicalinsurance.setlinfo.SiSetlinfo;
  6. import thyyxxk.webserver.entity.ybkf.TreeNodesResult;
  7. import thyyxxk.webserver.entity.ybkf.YbStatResult;
  8. import java.util.List;
  9. import java.util.Map;
  10. /**
  11. *@Author hsh
  12. *@Description 医保统计查询
  13. *@Date 2022/6/17 9:12
  14. *@Param
  15. *@Return
  16. **/
  17. @Mapper
  18. public interface YbStatDao {
  19. @Select("<script>" +
  20. "select psnCount=count(distinct a.setl_id), " +
  21. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  22. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(12,2)),2) as decimal(12,2)), " +
  23. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  24. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(12,2)), " +
  25. "acctPay=cast(round(sum(a.acct_pay),2) as decimal(12,2)), " +
  26. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(12,2)), " +
  27. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(12,2)), " +
  28. "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)-isnull(a.maf_pay,0)-isnull(a.hifob_pay,0)-isnull(a.hifes_pay,0)),2) as decimal(12,2)), " +
  29. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  30. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  31. "drugFeeRatio=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0))/sum(a.medfee_sumamt)*100,2) as decimal(12,2)), " +
  32. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)), " +
  33. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(12,2)) " +
  34. "from t_si_setlinfo a " +
  35. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  36. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  37. "<if test=\"insuplcAdmdvs != null and insuplcAdmdvs.size > 0 \">" +
  38. " and a.insuplc_admdvs in " +
  39. " <foreach collection='insuplcAdmdvs' item='item' index='index' open='(' close=')' separator=','> " +
  40. "#{item}" +
  41. "</foreach>" +
  42. "</if>" +
  43. "<if test=\"insurtype != null and insurtype.size > 0 \">" +
  44. " and a.insutype in " +
  45. " <foreach collection='insurtype' item='item' index='index' open='(' close=')' separator=','> " +
  46. "#{item}" +
  47. "</foreach>" +
  48. "</if>" +
  49. "<if test=\"med_type != null and med_type.size > 0 \">" +
  50. " and a.med_type in " +
  51. " <foreach collection='med_type' item='item' index='index' open='(' close=')' separator=','> " +
  52. "#{item}" +
  53. "</foreach>" +
  54. "</if>" +
  55. "</script>")
  56. YbStatResult selectYbStatInfo(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
  57. @Param("insuplcAdmdvs") List<String> insuplcAdmdvs, @Param("insurtype") List<String> insurtype,
  58. @Param("med_type") List<String> med_type);
  59. @Select("<script>" +
  60. "select psnCount=count(distinct a.setl_id), " +
  61. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  62. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(12,2)),2) as decimal(12,2)), " +
  63. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  64. "acctPay=cast(round(sum(a.acct_pay),2) as decimal(12,2)), " +
  65. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(12,2)), " +
  66. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(12,2)), " +
  67. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(12,2)), " +
  68. "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)-isnull(a.maf_pay,0)-isnull(a.hifob_pay,0)-isnull(a.hifes_pay,0)),2) as decimal(12,2)), " +
  69. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  70. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  71. "drugFeeRatio=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0))/sum(a.medfee_sumamt)*100,2) as decimal(12,2)), " +
  72. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)), " +
  73. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(12,2)) " +
  74. "from t_si_setlinfo a " +
  75. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  76. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  77. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type != '2102' " +
  78. "</script>")
  79. YbStatResult selectYbStatInfoInProvinceOtherCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  80. @Select("<script>" +
  81. "select psnCount=count(distinct a.setl_id), " +
  82. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  83. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(12,2)),2) as decimal(12,2)), " +
  84. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  85. "acctPay=cast(round(sum(a.acct_pay),2) as decimal(12,2)), " +
  86. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(12,2)), " +
  87. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(12,2)), " +
  88. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(12,2)), " +
  89. "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)-isnull(a.maf_pay,0)-isnull(a.hifob_pay,0)-isnull(a.hifes_pay,0)),2) as decimal(12,2)), " +
  90. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  91. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  92. "drugFeeRatio=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0))/sum(a.medfee_sumamt)*100,2) as decimal(12,2)), " +
  93. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)), " +
  94. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(12,2)) " +
  95. "from t_si_setlinfo a " +
  96. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  97. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  98. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs not like '43%' " +
  99. "</script>")
  100. YbStatResult selectYbStatInfoInOutProvinceCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  101. @Select("<script>" +
  102. "select psnCount=count(distinct a.setl_id), " +
  103. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  104. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(12,2)),2) as decimal(12,2)), " +
  105. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  106. "acctPay=cast(round(sum(a.acct_pay),2) as decimal(12,2)), " +
  107. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(12,2)), " +
  108. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(12,2)), " +
  109. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(12,2)), " +
  110. "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)-isnull(a.maf_pay,0)-isnull(a.hifob_pay,0)-isnull(a.hifes_pay,0)),2) as decimal(12,2)), " +
  111. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  112. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  113. "drugFeeRatio=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0))/sum(a.medfee_sumamt)*100,2) as decimal(12,2)), " +
  114. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)), " +
  115. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(12,2)) " +
  116. "from t_si_setlinfo a " +
  117. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  118. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  119. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type = '2102' " +
  120. "</script>")
  121. YbStatResult selectYbStatInfoInProvinceOtherCitiesSingleDisease(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  122. @Select("<script>" +
  123. "select yf=convert(varchar(7), a.setl_time, 120), " +
  124. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  125. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  126. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  127. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)) " +
  128. "from t_si_setlinfo a " +
  129. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  130. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  131. "group by convert(varchar(7), a.setl_time, 120) " +
  132. "</script>")
  133. List<YbStatResult> selectYbStatRatio(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  134. @Select("<script>" +
  135. "select totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  136. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  137. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  138. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(12,2)) " +
  139. "from t_si_setlinfo a " +
  140. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  141. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  142. "</script>")
  143. YbStatResult selectYbStatRatioTotal(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  144. @Select("<script>" +
  145. "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType," +
  146. "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
  147. "from t_si_setlinfo a " +
  148. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  149. "left join zd_unit_code z on zy.small_dept = z.code " +
  150. "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
  151. "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
  152. "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
  153. "left join batj_ba4_modify ss2 on (ss2.zyh = a.pat_no and ss2.zycs = a.times and ss2.ssxh = '1') " +
  154. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  155. "<if test=\"insuplcAdmdvs != null and insuplcAdmdvs.size > 0 \">" +
  156. " and a.insuplc_admdvs in " +
  157. " <foreach collection='insuplcAdmdvs' item='item' index='index' open='(' close=')' separator=','> " +
  158. "#{item}" +
  159. "</foreach>" +
  160. "</if>" +
  161. "<if test=\"insurtype != null and insurtype.size > 0 \">" +
  162. " and a.insutype in " +
  163. " <foreach collection='insurtype' item='item' index='index' open='(' close=')' separator=','> " +
  164. "#{item}" +
  165. "</foreach>" +
  166. "</if>" +
  167. "<if test=\"med_type != null and med_type.size > 0 \">" +
  168. " and a.med_type in " +
  169. " <foreach collection='med_type' item='item' index='index' open='(' close=')' separator=','> " +
  170. "#{item}" +
  171. "</foreach>" +
  172. "</if>" +
  173. "</script>")
  174. List<SiSetlinfo> selectSiSetlInfoList(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
  175. @Param("insuplcAdmdvs") List<String> insuplcAdmdvs, @Param("insurtype") List<String> insurtype,
  176. @Param("med_type") List<String> med_type);
  177. @Select("<script>" +
  178. "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
  179. "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
  180. "from t_si_setlinfo a " +
  181. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  182. "left join zd_unit_code z on zy.small_dept = z.code " +
  183. "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
  184. "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
  185. "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
  186. "left join batj_ba4_modify ss2 on (ss2.zyh = a.pat_no and ss2.zycs = a.times and ss2.ssxh = '1') " +
  187. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  188. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type != '2102' " +
  189. "</script>")
  190. List<SiSetlinfo> selectSiSetlInfoListInProvinceOtherCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  191. @Select("<script>" +
  192. "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
  193. "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
  194. "from t_si_setlinfo a " +
  195. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  196. "left join zd_unit_code z on zy.small_dept = z.code " +
  197. "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
  198. "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
  199. "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
  200. "left join batj_ba4_modify ss2 on (ss2.zyh = a.pat_no and ss2.zycs = a.times and ss2.ssxh = '1') " +
  201. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  202. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs not like '43%' " +
  203. "</script>")
  204. List<SiSetlinfo> selectSiSetlInfoListInOutProvinceCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  205. @Select("<script>" +
  206. "select a.*, rtrim(zy.small_dept) as deptId, rtrim(z.name) as psnCertType, " +
  207. "rtrim(isnull(zd2.dis_diag_comment, zd1.dis_diag_comment)) as mainDiagnosis, rtrim(isnull(ss2.ssmc, ss1.ssmc)) as mainOperation " +
  208. "from t_si_setlinfo a " +
  209. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  210. "left join zd_unit_code z on zy.small_dept = z.code " +
  211. "left join zy_dis_diag_yb zd1 on (zd1.inpatient_no = a.pat_no and zd1.admiss_times = a.times and zd1.dis_diag_no = '1') " +
  212. "left join zy_dis_diag_yb_modify zd2 on (zd2.inpatient_no = a.pat_no and zd2.admiss_times = a.times and zd2.dis_diag_no = '1') " +
  213. "left join batj_ba4 ss1 on (ss1.zyh = a.pat_no and ss1.zycs = a.times and ss1.ssxh = '1') " +
  214. "left join batj_ba4_modify ss2 on (ss2.zyh = a.pat_no and ss2.zycs = a.times and ss2.ssxh = '1') " +
  215. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  216. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type = '2102' " +
  217. "</script>")
  218. List<SiSetlinfo> selectSiSetlInfoListInProvinceOtherCitiesSingleDisease(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  219. @Select("<script>" +
  220. "select yf=convert(varchar(7), a.setl_time, 120), a.medins_type, " +
  221. "psnCount=count(distinct a.setl_id), " +
  222. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  223. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(12,2)), " +
  224. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(12,2)), " +
  225. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(12,2)), " +
  226. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(12,2)), " +
  227. "otherFunds=cast(round(sum(isnull(a.fund_pay_sumamt,0)-isnull(a.hifp_pay,0)-isnull(a.cvlserv_pay,0)-isnull(a.hifmi_pay,0)-isnull(a.maf_pay,0)-isnull(a.hifob_pay,0)-isnull(a.hifes_pay,0)),2) as decimal(12,2)), " +
  228. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(12,2)), " +
  229. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(12,2)), " +
  230. "matFee=cast(round(isnull(sum(a.charge_sanitary_material),0),2) as decimal(12,2)) " +
  231. "from t_si_setlinfo a " +
  232. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  233. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  234. "group by convert(varchar(7), a.setl_time, 120), a.medins_type order by convert(varchar(7), a.setl_time, 120) " +
  235. "</script>")
  236. List<Map<String, Object>> selectBarChangeData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  237. @Select("select count(a.setl_id) value, 0 id, '医保病人数' name " +
  238. "from t_si_setlinfo a " +
  239. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time>=#{beginTime} and a.setl_time<=#{endTime} ")
  240. TreeNodesResult getTreeRootResult(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  241. @Select("<script> " +
  242. "select count(t.setl_id) value, 0 pid, rtrim(t.id) as id, rtrim(isnull(d.name, '其他')) name from " +
  243. "(select a.setl_id, isnull(zy.small_dept, zya.small_dept) id " +
  244. "from t_si_setlinfo a " +
  245. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  246. "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
  247. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  248. " ) t " +
  249. "left join zd_unit_code d on d.code = t.id " +
  250. "group by t.id, d.name " +
  251. "order by count(t.setl_id) desc " +
  252. "</script>")
  253. List<TreeNodesResult> selectTreeSecondData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
  254. @Select("<script> " +
  255. "select count(t.setl_id) as value, rtrim(t.pid) as pid, rtrim(t.id) as id, rtrim(isnull(e.name, '其他')) as name from " +
  256. "(select a.setl_id, isnull(zy.small_dept, zya.small_dept) pid, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) id " +
  257. "from t_si_setlinfo a " +
  258. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  259. "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
  260. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  261. " ) t " +
  262. "left join a_employee_mi e on e.code = t.id " +
  263. "group by t.pid, t.id, e.name " +
  264. "order by count(t.setl_id) desc " +
  265. "</script>")
  266. List<TreeNodesResult> selectTreeThirdData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
  267. @Select("<script> " +
  268. "select count(t.setl_id) as value, rtrim(t.uid) as uid, rtrim(t.pid) as pid, rtrim(isnull(t.medins_type, '其他')) as name from " +
  269. "(select a.setl_id, a.medins_type, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) pid, " +
  270. "isnull(isnull(zy.small_dept, zya.small_dept), 999) uid " +
  271. "from t_si_setlinfo a " +
  272. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  273. "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
  274. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  275. " ) t " +
  276. "group by t.uid, t.pid, t.medins_type " +
  277. "order by count(t.setl_id) desc " +
  278. "</script>")
  279. List<TreeNodesResult> selectTreeFourthData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType, @Param("insurType") String insurType);
  280. @Select("<script> " +
  281. "select count(t.setl_id) as rs, rtrim(isnull(t.medins_type, '其他')) as insurName, rtrim(isnull(e.name, '其他')) as doctorName, rtrim(isnull(d.name, '其他')) as deptName from " +
  282. "(select a.setl_id, a.medins_type, isnull(zy.small_dept, zya.small_dept) pid, isnull(isnull(zy.refer_physician, zya.refer_physician), 9999) id " +
  283. "from t_si_setlinfo a " +
  284. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  285. "left join zy_actpatient zya on (zya.inpatient_no = a.pat_no and zya.admiss_times = a.times) " +
  286. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  287. "<if test=\"insurType != null and insurType != '' \"> " +
  288. " and a.medins_type=#{insurType} " +
  289. "</if> " +
  290. ") t " +
  291. "left join zd_unit_code d on d.code = t.pid " +
  292. "left join a_employee_mi e on e.code = t.id " +
  293. "where 1=1 " +
  294. "<if test=\"dept != null and dept != '' \"> " +
  295. " and rtrim(d.name)=#{dept} " +
  296. "</if> " +
  297. "<if test=\"doctor != null and doctor != '' \"> " +
  298. " and rtrim(e.name)=#{doctor} " +
  299. "</if> " +
  300. "group by t.pid, t.id, t.medins_type, d.name, e.name " +
  301. "order by d.name, e.name, count(t.setl_id) desc " +
  302. "</script>")
  303. List<Map<String, Object>> selectTreeAllData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
  304. @Param("dept") String dept, @Param("doctor") String doctor, @Param("insurType") String insurType);
  305. }