Commit f4a89b1fea419cc651ff90ec67e1cbb0f7e58600
1 parent
2cbb347890
Exists in
master
and in
6 other branches
血糖
Showing 3 changed files with 249 additions and 10 deletions
platform-dal/src/main/java/com/lyms/platform/pojo/BloodPressure.java
View file @
f4a89b1
... | ... | @@ -38,6 +38,29 @@ |
38 | 38 | // 脉搏 |
39 | 39 | private Integer pulse; |
40 | 40 | |
41 | + | |
42 | + //0 未推送 1已经推送 | |
43 | + private Integer exceptionSend; | |
44 | + | |
45 | + //0 未推送 1已经推送 | |
46 | + private Integer sevenSend; | |
47 | + | |
48 | + public Integer getExceptionSend() { | |
49 | + return exceptionSend; | |
50 | + } | |
51 | + | |
52 | + public void setExceptionSend(Integer exceptionSend) { | |
53 | + this.exceptionSend = exceptionSend; | |
54 | + } | |
55 | + | |
56 | + public Integer getSevenSend() { | |
57 | + return sevenSend; | |
58 | + } | |
59 | + | |
60 | + public void setSevenSend(Integer sevenSend) { | |
61 | + this.sevenSend = sevenSend; | |
62 | + } | |
63 | + | |
41 | 64 | public String getPid() { |
42 | 65 | return pid; |
43 | 66 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
f4a89b1
... | ... | @@ -2,11 +2,14 @@ |
2 | 2 | |
3 | 3 | import com.alibaba.fastjson.JSONArray; |
4 | 4 | import com.alibaba.fastjson.JSONObject; |
5 | +import com.lyms.platform.beans.MsgRequest; | |
5 | 6 | import com.lyms.platform.biz.service.BloodPressureService; |
6 | 7 | import com.lyms.platform.biz.service.CommonService; |
7 | 8 | import com.lyms.platform.biz.service.PatientWeightService2; |
8 | 9 | import com.lyms.platform.biz.service.PatientsService; |
9 | -import com.lyms.platform.common.enums.YnEnums; | |
10 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
11 | +import com.lyms.platform.common.enums.*; | |
12 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
10 | 13 | import com.lyms.platform.common.result.BaseResponse; |
11 | 14 | import com.lyms.platform.common.result.PageResult; |
12 | 15 | import com.lyms.platform.common.result.RespBuilder; |
13 | 16 | |
... | ... | @@ -15,13 +18,17 @@ |
15 | 18 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
16 | 19 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
17 | 20 | import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade; |
21 | +import com.lyms.platform.operate.web.facade.SmsConfigFacade; | |
18 | 22 | import com.lyms.platform.operate.web.service.IBloodPressureService; |
19 | 23 | import com.lyms.platform.operate.web.utils.CollectionUtils; |
20 | 24 | import com.lyms.platform.operate.web.utils.MongoUtil; |
21 | -import com.lyms.platform.pojo.BloodPressure; | |
22 | -import com.lyms.platform.pojo.BpReportModel; | |
23 | -import com.lyms.platform.pojo.PatientWeight; | |
24 | -import com.lyms.platform.pojo.Patients; | |
25 | +import com.lyms.platform.permission.model.PatientService; | |
26 | +import com.lyms.platform.permission.model.PatientServiceQuery; | |
27 | +import com.lyms.platform.permission.model.Users; | |
28 | +import com.lyms.platform.permission.service.PatientServiceService; | |
29 | +import com.lyms.platform.permission.service.UsersService; | |
30 | +import com.lyms.platform.pojo.*; | |
31 | +import com.lyms.platform.query.BloodSugarQuery; | |
25 | 32 | import com.lyms.platform.query.PatientsQuery; |
26 | 33 | import org.apache.commons.lang.math.NumberUtils; |
27 | 34 | import org.springframework.beans.factory.annotation.Autowired; |
28 | 35 | |
29 | 36 | |
30 | 37 | |
31 | 38 | |
... | ... | @@ -468,17 +475,225 @@ |
468 | 475 | } |
469 | 476 | return status; |
470 | 477 | } |
478 | + @Autowired | |
479 | + private SmsConfigFacade smsConfigFacade; | |
480 | + @Autowired | |
481 | + private PatientsService patientsService; | |
482 | + @Autowired | |
483 | + private PatientServiceService patientServiceService; | |
471 | 484 | |
485 | + @Autowired | |
486 | + private UsersService usersService; | |
472 | 487 | |
473 | - | |
474 | 488 | @Override |
475 | - public BaseResponse notify(List<String> patientIds, Integer type) { | |
476 | - return null; | |
489 | + public BaseResponse notify(final List<String> patientIds, final Integer type) { | |
490 | + new Thread(new Runnable() { | |
491 | + @Override | |
492 | + public void run() { | |
493 | + if (CollectionUtils.isNotEmpty(patientIds)) | |
494 | + { | |
495 | + for (String patientId : patientIds) | |
496 | + { | |
497 | + Patients patient = patientsService.findOnePatientById(patientId); | |
498 | + if (patient != null) | |
499 | + { | |
500 | + SmsConfigModel configModel = new SmsConfigModel(); | |
501 | + // 1 推送服务, 2 推送和短信服务 3短信服务, | |
502 | + int startType = smsConfigFacade.hospitalIsStart(patient.getHospitalId(), configModel, SmsServiceEnums.XYTX.getId()); | |
503 | + | |
504 | + if (startType == 0) { | |
505 | + return; | |
506 | + } | |
507 | + | |
508 | + //短信前缀 | |
509 | + String messagePrefix = smsConfigFacade.getMsgPrefix(configModel, patient.getBookbuildingDoctor(), ServiceObjEnums.YUNOBJ.getId()); | |
510 | + | |
511 | + List<MsgRequest> messages = new ArrayList<>(); | |
512 | + MsgRequest mr = new MsgRequest(); | |
513 | + String content = ""; | |
514 | + | |
515 | + BloodPressure bp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(patientId)), BloodPressure.class); | |
516 | + if (type == 2) | |
517 | + { | |
518 | + content = "亲爱的准妈妈您好,我是您的私人血压管理医生,您目前已经很久没有记录您的血压值了,为了您和您孩子的健康,请您务必每天记录一下自己的血压,好让我们能随时关注到您和宝宝的健康状况,谢谢!"; | |
519 | + if (bp != null) | |
520 | + { | |
521 | + bp.setSevenSend(1); | |
522 | + bloodPressureService.update(bp); | |
523 | + } | |
524 | + } | |
525 | + else if (type == 3) | |
526 | + { | |
527 | + content = "亲爱的准妈妈您好,我是您的私人血压管理医生,您目前的血压数据十分不理想,请您迅速与我联系或来院进行复查身体情况。"; | |
528 | + if (bp != null) | |
529 | + { | |
530 | + bp.setExceptionSend(1); | |
531 | + bloodPressureService.update(bp); | |
532 | + } | |
533 | + } | |
534 | + | |
535 | + mr.setFirst("【" + messagePrefix + "】" + content); | |
536 | + mr.setObjType(ServiceObjEnums.YUNOBJ.getId()); | |
537 | + mr.setPhone(patient.getPhone()); | |
538 | + mr.setTimeType(SmsTimeTypeEnums.ONTIME.getId()); | |
539 | + mr.setTypeId(ProjectTypeEnums.YNXT.getId()); | |
540 | + mr.setPlanTime(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
541 | + mr.setSubTypeId(SmsServiceEnums.XYTX.getId()); | |
542 | + mr.setStatus(SmsStatusEnums.WFS.getId()); | |
543 | + mr.setHospitalId(patient.getHospitalId()); | |
544 | + mr.setTempId(""); | |
545 | + mr.setPatientId(patient.getId()); | |
546 | + mr.setSmsStatus(SmsStatusEnums.WFS.getId()); | |
547 | + mr.setServiceType(startType); //判断发送类型 | |
548 | + | |
549 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
550 | + patientQuery.setHospitalId(patient.getHospitalId()); | |
551 | + patientQuery.setParentid(patientId); | |
552 | + patientQuery.setSerType(PatientSerEnums.SerTypeEnums.tz.getId()); | |
553 | + | |
554 | + List<PatientService> patientServices = patientServiceService.queryPatientService(patientQuery); | |
555 | + | |
556 | + if (CollectionUtils.isNotEmpty(patientServices) && org.apache.commons.lang.StringUtils.isNotEmpty(patientServices.get(0).getSerDoct())) { | |
557 | + try { | |
558 | + Users users = usersService.getUsers(Integer.parseInt(patientServices.get(0).getSerDoct())); | |
559 | + if (users != null) { | |
560 | + mr.setKeyword1(users.getName()); | |
561 | + } | |
562 | + } catch (Exception e) { | |
563 | + mr.setKeyword1("产检医生"); | |
564 | + } | |
565 | + } | |
566 | + | |
567 | + mr.setKeyword2(DateUtil.getyyyy_MM_dd(new Date())); | |
568 | + mr.setRemark(""); | |
569 | + mr.setCreated(DateUtil.getyyyy_MM_dd_hms(new Date())); | |
570 | + mr.setWxTempId(WxTempleteIdEnums.YI_SHENG_ZHI_DAO.getId()); | |
571 | + messages.add(mr); | |
572 | + if (CollectionUtils.isNotEmpty(messages)) { | |
573 | + smsConfigFacade.saveMsg(messages, patient.getHospitalId()); | |
574 | + } | |
575 | + | |
576 | + } | |
577 | + } | |
578 | + } | |
579 | + } | |
580 | + }).start(); | |
581 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
477 | 582 | } |
478 | 583 | |
479 | 584 | @Override |
480 | 585 | public BaseResponse getBloodSugars(String doctorId, Integer type, Integer status, String keyword) { |
481 | - return null; | |
586 | + | |
587 | + List<Map> datas = new ArrayList<>(); | |
588 | + List<String> pids = new ArrayList<>(); | |
589 | + if (org.apache.commons.lang.StringUtils.isNotEmpty(keyword)) | |
590 | + { | |
591 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
592 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
593 | + patientsQuery.setQueryNo(keyword); | |
594 | + patientsQuery.setType(1); | |
595 | + List<Patients> pats = patientsService.queryPatient(patientsQuery); | |
596 | + if (CollectionUtils.isNotEmpty(pats)) | |
597 | + { | |
598 | + for (Patients pat : pats) | |
599 | + { | |
600 | + pids.add(pat.getId()); | |
601 | + } | |
602 | + } | |
603 | + else | |
604 | + { | |
605 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
606 | + } | |
607 | + } | |
608 | + | |
609 | + | |
610 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
611 | + patientQuery.setSerDoct(doctorId); | |
612 | + patientQuery.setSerType(PatientSerEnums.SerTypeEnums.xy.getId()); | |
613 | + patientQuery.setSerStatus(1); | |
614 | + if (CollectionUtils.isNotEmpty(pids)) | |
615 | + { | |
616 | + patientQuery.setParentIds((String[]) pids.toArray(new String[pids.size()])); | |
617 | + } | |
618 | + List<PatientService> list = patientServiceService.queryPatientService(patientQuery); | |
619 | + List<String> patientIds = new ArrayList<>(); | |
620 | + | |
621 | + if (CollectionUtils.isNotEmpty(list)) | |
622 | + { | |
623 | + for (PatientService ps : list) | |
624 | + { | |
625 | + Patients pat = patientsService.findOnePatientById(ps.getParentid()); | |
626 | + if (pat != null && pat.getType() == 1) | |
627 | + { | |
628 | + patientIds.add(ps.getParentid()); | |
629 | + } | |
630 | + } | |
631 | + } | |
632 | + | |
633 | + if (CollectionUtils.isNotEmpty(patientIds)) | |
634 | + { | |
635 | + Criteria cr = Criteria.where("parentId").in(patientIds); | |
636 | + | |
637 | + if (type == 2) | |
638 | + { | |
639 | + cr.and("modified").lte(DateUtil.addDay(new Date(),-7)); | |
640 | + if (status != null && status == 1) | |
641 | + { | |
642 | + cr.and("sevenSend").is(status); | |
643 | + } | |
644 | + else if (status != null && status == 0) | |
645 | + { | |
646 | + cr.orOperator(Criteria.where("sevenSend").is(0), Criteria.where("sevenSend").exists(false)); | |
647 | + } | |
648 | + } | |
649 | + //异常大于等于3次 | |
650 | + else if (type == 3) | |
651 | + { | |
652 | + if (status != null && status == 1) | |
653 | + { | |
654 | + cr.and("exceptionSend").is(status); | |
655 | + } | |
656 | + else if (status != null && status == 0) | |
657 | + { | |
658 | + cr.orOperator(Criteria.where("exceptionSend").is(0), Criteria.where("exceptionSend").exists(false)); | |
659 | + } | |
660 | + } | |
661 | + | |
662 | + List<BloodPressure> bps = mongoTemplate.find(Query.query(cr), BloodPressure.class); | |
663 | + if (CollectionUtils.isNotEmpty(bps)) | |
664 | + { | |
665 | + | |
666 | + for (BloodPressure bp : bps) | |
667 | + { | |
668 | + Patients patients = patientsService.findOnePatientById(bp.getParentId()); | |
669 | + Map map = new HashMap(); | |
670 | + if (type == 3) | |
671 | + { | |
672 | + Map<String, Map<String, Object>> infos = bp.getInfos(); | |
673 | + Object[] keys = infos.keySet().toArray(); | |
674 | + CollectionUtils.reverseArray(keys); | |
675 | + Object[] items = getKeys(keys); | |
676 | + int count = getExceptionCount(items, infos); | |
677 | + if (count < 3) | |
678 | + { | |
679 | + continue; | |
680 | + } | |
681 | + } | |
682 | + | |
683 | + map.put("patientId",patients != null ? patients.getId() : ""); | |
684 | + map.put("name",patients != null ? patients.getUsername() : ""); | |
685 | + map.put("age",patients != null ? DateUtil.getAge(patients.getBirth(), bp.getModified()): ""); | |
686 | + map.put("week",patients != null ? DateUtil.getWeekDesc(patients.getLastMenses(), bp.getModified()): ""); | |
687 | + map.put("bloodPressure",bp.getSsy()+"/"+bp.getSzy()); | |
688 | + map.put("days",DateUtil.getDays(bp.getModified(), new Date())); | |
689 | + map.put("phone",patients.getPhone()); | |
690 | + datas.add(map); | |
691 | + } | |
692 | + | |
693 | + } | |
694 | + } | |
695 | + | |
696 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
482 | 697 | } |
483 | 698 | |
484 | 699 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
f4a89b1
... | ... | @@ -1456,7 +1456,8 @@ |
1456 | 1456 | } |
1457 | 1457 | } |
1458 | 1458 | maps = sortMapByKey(maps); |
1459 | - if (maps.size() > 0) { | |
1459 | + maps = doHandle(maps, bloodSugars.get(0).getCreatYmdDate()); | |
1460 | + if (maps.size() > 0 && maps.size() >= 3) { | |
1460 | 1461 | int count = 0; |
1461 | 1462 | for (String key1 : maps.keySet()) { |
1462 | 1463 | List<BloodSugar> bss = maps.get(key1); |