PublicDao.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. package thyyxxk.webserver.dao.his;
  2. import org.apache.ibatis.annotations.Mapper;
  3. import org.apache.ibatis.annotations.Param;
  4. import org.apache.ibatis.annotations.Select;
  5. import org.apache.ibatis.annotations.Update;
  6. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  7. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  8. import thyyxxk.webserver.entity.login.UserInfo;
  9. import thyyxxk.webserver.entity.yibao.ZyActpatient;
  10. import java.math.BigDecimal;
  11. import java.util.List;
  12. import java.util.Set;
  13. /**
  14. * <p>
  15. * 描述: 公共接口
  16. * </p>
  17. *
  18. * @author xc
  19. * @date 2021-09-17 10:54
  20. */
  21. @Mapper
  22. public interface PublicDao {
  23. @Select("select role_id from dj_user_role where user_code = #{code}")
  24. List<Integer> huoQuJueSe(@Param("code") String code);
  25. /**
  26. * 把表锁住
  27. */
  28. @Update("update yz_sequence set act_order_no = act_order_no")
  29. void lockTable();
  30. /**
  31. * 查询医嘱
  32. *
  33. * @return 返回医嘱号
  34. */
  35. @Select("select act_order_no from yz_sequence")
  36. float getActOrderNo();
  37. /**
  38. * 插入新的医嘱
  39. *
  40. * @param actOrderNo 医嘱号
  41. */
  42. @Update("update yz_sequence set act_order_no = #{actOrderNo}")
  43. void updateActOrderNo(float actOrderNo);
  44. /**
  45. * 获取 这个科室 的子科室
  46. *
  47. * @param deptCode 科室编码
  48. * @return 返回自生和子科室
  49. */
  50. @Select("select code from zd_unit_code where (parent_code = #{deptCode} or code = #{deptCode}) and isnull(del_flag,0) = 0")
  51. List<String> getKeShiLieBiao(String deptCode);
  52. @Select("<script>" +
  53. "select code from zd_unit_code where (parent_code in " +
  54. "<foreach collection='deptCodeList' item='item' index='index' open='(' close=')' separator=','>" +
  55. " #{item,jdbcType = CHAR}" +
  56. "</foreach> " +
  57. "or code in " +
  58. "<foreach collection='deptCodeList' item='item' index='index' open='(' close=')' separator=','>" +
  59. "#{item,jdbcType = CHAR}" +
  60. "</foreach>" +
  61. ") and isnull(del_flag,0) = 0" +
  62. "</script>")
  63. List<String> getKeShiLieBiaoList(@Param("deptCodeList") List<String> deptCodeList);
  64. /**
  65. * 获取人员信息
  66. *
  67. * @param code 人员代码
  68. * @return 返回人员
  69. */
  70. @Select("select distinct rtrim(code) code,rtrim(name) name from a_employee_mi where (name like #{code} or code_rs like #{code} or py_code like #{code}) and isnull(del_flag,0) = 0")
  71. List<GetDropdownBox> getRenYuan(String code);
  72. /**
  73. * @param pyCode 拼音编码
  74. * @return 获取项目的名称和code
  75. */
  76. @Select("select distinct code,name from zd_charge_item where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})" +
  77. "union all " +
  78. "select distinct code,name from yp_zd_dict where (py_code like #{pyCode} or code like #{pyCode} or name like #{pyCode})")
  79. List<GetDropdownBox> getChargeCode(String pyCode);
  80. @Select("select rtrim(code) code,rtrim(name) name from zd_unit_code where isnull(del_flag,0) = 0")
  81. List<GetDropdownBox> getDept();
  82. @Select("select isnull(max(ledger_sn),1) from zy_ledger_file where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes}")
  83. Integer getLedgerSn(@Param("inpatientNo") String inpatient,
  84. @Param("admissTimes") Integer admissTimes);
  85. @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,admiss_date,dis_date,name, " +
  86. "responce_name = (select rtrim(name) name from zy_zd_responce_type where code = responce_type)," +
  87. "responce_type, " +
  88. "ward,ward_name = (select rtrim(name) name from zd_unit_code where code = ward), " +
  89. "ledger_sn = (select max(ledger_sn) from zy_ledger_file where a.inpatient_no = zy_ledger_file.inpatient_no and a.admiss_times = zy_ledger_file.admiss_times), " +
  90. "chu_yuan_yi_zhu = (case when (select count(1) from yz_act_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " +
  91. "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " +
  92. "then 1 " +
  93. "when (select count(1) from yz_inact_order where inpatient_no= a.inpatient_no and admiss_times= a.admiss_times " +
  94. "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')) > 0 " +
  95. "then 1 else 0 end ), " +
  96. "bed_no,total_charge,balance from zy_actpatient a where inpatient_no = #{inpatientNo} ")
  97. ZyActpatient getHuanZheJiBenXinXi(@Param("inpatientNo") String inpatientNo);
  98. @Update("update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} " +
  99. "and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and ori_detail_sn = -1 and charge_amount > 0")
  100. void chongZhiZhenLiuShui(@Param("inpatientNo") String inpatientNo,
  101. @Param("admissTimes") Integer admissTimes,
  102. @Param("ledgerSn") Integer ledgerSn);
  103. @Select("select ori_detail_sn from zy_detail_charge where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  104. "and ori_detail_sn is not null " +
  105. "and charge_amount < 0")
  106. List<Integer> huoQuTuiFeiYuanLiuShui(@Param("inpatientNo") String inpatientNo,
  107. @Param("admissTimes") Integer admissTimes,
  108. @Param("ledgerSn") Integer ledgerSn);
  109. @Update("<script>" +
  110. "update zy_detail_charge set ori_detail_sn = -1 where inpatient_no = '${inpatientNo}' and admiss_times = ${admissTimes} and ledger_sn = ${ledgerSn} " +
  111. "and charge_amount &gt; 0 and detail_sn in " +
  112. "<foreach collection='list' item='item' index='index' open='(' close=')' separator=','>" +
  113. "${item}" +
  114. "</foreach>" +
  115. "</script>")
  116. void genXingFuShuDuiYingZhenLiuShui(@Param("inpatientNo") String inpatientNo,
  117. @Param("admissTimes") Integer admissTimes,
  118. @Param("ledgerSn") Integer ledgerSn,
  119. @Param("list") List<Integer> detailSnList);
  120. @Select("select ori_detail_sn,sum(charge_fee) charge_fee,sum(charge_amount) charge_amount " +
  121. "from zy_detail_charge a " +
  122. "where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and order_no <> 6 and trans_flag_yb <> 2 " +
  123. " and ori_detail_sn is not null and charge_amount<0 " +
  124. "group by ori_detail_sn having count(1) > 1")
  125. List<ZyDetailCharge> chongFuTuiFeiLiuShui(@Param("inpatientNo") String inpatientNo,
  126. @Param("admissTimes") Integer admissTimes,
  127. @Param("ledgerSn") Integer ledgerSn);
  128. @Select("<script>" +
  129. "select detail_sn,charge_fee,charge_amount from zy_detail_charge where inpatient_no=#{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  130. "and detail_sn in " +
  131. "<foreach collection='oriSn' item='sn' open='(' close=')' separator=','>" +
  132. "#{sn}" +
  133. "</foreach>" +
  134. "</script>")
  135. List<ZyDetailCharge> getZhenShuLiuShui(@Param("inpatientNo") String inpatientNo,
  136. @Param("admissTimes") Integer admissTimes,
  137. @Param("ledgerSn") Integer ledgerSn,
  138. @Param("oriSn") Set<Integer> oriSn);
  139. @Update("<script>" +
  140. "<foreach collection='list' item='item' separator=';'>" +
  141. "update zy_detail_charge set ori_detail_sn = null where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  142. "and (detail_sn = #{item} or ori_detail_sn = #{item}) " +
  143. "</foreach>" +
  144. "</script>")
  145. void chongFuTuiFeiChongZhi(@Param("inpatientNo") String inpatientNo,
  146. @Param("admissTimes") Integer admissTimes,
  147. @Param("ledgerSn") Integer ledgerSn,
  148. @Param("list") List<Integer> oriDetailSn);
  149. @Select("select isnull(sum(charge_fee),0) from zy_detail_charge " +
  150. "where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and trans_flag_yb=2")
  151. BigDecimal zhenFuXingDiFeiYong(@Param("inpatientNo") String inpatientNo,
  152. @Param("admissTimes") Integer admissTimes,
  153. @Param("ledgerSn") Integer ledgerSn);
  154. @Update("update zy_detail_charge set trans_flag_yb = 0 where inpatient_no = #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} and " +
  155. "trans_flag_yb = 2")
  156. void chongXingZhengFuXiangDi(@Param("inpatientNo") String inpatientNo,
  157. @Param("admissTimes") Integer admissTimes,
  158. @Param("ledgerSn") Integer ledgerSn);
  159. @Select("select detail_sn from zy_detail_charge where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  160. "and trans_flag_yb <> 2 and charge_amount > 0 and ori_detail_sn is not null")
  161. List<Integer> zhenShuLiuShui(@Param("inpatientNo") String inpatientNo,
  162. @Param("admissTimes") Integer admissTimes,
  163. @Param("ledgerSn") Integer ledgerSn);
  164. @Select("select ori_detail_sn from zy_detail_charge where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  165. "and trans_flag_yb <> 2 and charge_amount < 0 and ori_detail_sn is not null")
  166. List<Integer> fuShuLiuShui(@Param("inpatientNo") String inpatientNo,
  167. @Param("admissTimes") Integer admissTimes,
  168. @Param("ledgerSn") Integer ledgerSn);
  169. @Update("<script>" +
  170. "<foreach collection='list' item='item' separator=';'>" +
  171. "update zy_detail_charge set ori_detail_sn = null where inpatient_no= #{inpatientNo} and admiss_times = #{admissTimes} and ledger_sn = #{ledgerSn} " +
  172. "and charge_fee &lt; 0 and ori_detail_sn = #{item}" +
  173. "</foreach>" +
  174. "</script> ")
  175. void chongZhiFuShuYuanLiuShui(@Param("inpatientNo") String inpatientNo,
  176. @Param("admissTimes") Integer admissTimes,
  177. @Param("ledgerSn") Integer ledgerSn,
  178. @Param("list") List<Integer> oriDetailSn);
  179. @Select("select top(1) code,dept_code,name,code_rs from a_employee_mi where (code = #{code} or code_rs = #{code}) and isnull(del_flag,0) = 0 ")
  180. UserInfo huoQuYuanGongBianMa(String code);
  181. @Select("SELECT small_dept FROM zd_dept_all where dept = #{deptCode}")
  182. List<String> bingFangSuoSuKeShi(String deptCode);
  183. // 重置 流水号
  184. @Select("select detail_sn from zy_detail_charge where inpatient_no= #{patNo} and admiss_times = #{times} " +
  185. "group by detail_sn having count(1) > 1 ")
  186. List<Integer> huoQuZhongYeFeiYong(@Param("patNo") String patNo,
  187. @Param("times") Integer times);
  188. @Update("<script>" +
  189. "<foreach collection='list' item='item' separator=';' index='index' >" +
  190. "update zy_detail_charge set detail_sn = (select isnull(max(detail_sn),1) + 1 from zy_detail_charge where inpatient_no= '${patNo}' and admiss_times = ${times}) " +
  191. "where inpatient_no= '${patNo}' and admiss_times = ${times} and ledger_sn = ${ledgerSn} and detail_sn = ${item}" +
  192. "</foreach>" +
  193. "</script>")
  194. void chongZhiLiuShui(@Param("patNo") String patNo,
  195. @Param("times") Integer times,
  196. @Param("ledgerSn") Integer ledgerSn,
  197. @Param("list") List<Integer> list);
  198. }