SiMzDao.java 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.webserver.entity.dictionary.CodeName;
  4. import thyyxxk.webserver.entity.markmtfees.*;
  5. import thyyxxk.webserver.entity.medicalinsurance.inpatient.AdmDiseinfo;
  6. import thyyxxk.webserver.entity.medicalinsurance.inpatient.AdmMdtrtinfo;
  7. import thyyxxk.webserver.entity.medicalinsurance.inpatient.Dscginfo;
  8. import thyyxxk.webserver.entity.medicalinsurance.inpatient.PreSetlmt;
  9. import thyyxxk.webserver.entity.medicalinsurance.outpatient.*;
  10. import thyyxxk.webserver.entity.medicalinsurance.query.PsnBaseInfo;
  11. import thyyxxk.webserver.entity.outpatient.medicalinfo.MzBlRecord;
  12. import java.util.Date;
  13. import java.util.List;
  14. /**
  15. * @description: 新医保门诊mapper
  16. * @author: DingJie
  17. * @create: 2021-06-28 14:35:25
  18. **/
  19. @Mapper
  20. public interface SiMzDao {
  21. @Select("select times from mz_patient_mi where patient_id=#{patientId} ")
  22. int selectMaxTimes(String patientId);
  23. @Select("select max(insuplc_admdvs) from t_si_pat_info where pat_no=#{patNo} and times=#{times} ")
  24. String selectAdmdvs(String patNo, int times);
  25. @Select("select * from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
  26. PsnBaseInfo selectPsnBaseinfo(String patNo, int times);
  27. @Select("SELECT rtrim(a.patient_id) as patientId,a.times,a.visit_dept_code,b.adress,rtrim(b.phone_no) as phoneNo, " +
  28. "rtrim(b.name) as name,b.age,sex=case when b.sex='1' then '男' when b.sex='2' then '女' else '未知' end, " +
  29. "visitDeptName=(select rtrim(name) from zd_unit_code where code=a.visit_dept_code), " +
  30. "a.doctor_code,a.visit_date,a.receipt_no,a.order_no,a.op_day,b.social_no, " +
  31. "doctorName=(select rtrim(name) from a_employee_mi where code=a.doctor_code), " +
  32. "doctorYbCode=(select rtrim(yb_code) from a_employee_mi where code=a.doctor_code), " +
  33. "icdText=case when nullif(a.icd_code_new,'') is null then rtrim(a.icd_text) else rtrim(a.icd_text_new) end, " +
  34. "admdvs=(select insuplc_admdvs from t_si_pat_info where pat_no=#{patientId} and times=#{times} and ledger_sn=0) " +
  35. "FROM mz_visit_table a, mz_patient_mi b " +
  36. "WHERE a.patient_id=#{patientId} AND a.times=#{times} and a.patient_id=b.patient_id")
  37. MzVisit selectMzVisit(String patientId, int times);
  38. @Select("select count(1) from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  39. int selectSiCount(String patNo, int times);
  40. @Select("select count(1) from powersi_mip_setlinfo where med_org_ord=#{hisOrdNum} and ord_state='SETTLED'")
  41. int selectMipayCount(String hisOrdNum);
  42. @Select("select count(1) from t_injury_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  43. int selectInjuryCount(String patNo, int times);
  44. @Select("select count(1) from t_mt_receipt where patient_id=#{patientId} and times=#{times} and " +
  45. "receipt_no=#{receiptNo} and order_no=#{orderNo}")
  46. int selectFeeCount(String patientId, int times, int receiptNo, int orderNo);
  47. @Select("select rtrim(name) from a_employee_mi where code=#{code}")
  48. String selectDoctorName(String code);
  49. @Select("select rtrim(specification) from yp_zd_dict where code=#{code} and serial=#{serial}")
  50. String selectSpecification(String code, String serial);
  51. @Select("select rtrim(supply_name) from mz_zd_supply_type where supply_code=#{code}")
  52. String selectSupplyName(String code);
  53. @Select("select rtrim(charge_unit) from zd_charge_item where code=#{code}")
  54. String selectXmChargeUnit(String code);
  55. @Select("select rtrim(name) from yp_zd_unit where code=#{code}")
  56. String selectDrugUnit(String code);
  57. @Select("select receipt_no from t_mt_receipt where patient_id=#{patNo} and times=#{times} group by receipt_no")
  58. List<Integer> selectGeneratedReceiptNos(String patNo, int times);
  59. @Select("select count(1) from mz_charge_detail where patient_id=#{patNo} and times=#{times} " +
  60. "and receipt_no=#{receiptNo} and pay_mark=0 and confirm_flag!=4")
  61. int isReceiptPayed(String patNo, int times, int receiptNo);
  62. @Delete("delete from t_mt_receipt where patient_id=#{patNo} and times=#{times} and receipt_no=#{receiptNo}")
  63. void deleteCertainReceipt(String patNo, int times, int receiptNo);
  64. @Insert("<script>" +
  65. "insert into t_mt_receipt (patient_id,times,receipt_no,order_no,item_no, " +
  66. "his_item_name,his_item_code,fee_date,input_date,medi_item_type,charge_fee, " +
  67. "price,quantity,drug_win,input_staff,input_man,serial_no,yb_trans_flag,charge_type, " +
  68. "bill_item_code,drug_unit,hosp_appr_flag) values " +
  69. "<foreach collection='list' item='item' separator=','>" +
  70. "(#{item.patientId},#{item.times},#{item.receiptNo},#{item.orderNo},#{item.itemNo}," +
  71. "#{item.drugName},#{item.chargeItemCode},#{item.priceTime},#{item.chargeDate},#{item.mediItemType}," +
  72. "#{item.chargeFee},#{item.price},#{item.quantity},#{item.drugWin},#{item.doctorCode}," +
  73. "#{item.doctorName},#{item.serialNo},0,#{item.groupNo},#{item.billItemCode},#{item.drugUnit}," +
  74. "#{item.hospApprFlag})" +
  75. "</foreach>" +
  76. "</script>")
  77. void insertMtReceipts(List<MzReceipt> list);
  78. @Delete("delete from t_mt_receipt where patient_id=#{patientId} and times=#{times} and " +
  79. "receipt_no=#{receiptNo} and order_no=#{orderNo}")
  80. void deleteMzReceipt(OrderNo param);
  81. @Delete("delete from t_mt_receipt where patient_id=#{patNo} and times=#{times}")
  82. void deleteAllReceipts(String patNo, int times);
  83. @Select("select rtrim(patient_id) as patNo,times,charge_date,receipt_no, " +
  84. "chargeFee=(select cast(sum(isnull(unit_price,0)*isnull(drug_win,1)*isnull(quantity,1)) as decimal(16,2))), " +
  85. "status=(select count(1) from t_mt_receipt d where d.patient_id=a.patient_id and d.times=a.times and d.receipt_no=a.receipt_no) " +
  86. "from mz_charge_detail a where a.patient_id=#{patNo} and a.charge_date>=#{start} and a.charge_date<=#{end} " +
  87. "and pay_mark=0 and confirm_flag!=4 and isnull(cash_id,'')!='99998' group by patient_id, times, charge_date,receipt_no order by times")
  88. List<MzDepositFile> selectMzDepositFiles(String patNo, String start, String end);
  89. @Select("select rtrim(patient_id) as patient_id,times,receipt_no,order_no,item_no,charge_item_code, " +
  90. "charge_bill_code,quantity,unit_price,serial,serial_no,frequency,drug_quan,charge_date, " +
  91. "supplyCode=(select top 1 rtrim(d.supply_name) from mz_zd_supply_type d where d.supply_code=a.supply_code)," +
  92. "doctorName=(select rtrim(d.name) from a_employee_mi d where d.code=a.doctor_code)," +
  93. "group_no,confirm_flag,instruction_text,drug_win,price_time,tc_no, " +
  94. "bill_item_code,doctor_code,tc_name,hosp_appr_flag," +
  95. "drugName=(case when group_no='00' then " +
  96. "(select d.name from zd_charge_item d where d.code=a.charge_item_code) else " +
  97. "(select top 1 d.name from yp_zd_dict d where d.code=a.charge_item_code) end)," +
  98. "drugUnit=(case when group_no='00' then " +
  99. "(select rtrim(d.charge_unit) from zd_charge_item d where d.code=a.charge_item_code) else " +
  100. "(select rtrim(d.name) from yp_zd_unit d where d.code=a.drug_unit) end)," +
  101. "specification=(case when group_no='00' then '' else " +
  102. "(select rtrim(d.specification) from yp_zd_dict d where d.code=a.charge_item_code and d.serial=a.serial) end)," +
  103. "ybComment=(case when group_no='00' then null else " +
  104. "(select max(d.yb_comment_new) from yp_zd_dict d where d.code=a.charge_item_code) end)," +
  105. "nationalCode=(case when group_no='00' then " +
  106. "(select isnull(d.national_code_27,d.national_code) from zd_charge_item d where d.code=a.charge_item_code) else " +
  107. "(select max(d.national_code) from yp_zd_dict d where d.code=a.charge_item_code) end) " +
  108. "from mz_charge_detail a where patient_id=#{patNo} and times=#{times} and " +
  109. "receipt_no=#{receipt} and pay_mark=0 and confirm_flag!=4 and bill_item_code!='TC' " +
  110. "and charge_item_code!='BILL99' and isnull(cash_id,'')!='99998'")
  111. List<MzReceipt> selectMzCharge(String patNo, int times, int receipt);
  112. @Select("select top 1 national_code from yp_zd_dict where code=#{code}")
  113. String selectYpNationalCode(String code);
  114. @Select("select isnull(national_code_27,national_code) from zd_charge_item where code=#{code}")
  115. String selectXmNationalCode(String code);
  116. @Select("select max(yb_comment_new) from yp_zd_dict where code=#{code} ")
  117. String selectYbComment(String code);
  118. @Delete("delete from t_si_mz_diag where pat_no=#{patNo} and times=#{times}")
  119. void deleteMzDiags(String patNo, int times);
  120. @Insert("insert into t_si_mz_diag (pat_no, times, diag_srt_no, diag_type, diag_code, diag_name, diag_dept, " +
  121. "dise_dor_no, dise_dor_name, diag_time, vali_flag, real_opter) " +
  122. "values (#{patNo}, #{times}, #{diagSrtNo}, #{diagType}, #{diagCode}, #{diagName}, #{diagDept}, " +
  123. "#{diseDorNo}, #{diseDorName}, #{diagTime}, #{valiFlag}, #{realOpter})")
  124. void insertNewMzDiag(SiMzDiag diag);
  125. @Update("update t_si_pat_info set insutype=#{insutype},balc=#{balc},insuplc_admdvs=#{admdvs}, " +
  126. "insuplc_admdvs_name=#{insuplcAdmdvsName} where pat_no=#{patNo} and times=#{times}")
  127. void updateSiZyInfoPsnNo(String patNo, int times, String insutype, String balc, String admdvs, String insuplcAdmdvsName);
  128. @Select("select count(1) from t_si_pat_info where pat_no=#{patNo} and times=#{times} ")
  129. int selectSiMzInfoCount(String patNo, int times);
  130. @Select("select top 1 * from t_si_pat_info where pat_no=#{patNo} order by times desc")
  131. PsnBaseInfo selectLatestPsnInfo(String patNo);
  132. @Insert("insert into t_si_pat_info (pat_no,times,ledger_sn,psn_no,psn_cert_type," +
  133. "insutype,insuplc_admdvs,insuplc_admdvs_name,certno,psn_name,gend,naty,brdy,age," +
  134. "med_type,psn_idet_type,psn_type,emp_name,create_datetime,balc) " +
  135. "values (#{patNo},#{times},#{ledgerSn},#{psnNo},#{psnCertType},#{insutype}," +
  136. "#{insuplc},#{insuplcAdmdvsName},#{certno},#{psnName},#{gend},#{naty},#{brdy},#{age}," +
  137. "#{medType},#{psnIdetType},#{psnType},#{empName},getdate(),#{balc})")
  138. void insertSiMzInfoPsnNo(PsnBaseInfo psnBaseinfo);
  139. @Update("update t_si_setlinfo set fund_pay_sumamt=#{fundPay},acct_pay=#{acctPay} " +
  140. "where pat_no=#{patientId} and times=#{times} and revoked=0")
  141. int modifyFundAmt(ModifyFundAmt amt);
  142. @Select("select count(1) from t_si_presetlinfo where pat_no=#{patNo} and times=#{times}")
  143. int selectPresettleCount(String patNo, int times);
  144. @Select("select staff_id from t_si_setlinfo where pat_no=#{patNo} and times=#{times} and revoked=0")
  145. String selectSetlStaff(String patNo, int times);
  146. @Select("select emr_chief_complaint,emr_hpi,emr_ps,emr_pe,emr_fzjc " +
  147. "from mz_bl_record where patient_id=#{patNo} and times=#{times} ")
  148. MzBlRecord selectMzBlRecord(String patNo, int times);
  149. @Select("select rtrim(max(receipt_bill)) from mz_receipt_serial " +
  150. "where patient_id=#{patNo} and times=#{times}")
  151. String selectReceiptBill(String patNo, int times);
  152. @Select("select result from t_si_log where msgid=#{msgid}")
  153. String getLogContent(String msgid);
  154. @Select("select b.psn_no,b.insutype,b.psn_name,a.visit_date as begntime, " +
  155. "mdtrtCertType=b.psn_cert_type,b.certno as mdtrtCertNo,certType=b.psn_cert_type,b.certno,b.med_type, " +
  156. "rtrim(a.patient_id) as iptNo, rtrim(a.visit_dept_code) as admDeptCodg, " +
  157. "atddrNo=(select rtrim(isnull(yb_code,code)) from a_employee_mi where code=a.doctor_code), " +
  158. "chfpdrName=(select rtrim(name) from a_employee_mi where code=a.doctor_code), " +
  159. "admDeptName=(select rtrim(name) from zd_unit_code where code=a.visit_dept_code), " +
  160. "admBed='JZ-1',exp_content='{}' from mz_visit_table a, t_si_pat_info b " +
  161. "where a.patient_id=#{patNo} and a.times=#{times} and b.pat_no=a.patient_id " +
  162. "and b.times=a.times and b.ledger_sn=0")
  163. AdmMdtrtinfo selectAdmMdtrtinfo(String patNo, int times);
  164. @Select("select endtime from t_si_setlinfo where pat_no=#{patNo} and times=#{times} " +
  165. "and ledger_sn=0 and revoked=0")
  166. Date selectSetlEndTime(String patNo, int times);
  167. @Select("select icd_code_new as code,icd_text_new as name from mz_visit_table " +
  168. "where patient_id=#{patNo} and times=#{times}")
  169. CodeName getMzIcd(String patNo, int times);
  170. @Select("select " +
  171. "psnNo=(select top 1 psn_no from t_si_pat_info where pat_no=#{patNo} and times=#{times}), " +
  172. "psnName=(select top 1 psn_name from t_si_pat_info where pat_no=#{patNo} and times=#{times}), " +
  173. "diag_type as diagType,diag_srt_no,diag_code,diag_name,diag_dept,diag_time, " +
  174. "maindiagFlag=case when diag_srt_no=1 then '1' else '0' end " +
  175. "from t_si_mz_diag where pat_no=#{patNo} and times=#{times}")
  176. List<AdmDiseinfo> getAdmDiseinfo(String patNo, int times);
  177. @Select("select psn_no,certno as mdtrtCertNo,certno,mdtrtCertType='02', " +
  178. "psn_cert_type,psn_type,psn_name,mdtrt_id,insutype,insuplc_admdvs, " +
  179. "medfeeSumamt=(select sum(charge_fee) from t_mt_receipt b where b.patient_id=a.pat_no " +
  180. "and b.times=a.times),expContent='{}'" +
  181. "from t_si_pat_info a where pat_no=#{patNo} and times=#{times} ")
  182. PreSetlmt getPreSetlmt(String patNo, int times);
  183. @Select("select a.mdtrt_id,a.psn_no,a.insutype,b.visit_date as endtime, " +
  184. "dscgDeptCodg=(select si_caty from zd_unit_code where code=b.visit_dept_code), " +
  185. "dscgDeptName=(select rtrim(name) from zd_unit_code where code=b.visit_dept_code) " +
  186. "from t_si_pat_info a, mz_visit_table b " +
  187. "where a.pat_no=#{patNo} and a.times=#{times} and a.ledger_sn=0 " +
  188. "and a.pat_no=b.patient_id and a.times=b.times")
  189. Dscginfo getDscginfo(String patNo, int times);
  190. @Select("select mdtrt_id from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
  191. String getMdtrtId(String patNo, int times);
  192. }