Commit 5908a8c189a59200e7df1ffe96143f71a5bc3ede
1 parent
7b38f16b35
Exists in
master
and in
6 other branches
血糖相关接口
Showing 3 changed files with 84 additions and 31 deletions
platform-common/src/main/java/com/lyms/platform/common/enums/BloodSugarEnums.java
View file @
5908a8c
1 | 1 | package com.lyms.platform.common.enums; |
2 | 2 | |
3 | -import com.lyms.platform.common.utils.StringUtils; | |
4 | - | |
5 | 3 | /** |
6 | 4 | * 血糖时间段枚举 |
7 | 5 | */ |
8 | 6 | |
... | ... | @@ -17,13 +15,13 @@ |
17 | 15 | private Integer id; |
18 | 16 | private String name; |
19 | 17 | |
20 | - public static String getName(String id) { | |
21 | - if(StringUtils.isEmpty(id)) { | |
18 | + public static String getName(Integer id) { | |
19 | + if(id == null) { | |
22 | 20 | return null; |
23 | 21 | } |
24 | 22 | BloodSugarEnums[] values = BloodSugarEnums.values(); |
25 | 23 | for (BloodSugarEnums value : values) { |
26 | - if (value.getId().equals(id)) { | |
24 | + if (value.getId() == id) { | |
27 | 25 | return value.getName(); |
28 | 26 | } |
29 | 27 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
5908a8c
... | ... | @@ -6,18 +6,20 @@ |
6 | 6 | import com.lyms.platform.common.enums.BloodSugarEnums; |
7 | 7 | import com.lyms.platform.common.enums.YnEnums; |
8 | 8 | import com.lyms.platform.common.result.BaseResponse; |
9 | +import com.lyms.platform.common.result.PageResult; | |
9 | 10 | import com.lyms.platform.common.result.RespBuilder; |
10 | 11 | import com.lyms.platform.common.utils.DateUtil; |
11 | 12 | import com.lyms.platform.common.utils.EnumUtil; |
12 | -import com.lyms.platform.common.utils.StringUtils; | |
13 | 13 | import com.lyms.platform.operate.web.facade.AccessPermissionFacade; |
14 | 14 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
15 | 15 | import com.lyms.platform.operate.web.service.IBloodSugarService; |
16 | 16 | import com.lyms.platform.operate.web.utils.CollectionUtils; |
17 | 17 | import com.lyms.platform.operate.web.utils.MongoUtil; |
18 | +import com.lyms.platform.pojo.BloodPressure; | |
18 | 19 | import com.lyms.platform.pojo.BloodSugar; |
19 | 20 | import com.lyms.platform.pojo.Patients; |
20 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
22 | +import org.springframework.data.domain.Sort; | |
21 | 23 | import org.springframework.data.mongodb.core.MongoTemplate; |
22 | 24 | import org.springframework.data.mongodb.core.query.Criteria; |
23 | 25 | import org.springframework.data.mongodb.core.query.Query; |
24 | 26 | |
25 | 27 | |
... | ... | @@ -57,33 +59,46 @@ |
57 | 59 | @Override |
58 | 60 | public BaseResponse list(String key, String vcCardNo, Integer weekStart, Integer weekEnd, Integer age, Integer page, Integer limit, Integer userId) { |
59 | 61 | List<String> hospitalIds = accessPermissionFacade.getCurrentUserHospPermissions(userId); |
60 | - Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospitalIds); | |
61 | - Criteria pCriteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospitalIds); | |
62 | - if(StringUtils.isNotEmpty(key)) { | |
63 | - pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); | |
64 | - } | |
65 | - if(StringUtils.isNotEmpty(vcCardNo)) { | |
66 | - pCriteria.and("vcCardNo").is(vcCardNo); | |
67 | - } | |
68 | - if(weekStart != null && weekEnd != null) { | |
69 | - Date start = DateUtil.getWeekStart(weekEnd); | |
70 | - Date end = DateUtil.getWeekEnd(weekStart); | |
71 | - pCriteria.and("lastMenses").gt(start).lte(end); | |
72 | - } | |
73 | - if(age != null) { | |
74 | - Date start = DateUtil.getBeforeAge(age); | |
75 | - Date end = DateUtil.getBeforeAge(age + 1); | |
76 | - pCriteria.and("birth").gt(end).lte(start); | |
77 | - } | |
78 | - List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
79 | - List<String> ids = new ArrayList<>(); | |
80 | - if(CollectionUtils.isNotEmpty(patients)) { | |
81 | - for (Patients patient : patients) { | |
82 | - ids.add(patient.getId()); | |
62 | + Criteria criteria = Criteria.where("yn").is(1).and("hospitalId").in(hospitalIds); | |
63 | + List<String> patientIds = mongoUtil.getPatientIdsByCondition(hospitalIds, key, vcCardNo, weekStart, weekEnd, age); | |
64 | + criteria.and("parentId").in(patientIds); | |
65 | + PageResult pageResult = findMongoPage(BloodSugar.class, Query.query(criteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit); | |
66 | + List<BloodSugar> bloodSugars = (List<BloodSugar>) pageResult.getGrid(); | |
67 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
68 | + for (BloodSugar bloodSugar : bloodSugars) { | |
69 | + Map<String, Object> temp = new HashMap<>(); | |
70 | + Patients p = mongoTemplate.findById(bloodSugar.getParentId(), Patients.class); | |
71 | + temp.put("id", bloodSugar.getParentId()); | |
72 | + if(p != null) { | |
73 | + temp.put("username", p.getUsername()); | |
74 | + temp.put("age", DateUtil.getAge(p.getBirth())); | |
75 | + temp.put("week", DateUtil.getWeekDesc(p.getLastMenses(), new Date())); | |
76 | + temp.put("riskLevel", mongoUtil.getRiskLevels(p)); //高危等级(颜色) | |
77 | + temp.put("riskFactor", mongoUtil.getRiskFactor(p)); // 高危因素 | |
78 | + temp.put("dueDate", DateUtil.getyyyy_MM_dd(p.getDueDate())); | |
79 | + temp.put("bloodSugar", bloodSugar.getBloodSugar() + "mmol/L"); | |
80 | + temp.put("bloodSugarType", BloodSugarEnums.getName(bloodSugar.getBloodSugarType())); | |
81 | + temp.put("status", getBloodSugarStatus(bloodSugar.getBloodSugarType(), bloodSugar.getBloodSugar())); | |
82 | + temp.put("vcCardNo", p.getVcCardNo()); | |
83 | + temp.put("pcerteTypeId", p.getPcerteTypeId()); | |
84 | + temp.put("cardNo", p.getCardNo()); | |
83 | 85 | } |
86 | + restList.add(temp); | |
84 | 87 | } |
85 | - criteria.and("parentId").in(ids); | |
86 | - return RespBuilder.buildSuccess(); | |
88 | + pageResult.setGrid(restList); | |
89 | + return RespBuilder.buildSuccess(pageResult); | |
90 | + } | |
91 | + | |
92 | + private String getBloodSugarStatus(Integer type, String bloodSugar) { | |
93 | + if(type == BloodSugarEnums.A.getId()) { | |
94 | + return Double.parseDouble(bloodSugar) > 5.6D ? "高血糖" : Double.parseDouble(bloodSugar) < 3.3D ? "低血糖" : "正常"; | |
95 | + } else if(type == BloodSugarEnums.B.getId() || type == BloodSugarEnums.D.getId() || type == BloodSugarEnums.F.getId() ) { | |
96 | + return Double.parseDouble(bloodSugar) > 5.8D ? "高血糖" : Double.parseDouble(bloodSugar) < 3.3D ? "低血糖" : "正常"; | |
97 | + } else if(type == BloodSugarEnums.I.getId()) { | |
98 | + return Double.parseDouble(bloodSugar) > 7.8D ? "高血糖" : Double.parseDouble(bloodSugar) < 6.1D ? "低血糖" : "正常"; | |
99 | + } else { | |
100 | + return Double.parseDouble(bloodSugar) > 6.7D ? "高血糖" : Double.parseDouble(bloodSugar) < 4.4D ? "低血糖" : "正常"; | |
101 | + } | |
87 | 102 | } |
88 | 103 | |
89 | 104 | @Override |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/utils/MongoUtil.java
View file @
5908a8c
... | ... | @@ -592,6 +592,46 @@ |
592 | 592 | return sb.length() > 0 ? sb.substring(0, sb.length() - 1).toString() : sb.toString(); |
593 | 593 | } |
594 | 594 | |
595 | + /** | |
596 | + * @param key 姓名/证件号/联系方式 | |
597 | + * @param vcCardNo 就诊卡 | |
598 | + * @param weekStart 当前开始孕周 | |
599 | + * @param weekEnd 当前结束孕周 | |
600 | + * @param age 年龄 | |
601 | + * @return | |
602 | + */ | |
603 | + public List<Patients> getPatientByCondition(List<String> hospitalIds, String key, String vcCardNo, Integer weekStart, Integer weekEnd, Integer age) { | |
604 | + Criteria pCriteria = Criteria.where("yn").is(1).and("hospitalId").in(hospitalIds); | |
605 | + if(StringUtils.isNotEmpty(key)) { | |
606 | + pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key)); | |
607 | + } | |
608 | + if(StringUtils.isNotEmpty(vcCardNo)) { | |
609 | + pCriteria.and("vcCardNo").is(vcCardNo); | |
610 | + } | |
611 | + if(weekStart != null && weekEnd != null) { | |
612 | + Date start = DateUtil.getWeekStart(weekEnd); | |
613 | + Date end = DateUtil.getWeekEnd(weekStart); | |
614 | + pCriteria.and("lastMenses").gt(start).lte(end); | |
615 | + } | |
616 | + if(age != null) { | |
617 | + Date start = DateUtil.getBeforeAge(age); | |
618 | + Date end = DateUtil.getBeforeAge(age + 1); | |
619 | + pCriteria.and("birth").gt(end).lte(start); | |
620 | + } | |
621 | + List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
595 | 622 | |
623 | + return patients; | |
624 | + } | |
625 | + | |
626 | + public List<String> getPatientIdsByCondition(List<String> hospitalIds, String key, String vcCardNo, Integer weekStart, Integer weekEnd, Integer age) { | |
627 | + List<Patients> patients = getPatientByCondition(hospitalIds, key, vcCardNo, weekStart, weekEnd, age); | |
628 | + List<String> ids = new ArrayList<>(); | |
629 | + if(CollectionUtils.isNotEmpty(patients)) { | |
630 | + for (Patients patient : patients) { | |
631 | + ids.add(patient.getId()); | |
632 | + } | |
633 | + } | |
634 | + return ids; | |
635 | + } | |
596 | 636 | } |