SiMzDao.java 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. package thyyxxk.webserver.dao.his.medicalinsurance;
  2. import org.apache.ibatis.annotations.*;
  3. import thyyxxk.webserver.entity.markmtfees.*;
  4. import thyyxxk.webserver.entity.medicalinsurance.outpatient.MzPatientInfo;
  5. import thyyxxk.webserver.entity.medicalinsurance.outpatient.*;
  6. import thyyxxk.webserver.entity.medicalinsurance.query.InsuInfo;
  7. import thyyxxk.webserver.entity.medicalinsurance.query.PsnBaseInfo;
  8. import thyyxxk.webserver.entity.medicalinsurance.query.SiPatInfo;
  9. import java.util.List;
  10. /**
  11. * @description: 新医保门诊mapper
  12. * @author: DingJie
  13. * @create: 2021-06-28 14:35:25
  14. **/
  15. @Mapper
  16. public interface SiMzDao {
  17. @Select("select times from mz_patient_mi where patient_id=#{patientId} ")
  18. Integer selectMaxTimes(@Param("patientId") String patientId);
  19. @Select("select insuplc_admdvs from t_si_pat_info where " +
  20. "pat_no=#{patNo} and times=#{times} and ledger_sn=#{ledgerSn}")
  21. String selectAdmdvs(@Param("patNo") String patNo,
  22. @Param("times") int times,
  23. @Param("ledgerSn") int ledgerSn);
  24. @Select("SELECT a.patient_id,a.times,a.visit_dept_code,b.adress,b.phone_no, " +
  25. "b.name,b.age,sex=case when b.sex='1' then '男' when b.sex='2' then '女' else '未知' end, " +
  26. "visitDeptName=(select rtrim(name) from zd_unit_code where code=a.visit_dept_code), " +
  27. "a.doctor_code,a.visit_date,a.receipt_no,a.order_no,a.op_day, " +
  28. "doctorName=(select rtrim(name) from a_employee_mi where code=a.doctor_code), " +
  29. "doctorYbCode=(select rtrim(yb_code) from a_employee_mi where code=a.doctor_code), " +
  30. "icdText=case when nullif(a.icd_code_new,'') is null then rtrim(a.icd_text) else rtrim(a.icd_text_new) end, " +
  31. "settledFlag=(select count(1) from t_si_setlinfo where pat_no=#{patientId} and times=#{times} and revoked=0) " +
  32. "FROM mz_visit_table a, mz_patient_mi b " +
  33. "WHERE a.patient_id=#{patientId} AND a.times=#{times} and a.patient_id=b.patient_id")
  34. MzVisit selectMzVisit(@Param("patientId") String patientId,
  35. @Param("times") Integer times);
  36. @Select("select count(1) from t_mt_receipt where patient_id=#{patientId} and times=#{times} and " +
  37. "receipt_no=#{receiptNo} and order_no=#{orderNo}")
  38. int selectFeeCount(@Param("patientId") String patientId,
  39. @Param("times") Integer times,
  40. @Param("receiptNo") Integer receiptNo,
  41. @Param("orderNo") Integer orderNo);
  42. @Select("select rtrim(name) from a_employee_mi where code=#{code}")
  43. String selectDoctorName(@Param("code") String code);
  44. @Select("select rtrim(specification) from yp_zd_dict where code=#{code} and serial=#{serial}")
  45. String selectSpecification(@Param("code") String code, @Param("serial") String serial);
  46. @Select("select rtrim(supply_name) from mz_zd_supply_type where supply_code=#{code}")
  47. String selectSupplyName(@Param("code") String code);
  48. @Select("select rtrim(charge_unit) from zd_charge_item where code=#{code}")
  49. String selectXmChargeUnit(@Param("code") String code);
  50. @Select("select rtrim(name) from yp_zd_unit where code=#{code}")
  51. String selectDrugUnit(@Param("code") String code);
  52. @Insert("insert into t_mt_receipt (patient_id, times, receipt_no, order_no, item_no, his_item_name, " +
  53. "his_item_code, fee_date, input_date, medi_item_type, charge_fee, price, quantity, drug_win, " +
  54. "input_staff, input_man, serial_no, yb_trans_flag, charge_type, bill_item_code) values (" +
  55. "#{patientId},#{times},#{receiptNo},#{orderNo},#{itemNo},#{drugName},#{chargeItemCode}," +
  56. "#{priceTime},#{chargeDate},#{mediItemType},#{chargeFee},#{price},#{quantity},#{drugWin}," +
  57. "#{doctorCode},#{doctorName},#{serialNo},0, #{groupNo},#{billItemCode})")
  58. void insertBatchedMtFeeInfo(MzReceipt param);
  59. @Delete("delete from t_mt_receipt where patient_id=#{patientId} and times=#{times} and " +
  60. "receipt_no=#{receiptNo} and order_no=#{orderNo}")
  61. void deleteMzReceipt(OrderNo param);
  62. @Delete("delete from t_mt_receipt where patient_id=#{patNo} and times=#{times}")
  63. void deleteAllReceipts(@Param("patNo") String patNo,
  64. @Param("times") Integer times);
  65. @Select("select *, " +
  66. "chargeFee=(select sum(amount) from mz_deposit_file a where a.patient_id=patNo and a.times=temp.times and a.receipt_no=receiptNo), " +
  67. "status=(select count(1) from t_mt_receipt a where a.patient_id=patNo and a.times=temp.times and a.receipt_no=receiptNo) " +
  68. "from (SELECT rtrim(patient_id) patNo,times,rtrim(receipt_no) receiptNo,charge_date chargeDate FROM mz_deposit_file " +
  69. "where patient_id=#{patNo} and charge_date>=#{start} and charge_date<=#{end} " +
  70. " group by patient_id, times, receipt_no,charge_date) temp")
  71. List<MzDepositFile> selectMzDepositFiles(@Param("patNo") String patNo, @Param("start") String start, @Param("end") String end);
  72. @Select("select patient_id,times,receipt_no,order_no,item_no,charge_item_code, " +
  73. "charge_bill_code,quantity,unit_price,serial,serial_no, " +
  74. "frequency,drug_quan,drug_unit,supply_code,charge_date, " +
  75. "doctorName=(select rtrim(name) from a_employee_mi where code=doctor_code)," +
  76. "group_no,confirm_flag,instruction_text,drug_win,price_time,tc_no, " +
  77. "bill_item_code,doctor_code,tc_name,drugName=(case when group_no='00' then " +
  78. "(select name from zd_charge_item a where a.code=charge_item_code) else " +
  79. "(select top 1 name from yp_zd_dict a where a.code=charge_item_code) end)," +
  80. "nationalCode=(case when group_no='00' then " +
  81. "(select national_code from zd_charge_item a where a.code=charge_item_code) else " +
  82. "(select max(national_code) from yp_zd_dict a where a.code=charge_item_code) end) " +
  83. "from mz_charge_detail where patient_id=#{patNo} and times=#{times} and " +
  84. "receipt_no=#{receipt} and bill_item_code!='TC' and charge_item_code!='BILL99'")
  85. List<MzReceipt> selectMzCharge(@Param("patNo") String patNo, @Param("times") int times, @Param("receipt") int receipt);
  86. @Select("select max(national_code) from ${table} where code=#{code}")
  87. String selectNationalCode(@Param("code") String code, @Param("table") String table);
  88. @Delete("delete from t_si_mz_diag where pat_no=#{patNo} and times=#{times}")
  89. void deleteMzDiags(@Param("patNo") String patNo, @Param("times") int times);
  90. @Insert("insert into t_si_mz_diag (pat_no, times, diag_srt_no, diag_type, diag_code, diag_name, diag_dept, " +
  91. "dise_dor_no, dise_dor_name, diag_time, vali_flag, real_opter) " +
  92. "values (#{patNo}, #{times}, #{diagSrtNo}, #{diagType}, #{diagCode}, #{diagName}, #{diagDept}, " +
  93. "#{diseDorNo}, #{diseDorName}, #{diagTime}, #{valiFlag}, #{realOpter})")
  94. void insertNewMzDiag(SiMzDiag diag);
  95. @Update("update t_si_setlinfo set mz_saved=#{val} where pat_no=#{patNo} and times=#{times}")
  96. void updateMzSaved(@Param("patNo") String patNo, @Param("times") int times, @Param("val") int val);
  97. @Select("select count(1) from t_si_pat_info where pat_no=#{patNo} and times=#{times} ")
  98. int selectSiMzInfoCount(@Param("patNo") String patNo,
  99. @Param("times") int times);
  100. @Update("update t_si_pat_info set insutype=#{insutype},balc=#{balc} where pat_no=#{patNo} and times=#{times}")
  101. void updateSiZyInfoPsnNo(@Param("patNo") String patNo,
  102. @Param("times") int times,
  103. @Param("insutype") String insutype,
  104. @Param("balc") String balc);
  105. @Insert("insert into t_si_pat_info (pat_no, times, ledger_sn, psn_no, psn_cert_type, insutype, insuplc_admdvs, " +
  106. "certno, psn_name, gend, naty, brdy, age, med_type, psn_idet_type,psn_type,emp_name, create_datetime, balc) " +
  107. "values (#{patNo},#{times},#{ledgerSn},#{psnNo},#{psnCertType},#{insutype},#{insuplc},#{certno}," +
  108. "#{psnName},#{gend},#{naty},#{brdy},#{age},#{medType},#{psnIdetType},#{psnType},#{empName},getdate(),#{balc})")
  109. void insertSiMzInfoPsnNo(PsnBaseInfo psnBaseinfo);
  110. @Select("select * from t_si_pat_info where pat_no=#{patNo} and times=#{times}")
  111. SiPatInfo selectSiPatInfoForMz(@Param("patNo") String patNo,
  112. @Param("times") int times);
  113. }