diff --git a/src/main/java/com/emr/controller/BatchApplyDetailsController.java b/src/main/java/com/emr/controller/BatchApplyDetailsController.java index aa0660c..d0870a7 100644 --- a/src/main/java/com/emr/controller/BatchApplyDetailsController.java +++ b/src/main/java/com/emr/controller/BatchApplyDetailsController.java @@ -1,5 +1,6 @@ package com.emr.controller; +import com.emr.dto.FastBorrowingDto; import com.emr.entity.BatchApplyDetails; import com.emr.service.BatchApplyDetails.BatchApplyDetailsService; import com.emr.util.ExceptionPrintUtil; @@ -9,6 +10,7 @@ import com.emr.vo.commomSearch.CommomVo; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; @@ -70,13 +72,13 @@ public class BatchApplyDetailsController { */ @RequestMapping("getBatchApplyDetails") @ResponseBody - public PageInfo getBatchApplyDetails(Integer page, Integer limit, int batchId,String inpatientNo) { + public PageInfo getBatchApplyDetails(Integer page, Integer limit, int batchId, String inpatientNo) { if (null != page && null != limit) { PageHelper.startPage(page, limit); } try { //查询 - List list = batchApplyDetailsService.getBatchApplyDetails(batchId,inpatientNo); + List list = batchApplyDetailsService.getBatchApplyDetails(batchId, inpatientNo); return new PageInfo<>(list); } catch (Exception e) { ExceptionPrintUtil.printException(e); @@ -97,11 +99,8 @@ public class BatchApplyDetailsController { if (StringUtils.isBlank(batchBorrowingVo.getPatientIds())) { return Msg.fail("病案主键为空"); } - int i = batchApplyDetailsService.addBatchBorrowing(batchBorrowingVo); - if (i == 0) { - return Msg.fail("批量申请保存失败"); - } - return Msg.success("批量申请保存成功"); + Msg msg = batchApplyDetailsService.addBatchBorrowing(batchBorrowingVo); + return msg; } /** @@ -113,8 +112,8 @@ public class BatchApplyDetailsController { */ @RequestMapping("deleteById") @ResponseBody - public int deleteById(int id,int batchId) { - return batchApplyDetailsService.deleteById(id,batchId); + public int deleteById(int id, int batchId) { + return batchApplyDetailsService.deleteById(id, batchId); } /** @@ -139,7 +138,90 @@ public class BatchApplyDetailsController { */ @RequestMapping("agreeById") @ResponseBody - public int agreeById(String ids,Integer batchId) { - return batchApplyDetailsService.agreeById(ids,batchId); + public int agreeById(String ids, Integer batchId) { + return batchApplyDetailsService.agreeById(ids, batchId); + } + + /** + * @description: 快速归还接口 + * @params: barCode + * @return: int + * @author linjj + * @date: 2023/12/27 17:05 + */ + @RequestMapping("updateReturn") + @ResponseBody + public int updateReturn(String barCode,String barCodeName) { + return batchApplyDetailsService.updateReturn(barCode,barCodeName); } + + /** + * @description: 快速借阅接口 + * @params: FastBorrowingDto + * @return: Msg + * @author linjj + * @date: 2023/12/29 10:06 + */ + @RequestMapping("fastBorrowing") + @ResponseBody + public Msg fastBorrowing(FastBorrowingDto dto) { + if (null==dto.getEffeDays()) { + return Msg.BorrowingFail("申请天数不能为空!!"); + } + if (StringUtils.isBlank(dto.getApplyType())) { + return Msg.BorrowingFail("申请类型不能为空!!"); + } + if (StringUtils.isBlank(dto.getApplyReason())) { + return Msg.BorrowingFail("申请理由不能为空"); + } + if (StringUtils.isBlank(dto.getBarCode())) { + return Msg.BorrowingFail("条形码不能为空"); + } + return batchApplyDetailsService.addFastBorrowing(dto); + } + + + /** + * @description: 批次申请快速归还 + * @params: barCode + * @return: barCodeName + * @author linjj + * @date: 2024/1/8 9:02 + */ + @RequestMapping("updateBatchApply") + @ResponseBody + public Msg updateBatchApply(String barCode,String barCodeName,Integer batchId){ + if (StringUtils.isBlank(barCode)){ + return Msg.BorrowingFail("条形码不能为空"); + } + if (StringUtils.isBlank(barCodeName)){ + return Msg.BorrowingFail("归还人工号不能为空"); + } + return batchApplyDetailsService.updateBatchApply(barCode,barCodeName,batchId); + } + /** + * @description: 批次申请快速借阅 + * @params: fastBatchApply + * @return: FastBorrowingDto + * @author linjj + * @date: 2024/1/8 14:52 + */ + @RequestMapping("fastBatchApply") + @ResponseBody + public Msg fastBatchApply(FastBorrowingDto dto) { + if (null==dto.getEffeDays()) { + return Msg.BorrowingFail("申请天数不能为空!!"); + } + if (StringUtils.isBlank(dto.getApplyType())) { + return Msg.BorrowingFail("申请类型不能为空!!"); + } + if (StringUtils.isBlank(dto.getApplyReason())) { + return Msg.BorrowingFail("申请理由不能为空"); + } + if (StringUtils.isBlank(dto.getBarCode())) { + return Msg.BorrowingFail("条形码不能为空"); + } + return batchApplyDetailsService.fastBatchApply(dto); + } + } diff --git a/src/main/java/com/emr/controller/emrApprove/ApproveController.java b/src/main/java/com/emr/controller/emrApprove/ApproveController.java index 2d17a5e..4fdc4d6 100644 --- a/src/main/java/com/emr/controller/emrApprove/ApproveController.java +++ b/src/main/java/com/emr/controller/emrApprove/ApproveController.java @@ -550,6 +550,7 @@ public class ApproveController { return ResultUtil.ok(); } + /** * @MethodName: exportExcelApplyList * @Description: 根据搜索条件导出excel,申请列表集合 diff --git a/src/main/java/com/emr/dao/Archive_MasterMapper.java b/src/main/java/com/emr/dao/Archive_MasterMapper.java new file mode 100644 index 0000000..3640a01 --- /dev/null +++ b/src/main/java/com/emr/dao/Archive_MasterMapper.java @@ -0,0 +1,27 @@ +package com.emr.dao; + +import com.emr.vo.UpdateReturnVo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @InterfaceName Archive_MasterMapper + * @Description 基础数据接口 + * @Author linjj + * @Date 2023/12/27 17:09 + * @Version 1.0 + */ +@Mapper +public interface Archive_MasterMapper { + + /** + * @description: 根据条形id查询住院号住院次数 + * @params: barCode + * @return: UpdateReturnVo + * @author linjj + * @date: 2023/12/27 17:11 + */ + List getInpNoAndVisitIdByBarCode(@Param("barCode") String barCode); +} diff --git a/src/main/java/com/emr/dao/BatchApplyDetailsMapper.java b/src/main/java/com/emr/dao/BatchApplyDetailsMapper.java index 7b75b8d..6b6c40c 100644 --- a/src/main/java/com/emr/dao/BatchApplyDetailsMapper.java +++ b/src/main/java/com/emr/dao/BatchApplyDetailsMapper.java @@ -32,4 +32,14 @@ public interface BatchApplyDetailsMapper { int upadteApplyDetailsList(@Param("list") List list); String getEffectiveTime(@Param("ids") Integer ids,@Param("examineTimes") String examineTimes); + + + int getNumInpNoAndAdmissTimes(@Param("inpatientNo")String inpatientNo,@Param("admissTimes")int admissTimes,@Param("batchId")int batchId); + + + List getIdInpNoAndAdmissTimes(@Param("inpatientNo")String inpatientNo,@Param("admissTimes")String admissTimes,@Param("batchId")int batchId); + + + int updateBatchApplyDetails(@Param("id")String id,@Param("userName")String userName,@Param("barCodeName")String barCodeName,@Param("returnTime")String returnTime); + } diff --git a/src/main/java/com/emr/dao/CommomMapper.java b/src/main/java/com/emr/dao/CommomMapper.java index c446bc3..6619e69 100644 --- a/src/main/java/com/emr/dao/CommomMapper.java +++ b/src/main/java/com/emr/dao/CommomMapper.java @@ -140,4 +140,6 @@ public interface CommomMapper { int selectAllMaster(@Param("inpatientNo")String inpatientNo,@Param("idCard")String idCar); + String getPatientIdByInpNoAndVisitId(@Param("inpNo")String inpNo,@Param("visitId")String visitId); + } \ No newline at end of file diff --git a/src/main/java/com/emr/dao/approve/Emr_Apply_ApproveMapper.java b/src/main/java/com/emr/dao/approve/Emr_Apply_ApproveMapper.java index e26055d..268fd6a 100644 --- a/src/main/java/com/emr/dao/approve/Emr_Apply_ApproveMapper.java +++ b/src/main/java/com/emr/dao/approve/Emr_Apply_ApproveMapper.java @@ -1,6 +1,7 @@ package com.emr.dao.approve; import com.emr.entity.approve.Emr_Apply_Approve; +import com.emr.vo.ApplyStateVo; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -82,4 +83,26 @@ public interface Emr_Apply_ApproveMapper { Emr_Apply_Approve selectByApplyerAndPatientId(@Param("userName")String userName,@Param("patientId")String patientId); ListexpireTime(@Param("currentTime") String currentTime,@Param("effeDays") int effeDays); + + /** + * @description: 根据住院号修改归还状态 + * @author linjj + * @date: 2023/12/27 17:14 + */ + int UpdateReturnState(@Param("id") String id, @Param("returnName")String returnName, @Param("returnTime")String returnTime, + @Param("returnNameString")String returnNameString); + /** + * @description: 查询是否有需要归还病历 + * @author linjj + * @date: 2023/12/28 16:11 + */ + List getReturnState(@Param("inpNo") String inpNo, @Param("visitId") String visitId, @Param("userName")String userName); + /** + * @description: 快速借阅查收是否存在 + * @params: + * @return: + * @author linjj + * @date: 2023/12/29 10:20 + */ + List getApproverState(@Param("inpNo") String inpNo, @Param("visitId") String visitId, @Param("userName")String userName); } \ No newline at end of file diff --git a/src/main/java/com/emr/dto/FastBorrowingDto.java b/src/main/java/com/emr/dto/FastBorrowingDto.java new file mode 100644 index 0000000..815583c --- /dev/null +++ b/src/main/java/com/emr/dto/FastBorrowingDto.java @@ -0,0 +1,26 @@ +package com.emr.dto; + +import lombok.Data; + +/** + * @ClassName FastBorrowingDto + * @Description 快速借阅入参 + * @Author linjj + * @Date 2023/12/29 10:03 + * @Version 1.0 + */ +@Data +public class FastBorrowingDto { + + private Integer effeDays; + + private String applyType; + + private String applyReason; + + private String barCode; + + private String userName; + + private int batchId; +} diff --git a/src/main/java/com/emr/entity/BatchApply.java b/src/main/java/com/emr/entity/BatchApply.java index 21a8a21..e6cdb71 100644 --- a/src/main/java/com/emr/entity/BatchApply.java +++ b/src/main/java/com/emr/entity/BatchApply.java @@ -28,4 +28,6 @@ public class BatchApply { //创建时间 private String applyName; + + private Integer readNums; } diff --git a/src/main/java/com/emr/entity/BatchApplyDetails.java b/src/main/java/com/emr/entity/BatchApplyDetails.java index 68d9986..e47ab32 100644 --- a/src/main/java/com/emr/entity/BatchApplyDetails.java +++ b/src/main/java/com/emr/entity/BatchApplyDetails.java @@ -49,5 +49,14 @@ public class BatchApplyDetails { private String examineName; //审批时间 private String examineTime; - + //归还人 + private String returnName; + //归还人姓名 + private String returnNameString; + //归还时间 + private String returnTime; + //申请人姓名 + private String handlingNameString; + //审批人姓名 + private String examineNameString; } diff --git a/src/main/java/com/emr/entity/approve/Emr_Apply_Approve.java b/src/main/java/com/emr/entity/approve/Emr_Apply_Approve.java index d16b4e2..d2d45f9 100644 --- a/src/main/java/com/emr/entity/approve/Emr_Apply_Approve.java +++ b/src/main/java/com/emr/entity/approve/Emr_Apply_Approve.java @@ -9,6 +9,16 @@ public class Emr_Apply_Approve { private String applyTime; + private String returnState; + + public String getReturnState() { + return returnState; + } + + public void setReturnState(String returnState) { + this.returnState = returnState; + } + private String effeTime; private Integer effeDays; @@ -262,4 +272,34 @@ public class Emr_Apply_Approve { public void setDisDate(Date disDate) { this.disDate = disDate; } + + private String returnName; + + private String returnTime; + + private String returnNameString; + + public String getReturnName() { + return returnName; + } + + public void setReturnName(String returnName) { + this.returnName = returnName; + } + + public String getReturnTime() { + return returnTime; + } + + public void setReturnTime(String returnTime) { + this.returnTime = returnTime; + } + + public String getReturnNameString() { + return returnNameString; + } + + public void setReturnNameString(String returnNameString) { + this.returnNameString = returnNameString; + } } \ No newline at end of file diff --git a/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsService.java b/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsService.java index 462b41a..dd1bbe4 100644 --- a/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsService.java +++ b/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsService.java @@ -1,7 +1,9 @@ package com.emr.service.BatchApplyDetails; +import com.emr.dto.FastBorrowingDto; import com.emr.entity.BatchApplyDetails; import com.emr.vo.BatchBorrowingVo; +import com.emr.vo.Msg; import com.emr.vo.commomSearch.CommomVo; import java.util.List; @@ -21,11 +23,19 @@ public interface BatchApplyDetailsService { List getBatchApplyDetails(int batchId,String inpatientNo); - int addBatchBorrowing(BatchBorrowingVo batchBorrowingVo); + Msg addBatchBorrowing(BatchBorrowingVo batchBorrowingVo); int deleteById(int id,int batchId); int rejectById(int id); int agreeById(String ids,Integer batchId); + + int updateReturn(String barCode,String barCodeName); + + Msg addFastBorrowing(FastBorrowingDto dto); + + Msg updateBatchApply(String barCode,String barCodeName,int batchId); + + Msg fastBatchApply(FastBorrowingDto dto); } diff --git a/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsServiceImpl.java b/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsServiceImpl.java index 47733c6..6edb8f5 100644 --- a/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsServiceImpl.java +++ b/src/main/java/com/emr/service/BatchApplyDetails/BatchApplyDetailsServiceImpl.java @@ -1,19 +1,22 @@ package com.emr.service.BatchApplyDetails; -import com.emr.dao.BatchApplyDetailsMapper; -import com.emr.dao.BatchApplyMapper; -import com.emr.dao.EmrComomSetMapper; -import com.emr.dao.Emr_DictionaryMapper; +import com.emr.dao.*; +import com.emr.dao.approve.Emr_Apply_ApproveMapper; +import com.emr.dto.FastBorrowingDto; import com.emr.entity.*; +import com.emr.entity.approve.Emr_Apply_Approve; +import com.emr.service.CommomService; +import com.emr.service.approve.ApplyApproveService; import com.emr.util.ListUtils; import com.emr.util.Setters; -import com.emr.vo.BatchApplyDetailsVo; -import com.emr.vo.BatchApplyVo; -import com.emr.vo.BatchBorrowingVo; +import com.emr.vo.*; import com.emr.vo.commomSearch.CommomVo; import org.apache.commons.lang3.StringUtils; +import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -39,6 +42,21 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { BatchApplyDetailsMapper batchApplyDetailsMapper; @Autowired EmrComomSetMapper emrComomSetMapper; + @Autowired + Archive_MasterMapper archiveMasterMapper; + @Autowired + Emr_Apply_ApproveMapper emrApplyApproveMapper; + @Autowired + private Emr_Apply_ApproveMapper applyApproveMapper; + @Autowired + private CommomMapper commomMapper; + @Value("${applyApproveFlag}") + private String applyApproveFlag; + @Autowired + private ApplyApproveService applyApproveService; + + @Autowired + private CommomService commomService; @Override public List addCommomVo(CommomVo commomVo) { @@ -47,21 +65,27 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { convertDepartment(list); //当查询集合中只有一条记录时直接插入申请列表 if (commomVo.getRefreshTable() == 1) { - addApplyDetails(list, commomVo.getBatchId(),commomVo.getApplyName()); + //判断是否已经存在并且未过期 + int i = batchApplyDetailsMapper.getNumInpNoAndAdmissTimes(list.get(0).getInpatientNo(), list.get(0).getAdmissTimes(), commomVo.getBatchId()); + if (i == 0) { + addApplyDetails(list, commomVo.getBatchId(), commomVo.getApplyName()); + } else { + list.get(0).setApplyStatc("住院号:" + list.get(0).getInpatientNo() + "住院次数:" + list.get(0).getAdmissTimes() + "已经申请且在有效期内,无需重复申请!!!"); + } } return list; } @Override - public List getBatchApplyDetails(int batchId,String inpatientNo) { + public List getBatchApplyDetails(int batchId, String inpatientNo) { //获取系统当前时间 SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); String format = fmt.format(new Date()); - List batchApplyDetails = batchApplyDetailsMapper.getBatchApplyDetails(batchId,inpatientNo); + List batchApplyDetails = batchApplyDetailsMapper.getBatchApplyDetails(batchId, inpatientNo); for (BatchApplyDetails list : batchApplyDetails) { //判断是否过期如果过期状态为4 String effectiveTime = list.getEffectiveTime(); - if (StringUtils.isNotBlank(effectiveTime) ) { + if (StringUtils.isNotBlank(effectiveTime)) { if ((effectiveTime.compareTo(format)) == -1) { list.setApplyStatc(4); } @@ -71,14 +95,25 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { } @Override - public int addBatchBorrowing(BatchBorrowingVo batchBorrowingVo) { + public Msg addBatchBorrowing(BatchBorrowingVo batchBorrowingVo) { //查询患者基础数据 List commomList = batchApplyMapper.getCommomVoByPatientIds(batchBorrowingVo.getPatientIds()); - return addApplyDetailsList(commomList, batchBorrowingVo); + //判断是否已经存在并且未过期 + for (CommomVo list : commomList) { + int i = batchApplyDetailsMapper.getNumInpNoAndAdmissTimes(list.getInpatientNo(), list.getAdmissTimes(), batchBorrowingVo.getBatchId()); + if (i > 0) { + return Msg.addBatchFail("住院号:" + list.getInpatientNo() + "住院次数:" + list.getAdmissTimes() + "已经申请且在有效期内,无需重复申请!!!"); + } + } + int i = addApplyDetailsList(commomList, batchBorrowingVo); + if (i == 1) { + return Msg.addBatchSuccess("批量申请保存成功"); + } + return Msg.addBatchFail("批量申请保存失败"); } @Override - public int deleteById(int id,int batchId) { + public int deleteById(int id, int batchId) { //更新批次数量 delBorrowingNum(batchId); return batchApplyDetailsMapper.deleteById(id); @@ -93,7 +128,8 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { // 从session获取用户名 Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); BatchApplyDetailsVo batchApplyDetailsVo = new BatchApplyDetailsVo(); - batchApplyDetailsVo.setExamineName(user.getUserPosition()); + batchApplyDetailsVo.setExamineName(user.getUserName()); + batchApplyDetailsVo.setExamineNameString(user.getUserPosition()); batchApplyDetailsVo.setExamineTime(fmt.format(new Date())); batchApplyDetailsVo.setId(id); batchApplyDetailsVo.setApplyStatc(3); @@ -102,7 +138,7 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { @Override public int agreeById(String ids, Integer batchId) { - int i=0; + int i = 0; //获取系统当前时间 SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); //获取登录用户信息 @@ -116,7 +152,8 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { //遍历审核信息 for (Integer id : idsList) { BatchApplyDetailsVo batchApplyDetailsVo = new BatchApplyDetailsVo(); - batchApplyDetailsVo.setExamineName(user.getUserPosition()); + batchApplyDetailsVo.setExamineName(user.getUserName()); + batchApplyDetailsVo.setExamineNameString(user.getUserPosition()); batchApplyDetailsVo.setExamineTime(fmt.format(new Date())); batchApplyDetailsVo.setApplyStatc(1); batchApplyDetailsVo.setId(id); @@ -125,32 +162,217 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { //给有效时间赋值 upDateEffectiveTimeList(list); boolean b = upadteApplyDetais(list); - if (b){ - i=1; + if (b) { + i = 1; } //更新审批数量 - upDateAgreeNum(batchId,list.size()); + upDateAgreeNum(batchId, list.size()); + return i; + } + + @Override + public int updateReturn(String barCode, String barCodeName) { + int i = 0; + Power_User user = new Power_User(); + //获取系统当前时间 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss "); + //获取登录用户信息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + //不为空直接用barCodeName为空拿当前登录userName + if (StringUtils.isNotBlank(barCodeName)) { + user.setUserName(barCodeName); + String s = convertUserName(user.getUserName()); + if (StringUtils.isBlank(s)) { + return i; + } + user.setUserPosition(s); + } else { + // 从session获取用户名 + user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + } + List inpNoAndVisitIdByBarCode = archiveMasterMapper.getInpNoAndVisitIdByBarCode(barCode); + //集合为空则返回2无需要归还病历 + if (CollectionUtils.isEmpty(inpNoAndVisitIdByBarCode)) { + i = 2; + return i; + } + //查询是否有需要归还病历 + for (UpdateReturnVo list : inpNoAndVisitIdByBarCode) { + List ids = emrApplyApproveMapper.getReturnState(list.getInpNo(), list.getVisitId(), user.getUserName()); + //集合为空则返回2无需要归还病历 + if (CollectionUtils.isEmpty(ids)) { + i = 2; + return i; + } + //需要归还病历id + ApplyStateVo applyStateVo = ids.get(ids.size() - 1); + //如果最后一条记录是已归还则不需要在次归还 + if (StringUtils.isNotBlank(applyStateVo.getReturnState())) { + i = 2; + return i; + } + i = emrApplyApproveMapper.UpdateReturnState(applyStateVo.getId(), user.getUserName(), fmt.format(new Date()), user.getUserPosition()); + return i; + } return i; } - private void upDateAgreeNum(int batchId,int readNum){ + @Override + public Msg addFastBorrowing(FastBorrowingDto dto) { + Power_User user = new Power_User(); + //保存实体 + Emr_Apply_Approve applyApprove = new Emr_Apply_Approve(); + //获取系统当前时间 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss "); + //获取登录用户信息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + if (StringUtils.isNotBlank(dto.getUserName())) { + user.setUserName(dto.getUserName()); + } else { + // 从session获取用户名 + user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + } + //查询是否未过期 + //根据条形码查询信息 + List list = archiveMasterMapper.getInpNoAndVisitIdByBarCode(dto.getBarCode()); + //集合为空则返回无该条形码病历 + if (CollectionUtils.isEmpty(list)) { + return Msg.BorrowingFail("无该条形码病历"); + } + //查询patientId + String patientId = commomMapper.getPatientIdByInpNoAndVisitId(list.get(0).getInpNo(), list.get(0).getVisitId()); + if (StringUtils.isBlank(patientId)) { + return Msg.BorrowingFail("无该条形码已归档病历"); + } + //判断是否有未过期切未归还病历 + List approves = applyApproveMapper.getApproverState(list.get(0).getInpNo(), list.get(0).getVisitId(), user.getUserName()); + if (!CollectionUtils.isEmpty(approves)) { + return Msg.BorrowingFail("该病案另一个申请还处于有效期,无须重复申请!"); + } + //有效期是否过滤节假日 + if (applyApproveFlag.equals("1")) { + SimpleDateFormat fmt1 = new SimpleDateFormat("yyyy-MM-dd"); + List expireTimeList = applyApproveService.expireTime(fmt1.format(new Date()), applyApprove.getEffeDays()); + String s = expireTimeList.get(expireTimeList.size() - 1); + applyApprove.setEffeTime(s); + } else { + Calendar calendar2 = Calendar.getInstance(); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); + calendar2.add(Calendar.DATE, 3); + applyApprove.setEffeTime(sdf2.format(calendar2.getTime())); + } + applyApprove.setApplyer(user.getUserName()); + applyApprove.setApplyTime(fmt.format(new Date())); + applyApprove.setEffeDays(dto.getEffeDays()); + applyApprove.setApplyType(dto.getApplyType()); + applyApprove.setApplyReason(dto.getApplyReason()); + applyApprove.setApplyState("2"); + applyApprove.setPatientId(patientId); + applyApprove.setAdmissId(list.get(0).getInpNo()); + applyApprove.setInpatientNo(list.get(0).getInpNo()); + applyApprove.setAdmissTimes(Short.parseShort(list.get(0).getVisitId())); + applyApprove.setDisDate(list.get(0).getDischargeDateTime()); + int i = applyApproveMapper.insertSelective(applyApprove); + if (i == 1) { + return Msg.success("条形码" + dto.getBarCode() + "快速借阅成功"); + } + return Msg.BorrowingFail("条形码" + dto.getBarCode() + "快速借阅失败"); + } + + @Override + public Msg updateBatchApply(String barCode, String barCodeName, int batchId) { + //转换用户名 + String userName = convertUserName(barCodeName); + //获取系统当前时间 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss "); + if (StringUtils.isBlank(userName)){ + return Msg.BorrowingFail("该工号:" + barCodeName + "查询不到对应用户名"); + } + //根据条形码查询病历 + List list = archiveMasterMapper.getInpNoAndVisitIdByBarCode(barCode); + //集合为空则未查询到该条形码病历 + if (CollectionUtils.isEmpty(list)) { + return Msg.BorrowingFail("未查询到该条形码病历"); + } + //根据条形码查询批量表需要归还病历 + List ids = batchApplyDetailsMapper.getIdInpNoAndAdmissTimes(list.get(0).getInpNo(), list.get(0).getVisitId(), batchId); + if (CollectionUtils.isEmpty(ids)) { + return Msg.BorrowingFail("该条形码:" + barCode + "无需要归还的病历"); + } + int i = batchApplyDetailsMapper.updateBatchApplyDetails(ids.get(ids.size() - 1), userName, barCodeName, fmt.format(new Date())); + if (i==1){ + return Msg.success("该条形码:" + barCode + "快速归还成功"); + } + return Msg.BorrowingFail("该条形码:" + barCode + "快速归还失败"); + } + + @Override + public Msg fastBatchApply(FastBorrowingDto dto) { + //获取系统当前时间 + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); + //获取登录用户信息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + // 从session获取用户名 + Power_User user = (Power_User) request.getSession().getAttribute("CURRENT_USER"); + List NewList = Collections.synchronizedList(new ArrayList<>()); + //根据条形码查询信息 + List updateReturnVo = archiveMasterMapper.getInpNoAndVisitIdByBarCode(dto.getBarCode()); + //集合为空则返回无该条形码病历 + if (CollectionUtils.isEmpty(updateReturnVo)) { + return Msg.BorrowingFail("无该条形码病历"); + } + //判断是否已经借阅 + for (UpdateReturnVo list:updateReturnVo){ + int i = batchApplyDetailsMapper.getNumInpNoAndAdmissTimes(list.getInpNo(), Integer.parseInt(list.getVisitId()), dto.getBatchId()); + if (i > 0) { + return Msg.addBatchFail("住院号:" + list.getInpNo() + "住院次数:" + list.getVisitId() + "已经申请且在有效期内,无需重复申请!!!"); + } + //插入申请借阅详情集合 + BatchApplyDetailsVo batchApplyDetailsVo = new BatchApplyDetailsVo(); + batchApplyDetailsVo.setBatchId(dto.getBatchId()); + batchApplyDetailsVo.setApplyName(dto.getUserName()); + batchApplyDetailsVo.setApplyDate(user.getRemark()); + batchApplyDetailsVo.setApplyTime(fmt.format(new Date())); + batchApplyDetailsVo.setEffectiveDay(dto.getEffeDays()); + batchApplyDetailsVo.setInpatientNo(list.getInpNo()); + batchApplyDetailsVo.setAdmissTimes(Short.parseShort(list.getVisitId())); + batchApplyDetailsVo.setPatientName(list.getName()); + batchApplyDetailsVo.setDisTime(list.getDischargeDateTime().toString()); + batchApplyDetailsVo.setApplyReason(dto.getApplyReason()); + batchApplyDetailsVo.setApplyFlag(2); + batchApplyDetailsVo.setApplyStatc(2); + batchApplyDetailsVo.setHandlingName(user.getUserName()); + batchApplyDetailsVo.setHandlingNameString(user.getUserPosition()); + //将对象传入集合 + NewList.add(batchApplyDetailsVo); + } + //同步数量 + updateNum(dto.getBatchId(), NewList.size()); + int i = batchApplyDetailsMapper.addBatchApplyDetails(NewList); + if (i==1){ + return Msg.success("条形码:"+dto.getBarCode()+"快速借阅成功"); + } + return Msg.BorrowingFail("条形码:"+dto.getBarCode()+"快速借阅成功"); + } + + private void upDateAgreeNum(int batchId, int readNum) { BatchApplyVo batchApplyVo = batchApplyMapper.getreadNum(batchId); int i = readNum + batchApplyVo.getReadNum(); - batchApplyMapper.updateReadNumm(i,batchId); + batchApplyMapper.updateReadNumm(i, batchId); // //如果借阅数量跟审批数量一样则改为已审批 - if (batchApplyVo.getBorrowingNum()==i){ - batchApplyMapper.updateStatc(2,batchId); - }else { - batchApplyMapper.updateStatc(3,batchId); + if (batchApplyVo.getBorrowingNum() == i) { + batchApplyMapper.updateStatc(2, batchId); + } else { + batchApplyMapper.updateStatc(3, batchId); } } - private boolean upadteApplyDetais(List list){ - boolean flag=false; - for (BatchApplyDetailsVo batchApplyDetailsVo:list){ + private boolean upadteApplyDetais(List list) { + boolean flag = false; + for (BatchApplyDetailsVo batchApplyDetailsVo : list) { batchApplyDetailsMapper.upadteApplyDetails(batchApplyDetailsVo); - flag=true; + flag = true; } return flag; } @@ -186,6 +408,7 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { batchApplyDetailsVo.setApplyFlag(batchBorrowingVo.getApplyFlag()); batchApplyDetailsVo.setApplyStatc(2); batchApplyDetailsVo.setHandlingName(user.getUserName()); + batchApplyDetailsVo.setHandlingNameString(user.getUserPosition()); //将对象传入集合 list.add(batchApplyDetailsVo); } @@ -214,7 +437,7 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { } - private void addApplyDetails(List list, int batchId,String ApplyName) { + private void addApplyDetails(List list, int batchId, String ApplyName) { //获取系统设置的默认参数 EmrComomSet emrComomSet = emrComomSetMapper.selectByPrimaryKey(1); //获取登录用户信息 @@ -238,6 +461,7 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { batchApplyDetailsVo.setApplyReason("需要借阅这份病历"); batchApplyDetailsVo.setApplyFlag(1); batchApplyDetailsVo.setApplyStatc(2); + batchApplyDetailsVo.setHandlingNameString(user.getUserPosition()); List batchApplyDetailsList = Arrays.asList(batchApplyDetailsVo); batchApplyDetailsMapper.addBatchApplyDetails(batchApplyDetailsList); //新增时同步批次数量先获取原先数量 @@ -268,5 +492,25 @@ public class BatchApplyDetailsServiceImpl implements BatchApplyDetailsService { batchApplyMapper.updateBorrowingNum(i, batchId); } + //转换用户名 + private String convertUserName(String userName) { + String userNameString = null; + //获取登录用户信息 + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + //获取用户名 + List userList = null; + try { + userList = commomService.getUserList(userName, request); + } catch (Exception e) { + throw new RuntimeException(e); + } + for (User user1 : userList) { + String name = user1.getName(); + if (StringUtils.isNotBlank(userName) && user1.getUserName().equals(userName)) { + userNameString = name; + } + } + return userNameString; + } } diff --git a/src/main/java/com/emr/service/batchApply/BatchApplyServiceImpl.java b/src/main/java/com/emr/service/batchApply/BatchApplyServiceImpl.java index d8b4102..4e77df6 100644 --- a/src/main/java/com/emr/service/batchApply/BatchApplyServiceImpl.java +++ b/src/main/java/com/emr/service/batchApply/BatchApplyServiceImpl.java @@ -7,6 +7,7 @@ import com.emr.entity.BatchApply; import com.emr.entity.BatchApplyDetails; import com.emr.entity.Emr_Dictionary; import com.emr.entity.Power_User; +import com.emr.util.ListUtil; import com.emr.util.ListUtils; import com.emr.util.Setters; import com.emr.vo.BatchApplyDetailsVo; @@ -54,7 +55,22 @@ public class BatchApplyServiceImpl implements BatchApplyService { batchApplyVo.setCreateName(user.getUserName()); } } - return batchApplyMapper.selectBatchApply(batchApplyVo); + List batchApplies = batchApplyMapper.selectBatchApply(batchApplyVo); + for (BatchApply list:batchApplies){ + //判断该批次审批状态 + if (list.getReadNums()==0){ + list.setStatc(0); + continue; + } + if (list.getReadNums()==list.getBorrowingNum()){ + list.setStatc(2); + continue; + } + if (list.getReadNums() Map toMap(List list, FieldSelector selector) { + if (CollectionUtils.isEmpty(list)) return Collections.emptyMap(); + Map map = new HashMap<>(list.size()); + for (T t : list) { + K key = selector.select(t); + if (key != null) map.put(key, t); + } + return map; + } + + public static Map> groupBy(List list, FieldSelector selector) { + if (CollectionUtils.isEmpty(list)) return Collections.emptyMap(); + Map> map = new HashMap<>(); + for (T t : list) { + K key = selector.select(t); + if (key == null) continue; + if (!map.containsKey(key)) { + map.put(key, new ArrayList()); + } + map.get(key).add(t); + } + return map; + } + + public static List select(List list, FieldSelector selector) { + if (CollectionUtils.isEmpty(list)) return Collections.emptyList(); + List filedList = new ArrayList<>(list.size()); + for (T t : list) { + K key = selector.select(t); + if (key != null) filedList.add(key); + } + return filedList; + } + + public static List distinctSelect(List list, FieldSelector selector) { + if (CollectionUtils.isEmpty(list)) return Collections.emptyList(); + Set filedSet = new HashSet<>(); + for (T t : list) { + K key = selector.select(t); + if (key != null) filedSet.add(key); + } + return new ArrayList<>(filedSet); + } + + @SafeVarargs + public static List unionWithoutDuplicate(List... values) { + if (null == values || values.length <= 0) return Collections.emptyList(); + Set unionFiledSet = new HashSet<>(); + for (List value : values) { + if (!CollectionUtils.isEmpty(value)) { + unionFiledSet.addAll(value); + } + } + return new ArrayList<>(unionFiledSet); + } + + public static List skipDuplicateKey(List list, FieldSelector selector) { + if (CollectionUtils.isEmpty(list)) return Collections.emptyList(); + List filedList = new ArrayList<>(list.size()); + Map map = toMap(list, selector); + for (K key : map.keySet()) { + filedList.add(map.get(key)); + } + return filedList; + } +} diff --git a/src/main/java/com/emr/util/ListUtils.java b/src/main/java/com/emr/util/ListUtils.java index 17cceea..893f6b0 100644 --- a/src/main/java/com/emr/util/ListUtils.java +++ b/src/main/java/com/emr/util/ListUtils.java @@ -29,6 +29,47 @@ public final class ListUtils { return map; } + public static List> partition(List list, int size) { + if (list == null) { + throw new NullPointerException("List must not be null"); + } else if (size <= 0) { + throw new IllegalArgumentException("Size must be greater than 0"); + } else { + return new Partition(list, size); + } + } + + private static class Partition extends AbstractList> { + private final List list; + private final int size; + + private Partition(List list, int size) { + this.list = list; + this.size = size; + } + + public List get(int index) { + int listSize = this.size(); + if (index < 0) { + throw new IndexOutOfBoundsException("Index " + index + " must not be negative"); + } else if (index >= listSize) { + throw new IndexOutOfBoundsException("Index " + index + " must be less than size " + listSize); + } else { + int start = index * this.size; + int end = Math.min(start + this.size, this.list.size()); + return this.list.subList(start, end); + } + } + + public int size() { + return (int)Math.ceil((double)this.list.size() / (double)this.size); + } + + public boolean isEmpty() { + return this.list.isEmpty(); + } + } + public static List select(List list, FieldSelector selector) { if (CollectionUtils.isEmpty(list)) return Collections.emptyList(); List filedList = new ArrayList<>(list.size()); diff --git a/src/main/java/com/emr/vo/ApplyStateVo.java b/src/main/java/com/emr/vo/ApplyStateVo.java new file mode 100644 index 0000000..faacb28 --- /dev/null +++ b/src/main/java/com/emr/vo/ApplyStateVo.java @@ -0,0 +1,16 @@ +package com.emr.vo; + +import lombok.Data; + +/** + * @ClassName ApplyState + * @Author linjj + * @Date 2023/12/29 9:15 + * @Version 1.0 + */ +@Data +public class ApplyStateVo { + + private String id; + private String returnState; +} diff --git a/src/main/java/com/emr/vo/BatchApplyDetailsVo.java b/src/main/java/com/emr/vo/BatchApplyDetailsVo.java index f394d27..a6b2c94 100644 --- a/src/main/java/com/emr/vo/BatchApplyDetailsVo.java +++ b/src/main/java/com/emr/vo/BatchApplyDetailsVo.java @@ -49,4 +49,8 @@ public class BatchApplyDetailsVo { private String examineName; //审批时间 private String examineTime; + //申请人姓名 + private String handlingNameString; + //审批人姓名 + private String examineNameString; } diff --git a/src/main/java/com/emr/vo/Msg.java b/src/main/java/com/emr/vo/Msg.java index 18f24c4..f37c7df 100644 --- a/src/main/java/com/emr/vo/Msg.java +++ b/src/main/java/com/emr/vo/Msg.java @@ -66,12 +66,41 @@ public class Msg { } public static Msg success(String msg){ + Msg result=new Msg(); + result.setCode(200); + result.setMsg(msg); + return result; + } + + + public static Msg addBatchSuccess(String msg){ + Msg result=new Msg(); + result.setCode(200); + result.setMsg(msg); + return result; + } + + + public static Msg addBatchFail(String msg){ Msg result=new Msg(); result.setCode(100); result.setMsg(msg); return result; } + + + public static Msg BorrowingFail(String msg){ + Msg result=new Msg(); + result.setCode(100); + result.setMsg(msg); + return result; + } + + + + + public Msg add(String key,Object value){ this.getExtend().put(key, value); return this; diff --git a/src/main/java/com/emr/vo/UpdateReturnVo.java b/src/main/java/com/emr/vo/UpdateReturnVo.java new file mode 100644 index 0000000..6244c83 --- /dev/null +++ b/src/main/java/com/emr/vo/UpdateReturnVo.java @@ -0,0 +1,23 @@ +package com.emr.vo; + +import lombok.Data; + +import java.util.Date; + +/** + * @ClassName updateReturnVo + * @Description 快速归还查询住院号、住院次数 + * @Author linjj + * @Date 2023/12/27 17:08 + * @Version 1.0 + */ +@Data +public class UpdateReturnVo { + private String inpNo; + + private String visitId; + + private Date dischargeDateTime; + + private String name; +} diff --git a/src/main/java/com/emr/vo/commomSearch/CommomVo.java b/src/main/java/com/emr/vo/commomSearch/CommomVo.java index b3b9598..0d610d0 100644 --- a/src/main/java/com/emr/vo/commomSearch/CommomVo.java +++ b/src/main/java/com/emr/vo/commomSearch/CommomVo.java @@ -11,8 +11,19 @@ public class CommomVo { private String name;//姓名 + + private String applyStatc; + private String admissId;//住院号 + public String getApplyStatc() { + return applyStatc; + } + + public void setApplyStatc(String applyStatc) { + this.applyStatc = applyStatc; + } + private String sex;//性别 private String age;//年龄(岁) diff --git a/src/main/resources/mapper/Archive_MasterMapper.xml b/src/main/resources/mapper/Archive_MasterMapper.xml new file mode 100644 index 0000000..f1135f6 --- /dev/null +++ b/src/main/resources/mapper/Archive_MasterMapper.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/BatchApplyDetailsMapper.xml b/src/main/resources/mapper/BatchApplyDetailsMapper.xml index 827dfac..9b1bd87 100644 --- a/src/main/resources/mapper/BatchApplyDetailsMapper.xml +++ b/src/main/resources/mapper/BatchApplyDetailsMapper.xml @@ -4,12 +4,12 @@ insert into batch_apply_details (batch_id,apply_name,apply_time,apply_reason,apply_flag, - apply_date,apply_statc,dis_time,effective_day,patient_name,inpatient_no,admiss_times,handling_name + apply_date,apply_statc,dis_time,effective_day,patient_name,inpatient_no,admiss_times,handling_name,handling_name_string ) values (#{item.batchId},#{item.applyName},#{item.applyTime}, #{item.applyReason},#{item.applyFlag},#{item.applyDate},#{item.applyStatc}, - #{item.disTime},#{item.effectiveDay},#{item.patientName},#{item.inpatientNo},#{item.admissTimes},#{item.handlingName} + #{item.disTime},#{item.effectiveDay},#{item.patientName},#{item.inpatientNo},#{item.admissTimes},#{item.handlingName},#{item.handlingNameString} ) @@ -31,6 +31,9 @@ apply_statc=#{applyStatc}, + + examine_name_string=#{examineNameString}, + where id = #{id} @@ -57,6 +60,10 @@ where id = #{item.id} + + update batch_apply_details set apply_statc=5,return_name=#{barCodeName},return_time=#{returnTime},return_name_string=#{userName} + where id=#{id} + @@ -84,4 +91,13 @@ + + + \ No newline at end of file diff --git a/src/main/resources/mapper/BatchApplyMapper.xml b/src/main/resources/mapper/BatchApplyMapper.xml index 923abee..ccaec19 100644 --- a/src/main/resources/mapper/BatchApplyMapper.xml +++ b/src/main/resources/mapper/BatchApplyMapper.xml @@ -68,7 +68,9 @@ + update commomtable diff --git a/src/main/resources/mapper/approve/Emr_Apply_ApproveMapper.xml b/src/main/resources/mapper/approve/Emr_Apply_ApproveMapper.xml index bd2dffc..d24da94 100644 --- a/src/main/resources/mapper/approve/Emr_Apply_ApproveMapper.xml +++ b/src/main/resources/mapper/approve/Emr_Apply_ApproveMapper.xml @@ -19,6 +19,10 @@ + + + + id, applyer, apply_time, effe_time, effe_days, apply_type, apply_reason, apply_state, @@ -269,6 +273,8 @@ AND approve_state != '2' AND + approver is not null + AND applyer = #{userName} AND patient_id IN (${patientId}) @@ -322,7 +328,11 @@ CASE WHEN effe_time <= convert(varchar(10),getdate()-1,23) THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批' END approve_state, c.name, - CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus + CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus, + return_state, + return_name, + return_time, + return_name_string FROM emr_apply_approve a LEFT JOIN @@ -407,7 +417,11 @@ CASE WHEN effe_time <= convert(varchar(10),getdate(),23) THEN '已过期' WHEN approve_state = '1' THEN '审核通过' WHEN approve_state='2' THEN '审核不通过' WHEN approve_state is null THEN '待审批' WHEN approve_state = '' THEN '待审批' END approve_state, c.name, - CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus + CASE WHEN emr_lock.id is null THEN 0 ELSE 1 END lockStatus, + return_state, + return_name, + return_time, + return_name_string FROM emr_apply_approve a LEFT JOIN @@ -661,6 +675,11 @@ where id in (${idsStr}) + + update emr_apply_approve set return_state='1',return_name=#{returnName}, + return_time=#{returnTime},return_name_string=#{returnNameString} + where id=#{id} + SELECT top (${effeDays}) date FROM emr_holiday_set where date> #{currentTime} AND flag=1 + + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/approveManage/approveList/approveList174.jsp b/src/main/webapp/WEB-INF/views/approveManage/approveList/approveList174.jsp index 7cb3f7c..6367664 100644 --- a/src/main/webapp/WEB-INF/views/approveManage/approveList/approveList174.jsp +++ b/src/main/webapp/WEB-INF/views/approveManage/approveList/approveList174.jsp @@ -5,7 +5,7 @@ <%@ include file="/WEB-INF/jspf/common.jspf" %> - + 申请列表 @@ -19,71 +19,87 @@ var path = "${path}";