SiZyDao.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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. // "diseDorNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=oper_id), " +
  39. // "diseDorName=(select rtrim(name) from a_employee_mi where code=oper_id), " +
  40. "op_date as diagTime " +
  41. "from zy_in_diag_yb where inpatient_no=#{patNo} and admiss_times=#{times}")
  42. List<AdmDiseinfo> selectAdmDiags(@Param("patNo") String patNo, @Param("times") int times);
  43. /**
  44. * 获取入院基本信息
  45. *
  46. * @param inpatientNo 住院号
  47. * @param ledgerSn 账页号
  48. * @return 入院基本信息
  49. */
  50. @Select("select b.psn_no,b.insutype,b.psn_name,isnull(a.yb_register_date,a.admiss_date) as begntime, " +
  51. "mdtrtCertType='02',b.certno as mdtrtCertNo,certType='1',b.certno,b.med_type, " +
  52. "rtrim(a.inpatient_no) as iptNo,a.dise_code as diseCodg,a.dise_name, " +
  53. "atddrNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=isnull(a.refer_physician,a.admiss_physician)), " +
  54. "chfpdrName=(select rtrim(name) from a_employee_mi where code=isnull(a.refer_physician,a.admiss_physician)), " +
  55. "rtrim(a.small_dept) as admDeptCodg, " +
  56. "admDeptName=(select rtrim(name) from zd_unit_code where code=a.small_dept), " +
  57. "rtrim(a.bed_no) as admBed,a.exp_content " +
  58. "from zy_actpatient a, t_si_pat_info b " +
  59. "where a.inpatient_no=#{inpatientNo} and b.pat_no=a.inpatient_no " +
  60. "and b.times=a.admiss_times and b.ledger_sn=#{ledgerSn}")
  61. AdmMdtrtinfo selectAdmMdtrtinfo(@Param("inpatientNo") String inpatientNo,
  62. @Param("ledgerSn") int ledgerSn);
  63. /**
  64. * 获取当前患者最大账页号
  65. *
  66. * @param inpatientNo 住院号
  67. * @param admissTimes 住院次数
  68. * @return 账页号
  69. */
  70. @Select("select isnull(max(ledger_sn), isnull(min(ledger_sn), 1)) from zy_ledger_file where " +
  71. "inpatient_no=#{inpatientNo} and admiss_times=#{admissTimes}")
  72. Integer selectMaxLedgerSn(@Param("inpatientNo") String inpatientNo,
  73. @Param("admissTimes") int admissTimes);
  74. /**
  75. * 撤销医保费用上传后,更改上传标志为0
  76. *
  77. * @param inpatientNo 住院号
  78. * @param admissTimes 住院次数
  79. * @param ledgerSn 账页号
  80. */
  81. @Update("update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{inpatientNo} and " +
  82. "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)!=2")
  83. void revokeAllUploadFee(@Param("inpatientNo") String inpatientNo,
  84. @Param("admissTimes") int admissTimes,
  85. @Param("ledgerSn") int ledgerSn);
  86. @Update("<script>" +
  87. "update zy_detail_charge set trans_flag_yb=0 where inpatient_no=#{inpatientNo} and " +
  88. "admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn} and isnull(trans_flag_yb,0)!=2 " +
  89. "and detail_sn in " +
  90. "<foreach collection='list' item='sn' separator=',' open='(' close=')'>" +
  91. "#{sn}</foreach>" +
  92. "</script>")
  93. void revokePartUploadFee(@Param("inpatientNo") String inpatientNo,
  94. @Param("admissTimes") int admissTimes,
  95. @Param("ledgerSn") int ledgerSn,
  96. @Param("list") List<Integer> list);
  97. @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{zyh} and " +
  98. "admiss_times=#{zycs} and detail_sn in (#{sn}, #{sn2})")
  99. void updateYbTransFlagInPair(@Param("zyh") String zyh, @Param("zycs") Integer zycs,
  100. @Param("sn") Integer sn, @Param("sn2") Integer sn2);
  101. @Update("update zy_detail_charge set trans_flag_yb=2 where inpatient_no=#{zyh} and " +
  102. "admiss_times=#{zycs} and detail_sn=#{sn} ")
  103. void updateSingleYbTransFlag(@Param("zyh") String zyh, @Param("zycs") Integer zycs, @Param("sn") Integer sn);
  104. /**
  105. * 更新患者医保报销金额
  106. *
  107. * @param fundPay 医保报销金额
  108. * @param inpatientNo 住院号
  109. * @param admissTimes 住院次数
  110. * @param ledgerSn 账页号
  111. */
  112. @Update("update zy_ledger_file set charge_yb=#{fundPay} where inpatient_no=#{inpatientNo} " +
  113. "and admiss_times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  114. void updateFundPay(@Param("fundPay") String fundPay,
  115. @Param("inpatientNo") String inpatientNo,
  116. @Param("admissTimes") int admissTimes,
  117. @Param("ledgerSn") int ledgerSn);
  118. /**
  119. * 获取预结算参数
  120. *
  121. * @param patNo 住院号
  122. * @param times 住院次数
  123. * @param ledgerSn 账页号
  124. * @return 预结算参数
  125. */
  126. @Select("select psn_no,certno as mdtrtCertNo,certno,mdtrtCertType='02', " +
  127. "psn_cert_type,psn_type,mdtrt_id,insutype,insuplc_admdvs, " +
  128. "medfeeSumamt=(select sum(charge_fee) from zy_detail_charge b where b.inpatient_no=a.pat_no " +
  129. "and b.admiss_times=a.times and b.ledger_sn=a.ledger_sn and isnull(b.infant_flag,0)=0 " +
  130. "and trans_flag_yb!=2 and charge_date<=#{endtime}) " +
  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 psn_no,certno as mdtrtCertNo,certno,mdtrtCertType='02', " +
  137. "psn_cert_type,psn_type,mdtrt_id,insutype,insuplc_admdvs, " +
  138. "medfeeSumamt=(select sum(charge_fee) from zy_detail_charge b where b.inpatient_no=a.pat_no " +
  139. "and b.admiss_times=a.times and b.ledger_sn=a.ledger_sn and isnull(b.infant_flag,0)=0 " +
  140. "and trans_flag_yb!=2 and charge_date>=#{begntime} and charge_date<=#{endtime}) " +
  141. "from t_si_pat_info a where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  142. PreSetlmt selectPreSetlmtForMidSetl(@Param("patNo") String patNo,
  143. @Param("times") int times,
  144. @Param("ledgerSn") int ledgerSn,
  145. @Param("begntime") Date begntime,
  146. @Param("endtime") Date endtime);
  147. @Select("select a.mdtrt_id,a.psn_no,a.insutype,b.start_time as endtime,b.exec_unit as dscgDeptCodg, " +
  148. "dscgDeptName=(select rtrim(name) from zd_unit_code where code=b.exec_unit) " +
  149. "from t_si_pat_info a, yz_act_order b " +
  150. "where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{ledgerSn} " +
  151. "and a.pat_no=b.inpatient_no and a.times=b.admiss_times " +
  152. "and b.status_flag>'1' and isnull(b.group_no, '00')='00' and b.order_code in ('06026','06053','05973')")
  153. Dscginfo selectDscginfo(@Param("patNo") String patNo,
  154. @Param("times") int times,
  155. @Param("ledgerSn") int ledgerSn);
  156. @Select("select a.mdtrt_id,a.psn_no,a.insutype,b.small_dept as dscgDeptCodg, " +
  157. "dscgDeptName=(select rtrim(name) from zd_unit_code where code=b.small_dept) " +
  158. "from t_si_pat_info a, zy_actpatient b " +
  159. "where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=#{ledgerSn} " +
  160. "and a.pat_no=b.inpatient_no and a.times=b.admiss_times ")
  161. Dscginfo selectDscginfoForMidSetl(@Param("patNo") String patNo,
  162. @Param("times") int times,
  163. @Param("ledgerSn") int ledgerSn);
  164. @Select("select insuplc_admdvs from t_si_pat_info where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  165. String selectAdmdvs(@Param("patNo") String patNo,
  166. @Param("times") int times,
  167. @Param("ledgerSn") int ledgerSn);
  168. /**
  169. * 获取患者出院医保诊断
  170. *
  171. * @param patNo 住院号
  172. * @param times 住院次数
  173. * @param ledgerSn 账页号
  174. * @return 患者出院医保诊断
  175. */
  176. @Select("select b.mdtrt_id,b.psn_no, " +
  177. "a.si_diag_type as diagType, " +
  178. "maindiagFlag=case when a.dis_diag_no=1 then 1 else 0 end, " +
  179. "a.dis_diag_no as diagSrtNo, " +
  180. "rtrim(a.dis_diag) as diagCode, " +
  181. "rtrim(a.dis_diag_comment) as diagName, " +
  182. "diagDept=(select rtrim(dept_code) from a_employee_mi where code=a.op_id_code), " +
  183. "diseDorNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=op_id_code), " +
  184. "diseDorName=(select rtrim(name) from a_employee_mi where code=a.op_id_code), " +
  185. "a.op_diag_date as diagTime " +
  186. "from zy_dis_diag_yb a, t_si_pat_info b " +
  187. "where b.pat_no=#{patNo} and b.times=#{times} and b.ledger_sn=#{ledgerSn} " +
  188. "and a.inpatient_no=b.pat_no and a.admiss_times=b.times")
  189. List<SetlDiseinfo> selectSetlDises(@Param("patNo") String patNo,
  190. @Param("times") int times,
  191. @Param("ledgerSn") int ledgerSn);
  192. /**
  193. * 入院登记成功后更新患者医保信息
  194. *
  195. * @param p 患者基本信息
  196. */
  197. @Update("update t_si_pat_info set insuplc_admdvs=#{insuplcAdmdvs},psn_type=#{psnType},emp_name=#{empName},balc=#{balc}," +
  198. "mdtrt_id=#{mdtrtId},insutype=#{insutype},visit_datetime=#{ybRegisterDate},adm_reg_msgid=#{admRegMsgid} " +
  199. "where pat_no=#{inpatientNo} and times=#{admissTimes} and ledger_sn=#{ledgerSn}")
  200. void afterAdmissRegister(ZyPatientInfo p);
  201. @Update("update zy_actpatient set responce_type=#{restype},med_type=#{medtype} where inpatient_no=#{patNo} ;" +
  202. "update zy_ledger_file set responce_type=#{restype} where inpatient_no=#{patNo} " +
  203. "and admiss_times=#{times} and ledger_sn=#{sn}")
  204. void updateResponceType(@Param("restype") String restype,
  205. @Param("medtype") String medtype,
  206. @Param("patNo") String patNo,
  207. @Param("times") int times,
  208. @Param("sn") int sn);
  209. @Select("select code from zy_zd_responce_type where med_type=#{medtype} ")
  210. String selectResponceType(@Param("medtype") String medtype);
  211. @Update("update t_si_setlinfo set revoked=1 where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  212. void deleteSetlInfo(@Param("patNo") String patNo, @Param("times") int times, @Param("ledgerSn") int ledgerSn);
  213. @Update("delete from t_si_setldetail where pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  214. void deleteSetlDetail(@Param("patNo") String patNo, @Param("times") int times, @Param("ledgerSn") int ledgerSn);
  215. @Update("update t_si_pat_info set rvk_setl_msgid=#{rvkSetlMsgid} where " +
  216. "pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  217. void updateRvkSetlMsgid(@Param("patNo") String patNo,
  218. @Param("times") int times,
  219. @Param("ledgerSn") int ledgerSn,
  220. @Param("rvkSetlMsgid") String rvkSetlMsgid);
  221. @Delete("delete from t_si_setl_fee_detl where mdtrt_id=#{mdtrtId}")
  222. void deleteSiSetlFeeDetl(@Param("mdtrtId") String mdtrtId);
  223. @Delete("delete from zy_ledger_file_yb where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  224. void deleteZyLedgerFileYb(@Param("patNo") String patNo,
  225. @Param("times") int times,
  226. @Param("ledgerSn") int ledgerSn);
  227. @Delete("delete from zy_receipt where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  228. void deleteZyReceipt(@Param("patNo") String patNo,
  229. @Param("times") int times,
  230. @Param("ledgerSn") int ledgerSn);
  231. @Update("update zy_ledger_file set settle_type=0 where inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  232. void updateSettleType(@Param("patNo") String patNo,
  233. @Param("times") int times,
  234. @Param("ledgerSn") int ledgerSn);
  235. @Update("update zy_detail_charge set charge_status=2 where charge_status=3 and " +
  236. "inpatient_no=#{patNo} and admiss_times=#{times} and ledger_sn=#{ledgerSn}")
  237. void updateChargeStatus(@Param("patNo") String patNo,
  238. @Param("times") int times,
  239. @Param("ledgerSn") int ledgerSn);
  240. }