MobilePayService.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. package thyyxxk.simzfeeoprnsystm.service;
  2. import lombok.extern.slf4j.Slf4j;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5. import thyyxxk.simzfeeoprnsystm.dao.MobilePayDao;
  6. import thyyxxk.simzfeeoprnsystm.pojo.*;
  7. import thyyxxk.simzfeeoprnsystm.pojo.mobilepay.*;
  8. import thyyxxk.simzfeeoprnsystm.utils.DateUtil;
  9. import thyyxxk.simzfeeoprnsystm.utils.StringUtil;
  10. import java.io.IOException;
  11. import java.util.List;
  12. import java.util.Objects;
  13. @Slf4j
  14. @Service
  15. public class MobilePayService {
  16. private final MobilePayDao dao;
  17. private final SiMzFeeService mzService;
  18. @Autowired
  19. public MobilePayService(MobilePayDao dao, SiMzFeeService mzService) throws IOException {
  20. this.dao = dao;
  21. this.mzService = mzService;
  22. }
  23. private String writeMtReceipt(String patNo, Integer times) {
  24. MzPatientInfo mzptnt = new MzPatientInfo();
  25. mzptnt.setPatNo(patNo);
  26. mzptnt.setTimes(times);
  27. return mzService.generateSiMzFees(mzptnt);
  28. }
  29. public Upload6201 getUpload6201(InsuinfoRequest request) throws Exception {
  30. String wrt = writeMtReceipt(request.getPatNo(), request.getTimes());
  31. if (!Objects.equals(wrt, "SUCCESS")) {
  32. return null;
  33. }
  34. Upload6201 upload6201 = dao.selectUpload6201(request.getPatNo(), request.getTimes());
  35. if (null == upload6201) {
  36. // mz_visit_table为空
  37. throw new Exception("患者就诊信息为空,请联系医生重开处方。");
  38. }
  39. upload6201.setMedType("11");
  40. upload6201.setCaty(upload6201.getDeptId());
  41. List<Diseinfo> diseinfoList = dao.selectMpDiseinfos(request.getPatNo(), request.getTimes());
  42. if (diseinfoList.isEmpty()) {
  43. VisitTableIcd icd = dao.selectMzVisitIcd(request.getPatNo(), request.getTimes());
  44. if (null == icd || StringUtil.isBlank(icd.getIcdCode())) {
  45. throw new Exception("医保标准诊断不能为空,请联系医生填写。");
  46. }
  47. String[] icdCodeArr = icd.getIcdCode().split(",");
  48. String[] icdNameArr = icd.getIcdName().split(",");
  49. for (int i = 0; i < icdCodeArr.length; i++) {
  50. Diseinfo diseinfo = new Diseinfo();
  51. diseinfo.setDiagType("1");
  52. diseinfo.setDiagSrtNo(i + 1);
  53. diseinfo.setDiagCode(icdCodeArr[i]);
  54. diseinfo.setDiagName(icdNameArr[i]);
  55. diseinfo.setDiagDept(upload6201.getDeptName());
  56. diseinfo.setDiseDorNo(icd.getDrCode());
  57. diseinfo.setDiseDorName(icd.getDrName());
  58. diseinfo.setDiagTime(DateUtil.formatDatetime(icd.getVisitDate()));
  59. diseinfo.setValiFlag("1");
  60. diseinfoList.add(diseinfo);
  61. }
  62. }
  63. upload6201.setDiseinfoList(diseinfoList);
  64. upload6201.setFeedetailList(dao.selectMpFees(request.getPatNo(), request.getTimes()));
  65. return upload6201;
  66. }
  67. }