SiAdmVerifyService.java 4.6 KB

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