JieShouHuiZhenService.java 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package thyyxxk.webserver.service.casefrontsheet;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import lombok.extern.slf4j.Slf4j;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.stereotype.Service;
  7. import thyyxxk.webserver.config.exception.ExceptionEnum;
  8. import thyyxxk.webserver.dao.his.casefrontsheet.JieShouHuiZhenDao;
  9. import thyyxxk.webserver.entity.ResultVo;
  10. import thyyxxk.webserver.entity.casefrontsheet.JieShouHuiZhenPojo;
  11. import thyyxxk.webserver.service.PublicServer;
  12. import thyyxxk.webserver.utils.*;
  13. import java.util.List;
  14. /**
  15. * <p>
  16. * 描述: 接受会诊申请
  17. * </p>
  18. *
  19. * @author xc
  20. * @date 2021-07-27 10:29
  21. */
  22. @Service
  23. @Slf4j
  24. public class JieShouHuiZhenService {
  25. private final JieShouHuiZhenDao dao;
  26. private final PublicServer publicServer;
  27. @Autowired
  28. public JieShouHuiZhenService(JieShouHuiZhenDao dao, PublicServer publicServer) {
  29. this.dao = dao;
  30. this.publicServer = publicServer;
  31. }
  32. /**
  33. * @param deptCode 科室code
  34. * @param currentPage 当前页
  35. * @param pageSize 页大小
  36. * @param startTime 开始时间
  37. * @param endTime 接受时间
  38. * @return 返回没有会诊的信息
  39. */
  40. public ResultVo<Page<JieShouHuiZhenPojo>> getHuiZhenData(String deptCode, long currentPage, long pageSize, String startTime, String endTime) {
  41. List<String> deptList = publicServer.getKeShiLieBiaoList(deptCode);
  42. QueryWrapper<?> qw = new QueryWrapper<>();
  43. qw.eq("status_flag", "1")
  44. .ge("req_date", startTime)
  45. .le("req_date", endTime);
  46. if (ListUtil.notBlank(deptList)) {
  47. qw.and(QueryWrapper -> QueryWrapper.in("req_dept1", deptList).or().in("req_dept2", deptList));
  48. }
  49. Page<JieShouHuiZhenPojo> page = new Page<>(currentPage, pageSize);
  50. dao.getHuiZhenData(page, qw);
  51. return ResultVoUtil.success(page);
  52. }
  53. /**
  54. * @param deptCode 根据科室的编码来获取 科室的名字
  55. * @return 返回科室名字
  56. */
  57. public ResultVo<String> getDeptName(String deptCode) {
  58. return ResultVoUtil.success(dao.getDeptName(deptCode));
  59. }
  60. /**
  61. * @param admissTimes 住院次数
  62. * @param reqTimes 申请次数
  63. * @param inpatientNo 住院号
  64. * @return 返回具体信息
  65. */
  66. public ResultVo<JieShouHuiZhenPojo> getHuanZheXinXi(Integer admissTimes, Integer reqTimes, String inpatientNo) {
  67. JieShouHuiZhenPojo pojo = dao.getHuanZheXinXi(admissTimes, reqTimes, inpatientNo);
  68. if (pojo.getBirthDate() != null) {
  69. pojo.setAge(DateUtil.calculateAge(pojo.getBirthDate(),null));
  70. }
  71. return ResultVoUtil.success(pojo);
  72. }
  73. /**
  74. * @param param 更新的 主键 以及 更新的数据
  75. * @return 返回更新 提示
  76. */
  77. public ResultVo<String> wanChenHuiZhen(JieShouHuiZhenPojo param) {
  78. if (param.getAdmissTimes() != null && param.getReqTimes() != null && StringUtil.notBlank(param.getInpatientNo())) {
  79. if (StringUtil.isBlank(param.getHzComment())) {
  80. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER, "会诊意见不能为空。");
  81. }
  82. param.setHzDoctor2(TokenUtil.getTokenUserId());
  83. dao.wanChenHuiZhen(param);
  84. log.info("完成会诊 ==》 操作人:{},数据:{}", TokenUtil.getTokenUserId(), param);
  85. return ResultVoUtil.success(ExceptionEnum.SUCCESS_AND_NOTIFICATION, param.getStatusFlag() == 1 ? "仅保存" : "完成会诊");
  86. }
  87. return ResultVoUtil.fail(ExceptionEnum.NULL_POINTER);
  88. }
  89. }