SiZyDao.java 13 KB

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