| | |
| | | } |
| | | } |
| | | |
| | | //2.药品宣教 |
| | | for (PatMedInhosp patMedInhosp : patMedInhosps) { |
| | | String medicalCode = patMedInhosp.getMedicalCode(); |
| | | if (StringUtils.isNotEmpty(medicalCode)) { |
| | | String[] split = medicalCode.split(","); |
| | | // 防御性编程:确保 medicalCompany 和 medicalName 不为 null |
| | | String medicalCompanyStr = patMedInhosp.getMedicalCompany() != null ? patMedInhosp.getMedicalCompany() : ""; |
| | | String medicalNameStr = patMedInhosp.getMedicalName() != null ? patMedInhosp.getMedicalName() : ""; |
| | | String[] medicalCompanyArray = medicalCompanyStr.split(","); |
| | | String[] medicalNameArray = medicalNameStr.split(","); |
| | | //2.药品宣教(省立同德的需求,其它地方没提) |
| | | if (active.equals("sltd")) { |
| | | for (PatMedInhosp patMedInhosp : patMedInhosps) { |
| | | String medicalCode = patMedInhosp.getMedicalCode(); |
| | | if (StringUtils.isNotEmpty(medicalCode)) { |
| | | String[] split = medicalCode.split(","); |
| | | // 防御性编程:确保 medicalCompany 和 medicalName 不为 null |
| | | String medicalCompanyStr = patMedInhosp.getMedicalCompany() != null ? patMedInhosp.getMedicalCompany() : ""; |
| | | String medicalNameStr = patMedInhosp.getMedicalName() != null ? patMedInhosp.getMedicalName() : ""; |
| | | String[] medicalCompanyArray = medicalCompanyStr.split(","); |
| | | String[] medicalNameArray = medicalNameStr.split(","); |
| | | |
| | | for (int i = 0; i < split.length; i++) { |
| | | ServiceTaskmedical serviceTaskmedical = new ServiceTaskmedical(); |
| | | //拿药品编码和公司去查 |
| | | serviceTaskmedical.setMedicalCode(split[i]); |
| | | // 防止下标越界:如果数组长度不一致,取最小长度 |
| | | if (i < medicalCompanyArray.length) { |
| | | serviceTaskmedical.setMedicalName(medicalCompanyArray[i]); |
| | | } else { |
| | | log.warn("【药品宣教】药品编码{}对应的公司信息下标越界,medicalCompany 数组长度={}, 当前索引={}", split[i], medicalCompanyArray.length, i); |
| | | serviceTaskmedical.setMedicalName(""); // 越界时设置为空 |
| | | for (int i = 0; i < split.length; i++) { |
| | | ServiceTaskmedical serviceTaskmedical = new ServiceTaskmedical(); |
| | | //拿药品编码和公司去查 |
| | | serviceTaskmedical.setMedicalCode(split[i]); |
| | | // 防止下标越界:如果数组长度不一致,取最小长度 |
| | | if (i < medicalCompanyArray.length) { |
| | | serviceTaskmedical.setMedicalCompany(medicalCompanyArray[i]); |
| | | } else { |
| | | log.warn("【药品宣教】药品编码{}对应的公司信息下标越界,medicalCompany 数组长度={}, 当前索引={}", split[i], medicalCompanyArray.length, i); |
| | | serviceTaskmedical.setMedicalName(""); // 越界时设置为空 |
| | | } |
| | | List<ServiceTaskmedical> serviceTaskmedicals = serviceTaskmedicalMapper.selectServiceTaskmedicalList(serviceTaskmedical); |
| | | if (CollectionUtils.isNotEmpty(serviceTaskmedicals)) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp.getPatid()); |
| | | // check=true,让 writeInSubTask 内部做去重校验 |
| | | writeInSubTask(serviceTaskmedicals.get(0).getTaskId(), true, patMedInhosp, patArchive, 0, config); |
| | | } |
| | | //查不到的药品就是不需要宣教的,就不管了 |
| | | } |
| | | List<ServiceTaskmedical> serviceTaskmedicals = serviceTaskmedicalMapper.selectServiceTaskmedicalList(serviceTaskmedical); |
| | | if (CollectionUtils.isNotEmpty(serviceTaskmedicals)) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedInhosp.getPatid()); |
| | | writeInSubTask(serviceTaskmedicals.get(0).getTaskId(), false, patMedInhosp, patArchive, 0, config); |
| | | } |
| | | //查不到的药品就是不需要宣教的,就不管了 |
| | | } |
| | | } |
| | | } |
| | | |
| | | //3.出院随访 - 基于规则的任务生成 |
| | | // 获取所有需要处理的出院患者(科室维度未处理) |
| | | |
| | |
| | | |
| | | if (CollectionUtils.isNotEmpty(serviceTasks)) { |
| | | for (ServiceTask serviceTask : serviceTasks) { |
| | | if(!ObjectUtils.isEmpty(serviceTask.getTaskid())){ |
| | | if (!ObjectUtils.isEmpty(serviceTask.getTaskid())) { |
| | | ServiceTaskSchedule serviceTaskSchedule = new ServiceTaskSchedule(); |
| | | ServiceTaskSchedule taskSchedule = new ServiceTaskSchedule(); |
| | | taskSchedule.setTaskid(serviceTask.getTaskid()); |
| | | List<ServiceTaskSchedule> serviceTaskSchedules = serviceTaskScheduleMapper.selectServiceTaskScheduleList(taskSchedule); |
| | | if(CollectionUtils.isNotEmpty(serviceTaskSchedules)){ |
| | | if (CollectionUtils.isNotEmpty(serviceTaskSchedules)) { |
| | | serviceTaskSchedule = serviceTaskSchedules.get(0); |
| | | String deptCodes = serviceTaskSchedule.getDeptCodes(); |
| | | String wardCodes = serviceTaskSchedule.getWardCodes(); |
| | |
| | | Integer type = 1; |
| | | if (StringUtils.isNotEmpty(deptCodes)) { |
| | | type = 1; |
| | | deptCodeList = Arrays.asList(deptCodes.split(",")); |
| | | deptCodeList = new ArrayList<>(Arrays.asList(deptCodes.split(","))); |
| | | } |
| | | if(StringUtils.isNotEmpty(wardCodes)) { |
| | | if (StringUtils.isNotEmpty(wardCodes)) { |
| | | type = 2; |
| | | wardCodeList = Arrays.asList(wardCodes.split(",")); |
| | | wardCodeList = new ArrayList<>(Arrays.asList(wardCodes.split(","))); |
| | | } |
| | | if(StringUtils.isNotEmpty(icd10Codes)) { |
| | | if (StringUtils.isNotEmpty(icd10Codes)) { |
| | | type = 3; |
| | | icd10CodeList = Arrays.asList(icd10Codes.split(",")); |
| | | icd10CodeList = new ArrayList<>(Arrays.asList(icd10Codes.split(","))); |
| | | } |
| | | if (StringUtils.isNotEmpty(opLevelCodes)) { |
| | | type = 6; |
| | | opLevelCodeList = Arrays.asList(opLevelCodes.split(",")); |
| | | opLevelCodeList = new ArrayList<>(Arrays.asList(opLevelCodes.split(","))); |
| | | } |
| | | //非手术处理方式 |
| | | if(type != 6){ |
| | | if (type != 6) { |
| | | PatMedInhosp patMedInhospVo = new PatMedInhosp(); |
| | | patMedInhospVo.setScheduleCheckFlag("0"); |
| | | patMedInhospVo.setInhospstate("1"); |
| | |
| | | List<PatMedInhosp> patList = patMedInhospMapper.selectPatMedInhospList(patMedInhospVo); |
| | | log.info("dealOutHospInfoBySchedule 任务组随访, taskid = {}, 扫描患者人数 {}", serviceTask.getTaskid(), patList.size()); |
| | | |
| | | for(PatMedInhosp patMedInhosp : patList){ |
| | | for (PatMedInhosp patMedInhosp : patList) { |
| | | ServiceTaskScheduleDetail scheduleDetailVo = new ServiceTaskScheduleDetail(); |
| | | scheduleDetailVo.setTaskid(serviceTask.getTaskid()); |
| | | scheduleDetailVo.setScheduleid(serviceTaskSchedule.getId()); |
| | |
| | | |
| | | ServiceSubtask serviceSubtask = boxedServiceSubtask(serviceTask, patMedInhosp, patArchive, config, type); |
| | | List<Map<String, Object>> preachformList = new ArrayList<>(); |
| | | if(StringUtils.isNotEmpty(serviceTask.getPreachformDesc())){ |
| | | if (StringUtils.isNotEmpty(serviceTask.getPreachformDesc())) { |
| | | try { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | preachformList = objectMapper.readValue(serviceTask.getPreachformDesc(), List.class); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | log.error("任务组preachformDesc解析失败,taskid={},inhospid={}", serviceTask.getTaskid(), patMedInhosp.getInhospid()); |
| | | } |
| | | } |
| | |
| | | flagUpd.setScheduleCheckFlag("1"); |
| | | patMedInhospMapper.updatePatMedInhosp(flagUpd); |
| | | } |
| | | }else { |
| | | } else { |
| | | //任务组 - 手术随访 |
| | | if(CollectionUtils.isNotEmpty(opLevelCodeList)){ |
| | | if (CollectionUtils.isNotEmpty(opLevelCodeList)) { |
| | | PatMedOperationItem pmoi = new PatMedOperationItem(); |
| | | //获取需要出院疾病随访,未处理的数据 |
| | | pmoi.setOpercheckFlag("0"); |
| | |
| | | pmoi.setWardCodes(wardCodeList); |
| | | pmoi.setOpLevelCodes(opLevelCodeList); |
| | | List<PatMedOperationItem> patMedOperationItems = patMedOperationItemMapper.selectOperationItemList(pmoi); |
| | | for(PatMedOperationItem patMedOperationItem : patMedOperationItems){ |
| | | for (PatMedOperationItem patMedOperationItem : patMedOperationItems) { |
| | | PatArchive patArchive = patArchiveMapper.selectPatArchiveByPatid(patMedOperationItem.getPatid()); |
| | | if (Objects.isNull(patArchive)) { |
| | | continue; |
| | |
| | | patMedInhospVo.setInhospstate("1"); |
| | | patMedInhospVo.setFuflag("1"); |
| | | List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhospVo); |
| | | if(CollectionUtils.isNotEmpty(patMedInhospList)){ |
| | | if (CollectionUtils.isNotEmpty(patMedInhospList)) { |
| | | ServiceTaskScheduleDetail scheduleDetailVo = new ServiceTaskScheduleDetail(); |
| | | scheduleDetailVo.setTaskid(serviceTask.getTaskid()); |
| | | scheduleDetailVo.setScheduleid(serviceTaskSchedule.getId()); |
| | |
| | | //封装serviceSubtask |
| | | ServiceSubtask serviceSubtask = boxedServiceSubtaskForOp(serviceTask, patMedInhospList.get(0), patMedOperationItem, patArchive, config); |
| | | List<Map<String, Object>> preachformList = new ArrayList<>(); |
| | | if(StringUtils.isNotEmpty(serviceTask.getPreachformDesc())){ |
| | | if (StringUtils.isNotEmpty(serviceTask.getPreachformDesc())) { |
| | | try { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | preachformList = objectMapper.readValue(serviceTask.getPreachformDesc(), List.class); |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | log.error("任务组(手术)preachformDesc解析失败,taskid={}", serviceTask.getTaskid()); |
| | | } |
| | | } |
| | |
| | | List<ServiceTask> serviceTasks = serviceTaskMapper.selectServiceTaskList(st); |
| | | ServiceTask serviceTask = null; |
| | | if (CollectionUtils.isEmpty(serviceTasks)) { |
| | | if (type == 0) { |
| | | log.info("该患者药品宣教长期任务不存在,任务ID为:{}", taskid); |
| | | patMedInhosp1.setMedcheckFlag("2"); |
| | | patMedInhosp1.setLongTaskReason(longTaskReason + " & 该患者药品宣教长期任务不存在,任务ID为:" + taskid); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp1); |
| | | return; |
| | | } |
| | | if (type == 1) { |
| | | log.info("该患者出院随访长期任务不存在,任务ID为:{}", taskid); |
| | | patMedInhosp1.setDeptcheckFlag("2"); |
| | |
| | | addServiceSubtaskPreachform(serviceSubtask, null); |
| | | } |
| | | |
| | | //将check_flag改成1(已处理) |
| | | //将 check_flag 改成 1(已处理) |
| | | if (i == 1) { |
| | | PatMedInhosp patMedInhosp2 = new PatMedInhosp(); |
| | | patMedInhosp2.setInhospid(patMedInhosp1.getInhospid()); |
| | |
| | | if (type == 1) patMedInhosp2.setDeptcheckFlag("2"); |
| | | if (type == 2) patMedInhosp2.setWardcheckFlag("2"); |
| | | if (type == 3) patMedInhosp2.setDiagcheckFlag("2"); |
| | | if (type == 0) patMedInhosp2.setMedcheckFlag("2"); |
| | | patMedInhosp2.setRemark("生成子任务报错回滚 " + type); |
| | | patMedInhospMapper.updatePatMedInhosp(patMedInhosp2); |
| | | e.printStackTrace(); |
| | |
| | | patMedInhosp.setPatid((patMedOperationItem.getPatid())); |
| | | patMedInhosp.setInhospstate("1"); |
| | | patMedInhosp.setFuflag("1"); |
| | | //手术随访 |
| | | if(!active.equals("hzszlyy")){ |
| | | patMedInhosp.setSerialnum(patMedOperationItem.getSerialnum()); |
| | | } |
| | | List<PatMedInhosp> patMedInhospList = patMedInhospMapper.selectPatMedInhospList(patMedInhosp); |
| | | |
| | | if (CollectionUtils.isEmpty(patMedInhospList)) { |
| | |
| | | if (ObjectUtils.isEmpty(serviceSubtask)) { |
| | | return; |
| | | } |
| | | if (StringUtils.isNotEmpty(patMedOperationItem.getDeptcode())) { |
| | | serviceSubtask.setVisitDeptCode(patMedOperationItem.getDeptcode()); |
| | | serviceSubtask.setVisitDeptName(patMedOperationItem.getDeptname()); |
| | | if (StringUtils.isNotEmpty(patMedOperationItem.getLeaveldeptcode())) { |
| | | serviceSubtask.setVisitDeptCode(patMedOperationItem.getLeaveldeptcode()); |
| | | serviceSubtask.setVisitDeptName(patMedOperationItem.getLeaveldeptname()); |
| | | } else { |
| | | serviceSubtask.setVisitDeptCode(patMedOperationItem.getHospitaldistrictcode()); |
| | | serviceSubtask.setVisitDeptName(patMedOperationItem.getHospitaldistrictname()); |
| | | serviceSubtask.setVisitDeptCode(patMedOperationItem.getLeavehospitaldistrictcode()); |
| | | serviceSubtask.setVisitDeptName(patMedOperationItem.getLeavehospitaldistrictname()); |
| | | } |
| | | //记录insertServiceSubtask语句返回状态 |
| | | Integer i = 0; |
| | |
| | | serviceSubtask.setTaskid(serviceTask.getTaskid()); |
| | | if (StringUtils.isNotEmpty(serviceTask.getLibtemplateid())) |
| | | serviceSubtask.setLibtemplateid(Long.valueOf(serviceTask.getLibtemplateid())); |
| | | serviceSubtask.setNurseId(patMedOperationItem.getNurseId()); |
| | | serviceSubtask.setNurseName(patMedOperationItem.getNurseName()); |
| | | // serviceSubtask.setInhospid(patMedInhosp.getInhospid()); |
| | | serviceSubtask.setDrcode(patMedOperationItem.getDrcode()); |
| | | serviceSubtask.setDrname(patMedOperationItem.getDrname()); |
| | | serviceSubtask.setDeptcode(patMedOperationItem.getDeptcode()); |
| | | serviceSubtask.setDeptname(patMedOperationItem.getDeptname()); |
| | | serviceSubtask.setNurseId(patMedInhosp1.getNurseId()); |
| | | serviceSubtask.setNurseName(patMedInhosp1.getNurseName()); |
| | | serviceSubtask.setInhospid(patMedInhosp1.getInhospid()); |
| | | serviceSubtask.setDrcode(patMedInhosp1.getDrcode()); |
| | | serviceSubtask.setDrname(patMedInhosp1.getDrname()); |
| | | serviceSubtask.setDeptcode(patMedInhosp1.getLeaveldeptcode()); |
| | | serviceSubtask.setDeptname(patMedInhosp1.getLeaveldeptname()); |
| | | serviceSubtask.setLeavehospitaldistrictcode(patMedInhosp1.getLeavehospitaldistrictcode()); |
| | | serviceSubtask.setLeavehospitaldistrictname(patMedInhosp1.getLeavehospitaldistrictname()); |
| | | |
| | | serviceSubtask.setTemplateid(serviceTask.getTemplateid()); |
| | | serviceSubtask.setTemplatename(serviceTask.getTemplatename()); |
| | |
| | | serviceSubtask.setSex(patArchive.getSex()); |
| | | serviceSubtask.setAge(patArchive.getAge()); |
| | | serviceSubtask.setSendstate(2L); |
| | | serviceSubtask.setManagementDoctor(patMedOperationItem.getDrname()); |
| | | serviceSubtask.setManagementDoctorCode(patMedOperationItem.getDrcode()); |
| | | // serviceSubtask.setStarttime(patMedInhosp.getStarttime()); |
| | | // serviceSubtask.setEndtime(patMedInhosp.getEndtime()); |
| | | serviceSubtask.setManagementDoctor(patMedInhosp1.getDrname()); |
| | | serviceSubtask.setManagementDoctorCode(patMedInhosp1.getDrcode()); |
| | | |
| | | serviceSubtask.setStarttime(patMedInhosp1.getStarttime()); |
| | | serviceSubtask.setEndtime(patMedInhosp1.getEndtime()); |
| | | |
| | | serviceSubtask.setServiceType(serviceTask.getServiceType()); |
| | | serviceSubtask.setPreachform(serviceTask.getPreachform()); |
| | | serviceSubtask.setHospType("2"); |
| | | serviceSubtask.setCreateTime(new Date()); |
| | | serviceSubtask.setUpdateTime(new Date()); |
| | | serviceSubtask.setCreateBy(patMedOperationItem.getNurseName()); |
| | | // serviceSubtask.setLeavehospitaldistrictcode(patArchive.getLeavehospitaldistrictcode()); |
| | | // serviceSubtask.setLeavehospitaldistrictname(patArchive.getLeavehospitaldistrictname()); |
| | | serviceSubtask.setCreateBy(patMedInhosp1.getNurseName()); |
| | | serviceSubtask.setOperationItemId(patMedOperationItem.getId()); |
| | | serviceSubtask.setUpdateBy(serviceTask.getUpdateBy()); |
| | | serviceSubtask.setUpdateTime(new Date()); |
| | |
| | | public void addOperationSubTask(String config) { |
| | | // 手术随访 |
| | | PatMedOperationItem pmoi = new PatMedOperationItem(); |
| | | //获取需要出院疾病随访,未处理的数据 |
| | | //获取需要出院手术随访,未处理的数据 |
| | | if(!active.equals("hzszlyy")){ |
| | | pmoi.setInhospstate("1"); |
| | | } |
| | | pmoi.setOpercheckFlag("0"); |
| | | pmoi.setMainFlag("1"); |
| | | |
| | |
| | | serviceTaskoper.setOplevelcode(opItem.getOplevelcode()); |
| | | |
| | | //根据科室、病区过滤 |
| | | serviceTaskoper.setDeptCode(opItem.getDeptcode()); |
| | | serviceTaskoper.setWardCode(opItem.getHospitaldistrictcode()); |
| | | if(StringUtils.isNotEmpty(opItem.getLeaveldeptcode())){ |
| | | serviceTaskoper.setDeptCode(opItem.getLeaveldeptcode()); |
| | | }else { |
| | | serviceTaskoper.setWardCode(opItem.getLeavehospitaldistrictcode()); |
| | | } |
| | | |
| | | List<ServiceTaskoper> serviceTaskopers = serviceTaskoperMapper.selectServiceTaskoperList(serviceTaskoper); |
| | | //如果部门模板为空(将deptIsNull设置为true) |
| | |
| | | // 根据患者的疾病,获取该疾病的长期任务 |
| | | ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag(); |
| | | serviceTaskdiag.setLongtask(1L); |
| | | serviceTaskdiag.setServiceType("2"); |
| | | // serviceTaskdiag.setServiceType("2"); |
| | | if (active.equals("nhfy")) { |
| | | //南华附一的icd10code有重复,所以用主诊断名称去查询 |
| | | serviceTaskdiag.setIcd10name(pmiJB.getLeavediagname()); |
| | |
| | | |
| | | ServiceTaskdiag serviceTaskdiag = new ServiceTaskdiag(); |
| | | serviceTaskdiag.setLongtask(1L); |
| | | serviceTaskdiag.setServiceType("2"); |
| | | // serviceTaskdiag.setServiceType("2"); |
| | | if (active.equals("nhfy")) { |
| | | serviceTaskdiag.setIcd10name(patMedInhosp1.getLeavediagname()); |
| | | if (StringUtils.isEmpty(patMedInhosp1.getLeavediagname())) { |