QueryDrugsAndProjectsDao.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. package thyyxxk.webserver.dao.his.querydata;
  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.datamodify.GetDropdownBox;
  6. import thyyxxk.webserver.entity.querydata.QueryDrugsAndProjects;
  7. import thyyxxk.webserver.entity.reports.illegalchargesanalysis.IllegalChargeData;
  8. import java.util.List;
  9. /**
  10. * <p>
  11. * 描述
  12. * </p>
  13. *
  14. * @author xc
  15. * @date 2021-04-16 16:01
  16. */
  17. @Mapper
  18. public interface QueryDrugsAndProjectsDao {
  19. /**
  20. * 获取科室
  21. *
  22. * @return 返回code和 name
  23. */
  24. @Select("select code,rtrim(name) name from zy_ward_code")
  25. List<GetDropdownBox> getWard();
  26. /**
  27. * 获取收费类型
  28. *
  29. * @return 返回code 和 name
  30. */
  31. @Select("select code,rtrim(name)name from zd_charge_class")
  32. List<GetDropdownBox> getChergeClass();
  33. /**
  34. * 查询收费项目
  35. *
  36. * @param param 传入查询条件 时间范围 科室 费用类型 收费编码
  37. * @return 返回
  38. */
  39. @Select("<script>" +
  40. "select a.charge_code_mx chargeCode,b.name name,sum(a.charge_amount) number,sum(charge_fee) amount_of_money, " +
  41. " classCode=c.name,source='住院' " +
  42. "from zy_detail_charge a , zd_charge_item b , zd_charge_class c " +
  43. "where a.charge_code_mx=b.code and b.class_code=c.code " +
  44. "<if test=\"startTime!=null and startTime!=''\">" +
  45. "and charge_date&gt;=#{startTime} and charge_date&lt;#{endTime} " +
  46. "</if>" +
  47. "<if test=\"classCode!=null and classCode!=''\">" +
  48. "and b.class_code=#{classCode} " +
  49. "</if>" +
  50. "<if test=\"ward!=null and ward!=''\">" +
  51. "and a.exec_unit=#{ward} " +
  52. "</if>" +
  53. "<if test=\"chargeCode!=null and chargeCode!=''\">" +
  54. "and charge_code_mx=#{chargeCode} " +
  55. "</if>" +
  56. "GROUP BY a.charge_code_mx,b.name,c.name " +
  57. "union all " +
  58. "select a.charge_item_code chargeCode,b.name name,sum(a.quantity*drug_win) amount_of_money, " +
  59. " sum(a.quantity*drug_win*unit_price) amountOfMoney, classCode=c.name,source='门诊' " +
  60. "from mz_charge_detail_b a , zd_charge_item b , zd_charge_class c " +
  61. "where a.charge_item_code=b.code and b.class_code=c.code " +
  62. "<if test=\"startTime!=null and startTime!=''\">" +
  63. "and a.charge_date&gt;=#{startTime} and a.charge_date&lt;#{endTime} " +
  64. "</if>" +
  65. "<if test=\"classCode!=null and classCode!=''\">" +
  66. "and b.class_code=#{classCode} " +
  67. "</if>" +
  68. "<if test=\"ward!=null and ward!=''\">" +
  69. "and a.exec_dept=#{ward} " +
  70. "</if>" +
  71. "<if test=\"chargeCode!=null and chargeCode!=''\">" +
  72. "and a.charge_item_code=#{chargeCode} " +
  73. "</if>" +
  74. " and a.pay_mark='0' " +
  75. "group by a.charge_item_code,a.serial,b.name,c.name" +
  76. "</script>")
  77. List<QueryDrugsAndProjects> queryProjects(QueryDrugsAndProjects param);
  78. /**
  79. * @param startTime 开始时间
  80. * @param endTime 结束时间
  81. * @param chargeCode 编码
  82. * @return 返回查询的数据
  83. */
  84. @Select("<script>" +
  85. "select patient, times, name, social_no, phone, admiss_date, dis_date,CONVERT(varchar(100), charge_date, 23) charge_date_string, dept,exec_unit,yb_type, " +
  86. " SUM(amount_of_money) amount_of_money,SUM(number) number,charge_code, source from (" +
  87. "SELECT " +
  88. " rtrim(a.inpatient_no) patient,a.admiss_times times,rtrim(b.name) name,b.social_no social_no,b.employer_tel phone,c.admiss_date,c.dis_date," +
  89. "CONVERT(varchar(100), a.charge_date, 23) charge_date, " +
  90. " (select name from zd_unit_code where code=c.small_dept) dept, " +
  91. "(select name from zd_unit_code where code= a.exec_unit) exec_unit, " +
  92. " (select name from zy_zd_responce_type where code=c.responce_type) yb_type, " +
  93. " sum(a.charge_amount) number,sum(a.charge_fee) amount_of_money,charge_code_mx charge_code,source='住院' " +
  94. "FROM zy_detail_charge a,a_patient_mi b,zy_inactpatient c " +
  95. "where charge_code_mx = #{chargeCode} " +
  96. " and a.inpatient_no=b.inpatient_no " +
  97. " and a.inpatient_no=c.inpatient_no " +
  98. " and a.admiss_times=c.admiss_times " +
  99. " and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  100. "<if test=\"dept != '' and dept !=null \">" +
  101. " and a.exec_unit = #{dept} " +
  102. "</if>" +
  103. "group by charge_code_mx,a.inpatient_no,a.admiss_times,b.name,b.social_no,b.employer_tel,c.admiss_date,c.dis_date,c.small_dept,a.exec_unit,c.responce_type,a.charge_date " +
  104. "union all " +
  105. "SELECT " +
  106. " rtrim(a.inpatient_no) patient,a.admiss_times times,rtrim(b.name) name ,b.social_no social_no,b.employer_tel phone,c.admiss_date,c.dis_date," +
  107. "CONVERT(varchar(100), a.charge_date, 23) charge_date," +
  108. " (select name from zd_unit_code where code=c.small_dept) dept, " +
  109. "(select name from zd_unit_code where code= a.exec_unit) exec_unit, " +
  110. " (select name from zy_zd_responce_type where code=c.responce_type) yb_type, " +
  111. " sum(a.charge_amount) number,sum(a.charge_fee) amount_of_money,charge_code_mx charge_code,source = '住院' " +
  112. "FROM zy_detail_charge a,a_patient_mi b,zy_actpatient c " +
  113. "where charge_code_mx = #{chargeCode} " +
  114. " and a.inpatient_no=b.inpatient_no " +
  115. " and a.inpatient_no=c.inpatient_no " +
  116. " and a.admiss_times=c.admiss_times " +
  117. " and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  118. "<if test=\"dept != '' and dept !=null \">" +
  119. " and a.exec_unit = #{dept} " +
  120. "</if>" +
  121. "group by charge_code_mx,a.inpatient_no,a.admiss_times,b.name,b.social_no,b.employer_tel,c.admiss_date,c.dis_date,c.small_dept,a.exec_unit,c.responce_type,a.charge_date " +
  122. "union all " +
  123. " select rtrim(a.patient_id) patient,a.times times,rtrim(b.name) name ,b.social_no social_no,b.phone_no phone," +
  124. "a.charge_date admiss_date,dis_date = null,CONVERT(varchar(100), a.charge_date, 23) charge_date, " +
  125. " (select name from zd_unit_code where code = a.warn_dept) dept, " +
  126. " (select name from zd_unit_code where code = a.exec_dept) exec_unit, " +
  127. " yb_type = '自费',sum(a.quantity*a.drug_win) number,sum(a.quantity*drug_win*unit_price) amount_of_money,a.charge_item_code,source = '门诊' " +
  128. " from mz_charge_detail_b a,mz_patient_mi b " +
  129. "where a.patient_id = b.patient_id " +
  130. "and a.times = b.times " +
  131. "and charge_item_code = #{chargeCode} " +
  132. "and charge_date &gt;= #{startTime} and charge_date &lt;= #{endTime} " +
  133. "<if test=\"dept != '' and dept !=null \">" +
  134. "and a.exec_dept = #{dept} " +
  135. "</if>" +
  136. "group by charge_item_code,a.patient_id,a.times,b.name,social_no,phone_no,charge_date,exec_dept,a.warn_dept) temp GROUP BY " +
  137. "patient,times,name,social_no,phone,admiss_date,dis_date,charge_date,dept,exec_unit,yb_type,amount_of_money,number,charge_code,source" +
  138. "</script>")
  139. // 如果不希望显示 0 的话 就去掉 amount_of_money 和 number
  140. List<QueryDrugsAndProjects> chaXunXiangMuHuoYaoPinJuTiXinXi(@Param("startTime") String startTime,
  141. @Param("endTime") String endTime,
  142. @Param("chargeCode") String chargeCode,
  143. @Param("dept") String dept);
  144. /**
  145. * 查询药品
  146. *
  147. * @param param 搜索条件 日期范围 是否为抗生素 药品大类 药品编码
  148. * @return 返回符合条件的数据
  149. */
  150. @Select("<script>" +
  151. "select a.charge_code_mx chargeCode," +
  152. "case a.serial when '01' then '药品(小)' when '99' then '药品(大)' end packageSpecification," +
  153. "b.name name,sum(a.charge_amount) number,sum(charge_fee) amountOfMoney,source='住院',classCode=c.name " +
  154. "from zy_detail_charge a,yp_zd_dict b,yp_zd_drug_kind c " +
  155. "where " +
  156. "1=1 " +
  157. "<if test=\"startTime!=null and startTime!=''\">" +
  158. "and charge_date&gt;=#{startTime} and charge_date&lt;#{endTime} " +
  159. "</if>" +
  160. "<if test=\"kssFlag!=null and kssFlag!=''\">" +
  161. "and b.kss_flag=#{kssFlag} " +
  162. "</if>" +
  163. "<if test=\"categoriesFlag!=null and categoriesFlag!=''\">" +
  164. "and b.categories_flag=#{categoriesFlag} " +
  165. "</if>" +
  166. " and a.charge_code_mx=b.code and a.serial=b.serial " +
  167. " and b.drug_kind=c.code " +
  168. "<if test=\"drugCode!=null and drugCode!=''\">" +
  169. "and b.code=#{drugCode} " +
  170. "</if>" +
  171. "GROUP BY a.charge_code_mx,a.serial,b.name,c.name " +
  172. "union all " +
  173. "select a.charge_item_code chargeCode," +
  174. "case a.serial when '01' then '药品(小)' when '99' then '药品(大)' end packageSpecification," +
  175. "b.name name,sum(a.quantity*drug_win) number,sum(a.quantity*drug_win*unit_price) amountOfMoney,source='门诊',classCode=c.name " +
  176. "from mz_charge_detail_b a,yp_zd_dict b,yp_zd_drug_kind c " +
  177. "where " +
  178. "1=1 " +
  179. "<if test=\"startTime!='' and startTime!=null\">" +
  180. "and a.charge_date&gt;=#{startTime} and a.charge_date&lt;#{endTime} " +
  181. "</if>" +
  182. "<if test=\"kssFlag!=null and kssFlag!=''\">" +
  183. "and b.kss_flag=#{kssFlag} " +
  184. "</if>" +
  185. "<if test=\"categoriesFlag!= null and categoriesFlag!=''\">" +
  186. "and b.categories_flag=#{categoriesFlag} " +
  187. "</if>" +
  188. "and a.charge_item_code=b.code " +
  189. "and a.serial=b.serial " +
  190. "and a.pay_mark='0' " +
  191. "and b.drug_kind=c.code " +
  192. "<if test=\"drugCode!=null and drugCode!='' \">" +
  193. "and b.code=#{drugCode} " +
  194. "</if>" +
  195. "group by a.charge_item_code,a.serial,b.name,c.name" +
  196. "</script>")
  197. List<QueryDrugsAndProjects> queryDrugs(QueryDrugsAndProjects param);
  198. /**
  199. * 查询药品或者项目名称
  200. *
  201. * @param tableName 表名
  202. * @param pyCode 首字母 以及 项目编码
  203. * @return 返回list
  204. */
  205. @Select("select rtrim(code) code,rtrim(name) name from ${tableName} where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
  206. List<GetDropdownBox> chaXunXiangMuhuoYaoPinCode(@Param("tableName") String tableName,
  207. @Param("pyCode") String pyCode);
  208. @Select("<script>" +
  209. "select rtrim(b.inpatient_no) inpatient_no,rtrim(a.name) name,a.responce_type,b.admiss_times," +
  210. "sum(b.charge4+b.charge6+b.charge8+b.charge9+b.charge11+b.charge18) jianChaFei," +
  211. "sum(b.charge13) jianYanFei,sum(b.total_charge) zongFeiYong, " +
  212. " (sum(b.charge4+b.charge6+b.charge8+b.charge9+b.charge11+b.charge18)+sum(b.charge13))/sum(b.total_charge) jcjyfzb, " +
  213. " a.admiss_date,a.dis_date, (select name from zd_unit_code where code=a.small_dept) deptName " +
  214. "from zy_inactpatient a,zy_ledger_file b " +
  215. "where a.inpatient_no not like '%$%' and a.inpatient_no not like 'S%' and a.inpatient_no not like 'JT%' " +
  216. " and a.inpatient_no=b.inpatient_no and a.admiss_times=b.admiss_times and b.settle_type&lt;&gt;1 " +
  217. "<if test=\"start !=null and start != '' \">" +
  218. " and a.admiss_date &gt;= #{start} and a.admiss_date &lt;= #{end} " +
  219. "</if>" +
  220. "<if test=\"responces.size > 0\" >" +
  221. "and a.responce_type in " +
  222. "<foreach collection='responces' item='item' index='index' open='(' close=')' separator=','>" +
  223. "#{item}" +
  224. "</foreach>" +
  225. "</if>" +
  226. "group by b.inpatient_no,b.admiss_times,a.admiss_date,a.dis_date,a.small_dept,a.name,a.responce_type " +
  227. "having (sum(b.charge4+b.charge6+b.charge8+b.charge9+b.charge11+b.charge18)+sum(b.charge13))&gt;0 " +
  228. "order by (sum(b.charge4+b.charge6+b.charge8+b.charge9+b.charge11+b.charge18)+sum(b.charge13))/sum(b.total_charge) desc" +
  229. "</script>")
  230. List<IllegalChargeData> chaXunJianYanJianCha(@Param("start") String start,
  231. @Param("end") String end,
  232. @Param("responces") List<String> responces);
  233. @Select("<script>" +
  234. "select rtrim(inpatient_no) patient,admiss_times times,dis_diag_comment,dis_diag_no from ba_first_page1 where " +
  235. "inpatient_no in " +
  236. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  237. "#{item}" +
  238. "</foreach>" +
  239. "</script>")
  240. List<QueryDrugsAndProjects> queryZhenDuan(@Param("list") List<String> list);
  241. }