SiZyDao.java 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.webserver.entity.medicalinsurance.inpatient.ZyPatientInfo;
  4. import thyyxxk.webserver.entity.medicalinsurance.inpatient.*;
  5. import java.util.Date;
  6. import java.util.List;
  7. /**
  8. * @description: 新医保住院mapper
  9. * @author: DingJie
  10. * @create: 2021-05-28 14:50:31
  11. **/
  12. @Mapper
  13. public interface SiZyDao {
  14. /**
  15. * 获取员工姓名
  16. *
  17. * @param staffId 员工5位长度唯一编码
  18. * @return 员工姓名
  19. */
  20. @Select("select rtrim(name) from a_employee_mi where code=#{staffId}")
  21. String selectStaffName(@Param("staffId") String staffId);
  22. /**
  23. * 获取入院医保诊断
  24. *
  25. * @param patNo 住院号
  26. * @param times 住院次数
  27. * @return 入院医保诊断
  28. */
  29. @Select("select psnNo=(select top 1 psn_no from t_si_pat_info where pat_no=#{patNo} and times=#{times}), " +
  30. "psnName=(select top 1 psn_name from t_si_pat_info where pat_no=#{patNo} and times=#{times}), " +
  31. "diag_type as diagType, " +
  32. "maindiagFlag=case when diag_no=1 then '1' else '0' end, " +
  33. "diag_no as diagSrtNo, " +
  34. "icd_code as diagCode, " +
  35. "icd_text as diagName, " +
  36. "diagDept=(select rtrim(name) from zd_unit_code where code=( " +
  37. "select small_dept from zy_actpatient where zy_actpatient.inpatient_no=zy_in_diag_yb.inpatient_no)), " +
  38. "op_date as diagTime " +
  39. "from zy_in_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
  40. List<AdmDiseinfo> selectAdmDiags(@Param("patNo") String patNo, @Param("times") int times);
  41. /**
  42. * 获取入院基本信息
  43. *
  44. * @param inpatientNo 住院号
  45. * @param ledgerSn 账页号
  46. * @return 入院基本信息
  47. */
  48. @Select("select b.psn_no,b.insutype,b.psn_name,isnull(a.yb_register_date,a.admiss_date) as begntime, " +
  49. "mdtrtCertType='02',b.certno as mdtrtCertNo,certType='1',b.certno,b.med_type, " +
  50. "rtrim(a.inpatient_no) as iptNo,a.dise_code as diseCodg,a.dise_name, " +
  51. "atddrNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=isnull(a.refer_physician,a.admiss_physician)), " +
  52. "chfpdrName=(select rtrim(name) from a_employee_mi where code=isnull(a.refer_physician,a.admiss_physician)), " +
  53. "rtrim(a.small_dept) as admDeptCodg, " +
  54. "admDeptName=(select rtrim(name) from zd_unit_code where code=a.small_dept), " +
  55. "rtrim(a.bed_no) as admBed,a.exp_content " +
  56. "from zy_actpatient a, t_si_pat_info b " +
  57. "where a.inpatient_no=#{inpatientNo} and b.pat_no=a.inpatient_no " +
  58. "and b.times=a.admiss_times and b.ledger_sn=#{ledgerSn}")
  59. AdmMdtrtinfo selectAdmMdtrtinfo(@Param("inpatientNo") String inpatientNo,
  60. @Param("ledgerSn") int ledgerSn);
  61. @Select("select endtime from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and ledger_sn=1 and revoked=0")
  62. Date selectSetlEndTime(@Param("patNo") String patNo,
  63. @Param("times") int times);
  64. /**
  65. * 获取当前患者最大账页号
  66. *
  67. * @param inpatientNo 住院号
  68. * @param admissTimes 住院次数
  69. * @return 账页号
  70. */
  71. @Select("select isnull(max(ledger_sn), isnull(min(ledger_sn), 1)) from zy_ledger_file where " +
  72. "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
  73. Integer selectMaxLedgerSn(@Param("inpatientNo") String inpatientNo,
  74. @Param("admissTimes") int admissTimes);
  75. /**
  76. * 撤销医保费用上传后,更改上传标志为0
  77. *
  78. * @param inpatientNo 住院号
  79. * @param admissTimes 住院次数
  80. * @param ledgerSn 账页号
  81. */
  82. @Update("update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{inpatientNo} and " +
  83. "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)!=2")
  84. void revokeAllUploadFee(@Param("inpatientNo") String inpatientNo,
  85. @Param("admissTimes") int admissTimes,
  86. @Param("ledgerSn") int ledgerSn);
  87. @Update("update zy_ledger_file set charge_yb=0,fund_pay_sumamt=0 where inpatient_no=#{inpatientNo} " +
  88. "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  89. void resetFundpayAmt(@Param("inpatientNo") String inpatientNo,
  90. @Param("admissTimes") int admissTimes,
  91. @Param("ledgerSn") int ledgerSn);
  92. @Update("<script>" +
  93. "update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{inpatientNo} and " +
  94. "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)!=2 " +
  95. "and detail_sn in " +
  96. "<foreach collection='list' item='sn' separator=',' open='(' close=')'>" +
  97. "#{sn}</foreach>" +
  98. "</script>")
  99. void revokePartUploadFee(@Param("inpatientNo") String inpatientNo,
  100. @Param("admissTimes") int admissTimes,
  101. @Param("ledgerSn") int ledgerSn,
  102. @Param("list") List<Integer> list);
  103. /**
  104. * 更新患者医保报销金额
  105. *
  106. * @param fundPay 医保报销金额
  107. * @param inpatientNo 住院号
  108. * @param admissTimes 住院次数
  109. * @param ledgerSn 账页号
  110. */
  111. @Update("update zy_ledger_file set charge_yb=#{fundPay},fund_pay_sumamt=#{fundPay} " +
  112. "where inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  113. void updateFundPay(@Param("fundPay") String fundPay,
  114. @Param("inpatientNo") String inpatientNo,
  115. @Param("admissTimes") int admissTimes,
  116. @Param("ledgerSn") int ledgerSn);
  117. /**
  118. * 获取预结算参数
  119. *
  120. * @param patNo 住院号
  121. * @param times 住院次数
  122. * @param ledgerSn 账页号
  123. * @return 预结算参数
  124. */
  125. @Select("select psn_no,certno as mdtrtCertNo,certno,mdtrtCertType='02', " +
  126. "psn_cert_type,psn_type,psn_name,mdtrt_id,insutype,insuplc_admdvs, " +
  127. "medfeeSumamt=(select sum(charge_fee) from zy_detail_charge b where b.inpatient_no=a.pat_no " +
  128. "and b.admiss_times=a.times and b.ledger_sn=a.ledger_sn and isnull(b.infant_flag,0)=0 " +
  129. "and trans_flag_yb!=2 and charge_date<=#{endtime})," +
  130. "expContent=(select d.exp_content from zy_actpatient d where d.inpatient_no=#{patNo}) " +
  131. "from t_si_pat_info a where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  132. PreSetlmt selectPreSetlmt(@Param("patNo") String patNo,
  133. @Param("times") int times,
  134. @Param("ledgerSn") int ledgerSn,
  135. @Param("endtime") String endtime);
  136. @Select("select start_time from yz_act_order with(nolock) where inpatient_no=#{patNo} and admiss_times=#{times} " +
  137. "and status_flag > '1' and isnull(group_no, '00')='00' and order_code in ('06026','06053','05973') and status_flag!='6' ")
  138. Date selectActOrderDisDate(@Param("patNo") String patNo, @Param("times") Integer times);
  139. @Select("select psn_no,certno as mdtrtCertNo,certno,mdtrtCertType='02', " +
  140. "psn_cert_type,psn_type,mdtrt_id,insutype,insuplc_admdvs, " +
  141. "medfeeSumamt=(select sum(charge_fee) from zy_detail_charge b where b.inpatient_no=a.pat_no " +
  142. "and b.admiss_times=a.times and b.ledger_sn=a.ledger_sn and isnull(b.infant_flag,0)=0 " +
  143. "and trans_flag_yb!=2 and charge_date>=#{begntime} and charge_date<=#{endtime}) " +
  144. "from t_si_pat_info a where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  145. PreSetlmt selectPreSetlmtForMidSetl(@Param("patNo") String patNo,
  146. @Param("times") int times,
  147. @Param("ledgerSn") int ledgerSn,
  148. @Param("begntime") Date begntime,
  149. @Param("endtime") Date endtime);
  150. @Select("select a.mdtrt_id,a.psn_no,a.insutype,b.start_time as endtime, " +
  151. "dscgDeptCodg=(select si_caty from zd_unit_code where code=c.zk_ward)," +
  152. "dscgDeptName=(select rtrim(name) from zd_unit_code where code=c.zk_ward) " +
  153. "from t_si_pat_info a, yz_act_order b,zy_actpatient c " +
  154. "where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{ledgerSn} " +
  155. "and a.pat_no=b.inpatient_no and a.times=b.admiss_times and a.pat_no=c.inpatient_no " +
  156. "and b.status_flag>'1' and isnull(b.group_no, '00')='00' and b.order_code in ('06026','06053','05973')")
  157. Dscginfo selectDscginfo(@Param("patNo") String patNo,
  158. @Param("times") int times,
  159. @Param("ledgerSn") int ledgerSn);
  160. @Select("select a.mdtrt_id,a.psn_no,a.insutype, " +
  161. "dscgDeptCodg=(select si_caty from zd_unit_code where code=b.zk_ward), " +
  162. "dscgDeptName=(select rtrim(name) from zd_unit_code where code=b.zk_ward) " +
  163. "from t_si_pat_info a, zy_actpatient b " +
  164. "where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{ledgerSn} " +
  165. "and a.pat_no=b.inpatient_no and a.times=b.admiss_times ")
  166. Dscginfo selectDscginfoForMidSetl(@Param("patNo") String patNo,
  167. @Param("times") int times,
  168. @Param("ledgerSn") int ledgerSn);
  169. @Select("select insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  170. String selectAdmdvs(@Param("patNo") String patNo,
  171. @Param("times") int times,
  172. @Param("ledgerSn") int ledgerSn);
  173. /**
  174. * 获取患者出院医保诊断
  175. *
  176. * @param patNo 住院号
  177. * @param times 住院次数
  178. * @param ledgerSn 账页号
  179. * @return 患者出院医保诊断
  180. */
  181. @Select("select b.mdtrt_id,b.psn_no, " +
  182. "a.si_diag_type as diagType, " +
  183. "maindiagFlag=case when a.dis_diag_no=1 then 1 else 0 end, " +
  184. "a.dis_diag_no as diagSrtNo, " +
  185. "rtrim(a.dis_diag) as diagCode, " +
  186. "rtrim(a.dis_diag_comment) as diagName, " +
  187. "diagDept=(select rtrim(dept_code) from a_employee_mi where code=a.op_id_code), " +
  188. "diseDorNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=op_id_code), " +
  189. "diseDorName=(select rtrim(name) from a_employee_mi where code=a.op_id_code), " +
  190. "a.op_diag_date as diagTime " +
  191. "from zy_dis_diag_yb a, t_si_pat_info b " +
  192. "where b.pat_no=#{patNo} and b.times=#{times} and b.ledger_sn=#{ledgerSn} " +
  193. "and a.inpatient_no=b.pat_no and a.admiss_times=b.times")
  194. List<SetlDiseinfo> selectSetlDises(@Param("patNo") String patNo,
  195. @Param("times") int times,
  196. @Param("ledgerSn") int ledgerSn);
  197. /**
  198. * 入院登记成功后更新患者医保信息
  199. *
  200. * @param p 患者基本信息
  201. */
  202. @Update("update t_si_pat_info set insuplc_admdvs=#{insuplcAdmdvs},psn_type=#{psnType},emp_name=#{empName},balc=#{balc}," +
  203. "mdtrt_id=#{mdtrtId},insutype=#{insutype},visit_datetime=#{ybRegisterDate},adm_reg_msgid=#{admRegMsgid} " +
  204. "where pat_no=#{inpatientNo} and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  205. void afterAdmissRegister(ZyPatientInfo p);
  206. @Update("update zy_actpatient set responce_type=#{restype},med_type=#{medtype} where inpatient_no=#{patNo} ;" +
  207. "update zy_ledger_file set responce_type=#{restype} where inpatient_no=#{patNo} " +
  208. "and admiss_times=#{times} and ledger_sn=#{sn}")
  209. void updateResponceType(@Param("restype") String restype,
  210. @Param("medtype") String medtype,
  211. @Param("patNo") String patNo,
  212. @Param("times") int times,
  213. @Param("sn") int sn);
  214. @Update("update zy_detail_charge set trans_flag_yb='2' where inpatient_no=#{patNo} " +
  215. "and admiss_times=#{times} and ledger_sn in (#{sn1}, #{sn2})")
  216. void updateTransFlag(@Param("patNo") String patNo,
  217. @Param("times") int times,
  218. @Param("sn1") int sn1,
  219. @Param("sn2") int sn2);
  220. @Select("select code from zy_zd_responce_type where med_type=#{medtype} ")
  221. String selectResponceType(@Param("medtype") String medtype);
  222. @Update("update t_si_setlinfo set revoked=1 where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  223. void deleteSetlInfo(@Param("patNo") String patNo, @Param("times") int times, @Param("ledgerSn") int ledgerSn);
  224. @Update("delete from t_si_setldetail where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  225. void deleteSetlDetail(@Param("patNo") String patNo, @Param("times") int times, @Param("ledgerSn") int ledgerSn);
  226. @Update("update t_si_pat_info set rvk_setl_msgid=#{rvkSetlMsgid} where " +
  227. "pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  228. void updateRvkSetlMsgid(@Param("patNo") String patNo,
  229. @Param("times") int times,
  230. @Param("ledgerSn") int ledgerSn,
  231. @Param("rvkSetlMsgid") String rvkSetlMsgid);
  232. @Delete("delete from t_si_setl_fee_detl where mdtrt_id=#{mdtrtId}")
  233. void deleteSiSetlFeeDetl(@Param("mdtrtId") String mdtrtId);
  234. @Delete("delete from zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  235. void deleteZyLedgerFileYb(@Param("patNo") String patNo,
  236. @Param("times") int times,
  237. @Param("ledgerSn") int ledgerSn);
  238. @Delete("delete from zy_receipt where inpatient_no=#{patNo} and admiss_times=#{times} " +
  239. "and ledger_sn=#{ledgerSn} and receipt_no='00000000'")
  240. void deleteZyReceipt(@Param("patNo") String patNo,
  241. @Param("times") int times,
  242. @Param("ledgerSn") int ledgerSn);
  243. @Update("update zy_ledger_file set settle_type=0 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  244. void updateSettleType(@Param("patNo") String patNo,
  245. @Param("times") int times,
  246. @Param("ledgerSn") int ledgerSn);
  247. @Update("update zy_detail_charge set charge_status=2 where charge_status=3 and " +
  248. "inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  249. void updateChargeStatus(@Param("patNo") String patNo,
  250. @Param("times") int times,
  251. @Param("ledgerSn") int ledgerSn);
  252. }