DismissDao.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. package thyyxxk.webserver.dao.his.inpatient;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.webserver.entity.dictionary.CodeName;
  4. import thyyxxk.webserver.entity.inpatient.dismiss.*;
  5. import java.math.BigDecimal;
  6. import java.util.Date;
  7. import java.util.List;
  8. import java.util.Map;
  9. @Mapper
  10. public interface DismissDao {
  11. @Select("select top 1 ltrim(rtrim(name)) from a_employee_mi where code=#{code}")
  12. String getOperateName(@Param("code") String code);
  13. @Select("select isnull(max ( ledger_sn ), isnull(min ( ledger_sn ), 1)) from zy_ledger_file where " +
  14. "inpatient_no=#{patNo} and admiss_times=#{times}")
  15. Integer getLedgerSn(@Param("patNo") String patNo, @Param("times") Integer times);
  16. @Update("exec zy_receive_drug @in_no=#{patNo},@times=#{times},@v_no=#{patNo}, @is_infant=0")
  17. void acceptFeeStepOne(@Param("patNo") String patNo, @Param("times") Integer times);
  18. @Update("exec zy_receive_one @in_no=#{patNo},@times=#{times},@v_no=#{patNo}, @is_infant=0")
  19. int acceptFeeStepTwo(@Param("patNo") String patNo, @Param("times") Integer times);
  20. @Update("exec dbo.zy_cngl_fyjs_list_yz_1 @in_no=#{patNo}, @in_times=#{times}")
  21. int getOrderList(@Param("patNo") String patNo, @Param("times") Integer times);
  22. @Select("select ltrim(rtrim(str(act_order_no))) as actOrderNo,rtrim(order_name) as orderName," +
  23. "charge_date as chargeDate, rtrim(charge_code) as chargeCode,charge_fee=rtrim(charge_fee), " +
  24. "chargeName=rtrim(charge_name), frequCode=rtrim(frequ_code)," +
  25. "cxFlag=cx_flag,drugSpecification=rtrim(drug_specification)," +
  26. "start_time,end_time,chargeAmount=charge_amount,page_no,charge_status," +
  27. "supplyCode=(select rtrim(name) from view_zd_supply_type where code=supply_code)," +
  28. "physician=(select rtrim(name) from a_employee_mi where code=physician)," +
  29. "enterOper=(select rtrim(name) from a_employee_mi where code=enter_oper)," +
  30. "execUnit=(select rtrim(name) from zd_unit_code where code=exec_unit)," +
  31. "wardName=(select rtrim(name) from zd_unit_code where code=ward_code)," +
  32. "order_code, group_no from zy_list where charge_status in ('5','6','8')")
  33. List<ActOrderDetail> getActOrderDetail();
  34. @Update("exec zy_calc_detail_again_new @in_no=#{patNo}," +
  35. "@times=#{times},@sn=#{ledgerSn},@orig_type='1',@new_type='1'")
  36. int hasUnsettledStepOne(@Param("patNo") String patNo,
  37. @Param("times") Integer times,
  38. @Param("ledgerSn") int ledgerSn);
  39. @Select("select isnull(sum(depo_amount),0) from zy_deposit_file where depo_type='Y' " +
  40. "and inpatient_no=#{patNo} and admiss_times=#{times}")
  41. int hasUnsettledStepTwo(@Param("patNo") String patNo, @Param("times") Integer times);
  42. @Select("SELECT count(1) FROM zy_detail_charge WHERE inpatient_no=#{patNo} AND " +
  43. "admiss_times=#{times} and ledger_sn>=1 AND charge_fee <> 0 and charge_status ='1'")
  44. int hasNotAccounted(@Param("patNo") String patNo, @Param("times") Integer times);
  45. @Select("SELECT message = N'药单号:' + CAST(page_no as VARCHAR) + " +
  46. " N',药品名称:' + + (select top 1 name from yp_zd_dict where charge_code = code) + " +
  47. " N',医嘱号:' + CAST(CAST(act_order_no AS DECIMAL) AS VARCHAR(20)) " +
  48. " FROM yp_zy_patient WHERE inpatient_no=#{patNo} AND " +
  49. "admiss_times=#{times} AND amount <> 0 and acct_sign <> '2' ")
  50. List<String> hasUnreceivedDrugList(@Param("patNo") String patNo, @Param("times") Integer times);
  51. @Select("SELECT count(1) FROM yz_zy_patient_fee WHERE inpatient_no=#{patNo} " +
  52. "AND admiss_times=#{times} and charge_date<=#{actOrderDisDate} AND charge_fee <> 0 " +
  53. "and charge_status <> '0' and charge_status <> '2' ")
  54. int hasUnreceivedFees(@Param("patNo") String patNo,
  55. @Param("times") Integer times,
  56. @Param("actOrderDisDate") Date actOrderDisDate);
  57. @Select("select count(1) from yz_yp_zy_order with(nolock) where inpatient_no=#{patNo} " +
  58. "and admiss_times=#{times} and (amount>0 or (amount<0 and drug_class!='d')) " +
  59. "and status_flag='1' and page_no=0")
  60. int hasUnSubmitDrugList(@Param("patNo") String patNo, @Param("times") Integer times);
  61. @Select("select b.group_name,pageNo=cast(a.page_no as decimal),a.page_no_ty " +
  62. "from yz_yp_zy_order a with(nolock),yp_zd_group_name b with(nolock) where a.inpatient_no=#{patNo} " +
  63. "and a.admiss_times=#{times} and (a.amount>0 or (a.amount<0 and a.drug_class!='d')) and " +
  64. "(case when a.amount>0 then a.page_no else a.page_no_ty end>0) and a.group_no=b.group_no and a.status_flag='1'")
  65. List<IllegalFee> hasUntreatedDrugOrder(@Param("patNo") String patNo, @Param("times") Integer times);
  66. @Select("select page_no_ty,charge_date as yp_charge_date from yz_yp_zy_order where inpatient_no=#{patNo} " +
  67. "and admiss_times=#{times} and page_class='HT' and status_flag='1'")
  68. List<IllegalFee> selectPageNoTys(@Param("patNo") String patNo, @Param("times") Integer times);
  69. @Select("SELECT count(1) FROM yz_zy_patient_fee WHERE inpatient_no=#{patNo} " +
  70. "AND admiss_times=#{times} and charge_date<=#{actOrderDisDate} AND " +
  71. "charge_fee <> 0 and charge_status='3'")
  72. int hasUnconfirmedMedicalTech(@Param("patNo") String patNo,
  73. @Param("times") Integer times,
  74. @Param("actOrderDisDate") Date actOrderDisDate);
  75. @Select("select * from (select sum(a.charge_fee) as code,a.charge_code_mx as chargeCode,b.name from zy_detail_charge a, " +
  76. "zd_charge_item b where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and " +
  77. "a.charge_code_mx=b.code group by a.charge_code_mx,b.name union select " +
  78. "sum(a.charge_fee) as code,a.charge_code_mx as chargeCode,b.name from zy_detail_charge a,yp_zd_dict b " +
  79. "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and a.charge_code_mx=b.code " +
  80. "group by a.charge_code_mx,b.name ) as x where x.code<0")
  81. List<IllegalFee> feeOrderNegative(@Param("patNo") String patNo, @Param("times") Integer times);
  82. @Delete("delete zy_tmp_settle_select_detail where inpatient_no=#{patNo} and admiss_times=#{times}")
  83. void deleteTemporaryTable(@Param("patNo") String patNo, @Param("times") Integer times);
  84. @Select("select dateadd(second,1,account_date) from zy_ledger_file where inpatient_no=#{patNo} and " +
  85. "admiss_times=#{times} and ledger_sn=(#{ledgerSn}-1)")
  86. Date selectLastLedgerAccountDate(@Param("patNo") String patNo, @Param("times") int times, @Param("ledgerSn") int ledgerSn);
  87. @Select("select admiss_date from ${table} where inpatient_no=#{patNo} and admiss_times=#{times}")
  88. Date selectAdmissDate(@Param("patNo") String patNo, @Param("times") Integer times, @Param("table") String table);
  89. @Select("SELECT settle_type FROM zy_ledger_file WHERE inpatient_no=#{patNo} " +
  90. "AND admiss_times=#{times} AND ledger_sn=#{ledgerSn}")
  91. int hasSettled(@Param("patNo") String patNo,
  92. @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
  93. @Select("select count(1) from zy_tmp_settle_select_detail where inpatient_no=#{patNo} " +
  94. "and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  95. int hasUncheckedFee(@Param("patNo") String patNo,
  96. @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
  97. @Select("select count(1) from yz_act_order where inpatient_no=#{patNo} and admiss_times=#{times} " +
  98. "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')")
  99. Integer countDisActOrders(@Param("patNo") String patNo, @Param("times") Integer times);
  100. @Select("select count(1) from yz_act_order where inpatient_no=#{patNo} and admiss_times=#{times} " +
  101. "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code='05973' ")
  102. Integer selectDeathOrderCount(@Param("patNo") String patNo, @Param("times") Integer times);
  103. @Select("select count(1) from yz_inact_order where inpatient_no=#{patNo} and admiss_times=#{times} " +
  104. "and status_flag > '2' and isnull(group_no,'00' )='00' and order_code in ('06026','06053','05973')")
  105. Integer countDisActOrders2(@Param("patNo") String patNo, @Param("times") Integer times);
  106. @Select("select (select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} " +
  107. "and admiss_times=#{times} and ledger_sn=#{ledgerSn} and isnull(charge_status, '1') <> '1') - " +
  108. "(select isnull(total_charge,0) from zy_ledger_file " +
  109. "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn})")
  110. BigDecimal getFeeOffset(@Param("patNo") String patNo,
  111. @Param("times") Integer times,
  112. @Param("ledgerSn") int ledgerSn);
  113. @Select("select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} and " +
  114. "admiss_times=#{times} and ledger_sn=#{ledgerSn} and isnull(charge_status, '1')!='1' and " +
  115. "isnull(trans_flag_yb,0)!=2 and charge_date ${compare} convert(varchar(19),#{timeLimit},21)")
  116. BigDecimal selectOverTimeLimitFee(@Param("patNo") String patNo,
  117. @Param("times") Integer times,
  118. @Param("ledgerSn") int ledgerSn,
  119. @Param("compare") String compare,
  120. @Param("timeLimit") Date timeLimit);
  121. @Delete("delete zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  122. void deleteZyLedgerFileYb(@Param("patNo") String patNo,
  123. @Param("times") Integer times,
  124. @Param("ledgerSn") int ledgerSn);
  125. @Insert("insert into zy_ledger_file_yb (inpatient_no,admiss_times,ledger_sn,total_cost,tczf,grzhzf,dbzf,xjzf," +
  126. "full_self_pay,part_self_pay,hospital_pay) values (#{inpatientNo},#{admissTimes},#{ledgerSn},#{totalCost}," +
  127. "#{tczf},#{grzhzf},#{dbzf},#{xjzf},#{fullSelfPay},#{partSelfPay},#{hospitalPay})")
  128. int insertZyLedgerFileYb(MedinsSettleFee settleFee);
  129. @Update("update zy_ledger_file set charge_yb=1 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  130. int beforeWriteReceiptTable(@Param("patNo") String patNo,
  131. @Param("times") Integer times,
  132. @Param("ledgerSn") int ledgerSn);
  133. @Delete("delete from zy_receipt where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  134. void deleteZyReceipt(@Param("patNo") String patNo,
  135. @Param("times") int times,
  136. @Param("ledgerSn") int ledgerSn);
  137. @Insert("insert into zy_receipt (inpatient_no,admiss_times,ledger_sn,receipt_sn,receipt_no," +
  138. "account_date,date_1,date_2,ward,dept,print_date,responce_unit,op_id_code,total_charge," +
  139. "charge1,charge2,charge3,charge4,charge5,charge6,charge7,charge8,charge9,charge10,charge11," +
  140. "charge12,charge13,charge14,charge15,charge16,charge17,charge18,charge19,charge20,charge21," +
  141. "charge22,charge23,charge24,charge25,charge26,charge27,charge28,charge29,charge30) " +
  142. "values (#{patNo},#{times},#{ledgerSn},#{receiptSn},'00000000',#{dismissDate}," +
  143. "#{admissDate},#{dismissDate},#{wardCode},#{deptCode},#{printDate},#{responceUnit},#{codeRs}," +
  144. "#{map.total},#{map.001},#{map.002},#{map.003},#{map.004},#{map.005},#{map.006},#{map.007},#{map.008},#{map.009},#{map.010}," +
  145. "#{map.011},#{map.012},#{map.013},#{map.014},#{map.015},#{map.016},#{map.017},#{map.018},#{map.019},#{map.020},#{map.021},#{map.022}," +
  146. "#{map.023},#{map.024},#{map.025},#{map.026},#{map.027},#{map.028},'0.00','0.00')")
  147. int writeReceiptTable(@Param("patNo") String patNo, @Param("times") Integer times,
  148. @Param("ledgerSn") int ledgerSn, @Param("receiptSn") int receiptSn,
  149. @Param("admissDate") Date admissDate, @Param("dismissDate") Date dismissDate,
  150. @Param("wardCode") String wardCode, @Param("deptCode") String deptCode,
  151. @Param("printDate") Date printDate, @Param("responceUnit") String responceUnit,
  152. @Param("codeRs") String codeRs, @Param("map") Map<String, String> map);
  153. @Select("select max(infant_flag) FROM zy_detail_charge WHERE inpatient_no=#{patNo} and admiss_times=#{times}")
  154. int hasInfant(@Param("patNo") String patNo, @Param("times") Integer times);
  155. @Update("update zy_ledger_file set account_date=#{zjdzDatetime},settle_type='1',balance=0,dept_code=#{deptCode}," +
  156. "last_balance=total_charge,settle=deposit-total_charge,ward_code=#{wardCode},op_id_code=#{staffId}," +
  157. "responce_type='01',charge_yb=0,fund_pay_sumamt=0,acct_pay=0 from zy_ledger_file " +
  158. "where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  159. int updateZifeiCostStatus(MedinsSettleFee settleFee);
  160. @Update("update zy_ledger_file set account_date=#{zjdzDatetime},settle_type='1',balance=0,last_balance=#{xjzf}, " +
  161. "settle=(deposit-#{xjzf}),ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{staffId},charge_yb=0," +
  162. "fund_pay_sumamt=#{tczf},acct_pay=#{grzhzf},hosp_part_amt=#{hospitalPay} where inpatient_no=#{inpatientNo} " +
  163. "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  164. int updateCostStatusWithoutInfant(MedinsSettleFee settleFee);
  165. @Update("update zy_ledger_file set account_date=#{zjdzDatetime},settle_type='1',balance=0,charge_yb=0, " +
  166. "last_balance=(total_charge-#{tczf}-#{grzhzf}),settle=(deposit-total_charge+#{tczf}+#{grzhzf}), " +
  167. "ward_code=#{wardCode},dept_code=#{deptCode},op_id_code=#{staffId},fund_pay_sumamt=#{tczf}, " +
  168. "acct_pay=#{grzhzf},hosp_part_amt=#{hospitalPay} " +
  169. "where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  170. int updateCostStatusWithInfant(MedinsSettleFee settleFee);
  171. @Update("update zy_detail_charge set charge_status=3 where charge_status=2 and " +
  172. "inpatient_no=#{patNo} AND admiss_times=#{times} AND ledger_sn=#{ledgerSn}")
  173. int updateZyDetailCharge(@Param("patNo") String patNo,
  174. @Param("times") Integer times, @Param("ledgerSn") int ledgerSn);
  175. @Select("select start_time from yz_act_order where inpatient_no=#{patNo} and admiss_times=#{times} " +
  176. "and status_flag > '1' and isnull(group_no, '00')='00' and order_code in ('06026','06053','05973')")
  177. Date selectActOrderDisDate(@Param("patNo") String patNo, @Param("times") Integer times);
  178. @Select("select start_time from yz_inact_order where inpatient_no=#{patNo} and admiss_times=#{times} " +
  179. "and status_flag > '1' and isnull(group_no, '00')='00' and order_code in ('06026','06053','05973')")
  180. Date selectActOrderDisDate2(@Param("patNo") String patNo, @Param("times") Integer times);
  181. @Update("update ${table} SET dis_date=#{disDate},dis_ward=ward,dis_dept=dept,job_nurse=#{codeRs}," +
  182. "bed_status='5' WHERE inpatient_no=#{patNo} AND admiss_times=#{times}")
  183. int updateZyActpatient(@Param("patNo") String patNo, @Param("times") Integer times,
  184. @Param("disDate") Date disDate, @Param("codeRs") String codeRs, @Param("table") String table);
  185. @Delete("DELETE FROM zy_inactpatient WHERE inpatient_no=#{patNo} AND admiss_times=#{times}")
  186. void deleteZyInactpatient(@Param("patNo") String patNo, @Param("times") Integer times);
  187. @Insert("INSERT INTO zy_inactpatient SELECT * FROM zy_actpatient WHERE inpatient_no=#{patNo} AND admiss_times=#{times}")
  188. int insertZyInactpatient(@Param("patNo") String patNo, @Param("times") Integer times);
  189. @Update("update ${table} SET dis_date=#{disDate},dis_ward=ward,dis_dept=dept WHERE inpatient_no >=#{patNo1} " +
  190. "and inpatient_no <= #{patNo6} and admiss_times=#{times}")
  191. void updateZyActpatientAgain(@Param("patNo1") String patNo1,
  192. @Param("patNo6") String patNo6,
  193. @Param("times") Integer times,
  194. @Param("disDate") Date disDate, @Param("table") String table);
  195. @Insert("INSERT INTO zy_inactpatient SELECT * FROM zy_actpatient WHERE inpatient_no >=#{patNo1} " +
  196. "and inpatient_no <= #{patNo6} and admiss_times=#{times}")
  197. void insertZyInactpatientAgain(@Param("patNo1") String patNo1,
  198. @Param("patNo6") String patNo6,
  199. @Param("times") Integer times);
  200. @Update("update zy_adt SET dis_date=#{disDate},orig_ward=#{wardCode},orig_dept=#{deptCode},orig_bed=#{bedNo} " +
  201. "WHERE inpatient_no=#{patNo} AND admiss_times=#{times} AND trans_times=0")
  202. int updateZyAdt(@Param("patNo") String patNo, @Param("times") Integer times,
  203. @Param("wardCode") String wardCode, @Param("deptCode") String deptCode,
  204. @Param("bedNo") String bedNo, @Param("disDate") Date disDate);
  205. @Update("update zy_bed_mi SET bed_status='1',admiss_times=NULL,inpatient_no=NULL WHERE " +
  206. "inpatient_no=#{patNo} AND admiss_times=#{times}")
  207. void updateZyBedMi(@Param("patNo") String patNo, @Param("times") Integer times);
  208. @Delete("DELETE FROM zy_actpatient WHERE inpatient_no=#{patNo}")
  209. void deleteZyActpatient(@Param("patNo") String patNo);
  210. @Delete("DELETE FROM zy_actpatient WHERE inpatient_no >= #{patNo1} and inpatient_no <= #{patNo6} " +
  211. " and admiss_times=#{times}")
  212. void deleteZyActpatientAgain(@Param("patNo1") String patNo1, @Param("patNo6") String patNo6,
  213. @Param("times") Integer times);
  214. @Insert("insert into zy_work_log (inpatient_no,admiss_times,ledger_sn,op_id,op_date,log_type," +
  215. "dept_code,ward_code,name) values (#{patNo},#{times},#{ledgerSn},#{codeRs}," +
  216. "getDate(),#{logType},#{deptCode},#{wardCode},#{userName})")
  217. int insertNewZyWorkLog(@Param("patNo") String patNo, @Param("times") Integer times,
  218. @Param("ledgerSn") int ledgerSn, @Param("wardCode") String wardCode,
  219. @Param("logType") String logType, @Param("deptCode") String deptCode,
  220. @Param("codeRs") String codeRs, @Param("userName") String userName);
  221. @Update("update ${table} set times_billed=(times_billed+1) where " +
  222. "inpatient_no=#{patNo} and admiss_times=#{times}")
  223. void updateTimesBilledByIncreaseOne(@Param("patNo") String patNo, @Param("times") Integer times, @Param("table") String table);
  224. @Insert("INSERT INTO zy_ledger_file (inpatient_no, admiss_times, ledger_sn, op_id_code, deposit, balance, " +
  225. "total_charge, charge1, charge2, charge3, charge4, charge5, charge6, charge7, charge8, charge9, " +
  226. "charge10, charge11, charge12, charge13, charge14, charge15, charge16, charge17, charge18, " +
  227. "charge19, charge20, last_balance, settle, settle_type) VALUES " +
  228. "(#{patNo}, #{times}, #{ledgerSn}, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, " +
  229. "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0')")
  230. void insertNewLedgerFile(@Param("patNo") String patNo,
  231. @Param("times") Integer times,
  232. @Param("ledgerSn") int ledgerSn);
  233. @Update("update zy_ledger_file set total_charge=" +
  234. "(select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} and " +
  235. "admiss_times=#{times} and ledger_sn=#{ledgerSn}) where inpatient_no=#{patNo} " +
  236. "and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  237. void updateZyLedgerFileTotalCharge(@Param("patNo") String patNo,
  238. @Param("times") Integer times,
  239. @Param("ledgerSn") int ledgerSn);
  240. @Select("select top 1 inpatient_no, admiss_times, depo_times, depo_date, op_id_code, depo_amount, depo_type, " +
  241. "status, ledger_sn, window_no, deleted from zy_deposit_file where inpatient_no=#{patNo} " +
  242. "and admiss_times=#{times} order by depo_times desc")
  243. DepositFile selectLatestDepositFile(@Param("patNo") String patNo,
  244. @Param("times") Integer times);
  245. @Select("select settle from zy_ledger_file where inpatient_no=#{patNo} and admiss_times=#{times} and " +
  246. "ledger_sn=#{ledgerSn}")
  247. String selectLastLedgerSettle(@Param("patNo") String patNo,
  248. @Param("times") Integer times,
  249. @Param("ledgerSn") Integer ledgerSn);
  250. @Insert("insert into zy_deposit_file (inpatient_no, admiss_times, depo_times, depo_date, op_id_code, " +
  251. "depo_amount, depo_type, status, ledger_sn, window_no, deleted) " +
  252. "values (#{inpatientNo},#{admissTimes},#{depoTimes},#{depoDate},#{opIdCode},#{depoAmount}, " +
  253. "#{depoType},#{status},#{ledgerSn},#{windowNo},#{deleted})")
  254. void insertNewDeposit(DepositFile depositFile);
  255. @Delete("delete from zy_deposit_file where inpatient_no=#{patNo} and admiss_times=#{times} and depo_type='B' ")
  256. void deleteZjdzSettleDeposit(@Param("patNo") String patNo,
  257. @Param("times") Integer times);
  258. @Update("update zy_detail_charge set ledger_sn=#{ledgerSn} where inpatient_no=#{patNo} " +
  259. "and admiss_times=#{times} and ledger_sn=#{lastSn} and charge_date>#{zjdzDate}")
  260. void updateFeesLedgerSn(@Param("patNo") String patNo,
  261. @Param("times") Integer times,
  262. @Param("ledgerSn") int ledgerSn,
  263. @Param("lastSn") int lastSn,
  264. @Param("zjdzDate") Date zjdzDate);
  265. @Update("update zy_actpatient set responce_type='01', visit_type='01', yb_type='', treat_type=''," +
  266. "yb_register_date=#{date} where inpatient_no=#{patNo} and admiss_times=#{times}")
  267. void clearMedinsInfo(@Param("patNo") String patNo, @Param("times") Integer times, @Param("date") Date date);
  268. @Select("select rtrim(hic_no_new) from a_patient_mi where inpatient_no=#{zyh}")
  269. String getHicNoNew(@Param("zyh") String zyh);
  270. @Update("update a_patient_mi set cpy=#{hicNew} where inpatient_no=#{zyh}")
  271. void updateCpy(@Param("zyh") String zyh, @Param("hicNew") String hicNew);
  272. @Update("update a_patient_mi set hic_no=#{hicNew} where inpatient_no=#{zyh}")
  273. void updateHic(@Param("zyh") String zyh, @Param("hicNew") String hicNew);
  274. @Select("select mdtrt_id,med_type from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  275. BriefMdtrtInfo selectMdtrtId(@Param("patNo") String patNo,
  276. @Param("times") Integer times,
  277. @Param("ledgerSn") int ledgerSn);
  278. @Select("select serial_no from t_injury_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  279. String selectInjurySerialNo(@Param("patNo") String patNo,
  280. @Param("times") Integer times,
  281. @Param("ledgerSn") int ledgerSn);
  282. @Select("select count(1) from zy_dis_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
  283. int hasDismissDiag(@Param("patNo") String patNo,
  284. @Param("times") Integer times);
  285. @Update("update zy_actpatient set total_charge=#{map.total},charge1=#{map.001},charge2=#{map.002}, " +
  286. "charge3=#{map.003},charge4=#{map.004},charge5=#{map.005},charge6=#{map.006},charge7=#{map.007}, " +
  287. "charge8=#{map.008},charge9=#{map.009},charge10=#{map.010},charge11=#{map.011},charge12=#{map.012}, " +
  288. "charge13=#{map.013},charge14=#{map.014},charge15=#{map.015},charge16=#{map.016},charge17=#{map.017}, " +
  289. "charge18=#{map.018},charge19=#{map.019},charge20=#{map.020},charge21=#{map.021},charge22=#{map.022}," +
  290. "charge23=#{map.023},charge24=#{map.024},charge25=#{map.025},charge26=#{map.026},charge27=#{map.027}, " +
  291. "charge28=#{map.028},charge29=0,charge30=0 where inpatient_no>=#{patNo1} and inpatient_no<=#{patNo6} and " +
  292. "admiss_times=#{times} ")
  293. void updateInfantfee(@Param("patNo1") String patNo1,
  294. @Param("patNo6") String patNo6,
  295. @Param("times") int times,
  296. @Param("map") Map<String, String> map);
  297. @Select("select b.bill_item_zy as bill_code, ledger_fee=sum(a.charge_fee), " +
  298. "infant_fee=sum(case when isnull(infant_flag,0)=1 then charge_fee else 0 end), " +
  299. "adult_fee=sum(case when isnull(infant_flag,0)!=1 then charge_fee else 0 end) " +
  300. "from zy_detail_charge a, zd_charge_item b " +
  301. "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and " +
  302. "a.ledger_sn=#{ledgerSn} and a.charge_status!='1' and " +
  303. "a.charge_date>=#{begntime} and a.charge_date<=#{endtime} and " +
  304. "a.charge_code=b.code group by b.bill_item_zy, a.ledger_sn")
  305. List<ReceiptFee> selectLedgerFees(@Param("patNo") String patNo,
  306. @Param("times") int times,
  307. @Param("ledgerSn") int ledgerSn,
  308. @Param("begntime") Date begntime,
  309. @Param("endtime") Date endtime);
  310. @Select("select code from zy_bill_item")
  311. List<String> selectBillCodes();
  312. @Select("select code from zy_zd_responce_type where med_type=(select med_type from t_si_pat_info " +
  313. "where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn} and isnull(mdtrt_id,'')!='')")
  314. String selectResponceType(@Param("patNo") String patNo,
  315. @Param("times") int times,
  316. @Param("ledgerSn") int ledgerSn);
  317. @Select("select cast(isnull(sum(depo_amount),0) as varchar(16)) from zy_deposit_file where " +
  318. "inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn} and " +
  319. "depo_type!='B' and status in (1,2) ")
  320. String selectDepositSumamt(@Param("patNo") String patNo,
  321. @Param("times") int times,
  322. @Param("ledgerSn") int ledgerSn);
  323. @Update("update zy_ledger_file set deposit=#{deposit}, balance=#{balance}, responce_type=#{restype}, " +
  324. "total_charge=#{map.total},charge1=#{map.001},charge2=#{map.002}, charge3=#{map.003},charge4=#{map.004}, " +
  325. "charge5=#{map.005},charge6=#{map.006},charge7=#{map.007}, charge8=#{map.008},charge9=#{map.009}, " +
  326. "charge10=#{map.010},charge11=#{map.011},charge12=#{map.012}, charge13=#{map.013},charge14=#{map.014}, " +
  327. "charge15=#{map.015},charge16=#{map.016},charge17=#{map.017}, charge18=#{map.018},charge19=#{map.019}, " +
  328. "charge20=#{map.020},charge21=#{map.021},charge22=#{map.022}, charge23=#{map.023},charge24=#{map.024}, " +
  329. "charge25=#{map.025},charge26=#{map.026},charge27=#{map.027}, charge28=#{map.028},charge29=0,charge30=0 " +
  330. "where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  331. void updateZyLedgerFileCharges(@Param("patNo") String patNo,
  332. @Param("times") int times,
  333. @Param("ledgerSn") int ledgerSn,
  334. @Param("deposit") String deposit,
  335. @Param("balance") String balance,
  336. @Param("restype") String restype,
  337. @Param("map") Map<String, String> map);
  338. @Update("update zy_actpatient set balance=#{balance},responce_type=#{restype}, total_charge=#{totalCost}, " +
  339. "charge1=#{map.001},charge2=#{map.002}, charge3=#{map.003},charge4=#{map.004},charge5=#{map.005}, " +
  340. "charge6=#{map.006},charge7=#{map.007}, charge8=#{map.008},charge9=#{map.009},charge10=#{map.010}, " +
  341. "charge11=#{map.011},charge12=#{map.012}, charge13=#{map.013},charge14=#{map.014},charge15=#{map.015}, " +
  342. "charge16=#{map.016},charge17=#{map.017}, charge18=#{map.018},charge19=#{map.019},charge20=#{map.020}, " +
  343. "charge21=#{map.021},charge22=#{map.022}, charge23=#{map.023},charge24=#{map.024},charge25=#{map.025}, " +
  344. "charge26=#{map.026},charge27=#{map.027}, charge28=#{map.028},charge29=0,charge30=0 where inpatient_no=#{patNo} ")
  345. void updateZyActpatientCharges(@Param("patNo") String patNo,
  346. @Param("totalCost") String totalCost,
  347. @Param("balance") String balance,
  348. @Param("restype") String restype,
  349. @Param("map") Map<String, String> map);
  350. @Select("select isnull(sum(charge_fee),0) from zy_detail_charge where inpatient_no=#{patNo} " +
  351. "and admiss_times=#{times} and ledger_sn>0 and isnull(charge_status,'1')!='1' ")
  352. String selectTotalCharge(@Param("patNo") String patNo,
  353. @Param("times") int times);
  354. @Select("select datediff(day,#{begn},#{end}) ")
  355. int selectInhospdays(@Param("begn") Date begn, @Param("end") Date end);
  356. @Select("select b.bill_item_zy as code,sum(a.charge_amount) as name from zy_detail_charge a, zd_charge_item b " +
  357. "where a.inpatient_no=#{patNo} and a.admiss_times=#{times} and a.charge_status!='1' and b.bill_item_zy " +
  358. "in ('003') and a.charge_code_mx not in ('017623','011062','010437','010435','011193') " +
  359. "and a.charge_code=b.code group by b.bill_item_zy")
  360. List<CodeName> selectChargeQuantities(@Param("patNo") String patNo,
  361. @Param("times") int times);
  362. }