From e461eeace58bc747f3365aba3fed1b0fe075916d Mon Sep 17 00:00:00 2001 From: zzc Date: Thu, 20 Feb 2025 18:08:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=85=A8=E5=B1=80=E5=BD=95?= =?UTF-8?q?=E9=9F=B3=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/web/FmsFollowupController.java | 7 + .../acupuncture/web/task/TaskController.java | 207 +++++++++++++----- .../acupuncture/web/task/TaskController1.java | 207 ++++++++++++++++++ .../src/main/resources/application-stage.yml | 2 +- .../src/main/resources/mbg.xml | 4 +- .../system/domain/dto/FmsFollowupDto.java | 22 +- .../system/domain/dto/PmsTreatmentDto.java | 24 ++ .../system/domain/po/FmsFollowupQueue.java | 22 ++ .../domain/po/FmsFollowupQueueExample.java | 120 ++++++++++ .../system/domain/vo/FmsFollowupVo.java | 53 ++++- .../system/persist/dao/FmsFollowupDao.java | 3 +- .../system/service/FmsFollowupService.java | 2 +- .../impl/FmsFollowupQueueServiceImpl.java | 11 +- .../service/impl/FmsFollowupServiceImpl.java | 17 +- .../service/impl/PmsPatientServiceImpl.java | 12 + .../service/impl/PmsTreatmentServiceImpl.java | 91 +++++--- .../resources/mapper/dao/FmsFollowupDao.xml | 24 +- .../resources/mapper/dao/StatisticsDao.xml | 4 + .../mapper/system/FmsFollowupQueueMapper.xml | 52 ++++- 19 files changed, 777 insertions(+), 107 deletions(-) create mode 100644 acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController1.java diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java index bcb8c765..aea89c50 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupController.java @@ -123,4 +123,11 @@ public class FmsFollowupController { fmsFollowupService.completeFollowup(dto); return JsonResponse.ok(); } + + @ApiOperation("修改随访工单状态") + @PostMapping("/status") + public JsonResponse status(@RequestBody @Validated FmsFollowupDto.UpdStatusDto dto){ + fmsFollowupService.updStatus(dto.getId(), dto.getStatus()); + return JsonResponse.ok(); + } } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java index d9066fe4..2951bb94 100644 --- a/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController.java @@ -5,8 +5,11 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; import com.acupuncture.common.annotation.Anonymous; +import com.acupuncture.common.core.redis.RedisCache; import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; +import com.acupuncture.system.domain.dto.FmsFollowupDto; import com.acupuncture.system.domain.po.FmsFollowupTask; +import com.acupuncture.system.domain.po.FmsFollowupTaskExample; import com.acupuncture.system.domain.po.FmsPatientQueueRelation; import com.acupuncture.system.domain.vo.FmsFollowupVo; import com.acupuncture.system.domain.vo.UmsDataSourceVo; @@ -14,11 +17,14 @@ import com.acupuncture.system.persist.dao.FmsFollowupDao; import com.acupuncture.system.persist.dao.UmsDataSourceDao; import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; +import com.acupuncture.system.service.FmsFollowupService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.quartz.TriggerUtils; import org.quartz.impl.triggers.CronTriggerImpl; +import org.quartz.spi.OperableTrigger; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; @@ -27,10 +33,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @Author zzc @@ -48,17 +51,23 @@ public class TaskController { @Resource private FmsFollowupDao fmsFollowupDao; @Resource + private FmsFollowupService fmsFollowupService; + @Resource private FmsFollowupTaskMapper fmsFollowupTaskMapper; @Resource private UmsDataSourceDao umsDataSourceDao; @Resource private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper; + @Resource + private RedisCache redisCache; @ApiOperation("定时任务添加随访工单") @PostMapping("/task") @Scheduled(fixedRate = 10000) @Anonymous public void task() { + // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 ) + //查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单 // UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result(); // result1.setDataSourceKey("MASTER"); @@ -68,7 +77,8 @@ public class TaskController { return; } //查询公共队列 - List queueResults = fmsFollowupDao.queryCommonQueue(null); + List queueResults = redisCache.getCacheList("common_followup_queue"); +// List queueResults = fmsFollowupDao.queryCommonQueue(null); //切换数据源 for (UmsDataSourceVo.Result result : query) { if ("MASTER".equals(result.getDataSourceKey())) { @@ -81,13 +91,23 @@ public class TaskController { List queueList = fmsFollowupDao.selectQueueList(null, null, null); if (CollectionUtil.isEmpty(queueList)) { - queueList = queueResults; + if (CollectionUtil.isEmpty(queueResults)) { + queueList = BeanUtil.copyToList(queueResults, FmsFollowupVo.FollowupQueueVO.class); + } } else { - queueList.addAll(queueResults); + if (CollectionUtil.isEmpty(queueResults)) { + queueList.addAll(BeanUtil.copyToList(queueResults, FmsFollowupVo.FollowupQueueVO.class)); + } } for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) { + Integer followWindowAdys = followupQueueVO.getFollowWindowAdys(); + //2. 查询队列随访患者列表 - List patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), (byte) 0); +// changeDataSource(result); + FmsFollowupDto.FollowupPatientQueryDTO followupPatientQueryDTO = new FmsFollowupDto.FollowupPatientQueryDTO(); + followupPatientQueryDTO.setQueueId(followupQueueVO.getId()); + List patientList = fmsFollowupService.queryPatient(followupPatientQueryDTO); +// List patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), null, null); if (CollectionUtil.isEmpty(patientList)) { continue; } @@ -117,6 +137,14 @@ public class TaskController { //3. 判断随访类型 if (followupQueueVO.getFollowupType() == 0) { //单次 + + //判断是否已有该次随访 + FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); + fmsFollowupTaskExample.createCriteria().andTimesEqualTo(1).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); + List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); + if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { + continue; + } FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); @@ -140,8 +168,14 @@ public class TaskController { fmsFollowupTask.setDelFlag((byte) 0); fmsFollowupTask.setCreateTime(new Date()); fmsFollowupTask.setStatus((byte) 0); - fmsFollowupTask.setStartTime(dateList.get(0)); - fmsFollowupTask.setEndTime(dateList.get(0)); + + //计算第一次随访的时间 + Calendar instance = Calendar.getInstance(); + instance.setTime(dateList.get(0)); + instance.set(Calendar.DAY_OF_MONTH, -followWindowAdys / 2); + fmsFollowupTask.setStartTime(instance.getTime()); + instance.set(Calendar.DAY_OF_MONTH, followWindowAdys); + fmsFollowupTask.setEndTime(instance.getTime()); fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); fmsFollowupTask.setFollowupTime(dateList.get(0)); changeDataSource(result); @@ -150,48 +184,55 @@ public class TaskController { } else { //周期 //4. 根据频次和总月数添加 - int i = 0; - for (Date date : dateList) { - i+=1; - //单次 - FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); - BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); - fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); - fmsFollowupTask.setName(followupPatient.getName()); - fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); - fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); - fmsFollowupTask.setGender(followupPatient.getGender()); - if (followupPatient.getBirthDate() != null) { - fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); - } - fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); - fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); - fmsFollowupTask.setTimes(i); - fmsFollowupTask.setPhone(followupPatient.getPhone()); - fmsFollowupTask.setTenantId(followupPatient.getTenantId()); - fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); - fmsFollowupTask.setIdCard(followupPatient.getIdCard()); - fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); - fmsFollowupTask.setQueueId(followupQueueVO.getId()); - fmsFollowupTask.setDelFlag((byte) 0); - fmsFollowupTask.setCreateTime(new Date()); - fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); - fmsFollowupTask.setStatus((byte) 0); - fmsFollowupTask.setStartTime(date); - fmsFollowupTask.setEndTime(date); - fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); - fmsFollowupTask.setFollowupTime(date); - changeDataSource(result); - fmsFollowupTask.setPatientId(followupPatient.getId()); - fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); + DateComparator dateComparator = getDate(dateList); + if (dateComparator.getDate() == null || dateComparator.getIndex() == null) { + continue; + } + Date date = dateComparator.getDate(); + Integer index = dateComparator.getIndex(); + + //判断是否已有该次随访 + FmsFollowupTaskExample fmsFollowupTaskExample = new FmsFollowupTaskExample(); + fmsFollowupTaskExample.createCriteria().andTimesEqualTo(index).andPatientIdEqualTo(followupPatient.getPatientId()).andQueueIdEqualTo(followupQueueVO.getId()); + List fmsFollowupTasks = fmsFollowupTaskMapper.selectByExample(fmsFollowupTaskExample); + if (CollectionUtil.isNotEmpty(fmsFollowupTasks)) { + continue; } + + FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); + BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); + fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); + fmsFollowupTask.setName(followupPatient.getName()); + fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); + fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); + fmsFollowupTask.setGender(followupPatient.getGender()); + if (followupPatient.getBirthDate() != null) { + fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); + } + fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setTimes(index); + fmsFollowupTask.setPhone(followupPatient.getPhone()); + fmsFollowupTask.setTenantId(followupPatient.getTenantId()); + fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); + fmsFollowupTask.setIdCard(followupPatient.getIdCard()); + fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); + fmsFollowupTask.setQueueId(followupQueueVO.getId()); + fmsFollowupTask.setDelFlag((byte) 0); + fmsFollowupTask.setCreateTime(new Date()); + fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); + fmsFollowupTask.setStatus((byte) 0); + + Calendar instance = Calendar.getInstance(); + instance.setTime(dateList.get(0)); + instance.set(Calendar.DAY_OF_MONTH, -followWindowAdys / 2); + fmsFollowupTask.setStartTime(date); + instance.set(Calendar.DAY_OF_MONTH, followWindowAdys); + fmsFollowupTask.setEndTime(instance.getTime()); + changeDataSource(result); + fmsFollowupTask.setPatientId(followupPatient.getId()); + fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); } - changeDataSource(result); - //将患者设置为已生成工单 - FmsPatientQueueRelation fmsPatientQueueRelation = BeanUtil.copyProperties(followupPatient, FmsPatientQueueRelation.class); - fmsPatientQueueRelation.setTaskFlag((byte) 1); - fmsPatientQueueRelation.setPatientId(followupPatient.getId()); - fmsPatientQueueRelationMapper.updateByPrimaryKeySelective(fmsPatientQueueRelation); } } @@ -202,4 +243,70 @@ public class TaskController { private static void changeDataSource(UmsDataSourceVo.Result result) { DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey()); } + + /** + * 法用于计算在指定时间范围内触发器的触发时间点。具体步骤如下: + * 初始化一个空列表 lst 存储触发时间点。 + * 克隆传入的触发器 trigg,并检查其下一个触发时间是否为空。如果为空,则设置开始时间和结束时间,并计算首次触发时间。 + * 使用 while 循环遍历触发器的触发时间点,直到没有更多触发时间或超出指定范围。 + * 如果触发时间在指定范围内,则将其添加到列表中,并更新触发器状态。 + * + * @param trigg cron表达式 + * @param from 患者出院时间 + * @param to 患者出院时间 + 随访总月数 + * @return + */ + public static List computeFireTimesBetween(OperableTrigger trigg, org.quartz.Calendar cal, Date from, Date to) { + LinkedList lst = new LinkedList(); + OperableTrigger t = (OperableTrigger) trigg.clone(); + if (t.getNextFireTime() == null) { + t.setStartTime(from); + t.setEndTime(to); + t.computeFirstFireTime(cal); + } + + while (true) { + Date d = t.getNextFireTime(); + if (d == null) { + break; + } + + if (d.before(from)) { + t.triggered(cal); + } else { + if (d.after(to)) { + break; + } + lst.add(d); + t.triggered(cal); + } + } + return Collections.unmodifiableList(lst); + } + + /** + * 返回当前时间之后的第一个date及对应顺序 + * + * @param dateList key 为顺序,value 为时间 + * @return + */ + public static DateComparator getDate(List dateList) { + Date today = new Date(); + DateComparator dateComparator = new DateComparator(); + for (int i = 0; i < dateList.size(); i++) { + Date date = dateList.get(i); + if (date.after(today)) { + dateComparator.setDate(date); + dateComparator.setIndex(i + 1); + return dateComparator; + } + } + return dateComparator; + } + + @Data + public static class DateComparator { + private Date date; + private Integer index; + } } diff --git a/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController1.java b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController1.java new file mode 100644 index 00000000..51183752 --- /dev/null +++ b/acupuncture-admin/src/main/java/com/acupuncture/web/task/TaskController1.java @@ -0,0 +1,207 @@ +//package com.acupuncture.web.task; +// +//import cn.hutool.core.bean.BeanUtil; +//import cn.hutool.core.collection.CollectionUtil; +//import cn.hutool.core.date.DateUtil; +//import cn.hutool.core.util.IdUtil; +//import com.acupuncture.common.annotation.Anonymous; +//import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder; +//import com.acupuncture.system.domain.po.FmsFollowupTask; +//import com.acupuncture.system.domain.po.FmsPatientQueueRelation; +//import com.acupuncture.system.domain.vo.FmsFollowupVo; +//import com.acupuncture.system.domain.vo.UmsDataSourceVo; +//import com.acupuncture.system.persist.dao.FmsFollowupDao; +//import com.acupuncture.system.persist.dao.UmsDataSourceDao; +//import com.acupuncture.system.persist.mapper.FmsFollowupTaskMapper; +//import com.acupuncture.system.persist.mapper.FmsPatientQueueRelationMapper; +//import io.swagger.annotations.Api; +//import io.swagger.annotations.ApiOperation; +//import lombok.extern.slf4j.Slf4j; +//import org.quartz.TriggerUtils; +//import org.quartz.impl.triggers.CronTriggerImpl; +//import org.springframework.scheduling.annotation.Scheduled; +//import org.springframework.transaction.annotation.Propagation; +//import org.springframework.transaction.annotation.Transactional; +//import org.springframework.web.bind.annotation.PostMapping; +//import org.springframework.web.bind.annotation.RequestMapping; +//import org.springframework.web.bind.annotation.RestController; +// +//import javax.annotation.Resource; +//import java.util.ArrayList; +//import java.util.Calendar; +//import java.util.Date; +//import java.util.List; +// +///** +// * @Author zzc +// * @Package com.acupuncture.web.controller.web +// * @Date 2025/2/13 8:50 +// * @description: +// */ +//@Slf4j +//@Api(tags = "定时任务相关") +//@RestController +//@RequestMapping("/task") +//@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) +//public class TaskController1 { +// +// @Resource +// private FmsFollowupDao fmsFollowupDao; +// @Resource +// private FmsFollowupTaskMapper fmsFollowupTaskMapper; +// @Resource +// private UmsDataSourceDao umsDataSourceDao; +// @Resource +// private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper; +// +// @ApiOperation("定时任务添加随访工单") +// @PostMapping("/task") +// @Scheduled(fixedRate = 10000) +// @Anonymous +// public void task() { +// // TODO 生成工单第一次生成之后2周的,往后只生成之后一周。第一次随访时间: ( 患者的出院时间 - 7 + 轮次时间) 到 (患者的出院时间 + 7 + 轮次时间 ) +// +// //查询租户,根据租户循环切换数据源,定时处理所有医院的随访工单 +//// UmsDataSourceVo.Result result1 = new UmsDataSourceVo.Result(); +//// result1.setDataSourceKey("MASTER"); +//// changeDataSource(result1); +// List query = umsDataSourceDao.query(); +// if (CollectionUtil.isEmpty(query)) { +// return; +// } +// //查询公共队列 +// List queueResults = fmsFollowupDao.queryCommonQueue(null); +// //切换数据源 +// for (UmsDataSourceVo.Result result : query) { +// if ("MASTER".equals(result.getDataSourceKey())) { +// continue; +// } +// changeDataSource(result); +// { +// //获取随访患者列表,根据患者出院日时间和队列添加工单 +// //1. 查询队列 +// List queueList = fmsFollowupDao.selectQueueList(null, null, null); +// +// if (CollectionUtil.isEmpty(queueList)) { +// queueList = queueResults; +// } else { +// queueList.addAll(queueResults); +// } +// for (FmsFollowupVo.FollowupQueueVO followupQueueVO : queueList) { +// //2. 查询队列随访患者列表 +// List patientList = fmsFollowupDao.queryPatient(followupQueueVO.getId(), (byte) 0, null); +// if (CollectionUtil.isEmpty(patientList)) { +// continue; +// } +// //随访总月数 +// Integer followupMonth = followupQueueVO.getFollowupMonth(); +// for (FmsFollowupVo.FollowupPatient followupPatient : patientList) { +// //获取随访到期时间 出院时间+随访总月数 = 到期时间 +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(followupPatient.getDischargeTime()); +// calendar.set(Calendar.MONTH, followupMonth); +// Date time = calendar.getTime(); +// +// //获取队列信息 +// String frequency = followupQueueVO.getFrequency(); +// List dateList = new ArrayList<>(); +// try { +// CronTriggerImpl cronTrigger = new CronTriggerImpl(); +// cronTrigger.setCronExpression(frequency); +// //TriggerUtils.computeFireTimesBetween(要计算触发时间的触发器对象, 用于计算触发时间的日历对象, 计算触发时间的起始时间点, 计算触发时间的结束时间点); +// dateList = TriggerUtils.computeFireTimesBetween(cronTrigger, null, followupPatient.getDischargeTime(), time); +// if (CollectionUtil.isEmpty(dateList)) { +// continue; +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// //3. 判断随访类型 +// if (followupQueueVO.getFollowupType() == 0) { +// //单次 +// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); +// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); +// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); +// fmsFollowupTask.setName(followupPatient.getName()); +// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); +// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); +// fmsFollowupTask.setGender(followupPatient.getGender()); +// if (followupPatient.getBirthDate() != null) { +// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); +// } +// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); +// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); +// fmsFollowupTask.setPhone(followupPatient.getPhone()); +// fmsFollowupTask.setTenantId(followupPatient.getTenantId()); +// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); +// fmsFollowupTask.setIdCard(followupPatient.getIdCard()); +// fmsFollowupTask.setTimes(1); +// fmsFollowupTask.setQueueId(followupQueueVO.getId()); +// fmsFollowupTask.setPatientId(followupPatient.getId()); +// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); +// fmsFollowupTask.setDelFlag((byte) 0); +// fmsFollowupTask.setCreateTime(new Date()); +// fmsFollowupTask.setStatus((byte) 0); +// fmsFollowupTask.setStartTime(dateList.get(0)); +// fmsFollowupTask.setEndTime(dateList.get(0)); +// fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); +// fmsFollowupTask.setFollowupTime(dateList.get(0)); +// changeDataSource(result); +// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); +// +// } else { +// //周期 +// //4. 根据频次和总月数添加 +// int i = 0; +// for (Date date : dateList) { +// i+=1; +// //单次 +// FmsFollowupTask fmsFollowupTask = new FmsFollowupTask(); +// BeanUtil.copyProperties(followupQueueVO, fmsFollowupTask); +// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); +// fmsFollowupTask.setName(followupPatient.getName()); +// fmsFollowupTask.setPinyinFull(followupPatient.getPinyinFull()); +// fmsFollowupTask.setPinyinSimple(followupPatient.getPinyinSimple()); +// fmsFollowupTask.setGender(followupPatient.getGender()); +// if (followupPatient.getBirthDate() != null) { +// fmsFollowupTask.setAge(DateUtil.age(followupPatient.getBirthDate(), new Date())); +// } +// fmsFollowupTask.setEthnicity(followupPatient.getEthnicity()); +// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); +// fmsFollowupTask.setTimes(i); +// fmsFollowupTask.setPhone(followupPatient.getPhone()); +// fmsFollowupTask.setTenantId(followupPatient.getTenantId()); +// fmsFollowupTask.setIdCardType(followupPatient.getIdCardType()); +// fmsFollowupTask.setIdCard(followupPatient.getIdCard()); +// fmsFollowupTask.setId(IdUtil.getSnowflakeNextId()); +// fmsFollowupTask.setQueueId(followupQueueVO.getId()); +// fmsFollowupTask.setDelFlag((byte) 0); +// fmsFollowupTask.setCreateTime(new Date()); +// fmsFollowupTask.setEducationYears(followupPatient.getEducationYears()); +// fmsFollowupTask.setStatus((byte) 0); +// fmsFollowupTask.setStartTime(date); +// fmsFollowupTask.setEndTime(date); +// fmsFollowupTask.setFollowuper(followupQueueVO.getPersonInCharge()); +// fmsFollowupTask.setFollowupTime(date); +// changeDataSource(result); +// fmsFollowupTask.setPatientId(followupPatient.getId()); +// fmsFollowupTaskMapper.insertSelective(fmsFollowupTask); +// } +// } +// changeDataSource(result); +// //将患者设置为已生成工单 +// FmsPatientQueueRelation fmsPatientQueueRelation = BeanUtil.copyProperties(followupPatient, FmsPatientQueueRelation.class); +// fmsPatientQueueRelation.setTaskFlag((byte) 1); +// fmsPatientQueueRelation.setPatientId(followupPatient.getId()); +// fmsPatientQueueRelationMapper.updateByPrimaryKeySelective(fmsPatientQueueRelation); +// } +// } +// +// } +// } +// } +// +// private static void changeDataSource(UmsDataSourceVo.Result result) { +// DynamicDataSourceContextHolder.setDataSourceType(result.getDataSourceKey()); +// } +//} diff --git a/acupuncture-admin/src/main/resources/application-stage.yml b/acupuncture-admin/src/main/resources/application-stage.yml index 081be83f..a08ab3d8 100644 --- a/acupuncture-admin/src/main/resources/application-stage.yml +++ b/acupuncture-admin/src/main/resources/application-stage.yml @@ -61,4 +61,4 @@ spring: multi-statement-allow: true file: PatientTemplate: /home/acupuncture/server/profile/PatientTemplate.xlsx - TreamentTemplate: /home/acupuncture/server/profile/PatientTemplate.xlsx \ No newline at end of file + TreamentTemplate: /home/acupuncture/server/profile/TreamentTemplate.xlsx \ No newline at end of file diff --git a/acupuncture-generator/src/main/resources/mbg.xml b/acupuncture-generator/src/main/resources/mbg.xml index 4df469e8..2a417959 100644 --- a/acupuncture-generator/src/main/resources/mbg.xml +++ b/acupuncture-generator/src/main/resources/mbg.xml @@ -59,9 +59,9 @@ - + -
+ diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java index f4569c62..878c351a 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java @@ -42,6 +42,12 @@ public class FmsFollowupDto { private String personInChargeUsername; private Byte status; + + @ApiModelProperty("随访窗口期") + private Integer followWindowAdys; + + @ApiModelProperty("临近提醒时间") + private Integer remindTime; } @Data @@ -63,6 +69,11 @@ public class FmsFollowupDto { private String personInChargeUsername; private Byte status; + @ApiModelProperty("随访窗口期") + private Integer followWindowAdys; + + @ApiModelProperty("临近提醒时间") + private Integer remindTime; } @Data @@ -109,7 +120,10 @@ public class FmsFollowupDto { @Data public static class FollowupPatientQueryDTO { // @NotNull(message = "队列ID不能为空") - private Long id; + private Long queueId; + @ApiModelProperty("0 无队列") + private Integer haveQueue; + } // FollowupTaskQueryDTO.java @@ -139,4 +153,10 @@ public class FmsFollowupDto { private Date followupTime; private String followupText; } + + @Data + public static class UpdStatusDto { + private Long id; + private Byte status; + } } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java index 16b6deb7..6d619893 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsTreatmentDto.java @@ -61,6 +61,14 @@ public class PmsTreatmentDto { } return age; } + + public Date getDischargeTime() { + //门诊使用门诊时间 + if (visitType == 0) { + return visitTime; + } + return dischargeTime; + } } @Data @@ -80,6 +88,7 @@ public class PmsTreatmentDto { private Integer visitType; private String visitNumber; private Date visitTime; + @JsonFormat(pattern = "yyyy-MM-dd") private Date dischargeTime; private String doctor; private String deptName; @@ -92,6 +101,21 @@ public class PmsTreatmentDto { private String updateBy; @ApiModelProperty("随访队列ID集合") private List queueIdList; + + public Date getDischargeTime() { + //门诊使用门诊时间 + if (visitType == 0) { + return visitTime; + } + return dischargeTime; + } + + public Integer getAge() { + if (birthDate != null) { + return DateUtil.age(birthDate, new Date()); + } + return age; + } } // TreatmentQueryDTO.java (查询用) diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueue.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueue.java index 1fae09ce..a4f77e44 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueue.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueue.java @@ -22,6 +22,8 @@ public class FmsFollowupQueue implements Serializable { private Byte status; + private Integer remindTime; + private Byte delFlag; private Long tenantId; @@ -36,6 +38,8 @@ public class FmsFollowupQueue implements Serializable { private String remark; + private Integer followWindowAdys; + private static final long serialVersionUID = 1L; public Long getId() { @@ -110,6 +114,14 @@ public class FmsFollowupQueue implements Serializable { this.status = status; } + public Integer getRemindTime() { + return remindTime; + } + + public void setRemindTime(Integer remindTime) { + this.remindTime = remindTime; + } + public Byte getDelFlag() { return delFlag; } @@ -166,6 +178,14 @@ public class FmsFollowupQueue implements Serializable { this.remark = remark == null ? null : remark.trim(); } + public Integer getFollowWindowAdys() { + return followWindowAdys; + } + + public void setFollowWindowAdys(Integer followWindowAdys) { + this.followWindowAdys = followWindowAdys; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -181,6 +201,7 @@ public class FmsFollowupQueue implements Serializable { sb.append(", personInCharge=").append(personInCharge); sb.append(", personInChargeUsername=").append(personInChargeUsername); sb.append(", status=").append(status); + sb.append(", remindTime=").append(remindTime); sb.append(", delFlag=").append(delFlag); sb.append(", tenantId=").append(tenantId); sb.append(", createBy=").append(createBy); @@ -188,6 +209,7 @@ public class FmsFollowupQueue implements Serializable { sb.append(", updateBy=").append(updateBy); sb.append(", updateTime=").append(updateTime); sb.append(", remark=").append(remark); + sb.append(", followWindowAdys=").append(followWindowAdys); sb.append("]"); return sb.toString(); } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueueExample.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueueExample.java index 2ceb98d4..d0c25e5d 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueueExample.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/po/FmsFollowupQueueExample.java @@ -685,6 +685,66 @@ public class FmsFollowupQueueExample { return (Criteria) this; } + public Criteria andRemindTimeIsNull() { + addCriterion("remind_time is null"); + return (Criteria) this; + } + + public Criteria andRemindTimeIsNotNull() { + addCriterion("remind_time is not null"); + return (Criteria) this; + } + + public Criteria andRemindTimeEqualTo(Integer value) { + addCriterion("remind_time =", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeNotEqualTo(Integer value) { + addCriterion("remind_time <>", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeGreaterThan(Integer value) { + addCriterion("remind_time >", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeGreaterThanOrEqualTo(Integer value) { + addCriterion("remind_time >=", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeLessThan(Integer value) { + addCriterion("remind_time <", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeLessThanOrEqualTo(Integer value) { + addCriterion("remind_time <=", value, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeIn(List values) { + addCriterion("remind_time in", values, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeNotIn(List values) { + addCriterion("remind_time not in", values, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeBetween(Integer value1, Integer value2) { + addCriterion("remind_time between", value1, value2, "remindTime"); + return (Criteria) this; + } + + public Criteria andRemindTimeNotBetween(Integer value1, Integer value2) { + addCriterion("remind_time not between", value1, value2, "remindTime"); + return (Criteria) this; + } + public Criteria andDelFlagIsNull() { addCriterion("del_flag is null"); return (Criteria) this; @@ -1134,6 +1194,66 @@ public class FmsFollowupQueueExample { addCriterion("remark not between", value1, value2, "remark"); return (Criteria) this; } + + public Criteria andFollowWindowAdysIsNull() { + addCriterion("follow_window_adys is null"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysIsNotNull() { + addCriterion("follow_window_adys is not null"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysEqualTo(Integer value) { + addCriterion("follow_window_adys =", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysNotEqualTo(Integer value) { + addCriterion("follow_window_adys <>", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysGreaterThan(Integer value) { + addCriterion("follow_window_adys >", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysGreaterThanOrEqualTo(Integer value) { + addCriterion("follow_window_adys >=", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysLessThan(Integer value) { + addCriterion("follow_window_adys <", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysLessThanOrEqualTo(Integer value) { + addCriterion("follow_window_adys <=", value, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysIn(List values) { + addCriterion("follow_window_adys in", values, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysNotIn(List values) { + addCriterion("follow_window_adys not in", values, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysBetween(Integer value1, Integer value2) { + addCriterion("follow_window_adys between", value1, value2, "followWindowAdys"); + return (Criteria) this; + } + + public Criteria andFollowWindowAdysNotBetween(Integer value1, Integer value2) { + addCriterion("follow_window_adys not between", value1, value2, "followWindowAdys"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java b/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java index 311bc76a..507a0d5a 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupVo.java @@ -6,6 +6,7 @@ import com.acupuncture.system.domain.po.FmsPatientQueueRelation; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import java.util.Calendar; import java.util.Date; import java.util.List; @@ -18,7 +19,7 @@ import java.util.List; public class FmsFollowupVo { @Data - public static class QueueResult{ + public static class QueueResult { @ApiModelProperty("") private Long id; @ApiModelProperty("队列名称") @@ -57,6 +58,11 @@ public class FmsFollowupVo { private String updateBy; private Date updateTime; private String remark; + @ApiModelProperty("随访窗口期") + private Integer followWindowAdys; + + @ApiModelProperty("临近提醒时间") + private Integer remindTime; } // FollowupTaskVO.java @@ -69,6 +75,8 @@ public class FmsFollowupVo { private String ethnicity; + private Integer times; + private Integer educationYears; private String phone; @@ -101,14 +109,45 @@ public class FmsFollowupVo { private String updateBy; private Date updateTime; private String remark; - private String queueName; - private String tenantName; + @ApiModelProperty("随访窗口期") + private Integer followWindowAdys; + + @ApiModelProperty("临近提醒时间") + private Integer remindTime; + + + public Integer getStatus() { + //随访状态(0待随访, 1已随访, 2失访(手动标记)) 超期根据时间判断 超期已随访 + if (status == 0) { + //待随访 判断是否超期 如当前>结束时间,则超期 + if (endTime != null && endTime.compareTo(new Date()) < 0) { + //超期 + return 4; + } + if (startTime != null) { + //判断是否临近随访时间 开始时间 + 临近提醒时间 < 当前时间 + Calendar instance = Calendar.getInstance(); + instance.setTime(startTime); + instance.set(Calendar.DAY_OF_MONTH, remindTime); + if (instance.getTime().compareTo(new Date()) < 0) { + return 3; + } + } + }else { + //超期已随访 + if (endTime != null && endTime.compareTo(new Date()) < 0) { + return 5; + } + } + return status; + } + } @Data - public static class FollowupPatient{ + public static class FollowupPatient { private Long id; private Long queueId; @@ -142,13 +181,17 @@ public class FmsFollowupVo { private String createBy; private Date createTime; + @ApiModelProperty("随访窗口期") + private Integer followWindowAdys; + @ApiModelProperty("临近提醒时间") + private Integer remindTime; public Long getPatientId() { return id; } @Data - public static class QueueVo{ + public static class QueueVo { private Long queueId; private String queueName; } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/FmsFollowupDao.java b/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/FmsFollowupDao.java index 28dbf994..87ff3502 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/FmsFollowupDao.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/FmsFollowupDao.java @@ -35,7 +35,8 @@ public interface FmsFollowupDao { @Param("status") Byte status); List queryPatient(@Param("id") Long id, - @Param("taskFlag") Byte taskFlag); + @Param("taskFlag") Byte taskFlag, + @Param("haveQueue")Integer haveQueue); /** * 查询随访任务 diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupService.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupService.java index 5f17ff4f..98c9b5f5 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupService.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/FmsFollowupService.java @@ -73,6 +73,6 @@ public interface FmsFollowupService { */ void completeFollowup(FmsFollowupDto.FollowupCompleteDTO dto); - + void updStatus(Long id, Byte status); } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java index 5b624d9a..e3865bee 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupQueueServiceImpl.java @@ -30,14 +30,15 @@ public class FmsFollowupQueueServiceImpl implements FmsFollowupQueueService { @Override @DataSource(DataSourceType.MASTER) public List queryCommonQueue(String name) { - List cacheList =redisCache.getCacheList(COMMON_FOLLOWUP_QUEUE); - if (CollectionUtil.isEmpty(cacheList)) { +// List cacheList =redisCache.getCacheList(COMMON_FOLLOWUP_QUEUE); +// if (CollectionUtil.isEmpty(cacheList)) { + redisCache.deleteObject(COMMON_FOLLOWUP_QUEUE); List followupQueueVOS = fmsFollowupDao.queryCommonQueue(name); redisCache.setCacheList(COMMON_FOLLOWUP_QUEUE, followupQueueVOS); return followupQueueVOS; - }else { - return BeanUtil.copyToList(cacheList, FmsFollowupVo.FollowupQueueVO.class); - } +// }else { +// return BeanUtil.copyToList(cacheList, FmsFollowupVo.FollowupQueueVO.class); +// } } } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java index 91e910e8..346c59bb 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/FmsFollowupServiceImpl.java @@ -44,6 +44,8 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { private FmsPatientQueueRelationMapper fmsPatientQueueRelationMapper; @Resource private RedisCache redisCache; + @Resource + private FmsFollowupTaskMapper fmsFollowupTaskMapper; @Override public List queryQueue(FmsFollowupDto.FollowupQueueQueryDTO dto) { @@ -79,7 +81,7 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { @Override public List queryPatient(FmsFollowupDto.FollowupPatientQueryDTO dto) { - List followupPatients = fmsFollowupDao.queryPatient(dto.getId(), null); + List followupPatients = fmsFollowupDao.queryPatient(dto.getQueueId(), null, dto.getHaveQueue()); if (CollectionUtil.isNotEmpty(followupPatients)) { List commonFollowupQueue = redisCache.getCacheList("common_followup_queue"); for (FmsFollowupVo.FollowupPatient followupPatient : followupPatients) { @@ -95,6 +97,9 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { map = followupQueueVOS1.stream().collect(Collectors.toMap(FmsFollowupVo.FollowupQueueVO::getId, Function.identity())); } for (FmsFollowupVo.FollowupPatient.QueueVo queueVo : queueVoList) { + if (queueVo == null || queueVo.getQueueId() == null) { + continue; + } FmsFollowupVo.FollowupQueueVO followupQueueVO = map.get(queueVo.getQueueId()); if (followupQueueVO != null) { queueVo.setQueueName(followupQueueVO.getName()); @@ -169,4 +174,14 @@ public class FmsFollowupServiceImpl implements FmsFollowupService { public void completeFollowup(FmsFollowupDto.FollowupCompleteDTO dto) { fmsFollowupDao.completeFollowup(dto); } + + @Override + public void updStatus(Long id, Byte status) { + FmsFollowupTask fmsFollowupTask = fmsFollowupTaskMapper.selectByPrimaryKey(id); + if (fmsFollowupTask != null) { + fmsFollowupTask.setStatus(status); + fmsFollowupTask.setUpdateBy(SecurityUtils.getUsername()); + fmsFollowupTaskMapper.updateByPrimaryKeySelective(fmsFollowupTask); + } + } } diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java index be21bb39..2bf84264 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java @@ -54,6 +54,18 @@ public class PmsPatientServiceImpl implements PmsPatientService { @Override public Long add(PmsPatientDto.PatientAdd dto) { + PmsPatientExample pmsPatientExample = new PmsPatientExample(); + pmsPatientExample.createCriteria().andDelFlagEqualTo((byte)0).andIdCardEqualTo(dto.getIdCard()).andIdCardTypeEqualTo(dto.getIdCardType()); + List pmsPatients = pmsPatientMapper.selectByExample(pmsPatientExample); + if (CollectionUtil.isNotEmpty(pmsPatients)) { + PmsPatient pmsPatient = BeanUtil.copyProperties(dto, PmsPatient.class); + pmsPatient.setUpdateBy(SecurityUtils.getUsername()); + pmsPatient.setUpdateTime(new Date()); + pmsPatient.setPinyinFull(PinyinUtil.getPinyin(dto.getName(), "")); + pmsPatient.setPinyinSimple(PinyinUtil.getFirstLetter(dto.getName(), "")); + pmsPatientMapper.updateByPrimaryKeySelective(pmsPatient); + return pmsPatient.getId(); + } PmsPatient pmsPatient = BeanUtil.copyProperties(dto, PmsPatient.class); pmsPatient.setId(IdUtil.getSnowflakeNextId()); pmsPatient.setPinyinFull(PinyinUtil.getPinyin(dto.getName(), "")); diff --git a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java index db8e5941..d3664137 100644 --- a/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java +++ b/acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsTreatmentServiceImpl.java @@ -37,10 +37,7 @@ import javax.annotation.Resource; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -95,6 +92,7 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { pmsTreatment.setPinyinFull(PinyinUtil.getPinyin(pmsTreatment.getName(), "")); pmsTreatment.setPinyinSimple(PinyinUtil.getFirstLetter(pmsTreatment.getName(), "")); pmsTreatment.setId(IdUtil.getSnowflakeNextId()); + pmsTreatment.setTenantId(SecurityUtils.getTenantId()); pmsTreatment.setDelFlag((byte) 0); pmsTreatment.setCreateBy(SecurityUtils.getUsername()); pmsTreatment.setCreateTime(new Date()); @@ -106,12 +104,26 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { FmsPatientQueueRelation patientQueueRelation = BeanUtil.copyProperties(dto, FmsPatientQueueRelation.class); patientQueueRelation.setId(IdUtil.getSnowflakeNextId()); patientQueueRelation.setDelFlag((byte) 0); + patientQueueRelation.setIdCard(dto.getIdCard()); + patientQueueRelation.setIdCardType(dto.getIdCardType().byteValue()); patientQueueRelation.setCreateBy(SecurityUtils.getUsername()); patientQueueRelation.setPatientId(patientId); patientQueueRelation.setQueueId(queueId); patientQueueRelation.setCreateTime(new Date()); fmsPatientQueueRelationMapper.insertSelective(patientQueueRelation); } + }else { + FmsPatientQueueRelation patientQueueRelation = BeanUtil.copyProperties(dto, FmsPatientQueueRelation.class); + patientQueueRelation.setId(IdUtil.getSnowflakeNextId()); + patientQueueRelation.setDelFlag((byte) 0); + patientQueueRelation.setCreateBy(SecurityUtils.getUsername()); + patientQueueRelation.setTenantId(SecurityUtils.getTenantId()); + patientQueueRelation.setIdCard(dto.getIdCard()); + patientQueueRelation.setIdCardType(dto.getIdCardType().byteValue()); + patientQueueRelation.setPatientId(patientId); + patientQueueRelation.setQueueId(null); + patientQueueRelation.setCreateTime(new Date()); + fmsPatientQueueRelationMapper.insertSelective(patientQueueRelation); } } @@ -141,6 +153,16 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { patientQueueRelation.setId(IdUtil.getSnowflakeNextId()); fmsPatientQueueRelationMapper.insertSelective(patientQueueRelation); } + }else { + FmsPatientQueueRelation patientQueueRelation = BeanUtil.copyProperties(dto, FmsPatientQueueRelation.class); + patientQueueRelation.setId(IdUtil.getSnowflakeNextId()); + patientQueueRelation.setDelFlag((byte) 0); + patientQueueRelation.setCreateBy(SecurityUtils.getUsername()); + patientQueueRelation.setPatientId(pmsTreatment.getPatientId()); + patientQueueRelation.setTenantId(pmsTreatment.getTenantId()); + patientQueueRelation.setQueueId(null); + patientQueueRelation.setCreateTime(new Date()); + fmsPatientQueueRelationMapper.insertSelective(patientQueueRelation); } } @@ -165,7 +187,10 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { pmsTreatmentRecordExample.createCriteria().andDelFlagEqualTo((byte) 0).andQuestionCodeEqualTo("JBXX_ZYZD").andTreatmentIdEqualTo(treatmentVO.getId()); List pmsTreatmentRecords = pmsTreatmentRecordMapper.selectByExample(pmsTreatmentRecordExample); if (CollectionUtil.isNotEmpty(pmsTreatmentRecords)) { - treatmentVO.setDiagnosisName(pmsTreatmentRecords.stream().map(PmsTreatmentRecord::getAnswer).collect(Collectors.joining(","))); + String answer = pmsTreatmentRecords.get(0).getAnswer(); + if (StrUtil.isNotEmpty(answer)) { + treatmentVO.setDiagnosisName(answer.replace("!@#", ",")); + } } List queueVos = fmsFollowupDao.queryQueueListByPatientId(treatmentVO.getPatientId()); if (CollectionUtil.isNotEmpty(queueVos)) { @@ -174,14 +199,20 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { List followupQueueVOS1 = BeanUtil.copyToList(commonFollowupQueue, FmsFollowupVo.FollowupQueueVO.class); map = followupQueueVOS1.stream().collect(Collectors.toMap(FmsFollowupVo.FollowupQueueVO::getId, Function.identity())); } + List list = new ArrayList<>(); for (PmsTreatmentVo.TreatmentVO.QueueVo queueVo : queueVos) { + if (queueVo == null || queueVo.getQueueId() == null) { + list.add(queueVo); + continue; + } FmsFollowupVo.FollowupQueueVO followupQueueVO = map.get(queueVo.getQueueId()); if (followupQueueVO != null) { queueVo.setQueueName(followupQueueVO.getName()); } } + queueVos.removeAll(list); } - treatmentVO.setQueueVoList(queueVos); + treatmentVO.setQueueVoList(CollectionUtil.isEmpty(queueVos) ? CollectionUtil.newArrayList() : queueVos); } } return query; @@ -278,33 +309,38 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { int row = 0; for (int i = 0; i < treatmentVOList.size(); i++) { row += 1; + // 建档时间 患者姓名 性别 年龄 民族 受教育程度 手机号码 证件类型(0身份证;1护照或外国人永居证; 2港澳居民来往内地通行; 3台湾居民来往大陆通行证; 4其他;) 证件号码 门诊/住院 门诊号/住院号 门诊时间/住院时间 出院时间 责任医生 建档人 + writer.writeCellValue(0, row, DateUtil.format(treatmentVOList.get(i).getCreateTime(), "yyyy-MM-dd HH:mm:ss")); writer.writeCellValue(1, row, treatmentVOList.get(i).getName()); writer.writeCellValue(2, row, treatmentVOList.get(i).getGender() == null ? "未知" : treatmentVOList.get(i).getGender() == 0 ? "男" : "女"); writer.writeCellValue(3, row, treatmentVOList.get(i).getAge()); + writer.writeCellValue(4, row, treatmentVOList.get(i).getEthnicity()); + writer.writeCellValue(5, row, treatmentVOList.get(i).getEducationYears()); + writer.writeCellValue(6, row, treatmentVOList.get(i).getPhone()); Integer idCardType = treatmentVOList.get(i).getIdCardType(); if (idCardType != null) { switch (idCardType) { case 0: - writer.writeCellValue(4, row, "身份证"); + writer.writeCellValue(7, row, "身份证"); break; case 1: - writer.writeCellValue(4, row, "护照或外国人永居证"); + writer.writeCellValue(7, row, "护照或外国人永居证"); break; case 2: - writer.writeCellValue(4, row, "港澳居民来往内地通行证"); + writer.writeCellValue(7, row, "港澳居民来往内地通行证"); break; case 3: - writer.writeCellValue(4, row, "其他"); + writer.writeCellValue(7, row, "其他"); } } - writer.writeCellValue(5, row, treatmentVOList.get(i).getIdCard()); - writer.writeCellValue(6, row, treatmentVOList.get(i).getVisitType() == 0 ? "门诊" : "住院"); - writer.writeCellValue(7, row, treatmentVOList.get(i).getVisitNumber()); - writer.writeCellValue(8, row, DateUtil.format(treatmentVOList.get(i).getVisitTime(), "yyyy-MM-dd HH:mm:ss")); - writer.writeCellValue(9, row, treatmentVOList.get(i).getDischargeTime()); - writer.writeCellValue(10, row, treatmentVOList.get(i).getDoctor()); - writer.writeCellValue(12, row, treatmentVOList.get(i).getCreateBy()); + writer.writeCellValue(8, row, treatmentVOList.get(i).getIdCard()); + writer.writeCellValue(9, row, treatmentVOList.get(i).getVisitType() == 0 ? "门诊" : "住院"); + writer.writeCellValue(9, row, treatmentVOList.get(i).getVisitNumber()); + writer.writeCellValue(10, row, DateUtil.format(treatmentVOList.get(i).getVisitTime(), "yyyy-MM-dd HH:mm:ss")); + writer.writeCellValue(12, row, DateUtil.format(treatmentVOList.get(i).getDischargeTime(), "yyyy-MM-dd HH:mm:ss")); + writer.writeCellValue(13, row, treatmentVOList.get(i).getDoctor()); + writer.writeCellValue(14, row, treatmentVOList.get(i).getCreateBy()); } String filename = StrUtil.format("患者档案-{}.xlsx", DateUtil.date().toString("yyyyMMdd")); @@ -332,7 +368,7 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { //读取excel List pmsPatientList = CollectionUtil.newArrayList(); ExcelUtil.readBySax(file.getInputStream(), 0, (sheetIndex, rowIndex, rowList) -> { - //患者姓名 性别 年龄 证件类型(0身份证;1护照或外国人永居证; 2港澳居民来往内地通行; 3台湾居民来往大陆通行证; 4其他;) 证件号码 门诊/住院 门诊号/住院号 门诊时间/住院时间 出院时间 责任医生 主要诊断 建档人 建档时间 档案状态 + // 建档时间 患者姓名 性别 年龄 民族 受教育程度 手机号码 证件类型(0身份证;1护照或外国人永居证; 2港澳居民来往内地通行; 3台湾居民来往大陆通行证; 4其他;) 证件号码 门诊/住院 门诊号/住院号 门诊时间/住院时间 出院时间 责任医生 建档人 try { if (rowIndex < 1) { return; @@ -340,17 +376,22 @@ public class PmsTreatmentServiceImpl implements PmsTreatmentService { PmsTreatmentDto.TreatmentAdd dto = new PmsTreatmentDto.TreatmentAdd(); dto.setName(rowList.get(1).toString()); dto.setGender(rowList.get(2).toString().trim().equals("男") ? 0 : 1); - String idcard = rowList.get(5).toString(); + dto.setAge(Integer.parseInt(rowList.get(3).toString())); + dto.setEthnicity(rowList.get(4).toString()); + dto.setEducationYears(Integer.parseInt(rowList.get(5).toString())); + dto.setPhone(rowList.get(6).toString()); + + String idcard = rowList.get(8).toString(); if (StrUtil.isNotEmpty(idcard) && IdcardUtil.isValidCard(idcard)) { dto.setBirthDate(IdcardUtil.getBirthDate(idcard)); } - dto.setIdCardType(rowList.get(4).toString().trim().equals("身份证") ? 0 : rowList.get(7).toString().trim().equals("护照或外国人永居证") ? 1 : rowList.get(7).toString().trim().equals("港澳居民来往内地通行证") ? 2 : rowList.get(7).toString().trim().equals("台湾居民来往大陆通行证") ? 3 : 4); + dto.setIdCardType(rowList.get(7).toString().trim().equals("身份证") ? 0 : rowList.get(7).toString().trim().equals("护照或外国人永居证") ? 1 : rowList.get(7).toString().trim().equals("港澳居民来往内地通行证") ? 2 : rowList.get(7).toString().trim().equals("台湾居民来往大陆通行证") ? 3 : 4); dto.setIdCard(idcard); - dto.setVisitType(rowList.get(6).toString().trim().equals("门诊") ? 0 : 1); - dto.setVisitNumber(rowList.get(7).toString()); - dto.setVisitTime(DateUtil.parse(rowList.get(8).toString())); - dto.setDischargeTime(DateUtil.parse(rowList.get(9).toString())); - dto.setDoctor(rowList.get(10).toString()); + dto.setVisitType(rowList.get(9).toString().trim().equals("门诊") ? 0 : 1); + dto.setVisitNumber(rowList.get(10).toString()); + dto.setVisitTime(DateUtil.parse(rowList.get(11).toString())); + dto.setDischargeTime(DateUtil.parse(rowList.get(12).toString())); + dto.setDoctor(rowList.get(13).toString()); dto.setCreateBy(SecurityUtils.getUsername()); dto.setStatus(0); dto.setCreateBy(SecurityUtils.getUsername()); diff --git a/acupuncture-system/src/main/resources/mapper/dao/FmsFollowupDao.xml b/acupuncture-system/src/main/resources/mapper/dao/FmsFollowupDao.xml index e65c51ee..7ce7c928 100644 --- a/acupuncture-system/src/main/resources/mapper/dao/FmsFollowupDao.xml +++ b/acupuncture-system/src/main/resources/mapper/dao/FmsFollowupDao.xml @@ -17,6 +17,8 @@ from fms_followup_queue + del_flag = 0 + and status = 1 and name like concat('%', #{name}, '%') @@ -33,6 +35,8 @@ person_in_charge as personInCharge, person_in_charge_username as personInChargeUsername, status, + follow_window_adys as followWindowAdys, + remind_time remindTime, create_by as createBy, create_time as createTime FROM fms_followup_queue @@ -88,25 +92,32 @@ r.tenant_id as tenantId, r.create_by as createBy, r.create_time as createTime, - q.name as queueName + q.name as queueName, + q.remind_time as remindTime, + q.follow_window_adys as followWindowAdys FROM fms_patient_queue_relation r left join fms_followup_queue q on r.queue_id = q.id or q.id is null WHERE r.del_flag = 0 + + AND r.queue_id is null + AND r.queue_id = #{id} AND r.task_flag = #{taskFlag} - group by r.id_card, r.tenant_id + group by r.patient_id, r.tenant_id + order by r.create_time desc diff --git a/acupuncture-system/src/main/resources/mapper/dao/StatisticsDao.xml b/acupuncture-system/src/main/resources/mapper/dao/StatisticsDao.xml index c18171b4..42d6e429 100644 --- a/acupuncture-system/src/main/resources/mapper/dao/StatisticsDao.xml +++ b/acupuncture-system/src/main/resources/mapper/dao/StatisticsDao.xml @@ -10,6 +10,7 @@ FROM pms_patient + del_flag = 0 AND tenant_id = #{tenantId} @@ -27,6 +28,7 @@ FROM pms_treatment + del_flag = 0 AND tenant_id = #{tenantId} @@ -74,6 +76,7 @@ FROM pms_patient + del_flag = 0 AND tenant_id = #{tenantId} @@ -96,6 +99,7 @@ FROM pms_patient + del_flag = 0 AND tenant_id = #{tenantId} diff --git a/acupuncture-system/src/main/resources/mapper/system/FmsFollowupQueueMapper.xml b/acupuncture-system/src/main/resources/mapper/system/FmsFollowupQueueMapper.xml index f7cb999c..ad80b0ff 100644 --- a/acupuncture-system/src/main/resources/mapper/system/FmsFollowupQueueMapper.xml +++ b/acupuncture-system/src/main/resources/mapper/system/FmsFollowupQueueMapper.xml @@ -11,6 +11,7 @@ + @@ -18,6 +19,7 @@ + @@ -79,8 +81,8 @@ id, name, followup_method, followup_type, frequency, followup_month, person_in_charge, - person_in_charge_username, status, del_flag, tenant_id, create_by, create_time, update_by, - update_time, remark + person_in_charge_username, status, remind_time, del_flag, tenant_id, create_by, create_time, + update_by, update_time, remark, follow_window_adys @@ -259,6 +275,9 @@ status = #{record.status,jdbcType=TINYINT}, + + remind_time = #{record.remindTime,jdbcType=INTEGER}, + del_flag = #{record.delFlag,jdbcType=TINYINT}, @@ -280,6 +299,9 @@ remark = #{record.remark,jdbcType=VARCHAR}, + + follow_window_adys = #{record.followWindowAdys,jdbcType=INTEGER}, + @@ -296,13 +318,15 @@ person_in_charge = #{record.personInCharge,jdbcType=VARCHAR}, person_in_charge_username = #{record.personInChargeUsername,jdbcType=VARCHAR}, status = #{record.status,jdbcType=TINYINT}, + remind_time = #{record.remindTime,jdbcType=INTEGER}, del_flag = #{record.delFlag,jdbcType=TINYINT}, tenant_id = #{record.tenantId,jdbcType=BIGINT}, create_by = #{record.createBy,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=TIMESTAMP}, update_by = #{record.updateBy,jdbcType=VARCHAR}, update_time = #{record.updateTime,jdbcType=TIMESTAMP}, - remark = #{record.remark,jdbcType=VARCHAR} + remark = #{record.remark,jdbcType=VARCHAR}, + follow_window_adys = #{record.followWindowAdys,jdbcType=INTEGER} @@ -334,6 +358,9 @@ status = #{status,jdbcType=TINYINT}, + + remind_time = #{remindTime,jdbcType=INTEGER}, + del_flag = #{delFlag,jdbcType=TINYINT}, @@ -355,6 +382,9 @@ remark = #{remark,jdbcType=VARCHAR}, + + follow_window_adys = #{followWindowAdys,jdbcType=INTEGER}, + where id = #{id,jdbcType=BIGINT} @@ -368,13 +398,15 @@ person_in_charge = #{personInCharge,jdbcType=VARCHAR}, person_in_charge_username = #{personInChargeUsername,jdbcType=VARCHAR}, status = #{status,jdbcType=TINYINT}, + remind_time = #{remindTime,jdbcType=INTEGER}, del_flag = #{delFlag,jdbcType=TINYINT}, tenant_id = #{tenantId,jdbcType=BIGINT}, create_by = #{createBy,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=TIMESTAMP}, update_by = #{updateBy,jdbcType=VARCHAR}, update_time = #{updateTime,jdbcType=TIMESTAMP}, - remark = #{remark,jdbcType=VARCHAR} + remark = #{remark,jdbcType=VARCHAR}, + follow_window_adys = #{followWindowAdys,jdbcType=INTEGER} where id = #{id,jdbcType=BIGINT} \ No newline at end of file