SiAdmVerifyService.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. package thyyxxk.webserver.service.medicalinsurance;
  2. import lombok.RequiredArgsConstructor;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.springframework.stereotype.Service;
  5. import thyyxxk.webserver.config.exception.ExceptionEnum;
  6. import thyyxxk.webserver.constants.sidicts.MedType;
  7. import thyyxxk.webserver.dao.his.medicalinsurance.SiAdmVerifyDao;
  8. import thyyxxk.webserver.entity.ResultVo;
  9. import thyyxxk.webserver.entity.medicalinsurance.inpatient.SiAdmissApply;
  10. import thyyxxk.webserver.entity.inpatient.patient.Patient;
  11. import thyyxxk.webserver.entity.inpatient.patient.ZyInYbDiag;
  12. import thyyxxk.webserver.service.hutoolcache.RegionCache;
  13. import thyyxxk.webserver.service.hutoolcache.UserCache;
  14. import thyyxxk.webserver.service.inpatient.PatientService;
  15. import thyyxxk.webserver.utils.ResultVoUtil;
  16. import thyyxxk.webserver.utils.StringUtil;
  17. import thyyxxk.webserver.utils.TokenUtil;
  18. import java.util.HashMap;
  19. import java.util.List;
  20. import java.util.Map;
  21. import java.util.Objects;
  22. /**
  23. * @author dj
  24. */
  25. @Slf4j
  26. @Service
  27. @RequiredArgsConstructor
  28. public class SiAdmVerifyService {
  29. private final SiAdmVerifyDao dao;
  30. private final PatientService ptntSrvc;
  31. private final UserCache userCache;
  32. private final RegionCache regionCache;
  33. public ResultVo<SiAdmissApply> selectAdmissApply(Patient p) {
  34. MedType medType = MedType.get(p.getMedType());
  35. if (null == medType) {
  36. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "医疗类别不能为空!");
  37. }
  38. if (medType == MedType.GENERAL_HOSPITALIZATION || p.getInpatientNo().startsWith("JT")) {
  39. SiAdmissApply apply = new SiAdmissApply();
  40. apply.setStatus(1);
  41. return ResultVoUtil.success(apply);
  42. }
  43. SiAdmissApply apply = dao.selectAdmissApply(p.getInpatientNo(), p.getAdmissTimes(), p.getLedgerSn());
  44. if (null == apply) {
  45. apply = new SiAdmissApply();
  46. apply.setAdmissDatetime(p.getYbRegisterDate());
  47. }
  48. return ResultVoUtil.success(apply);
  49. }
  50. public ResultVo<String> submitAdmissApply(SiAdmissApply apply) {
  51. if (StringUtil.isBlank(apply.getInputComment())) {
  52. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "申请理由不能为空!");
  53. }
  54. apply.setStatus(0);
  55. apply.setInputStaff(TokenUtil.getInstance().getTokenUserId());
  56. dao.deleteAdmissApply(apply.getPatNo(), apply.getTimes(), apply.getLedgerSn());
  57. dao.insertAdmissApply(apply);
  58. return ResultVoUtil.success("提交成功。");
  59. }
  60. public ResultVo<List<SiAdmissApply>> selectUnhandledApplies() {
  61. List<SiAdmissApply> list = dao.selectUnhandledApplies();
  62. for (SiAdmissApply apply : list) {
  63. apply.setInputName(userCache.getEmployeeName(apply.getInputStaff()));
  64. apply.setHandleStaffName(userCache.getEmployeeName(apply.getHandleStaff()));
  65. apply.setAdmdvsName(regionCache.get(apply.getAdmdvs()));
  66. apply.setMedTypeName(MedType.getName(apply.getMedType()));
  67. }
  68. return ResultVoUtil.success(list);
  69. }
  70. public ResultVo<Map<String, Object>> selectPatientInfo(SiAdmissApply apply) {
  71. ResultVo<Patient> ptntRsvo = ptntSrvc.getPatientInfo(apply.getPatNo());
  72. if (!Objects.equals(ptntRsvo.getCode(), ExceptionEnum.SUCCESS.getCode())) {
  73. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, ptntRsvo.getMessage());
  74. }
  75. Patient patient = ptntRsvo.getData();
  76. List<ZyInYbDiag> inYbDiags = ptntSrvc.getZyInYbDiags(apply.getPatNo(), apply.getTimes()).getData();
  77. for (ZyInYbDiag itm : inYbDiags) {
  78. itm.setOperName(userCache.getEmployeeName(itm.getOperId()));
  79. }
  80. Map<String, Object> map = new HashMap<>();
  81. map.put("apply", apply);
  82. map.put("patient", patient);
  83. map.put("indiags", inYbDiags);
  84. return ResultVoUtil.success(map);
  85. }
  86. public ResultVo<String> handleApply(SiAdmissApply apply) {
  87. if (StringUtil.isBlank(apply.getHandleComment())) {
  88. return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "处理意见不能为空!");
  89. }
  90. apply.setHandleStaff(TokenUtil.getInstance().getTokenUserId());
  91. dao.handleApply(apply);
  92. return ResultVoUtil.success("处理成功。");
  93. }
  94. }