陈昶聿
13 小时以前 dfdedd9df6386d062a8889d1cb5883f3294e0bb5
smartor/src/main/java/com/smartor/service/impl/PatMedOuthospServiceImpl.java
@@ -76,6 +76,11 @@
        PatMedOuthospQueryReq patMedOuthospQueryReq = DtoConversionUtils.sourceToTarget(patMedOuthosp, PatMedOuthospQueryReq.class);
        patMedOuthospQueryReq.setBeginAdmitdate(patMedOuthosp.getBeginTime());
        patMedOuthospQueryReq.setEndAdmitdate(patMedOuthosp.getEndTime());
        if(!CollectionUtils.isEmpty(patMedOuthosp.getDeptcodes())) {
            String result = String.join(",",   patMedOuthosp.getDeptcodes());
            patMedOuthospQueryReq.setDeptcode(result);
        }
        List<PatMedOuthosp> patMedOuthospQueryResps = patMedOuthospMapper.callSpQueryOuthosp(patMedOuthospQueryReq);
        if (patMedOuthosp.getPageNum() != null) {
            for (PatMedOuthosp patMedOuthosp1 : patMedOuthospQueryResps) {
@@ -304,7 +309,7 @@
        PatMedOuthospQueryReq req = new PatMedOuthospQueryReq();
        String deptcodes = CollectionUtils.isEmpty(patMedReq.getDeptcodeList()) ? null : String.join(",", patMedReq.getDeptcodeList());
        req.setBeginAdmitdate(patMedReq.getStartDate());
        req.setEndAdmitdate(patMedReq.getEndDate());
        req.setEndAdmitdate(DateUtils.addDays(patMedReq.getEndDate(),1));
        req.setDeptcode(deptcodes);
        req.setOrgid(patMedReq.getOrgid());
//        req.setCampusid(patMedReq.getCampusid());
@@ -334,6 +339,7 @@
    public Integer dealOutpatientInfo() {
        PatMedOuthosp patMedOuthosp = new PatMedOuthosp();
        patMedOuthosp.setDiagcheckFlag("0");
        patMedOuthosp.setFuflag("1");
        List<PatMedOuthosp> patMedOuthosps = selectPatMedOuthospList(patMedOuthosp);
        for (PatMedOuthosp patMedOuthosp1 : patMedOuthosps) {
            PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOuthosp1.getPatid());
@@ -469,7 +475,8 @@
    }
    //封装serviceSubtask
    private ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
    @Override
    public ServiceSubtask boxedServiceSubtask(ServiceTask serviceTask, PatMedOuthosp patMedOuthosp, PatArchive patArchive) {
        ServiceSubtask serviceSubtask = DtoConversionUtils.sourceToTarget(serviceTask, ServiceSubtask.class);
        serviceSubtask.setTaskid(serviceTask.getTaskid());
        if (StringUtils.isNotEmpty(serviceTask.getLibtemplateid()))
@@ -524,6 +531,68 @@
        return serviceSubtask;
    }
    /**
     *
     * @param patMedOuthosp
     * @return
     */
    @Override
    public Integer followUpAgainByPatMedOuthosp(PatMedOuthosp patMedOuthosp,Date adminDate, Integer visitTimeNum){
        int hoursToAdd = visitTimeNum * 24;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(adminDate);
        calendar.add(Calendar.HOUR_OF_DAY, hoursToAdd);
        Date newDate = calendar.getTime();
        Integer i = 0;
        String deptcode = patMedOuthosp.getDeptcode();
        Long patid = patMedOuthosp.getPatid();
        //查看有无进行中的任务
        ServiceSubtaskEntity serviceSubtaskEntity0 = new ServiceSubtaskEntity();
        serviceSubtaskEntity0.setOrgid(patMedOuthosp.getOrgid());
        serviceSubtaskEntity0.setSendstates(new ArrayList<>(Arrays.asList(1L, 2L, 3L, 7L)));
        serviceSubtaskEntity0.setPatid(patid);
        serviceSubtaskEntity0.setDeptcode(deptcode);
        serviceSubtaskEntity0.setSort(0);
        List<ServiceSubtask> serviceSubtaskList0 = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskEntity0);
        if(!CollectionUtils.isEmpty(serviceSubtaskList0)){
            ServiceSubtask serviceSubtask0 = serviceSubtaskList0.get(0);
            serviceSubtask0.setSendstate(6L);
            serviceSubtask0.setUpdateTime(new Date());
            serviceSubtask0.setFinishtime(adminDate);
            serviceSubtaskMapper.updateServiceSubtask(serviceSubtask0);
            ServiceSubtask serviceSubtask1 = serviceSubtaskList0.get(0);
            serviceSubtask1.setSendstate(2L);
            serviceSubtask1.setCreateTime(new Date());
            serviceSubtask1.setUpdateTime(new Date());
            serviceSubtask1.setVisitTime(newDate);
            serviceSubtask1.setLongSendTime(newDate);
            i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask1);
        }else {
            //查看已完成的任务
//            ServiceSubtaskEntity serviceSubtaskEntity = new ServiceSubtaskEntity();
//            serviceSubtaskEntity0.setOrgid(patMedOuthosp.getOrgid());
//            serviceSubtaskEntity.setSendstates(new ArrayList<>(Arrays.asList(6L)));
//            serviceSubtaskEntity.setPatid(patid);
//            serviceSubtaskEntity.setDeptcode(deptcode);
//            serviceSubtaskEntity.setSort(0);
//            List<ServiceSubtask> serviceSubtaskList = serviceSubtaskMapper.selectServiceSubtaskList(serviceSubtaskEntity);
//            if(!CollectionUtils.isEmpty(serviceSubtaskList)){
//                ServiceSubtask serviceSubtask = serviceSubtaskList.get(0);
//                serviceSubtask.setSendstate(2L);
//                serviceSubtask.setCreateTime(new Date());
//                serviceSubtask.setUpdateTime(new Date());
//
//                serviceSubtask.setVisitTime(newDate);
//                serviceSubtask.setLongSendTime(newDate);
//                i = serviceSubtaskMapper.insertServiceSubtask(serviceSubtask);
//            }
        }
        return i;
    }
    private Date addDays(Date date, Integer days) {
        if (days == null) {
            days = 1;