SiAdmVerifyService.java 4.4 KB

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