YbStatDao.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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.YbStatResult;
  7. import java.util.List;
  8. import java.util.Map;
  9. /**
  10. *@Author hsh
  11. *@Description 医保统计查询
  12. *@Date 2022/6/17 9:12
  13. *@Param
  14. *@Return
  15. **/
  16. @Mapper
  17. public interface YbStatDao {
  18. @Select("<script>" +
  19. "select psnCount=count(distinct a.setl_id), " +
  20. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  21. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
  22. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  23. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
  24. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
  25. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
  26. "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)),2) as decimal(10,2)), " +
  27. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  28. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  29. "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(10,2)), " +
  30. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)), " +
  31. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(10,2)) " +
  32. "from t_si_setlinfo a " +
  33. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  34. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  35. "<if test=\"insuplcAdmdvs != null and insuplcAdmdvs.size > 0 \">" +
  36. " and a.insuplc_admdvs in " +
  37. " <foreach collection='insuplcAdmdvs' item='item' index='index' open='(' close=')' separator=','> " +
  38. "#{item}" +
  39. "</foreach>" +
  40. "</if>" +
  41. "<if test=\"insurtype != null and insurtype.size > 0 \">" +
  42. " and a.insutype in " +
  43. " <foreach collection='insurtype' item='item' index='index' open='(' close=')' separator=','> " +
  44. "#{item}" +
  45. "</foreach>" +
  46. "</if>" +
  47. "<if test=\"med_type != null and med_type.size > 0 \">" +
  48. " and a.med_type in " +
  49. " <foreach collection='med_type' item='item' index='index' open='(' close=')' separator=','> " +
  50. "#{item}" +
  51. "</foreach>" +
  52. "</if>" +
  53. "</script>")
  54. YbStatResult selectYbStatInfo(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
  55. @Param("insuplcAdmdvs") List<String> insuplcAdmdvs, @Param("insurtype") List<String> insurtype,
  56. @Param("med_type") List<String> med_type);
  57. @Select("<script>" +
  58. "select psnCount=count(distinct a.setl_id), " +
  59. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  60. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
  61. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  62. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
  63. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
  64. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
  65. "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)),2) as decimal(10,2)), " +
  66. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  67. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  68. "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(10,2)), " +
  69. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)), " +
  70. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(10,2)) " +
  71. "from t_si_setlinfo a " +
  72. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  73. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  74. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type != '2102' " +
  75. "</script>")
  76. YbStatResult selectYbStatInfoInProvinceOtherCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  77. @Select("<script>" +
  78. "select psnCount=count(distinct a.setl_id), " +
  79. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  80. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
  81. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  82. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
  83. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
  84. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
  85. "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)),2) as decimal(10,2)), " +
  86. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  87. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  88. "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(10,2)), " +
  89. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)), " +
  90. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(10,2)) " +
  91. "from t_si_setlinfo a " +
  92. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  93. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  94. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs not like '43%' " +
  95. "</script>")
  96. YbStatResult selectYbStatInfoInOutProvinceCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  97. @Select("<script>" +
  98. "select psnCount=count(distinct a.setl_id), " +
  99. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  100. "avgInDays=cast(round(sum(datediff(day, zy.admiss_date, zy.dis_date))/cast(count(distinct a.setl_id) as decimal(10,2)),2) as decimal(10,2)), " +
  101. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  102. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
  103. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
  104. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
  105. "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)),2) as decimal(10,2)), " +
  106. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  107. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  108. "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(10,2)), " +
  109. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)), " +
  110. "matFeeRatio=cast(round(sum(a.charge_sanitary_material)/sum(a.medfee_sumamt)*100,2) as decimal(10,2)) " +
  111. "from t_si_setlinfo a " +
  112. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  113. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  114. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type = '2102' " +
  115. "</script>")
  116. YbStatResult selectYbStatInfoInProvinceOtherCitiesSingleDisease(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  117. @Select("<script>" +
  118. "select yf=convert(varchar(7), a.setl_time, 120), " +
  119. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  120. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  121. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  122. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)) " +
  123. "from t_si_setlinfo a " +
  124. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  125. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  126. "group by convert(varchar(7), a.setl_time, 120) " +
  127. "</script>")
  128. List<YbStatResult> selectYbStatRatio(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  129. @Select("<script>" +
  130. "select totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  131. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  132. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  133. "matFee=cast(round(sum(a.charge_sanitary_material),2) as decimal(10,2)) " +
  134. "from t_si_setlinfo a " +
  135. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  136. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  137. "</script>")
  138. YbStatResult selectYbStatRatioTotal(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  139. @Select("<script>" +
  140. "select a.* " +
  141. "from t_si_setlinfo a " +
  142. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  143. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  144. "<if test=\"insuplcAdmdvs != null and insuplcAdmdvs.size > 0 \">" +
  145. " and a.insuplc_admdvs in " +
  146. " <foreach collection='insuplcAdmdvs' item='item' index='index' open='(' close=')' separator=','> " +
  147. "#{item}" +
  148. "</foreach>" +
  149. "</if>" +
  150. "<if test=\"insurtype != null and insurtype.size > 0 \">" +
  151. " and a.insutype in " +
  152. " <foreach collection='insurtype' item='item' index='index' open='(' close=')' separator=','> " +
  153. "#{item}" +
  154. "</foreach>" +
  155. "</if>" +
  156. "<if test=\"med_type != null and med_type.size > 0 \">" +
  157. " and a.med_type in " +
  158. " <foreach collection='med_type' item='item' index='index' open='(' close=')' separator=','> " +
  159. "#{item}" +
  160. "</foreach>" +
  161. "</if>" +
  162. "</script>")
  163. List<SiSetlinfo> selectSiSetlInfoList(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType,
  164. @Param("insuplcAdmdvs") List<String> insuplcAdmdvs, @Param("insurtype") List<String> insurtype,
  165. @Param("med_type") List<String> med_type);
  166. @Select("<script>" +
  167. "select a.* " +
  168. "from t_si_setlinfo a " +
  169. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  170. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  171. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type != '2102' " +
  172. "</script>")
  173. List<SiSetlinfo> selectSiSetlInfoListInProvinceOtherCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  174. @Select("<script>" +
  175. "select a.* " +
  176. "from t_si_setlinfo a " +
  177. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  178. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  179. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs not like '43%' " +
  180. "</script>")
  181. List<SiSetlinfo> selectSiSetlInfoListInOutProvinceCities(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  182. @Select("<script>" +
  183. "select a.* " +
  184. "from t_si_setlinfo a " +
  185. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  186. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  187. "and a.insuplc_admdvs != '439900' and a.insuplc_admdvs like '43%' and a.insuplc_admdvs not like '4301%' and a.med_type = '2102' " +
  188. "</script>")
  189. List<SiSetlinfo> selectSiSetlInfoListInProvinceOtherCitiesSingleDisease(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  190. @Select("<script>" +
  191. "select yf=convert(varchar(7), a.setl_time, 120), a.medins_type, " +
  192. "psnCount=count(distinct a.setl_id), " +
  193. "inDays=sum(datediff(day, zy.admiss_date, zy.dis_date)), " +
  194. "totalFee=cast(round(sum(a.medfee_sumamt),2) as decimal(10,2)), " +
  195. "fundPooling=cast(round(sum(a.hifp_pay),2) as decimal(10,2)), " +
  196. "bigIllFundPooling=cast(round(sum(a.hifmi_pay),2) as decimal(10,2)), " +
  197. "civilServiceFund=cast(round(sum(a.cvlserv_pay),2) as decimal(10,2)), " +
  198. "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)),2) as decimal(10,2)), " +
  199. "allFunds=cast(round(sum(a.fund_pay_sumamt),2) as decimal(10,2)), " +
  200. "drugFee=cast(round(sum(isnull(a.charge_western_medicine,0) + isnull(a.charge_patent_medicine,0) + isnull(a.charge_herbal,0)),2) as decimal(10,2)), " +
  201. "matFee=cast(round(isnull(sum(a.charge_sanitary_material),0),2) as decimal(10,2)) " +
  202. "from t_si_setlinfo a " +
  203. "left join zy_inactpatient zy on (zy.inpatient_no = a.pat_no and zy.admiss_times = a.times) " +
  204. "where a.revoked=0 and a.setl_type=#{setlType} and a.setl_time&gt;=#{beginTime} and a.setl_time&lt;=#{endTime} " +
  205. "group by convert(varchar(7), a.setl_time, 120), a.medins_type order by convert(varchar(7), a.setl_time, 120) " +
  206. "</script>")
  207. List<Map<String, Object>> selectBarChangeData(@Param("beginTime") String beginTime, @Param("endTime") String endTime, @Param("setlType") String setlType);
  208. }