diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcArchiveController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcArchiveController.java index df459f4..f4536ba 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcArchiveController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcArchiveController.java @@ -5,7 +5,6 @@ import cn.afterturn.easypoi.excel.entity.ExportParams; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.lyms.talkonlineweb.annotation.TokenRequired; -import com.lyms.talkonlineweb.domain.ArticleInfo; import com.lyms.talkonlineweb.domain.LymsDoctor; import com.lyms.talkonlineweb.domain.LymsUser; import com.lyms.talkonlineweb.domain.LymsXljcArchive; @@ -14,6 +13,7 @@ import com.lyms.talkonlineweb.result.BaseResponse; import com.lyms.talkonlineweb.service.LymsDoctorService; import com.lyms.talkonlineweb.service.LymsUserService; import com.lyms.talkonlineweb.service.LymsXljcArchiveService; +import com.lyms.talkonlineweb.util.BeanUtils; import com.lyms.talkonlineweb.util.DateUtil; import com.lyms.talkonlineweb.util.StringUtil; import org.apache.poi.ss.usermodel.Workbook; @@ -24,14 +24,13 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; -import java.io.FileOutputStream; import java.net.URLEncoder; -import java.util.ArrayList; import java.util.Date; import java.util.List; /** * 心理检测档案管理 + * 档案管理已医院为维度,各种操作需要增加当前操作人员的所属医院条件 */ @RestController @@ -58,15 +57,15 @@ public class XljcArchiveController { @PostMapping @TokenRequired public BaseResponse saveArchive(@RequestBody @Validated LymsXljcArchive archive,BindingResult result,@RequestHeader String authorization){ - + LymsUser curUser=lymsUserService.getUserByToken(authorization); //身份证号转小写 archive.setIdno(archive.getIdno().toLowerCase()); - QueryWrapper query = new QueryWrapper<>(); query.eq("idno",archive.getIdno()); + query.eq("hid",curUser.getHid()); LymsXljcArchive lymsXljcArchive = lymsXljcArchiveService.getOne(query); if(lymsXljcArchive != null){ - return BaseResponse.error("该身份证号对应的档案已经存在"); + return BaseResponse.error("该身份证号对应的档案已经在该医院存在"); } if(result.hasErrors()){ BaseResponse baseResponse = new BaseResponse(); @@ -81,7 +80,6 @@ public class XljcArchiveController { archive.setHid(lymsDoctor.getHid()); archive.setDpid(lymsDoctor.getDpid()); archive.setAge(DateUtil.getAge(DateUtil.parseYMD(archive.getBirth()))); - LymsUser curUser=lymsUserService.getUserByToken(authorization); archive.setCreatedby(curUser.getUid()); archive.setCreatedtime(new Date()); lymsXljcArchiveService.save(archive); @@ -92,12 +90,12 @@ public class XljcArchiveController { @PutMapping @TokenRequired public BaseResponse updateArchive(@RequestBody @Validated LymsXljcArchive archive,BindingResult result,@RequestHeader String authorization){ - + LymsUser curUser=lymsUserService.getUserByToken(authorization); //身份证号转小写 archive.setIdno(archive.getIdno().toLowerCase()); - QueryWrapper query = new QueryWrapper<>(); query.eq("idno",archive.getIdno()); + query.eq("hid",curUser.getHid()); LymsXljcArchive lymsXljcArchive = lymsXljcArchiveService.getOne(query); if(lymsXljcArchive != null && lymsXljcArchive.getId() != archive.getId()){ return BaseResponse.error("该身份证号对应的档案已经存在"); @@ -111,8 +109,11 @@ public class XljcArchiveController { baseResponse.setErrorcode(1); return baseResponse; } + LymsDoctor lymsDoctor = lymsDoctorService.getById(archive.getBookbuilDoctor()); + archive.setHid(lymsDoctor.getHid()); + archive.setDpid(lymsDoctor.getDpid()); + archive.setAge(DateUtil.getAge(DateUtil.parseYMD(archive.getBirth()))); - LymsUser curUser=lymsUserService.getUserByToken(authorization); archive.setUpdatedby(curUser.getUid()); archive.setUpdatedtime(new Date()); lymsXljcArchiveService.updateById(archive); @@ -129,9 +130,14 @@ public class XljcArchiveController { @GetMapping("/{idno}") @TokenRequired public BaseResponse archiveByIdno(@PathVariable("idno") String idno,@RequestHeader String authorization){ + LymsUser curUser=lymsUserService.getUserByToken(authorization); QueryWrapper query = new QueryWrapper<>(); query.eq("idno",idno); + query.eq("hid",curUser.getHid()); LymsXljcArchive lymsXljcArchive = lymsXljcArchiveService.getOne(query); + if(lymsXljcArchive != null){ + lymsXljcArchive.setSexName(BeanUtils.tranferSexToText(lymsXljcArchive.getSex())); + } return BaseResponse.ok(lymsXljcArchive); } @@ -144,6 +150,11 @@ public class XljcArchiveController { @TokenRequired public BaseResponse archiveList(@RequestBody ArchiveParam archiveParam,@RequestHeader String authorization, int current, int size){ QueryWrapper query = new QueryWrapper<>(); + LymsUser curUser=lymsUserService.getUserByToken(authorization); + if(curUser.getHid() != null){ + query.eq("hid",curUser.getHid()); + } + if(StringUtil.isNotEmpty(archiveParam.getPname())){ query.eq("pname",archiveParam.getPname()); } @@ -153,16 +164,11 @@ public class XljcArchiveController { if(StringUtil.isNotEmpty(archiveParam.getTel())){ query.eq("tel",archiveParam.getTel()); } - //未指定建档医生,则根据登录用户所属医院 if(archiveParam.getBookbuilDoctor() != null){ query.eq("bookbuil_doctor",archiveParam.getBookbuilDoctor()); - }else { - LymsUser curUser=lymsUserService.getUserByToken(authorization); - if(curUser.getHid() != null){ - query.eq("hid",curUser.getHid()); - } } + if(StringUtil.isNotEmpty(archiveParam.getBookbuilDateStart())){ query.gt("bookbuil_date", DateUtil.parseYMD(archiveParam.getBookbuilDateStart())); } @@ -170,14 +176,21 @@ public class XljcArchiveController { query.lt("bookbuil_date", DateUtil.parseYMDHMS(archiveParam.getBookbuilDateEnd() + " 23:59:59" )); } Page page = new Page<>(current,size); - Page articlePagePage = lymsXljcArchiveService.page(page,query.orderByDesc("bookbuil_date")); - return BaseResponse.ok(articlePagePage); + Page archivePage = lymsXljcArchiveService.page(page,query.orderByDesc("bookbuil_date")); + for(LymsXljcArchive archive : archivePage.getRecords() ){ + archive.setSexName(BeanUtils.tranferSexToText(archive.getSex())); + } + return BaseResponse.ok(archivePage); } @PostMapping("/export") public void archiveExport(@RequestBody ArchiveParam archiveParam, @RequestHeader String authorization, HttpServletResponse response) throws Exception{ QueryWrapper query = new QueryWrapper<>(); + LymsUser curUser=lymsUserService.getUserByToken(authorization); + if(curUser.getHid() != null){ + query.eq("hid",curUser.getHid()); + } if(StringUtil.isNotEmpty(archiveParam.getPname())){ query.eq("pname",archiveParam.getPname()); } @@ -187,12 +200,8 @@ public class XljcArchiveController { if(StringUtil.isNotEmpty(archiveParam.getTel())){ query.eq("tel",archiveParam.getTel()); } - //未指定建档医生,则根据登录用户所属医院 if(archiveParam.getBookbuilDoctor() != null){ query.eq("bookbuil_doctor",archiveParam.getBookbuilDoctor()); - }else { - LymsUser curUser=lymsUserService.getUserByToken(authorization); - query.eq("hid",curUser.getHid()); } if(StringUtil.isNotEmpty(archiveParam.getBookbuilDateStart())){ @@ -203,10 +212,10 @@ public class XljcArchiveController { } List LymsXljcArchiveList = lymsXljcArchiveService.list(query.orderByDesc("bookbuil_date")); int size = LymsXljcArchiveList.size(); - for(int i = 1;i <= size; i++){ - LymsXljcArchive archive = LymsXljcArchiveList.get(i - 1); - archive.setSequence(i); - archive.setSexName(archive.getSex()==1?"男":"女"); + for(int i = 0 ;i <= size; i++){ + LymsXljcArchive archive = LymsXljcArchiveList.get(i); + archive.setSequence(i+1); + archive.setSexName(BeanUtils.tranferSexToText(archive.getSex())); } Workbook result = ExcelExportUtil.exportExcel( new ExportParams("心理检测患者档案表", "档案列表"), @@ -224,37 +233,4 @@ public class XljcArchiveController { } - - - public static void main(String[] args) throws Exception { - List list = new ArrayList<>(); - - LymsXljcArchive archive = new LymsXljcArchive(); - archive.setPname("A"); - archive.setAge(30); - archive.setIdno("111111111"); - archive.setTel("13811111111"); - archive.setSex(1); - archive.setBookbuilDate(new Date()); - archive.setBookbuilDoctorName("柴医生"); - list.add(archive); - - for(int i = 1 ; i<= list.size();i++){ - LymsXljcArchive archive1 = list.get(i - 1); - archive1.setSequence(i); - archive1.setSexName(archive1.getSex()==1?"男":"女"); - } - - ExportParams exportParams = new ExportParams("患者档案表", "档案列表"); - //exportParams.setAddIndex(true); - - Workbook sheets = ExcelExportUtil.exportExcel(exportParams, LymsXljcArchive.class, list); - FileOutputStream stream = new FileOutputStream("D:\\aa.xls"); - sheets.write(stream); - stream.close(); - sheets.close(); - } - - - } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcFormController.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcFormController.java index 4272ec0..0ce22c2 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcFormController.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/controller/XljcFormController.java @@ -10,11 +10,9 @@ import com.lyms.talkonlineweb.domain.LymsXljcArchive; import com.lyms.talkonlineweb.domain.LymsXljcRecord; import com.lyms.talkonlineweb.request.ExamineRecordListRequest; import com.lyms.talkonlineweb.request.XljcExamineRequest; -import com.lyms.talkonlineweb.request.XljcPatientRequest; import com.lyms.talkonlineweb.result.BaseResponse; import com.lyms.talkonlineweb.result.ExamineRecordCount; import com.lyms.talkonlineweb.result.HisExamineRecord; -import com.lyms.talkonlineweb.result.XljcPatientResult; import com.lyms.talkonlineweb.service.*; import com.lyms.talkonlineweb.util.BeanUtils; import com.lyms.talkonlineweb.util.StringUtil; @@ -65,17 +63,18 @@ public class XljcFormController { if(archId == null && StringUtil.isEmpty(idno)){ return BaseResponse.error("档案ID或者身份证号必须选择一个"); } - + LymsUser curUser=lymsUserService.getUserByToken(authorization); if(archId == null){ QueryWrapper query = new QueryWrapper<>(); query.eq("idno",idno); + query.eq("hid",curUser.getHid()); LymsXljcArchive lymsXljcArchive = lymsXljcArchiveService.getOne(query); if(lymsXljcArchive == null){ - return BaseResponse.error("该身份证号未创建档案"); + return BaseResponse.error("该身份证号在该医院未创建档案"); } archId = lymsXljcArchive.getId(); } - LymsUser curUser=lymsUserService.getUserByToken(authorization); + LymsXljcRecord record = new LymsXljcRecord(); record.setArchId(archId); record.setExamineHid(curUser.getHid()); @@ -153,7 +152,8 @@ public class XljcFormController { } /** - * 根据id查询检测记录,用于回显 + * 检测数量统计 按量表种类/医院 + * 该功能超级管理员可查看 * @param recordListRequest * @param authorization * @return @@ -162,6 +162,7 @@ public class XljcFormController { @TokenRequired public BaseResponse countExamineRecordGroupByFormType(ExamineRecordListRequest recordListRequest,@RequestHeader String authorization) { LymsUser curUser=lymsUserService.getUserByToken(authorization); + //超级管理员分配该菜单,对应医院为空 if(curUser.getHid() != null){ recordListRequest.setExamineHid(curUser.getHid()); } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java index 5222a16..5965429 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/mapper/LymsIllnessMapper.java @@ -2,12 +2,22 @@ package com.lyms.talkonlineweb.mapper; import com.lyms.talkonlineweb.domain.LymsIllness; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; /** * @Entity com.lyms.talkonlineweb.domain.LymsIllness */ public interface LymsIllnessMapper extends BaseMapper { + /** + * 查询患者在该医院是否有过诊断的病例信息 + * @param pid + * @param illCode + * @param hid + * @return + */ + Integer queryPatientHasIllnessCode(@Param("pid") Integer pid, @Param("illCode") Integer illCode,@Param("hid") Integer hid); + } diff --git a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsXljcRecordServiceImpl.java b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsXljcRecordServiceImpl.java index 0c7e341..6f12f07 100644 --- a/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsXljcRecordServiceImpl.java +++ b/talkonlineweb/src/main/java/com/lyms/talkonlineweb/service/impl/LymsXljcRecordServiceImpl.java @@ -103,24 +103,27 @@ public class LymsXljcRecordServiceImpl extends ServiceImpl 7){ trace.setNextExamineStatus(TraceStatusEnum.AUTO_TRACE.getCode()); }else{ + //小于等于7天来院检测,带追访记录标记作废,列表中看不到 trace.setYn(0); } lymsXljcRecordTraceService.updateById(trace); } + //生成本次待追访记录 if(xljcExamineRequest.getNextExamineDate() != null){ LymsXljcRecordTrace trace = new LymsXljcRecordTrace(); trace.setArchId(record.getArchId()); trace.setRid(record.getId()); trace.setNextExamineDate(xljcExamineRequest.getNextExamineDate()); trace.setNextExamineStatus(0); + trace.setYn(1); trace.setCreatedby(curUser.getUid()); trace.setCreatedtime(currentDate); lymsXljcRecordTraceService.save(trace); @@ -143,11 +146,11 @@ public class LymsXljcRecordServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper(); - queryWrapper.eq("r_id",rid); + queryWrapper.eq("rid",rid); LymsXljcRecordResult recordResult = lymsXljcRecordResultService.getOne(queryWrapper); QueryWrapper query = new QueryWrapper(); - query.eq("r_id",rid); + query.eq("rid",rid); List recordAnswers = lymsXljcRecordAnswerService.list(query); XljcExamineRequest request = new XljcExamineRequest(); @@ -200,6 +203,7 @@ public class LymsXljcRecordServiceImpl extends ServiceImpl tracePushRecords = lymsXljcTracePushRecordService.queryNeedPushRecords(); if(CollectionUtils.isEmpty(tracePushRecords)){ log.warn("不存在需要推送心理检测预约通知的数据"); return; } + + log.info("推送心理检测预约通知,size={}",tracePushRecords.size()); + Date currentDate = new Date(); for(LymsXljcTracePushRecord record: tracePushRecords){ - try{ + try { record.setStatus(2); record.setPushTime(new Date()); record.setCreatedby(1); record.setCreatedtime(currentDate); - if(record.getPid() == null){ + if (record.getPid() == null) { record.setMsg("该档案未查询到患者信息"); - }else if(StringUtil.isEmpty(record.getGzopenid())){ + } else if (StringUtil.isEmpty(record.getGzopenid())) { record.setMsg("该患者未关注公众号"); - }else{ - Map map=new HashMap<>(); - map.put("first",new DataEntity("您预约了"+ DateUtil.getDateTime(record.getNextExamineDate(),"yyyy年MM月dd日")+"复查,请及时复诊","#173177")); - map.put("keyword1",new DataEntity(record.getPname(),"#173177")); - map.put("keyword2",new DataEntity(record.getHname(),"#173177")); - map.put("keyword3",new DataEntity(record.getDpName(),"#173177")); - map.put("keyword4",new DataEntity(record.getDname(),"#173177")); - map.put("keyword5",new DataEntity(record.getDiagnosis(),"#173177")); - map.put("remark",new DataEntity("请遵医嘱及时复诊。","#173177")); - Map mapInfo=new HashMap<>(); - Integer code= WeiXinUtil.SendWeChatMsg(record.getGzopenid(), Constant.GZ_TEMPLATE_ID_RETURN_VISIT,map,mapInfo); - //公众号跳转小程序需要的登录信息 - if(null==code||code!=0){ - record.setMsg("推送心理检测预约通知失败!; code:"+code); - }else{ - record.setStatus(1); + } else { + Map map = new HashMap<>(); + map.put("first", new DataEntity("您预约了" + DateUtil.getDateTime(record.getNextExamineDate(), "yyyy年MM月dd日") + "复查,请及时复诊", "#173177")); + map.put("keyword1", new DataEntity(record.getPname(), "#173177")); + map.put("keyword2", new DataEntity(record.getHname(), "#173177")); + map.put("keyword3", new DataEntity(record.getDpName(), "#173177")); + map.put("keyword4", new DataEntity(record.getDname(), "#173177")); + map.put("keyword5", new DataEntity(record.getDiagnosis(), "#173177")); + map.put("remark", new DataEntity("请遵医嘱及时复诊。", "#173177")); + Map mapInfo = new HashMap<>(); + try { + Integer code = WeiXinUtil.SendWeChatMsg(record.getGzopenid(), Constant.GZ_TEMPLATE_ID_RETURN_VISIT, map, mapInfo); + //公众号跳转小程序需要的登录信息 + if (null == code || code != 0) { + record.setMsg("推送心理检测预约通知失败!; code:" + code); + } else { + record.setStatus(1); + } + } catch (Exception e) { + log.error("推送心理检测预约通知公众号请求异常,LymsXljcTracePushRecord={}", record, e); + record.setMsg("推送心理检测预约通知失败,msg=" + e.getMessage()); } + } lymsXljcTracePushRecordService.saveOrUpdate(record); - - }catch (Exception e){ - log.error("推送心理检测预约通知异常,LymsXljcTracePushRecord={}",record,e); + }catch (Exception ee){ + log.error("推送心理检测预约通知异常,LymsXljcTracePushRecord={}", record, ee); } } - - + log.info("推送心理检测预约通知结束"); } diff --git a/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml b/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml index 060ed78..df2ba51 100644 --- a/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml +++ b/talkonlineweb/src/main/resources/mapper/LymsIllnessMapper.xml @@ -19,4 +19,14 @@ createdby,createdtime,updatedby, updated_time + +