TransferInOfExpensesDao.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. package thyyxxk.webserver.dao.his.yibao;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import org.apache.ibatis.annotations.*;
  4. import thyyxxk.webserver.entity.datamodify.GetDropdownBox;
  5. import thyyxxk.webserver.entity.datamodify.MzChargeDetail;
  6. import thyyxxk.webserver.entity.datamodify.ZyDetailCharge;
  7. import thyyxxk.webserver.entity.yibao.ZyActpatient;
  8. import java.util.List;
  9. /**
  10. * <p>
  11. * 描述: 门急诊费用转入
  12. * </p>
  13. *
  14. * @author xc
  15. * @date 2021-05-25 17:35
  16. */
  17. @Mapper
  18. public interface TransferInOfExpensesDao {
  19. /**
  20. * 查询患者的基本信息
  21. *
  22. * @param inpatientNo 住院号
  23. * @return 返回一条信息
  24. */
  25. @Select("select rtrim(inpatient_no) inpatient_no,admiss_times,rtrim(zk_dept) zk_dept,ward,dept," +
  26. "rtrim(admiss_ward) wardCode," +
  27. "rtrim(small_dept) deptCode,zy_serial_no, " +
  28. "rtrim(isnull(operation, '')) as operation, " +
  29. "rtrim(refer_physician) refer_physician, " +
  30. "rtrim(consult_physician) consult_physician,zk_ward, " +
  31. "ledgerSn=(select max(ledger_sn) from zy_ledger_file " +
  32. "where inpatient_no=a.inpatient_no and admiss_times=a.admiss_times), " +
  33. "maxDetailSn=(select max(detail_sn) from zy_detail_charge " +
  34. "where inpatient_no=a.inpatient_no and admiss_times=a.admiss_times), " +
  35. "rtrim(a.name)name,sex,rtrim(bed_no)bed_no,(b.name) ward_name, " +
  36. "admiss_date,(c.name)responce_type_name,total_charge,balance " +
  37. "from zy_actpatient a left join zd_unit_code b on (a.ward = b.code) left join zy_zd_responce_type c on (a.responce_type = c.code) " +
  38. "where inpatient_no = #{inpatientNo}")
  39. ZyActpatient queryHuanZhe(String inpatientNo);
  40. /**
  41. * 根据机制号来查询门诊发票信息
  42. *
  43. * @param tableName 要查询的表格
  44. * @param serialNo 机制号
  45. * @return 返回多个
  46. */
  47. @Select("select " +
  48. " patient_name =rtrim(a.name), " +
  49. " item_name = c.name, " +
  50. " charge_amount = a.quantity, " +
  51. " self_flag=c.self_flag, " +
  52. " separate_flag = c.separate_flag, " +
  53. " suppress_flag = c.suppress_flag, " +
  54. " charge_code = a.charge_item_code, " +
  55. " charge_code_mx = a.charge_item_code, " +
  56. " serial = a.serial, " +
  57. " group_no = a.group_no, " +
  58. " price = a.unit_price, " +
  59. " charge_fee=a.unit_price * a.quantity * isnull(a.drug_win,1), " +
  60. " check_flag='0', " +
  61. " warn_dept =a.warn_dept, " +
  62. " doctor_code = a.doctor_code, " +
  63. " bill_item_code = rtrim(a.bill_item_code), " +
  64. " exec_dept = a.exec_dept " +
  65. "from ${tableName} a,mz_receipt_serial b,zd_charge_item c " +
  66. "where a.patient_id = b.patient_id and " +
  67. " a.times = b.times and " +
  68. " a.receipt_no = b.receipt_no and " +
  69. " a.serial_no= b.serial_no and " +
  70. " b.receipt_sn=#{serialNo} and " +
  71. " a.charge_item_code=c.code and " +
  72. " isnull(a.group_no,'00')='00' " +
  73. "union all " +
  74. "select patient_name =rtrim(a.name), " +
  75. " item_name = (select name from yp_zd_dict where yp_zd_dict.code=c.charge_code and yp_zd_dict.serial=c.serial),/*c.drugname,*/ " +
  76. " charge_amount = a.quantity, " +
  77. " self_flag=a.self_flag, " +
  78. " separate_flag = (select separate_flag from yp_zd_dict where yp_zd_dict.code=c.charge_code and yp_zd_dict.serial=c.serial), " +
  79. " suppress_flag = (select suprice_flag from yp_zd_dict where yp_zd_dict.code=c.charge_code and yp_zd_dict.serial=c.serial), " +
  80. " charge_code = a.charge_item_code, " +
  81. " charge_code_mx = a.charge_item_code, " +
  82. " serial = a.serial, " +
  83. " group_no = a.group_no, " +
  84. " price = a.unit_price, " +
  85. " charge_fee=a.unit_price * a.quantity * isnull(a.drug_win,1), " +
  86. " check_flag='0', " +
  87. " warn_dept =a.warn_dept, " +
  88. " doctor_code = a.doctor_code, " +
  89. " bill_item_code = rtrim(a.bill_item_code), " +
  90. " exec_dept = a.exec_dept " +
  91. "from ${tableName} a,mz_receipt_serial b,yp_base_yf c " +
  92. "where a.patient_id = b.patient_id and " +
  93. " a.times = b.times and " +
  94. " a.receipt_no = b.receipt_no and " +
  95. " a.serial_no= b.serial_no and " +
  96. " b.receipt_sn=#{serialNo} and " +
  97. " a.charge_item_code=c.charge_code and " +
  98. " a.serial = c.serial and " +
  99. " a.group_no = c.group_no and " +
  100. " isnull(a.group_no,'00')<>'00'")
  101. List<MzChargeDetail> getSerialNo(@Param("tableName") String tableName,
  102. @Param("serialNo") Integer serialNo);
  103. /**
  104. * 分页获取这个病人是通过急门诊转入的费用 如果确实插入了数据但是没有看到 那就是他们没有维护好两个字典表
  105. *
  106. * @param page 分页对象
  107. * @param inpatientNo 住院号
  108. * @return 返回
  109. */
  110. @Select("<script>" +
  111. "select * from (" +
  112. "select rtrim(inpatient_no)inpatient_no,admiss_times,detail_sn,ledger_sn, " +
  113. "charge_date,charge_code,charge_fee,a.charge_amount,charge_code_mx,(b.name)charge_code_name,gen_time, " +
  114. "zy_serial_no " +
  115. "from zy_detail_charge a,zd_charge_item b where (code =charge_code) and order_no=6 and inpatient_no = #{inpatientNo} " +
  116. "and admiss_times = #{admissTimes} AND (a.charge_amount !&lt; 0 or charge_code_mx = 'BILL99') " +
  117. "<if test=\"chargeCodeMX!=null and chargeCodeMX!=''\"> " +
  118. "and (charge_code_mx = #{chargeCodeMX} or charge_code = #{chargeCodeMX}) " +
  119. "</if> " +
  120. "union " +
  121. "select rtrim(inpatient_no)inpatient_no,admiss_times,detail_sn,ledger_sn, " +
  122. "charge_date,charge_code,charge_fee,a.charge_amount,charge_code_mx,(b.name)charge_code_name,gen_time, " +
  123. "zy_serial_no " +
  124. "from zy_detail_charge a,yp_zd_dict b where (code=charge_code) and order_no=6 and inpatient_no = #{inpatientNo} " +
  125. "and admiss_times = #{admissTimes} AND (a.charge_amount !&lt; 0 or charge_code_mx = 'BILL99') " +
  126. "<if test=\"chargeCodeMX!=null and chargeCodeMX!=''\"> " +
  127. "and (charge_code_mx = #{chargeCodeMX} or charge_code = #{chargeCodeMX}) " +
  128. "</if>" +
  129. ") temp" +
  130. "</script> ")
  131. List<ZyDetailCharge> getZyJiMenZhenZhuangRuFeiYong(IPage<ZyDetailCharge> page,
  132. @Param("inpatientNo") String inpatientNo,
  133. @Param("chargeCodeMX") String chargeCodeMX,
  134. @Param("admissTimes") String admissTimes);
  135. /**
  136. * 获取费用总和
  137. *
  138. * @param inpatientNo 住院号
  139. * @param chargeCodeMX 项目编码
  140. * @return 返回费用
  141. */
  142. @Select("<script>" +
  143. "select charge_fee,charge_amount,charge_code " +
  144. "from zy_detail_charge a where order_no=6 and inpatient_no = #{inpatientNo} " +
  145. "and admiss_times = #{admissTimes} " +
  146. "<if test=\"chargeCodeMX!=null and chargeCodeMX!=''\"> " +
  147. "and (charge_code_mx = #{chargeCodeMX} or charge_code = #{chargeCodeMX}) " +
  148. "</if> " +
  149. "</script>")
  150. List<ZyDetailCharge> sumZyFee(@Param("inpatientNo") String inpatientNo,
  151. @Param("chargeCodeMX") String chargeCodeMX,
  152. @Param("admissTimes") String admissTimes);
  153. /**
  154. * 删除病人通过急门诊转入的费用 数据
  155. *
  156. * @param param 删除的条件
  157. */
  158. @Delete("delete from zy_detail_charge where inpatient_no=#{inpatientNo} and " +
  159. "admiss_times =#{admissTimes} and ledger_sn=#{ledgerSn} and detail_sn=#{detailSn}")
  160. void shanChuFeiYong(ZyDetailCharge param);
  161. /**
  162. * 插入数据 急门诊数据转入住院费用
  163. * 这上面的数据都是在前面查询找到的
  164. *
  165. * @param info 住院患者的信息
  166. * @param zyFees 费用 list
  167. */
  168. @Insert("<script>" +
  169. "insert into zy_detail_charge (inpatient_no,admiss_times,ledger_sn,detail_sn,charge_date,op_id_code, " +
  170. "charge_code,infant_flag,charge_status,charge_amount,charge_fee,ward_code,dept_code,order_no,ope_flag, " +
  171. "gen_time,charge_code_mx,serial,doctor_code,trans_flag_yb,refer_physician,consult_physician,exec_unit,zy_serial_no) VALUES " +
  172. "<foreach collection='list' item='fee' separator=',' open='' close=''>" +
  173. "(#{info.inpatientNo}, #{info.admissTimes}, #{info.ledgerSn}, #{fee.detailSn}, getDate(), #{info.staffId}, " +
  174. "#{fee.chargeCode}, 0, 2, #{fee.chargeAmount}, cast(#{fee.chargeFee,jdbcType=DECIMAL} as decimal(14,5)), #{info.ward}, #{info.dept}, 6, " +
  175. "'',getDate(), #{fee.chargeCodeMx},#{fee.serial},#{fee.doctorCode},0,#{info.referPhysician}," +
  176. "#{info.consultPhysician},#{info.reqExecUnit},#{info.zySerialNo})" +
  177. "</foreach>" +
  178. "</script>")
  179. void insertInfoZyDetailCharge(@Param("info") ZyActpatient info,
  180. @Param("list") List<MzChargeDetail> zyFees);
  181. /**
  182. * 查询出这个患者的最大流水号,在新增费用的时候要加一
  183. *
  184. * @param inpatientNo 住院号
  185. * @param admissTimes 住院次数
  186. * @return 返回最大的流水号
  187. */
  188. @Select("select isnull(max(detail_sn),0) from zy_detail_charge where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
  189. Integer getMaxDetailSn(@Param("inpatientNo") String inpatientNo,
  190. @Param("admissTimes") Integer admissTimes);
  191. /**
  192. * 远程搜索 项目名称
  193. *
  194. * @param pyCode 拼音码 大写的
  195. * @return 返回多个项目的名称
  196. */
  197. @Select("select * from (" +
  198. "select code,rtrim(name)name from zd_charge_item where py_code like #{pyCode} " +
  199. "union " +
  200. "select code,rtrim(name)name from yp_zd_dict where py_code like #{pyCode}" +
  201. ") temp")
  202. List<GetDropdownBox> queryEntryName(@Param("pyCode") String pyCode);
  203. // 9498.58,-7498.58,420.00
  204. }