Commit 0b832311f44ce98714fdbd4d83d520b36a939606
1 parent
290c232c98
Exists in
master
and in
6 other branches
血糖血压相关接口
Showing 7 changed files with 169 additions and 47 deletions
- platform-common/src/main/java/com/lyms/platform/common/enums/ErrorPatientEnums.java
- platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RemoteFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TempFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
platform-common/src/main/java/com/lyms/platform/common/enums/ErrorPatientEnums.java
View file @
0b83231
| ... | ... | @@ -4,6 +4,43 @@ |
| 4 | 4 | * 健康异常孕妇 |
| 5 | 5 | */ |
| 6 | 6 | public enum ErrorPatientEnums { |
| 7 | - PATIENT_WEIGHT, TEMP, BLOOD_PRESSURE, BLOOD_SUGAR; | |
| 7 | + PATIENT_WEIGHT(1, "体重"), TEMP(2, "体温"), BLOOD_PRESSURE(3, "血压"), BLOOD_SUGAR(4, "血糖"); | |
| 8 | + | |
| 9 | + private Integer id; | |
| 10 | + private String name; | |
| 11 | + | |
| 12 | + ErrorPatientEnums(Integer id, String name) { | |
| 13 | + this.id = id; | |
| 14 | + this.name = name; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public static String getName(Integer id) { | |
| 18 | + if(id == null) { | |
| 19 | + return null; | |
| 20 | + } | |
| 21 | + ErrorPatientEnums[] values = ErrorPatientEnums.values(); | |
| 22 | + for (ErrorPatientEnums value : values) { | |
| 23 | + if (value.getId() == id) { | |
| 24 | + return value.getName(); | |
| 25 | + } | |
| 26 | + } | |
| 27 | + return null; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public Integer getId() { | |
| 31 | + return id; | |
| 32 | + } | |
| 33 | + | |
| 34 | + public void setId(Integer id) { | |
| 35 | + this.id = id; | |
| 36 | + } | |
| 37 | + | |
| 38 | + public String getName() { | |
| 39 | + return name; | |
| 40 | + } | |
| 41 | + | |
| 42 | + public void setName(String name) { | |
| 43 | + this.name = name; | |
| 44 | + } | |
| 8 | 45 | } |
platform-common/src/main/java/com/lyms/platform/common/utils/DateUtil.java
View file @
0b83231
| ... | ... | @@ -1407,6 +1407,8 @@ |
| 1407 | 1407 | System.out.println(" end>> " + getyyyy_MM_dd(map.get("end"))); |
| 1408 | 1408 | }*/ |
| 1409 | 1409 | |
| 1410 | + Date yesterday = DateUtil.getYesterday(); | |
| 1411 | + System.out.println(yesterday.toLocaleString()); | |
| 1410 | 1412 | System.out.println(getBetweenDay(7)); |
| 1411 | 1413 | |
| 1412 | 1414 | Date date = parseDate("2017-11-30"); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/RemoteController.java
View file @
0b83231
| ... | ... | @@ -6,6 +6,8 @@ |
| 6 | 6 | import com.lyms.platform.common.base.BaseController; |
| 7 | 7 | import com.lyms.platform.common.base.LoginContext; |
| 8 | 8 | import com.lyms.platform.common.enums.YnEnums; |
| 9 | +import com.lyms.platform.common.result.BaseResponse; | |
| 10 | +import com.lyms.platform.common.result.RespBuilder; | |
| 9 | 11 | import com.lyms.platform.common.utils.JsonUtil; |
| 10 | 12 | import com.lyms.platform.common.utils.MessageUtil; |
| 11 | 13 | import com.lyms.platform.common.utils.PropertiesUtils; |
| ... | ... | @@ -53,9 +55,9 @@ |
| 53 | 55 | public static final String center_statistics_url= PropertiesUtils.getPropertyValue("center_statistics_url"); |
| 54 | 56 | |
| 55 | 57 | @ResponseBody |
| 56 | - @RequestMapping(value = "/error/fy/list/{operaterId}", method = RequestMethod.GET) | |
| 57 | - public List<Map<String, Object>> errorYfList(@PathVariable String operaterId) { | |
| 58 | - return remoteFacade.errorYfList(operaterId); | |
| 58 | + @RequestMapping(value = "/error/fy/list", method = RequestMethod.GET) | |
| 59 | + public BaseResponse errorYfList(@RequestParam String operaterId, String parentIds) { | |
| 60 | + return RespBuilder.buildSuccess(remoteFacade.errorYfList(operaterId, parentIds)); | |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | 63 | @RequestMapping(value = "/bookArchive",method = RequestMethod.GET) |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/RemoteFacade.java
View file @
0b83231
| 1 | 1 | package com.lyms.platform.operate.web.facade; |
| 2 | 2 | |
| 3 | +import com.lyms.platform.common.enums.BloodSugarEnums; | |
| 3 | 4 | import com.lyms.platform.common.enums.ErrorPatientEnums; |
| 4 | 5 | import com.lyms.platform.common.utils.DateUtil; |
| 6 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
| 5 | 7 | import com.lyms.platform.operate.web.utils.MathUtil; |
| 6 | -import com.lyms.platform.pojo.BloodPressure; | |
| 7 | -import com.lyms.platform.pojo.PatientWeight; | |
| 8 | -import com.lyms.platform.pojo.Patients; | |
| 9 | -import com.lyms.platform.pojo.TempModel; | |
| 8 | +import com.lyms.platform.pojo.*; | |
| 10 | 9 | import org.apache.commons.collections.MapUtils; |
| 11 | 10 | import org.apache.commons.lang.StringUtils; |
| 12 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | 12 | |
| 14 | 13 | |
| 15 | 14 | |
| 16 | 15 | |
| 17 | 16 | |
| 18 | 17 | |
| 19 | 18 | |
| 20 | 19 | |
| 21 | 20 | |
| ... | ... | @@ -24,51 +23,112 @@ |
| 24 | 23 | @Component |
| 25 | 24 | public class RemoteFacade { |
| 26 | 25 | |
| 26 | + private static final String ID_SEPARATOR = "_"; | |
| 27 | + | |
| 27 | 28 | @Autowired |
| 28 | 29 | private MongoTemplate mongoTemplate; |
| 29 | 30 | |
| 30 | - public List<Map<String, Object>> errorYfList(String operaterId) { | |
| 31 | + public List<Map<String, Object>> errorYfList(String operaterId, String parentIds) { | |
| 31 | 32 | Date yesterday = DateUtil.getYesterday(); |
| 32 | 33 | List<Map<String, Object>> restList = new ArrayList<>(); |
| 34 | + Query pwQuery = Query.query(Criteria.where("operaterId").is(operaterId)).with(new Sort(Sort.Direction.ASC, "created")); | |
| 35 | + Query bpQuery = Query.query(Criteria.where("operaterId").is(operaterId).and("modified").gt(yesterday)).with(new Sort(Sort.Direction.ASC, "created")); | |
| 36 | + Query bsQuery = Query.query(Criteria.where("operaterId").is(operaterId).and("modified").gt(yesterday)).with(new Sort(Sort.Direction.ASC, "created")); | |
| 37 | + Query tempQuery = Query.query(Criteria.where("operaterId").is(operaterId).and("modified").gt(yesterday)).with(new Sort(Sort.Direction.ASC, "created")); | |
| 38 | + if(StringUtils.isNotEmpty(parentIds)) { | |
| 39 | + List<String> list = CollectionUtils.asList(parentIds, String.class); | |
| 40 | + pwQuery.addCriteria(Criteria.where("patientId").in(list)); | |
| 41 | + bpQuery.addCriteria(Criteria.where("parentId").in(list)); | |
| 42 | + tempQuery.addCriteria(Criteria.where("parentId").in(list)); | |
| 43 | + } | |
| 33 | 44 | |
| 34 | - List<PatientWeight> patientWeights = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)).with(new Sort(Sort.Direction.DESC, "created")), PatientWeight.class); | |
| 35 | - List<BloodPressure> bloodPressures = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)).with(new Sort(Sort.Direction.DESC, "created")), BloodPressure.class); | |
| 36 | - List<TempModel> tempModels = mongoTemplate.find(Query.query(Criteria.where("operaterId").is(operaterId)).with(new Sort(Sort.Direction.DESC, "created")), TempModel.class); | |
| 45 | + /** 体重未记录修改日期 所以全表扫描 */ | |
| 46 | + List<PatientWeight> patientWeights = mongoTemplate.find(pwQuery, PatientWeight.class); | |
| 47 | + List<BloodPressure> bloodPressures = mongoTemplate.find(bpQuery, BloodPressure.class); | |
| 48 | + List<BloodSugar> bloodSugars = mongoTemplate.find(bsQuery, BloodSugar.class); | |
| 49 | + List<TempModel> tempModels = mongoTemplate.find(tempQuery, TempModel.class); | |
| 37 | 50 | |
| 51 | + /** 血压 */ | |
| 52 | + for (BloodPressure bloodPressure : bloodPressures) { | |
| 53 | + Map<String, Object> temp = new HashMap<>(); | |
| 54 | + Patients patients = null; | |
| 55 | + for (Map.Entry<String,Map<String,Object>> entry : bloodPressure.getInfos().entrySet()) { | |
| 56 | + if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { | |
| 57 | + String bpStatus = getBpStatus(entry.getValue().get("ssy").toString(), entry.getValue().get("szy").toString()); | |
| 58 | + if(StringUtils.isNotEmpty(bpStatus)) { | |
| 59 | + patients = (patients == null ? mongoTemplate.findById(bloodPressure.getParentId(), Patients.class) : patients); | |
| 60 | + setTempInfo(bloodPressure.getId() + ID_SEPARATOR + entry.getKey(), temp, patients, | |
| 61 | + entry.getValue().get("ssy") + "/" + entry.getValue().get("szy") + "mmHg", bpStatus, "(收缩压:90-140 舒张压:60-90)", ErrorPatientEnums.BLOOD_PRESSURE); | |
| 62 | + } | |
| 63 | + } | |
| 64 | + } | |
| 65 | + if(temp != null) { | |
| 66 | + restList.add(temp); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** 血糖 */ | |
| 71 | + Map<String, Map<String, Object>> bloodSugarCache = new HashMap<>(); | |
| 72 | + for (BloodSugar bloodSugar : bloodSugars) { | |
| 73 | + Integer type = bloodSugar.getBloodSugarType(); | |
| 74 | + Double min = 0D; | |
| 75 | + Double max = 0D; | |
| 76 | + if(type == BloodSugarEnums.A.getId()) { | |
| 77 | + min = 3.3D; | |
| 78 | + max = 5.6D; | |
| 79 | + } else if(type == BloodSugarEnums.B.getId() || type == BloodSugarEnums.D.getId() || type == BloodSugarEnums.F.getId() ) { | |
| 80 | + min = 3.3D; | |
| 81 | + max = 5.8D; | |
| 82 | + } else if(type == BloodSugarEnums.I.getId()) { | |
| 83 | + min = 6.1D; | |
| 84 | + max = 7.8D; | |
| 85 | + } else { | |
| 86 | + min = 4.4D; | |
| 87 | + max = 6.7D; | |
| 88 | + } | |
| 89 | + if(Double.parseDouble(bloodSugar.getBloodSugar()) > max || Double.parseDouble(bloodSugar.getBloodSugar()) < min) { | |
| 90 | + Map<String, Object> temp = new HashMap<>(); | |
| 91 | + temp.put("name", BloodSugarEnums.getName(bloodSugar.getBloodSugarType())); | |
| 92 | + bloodSugarCache.put(bloodSugar.getId(), temp); | |
| 93 | + setTempInfo(bloodSugar.getId(), temp, mongoTemplate.findById(bloodSugar.getParentId(), Patients.class), bloodSugar.getBloodSugar(), Double.parseDouble(bloodSugar.getBloodSugar()) > max ? "高血糖" : "低血糖", | |
| 94 | + "(" + min +"-" + max + ")", ErrorPatientEnums.BLOOD_SUGAR); | |
| 95 | + } | |
| 96 | + } | |
| 97 | + restList.addAll(bloodSugarCache.values()); | |
| 98 | + | |
| 99 | + /** 体重 */ | |
| 38 | 100 | for (PatientWeight patientWeight : patientWeights) { |
| 39 | - Patients patients = mongoTemplate.findById(patientWeight.getPatientId(), Patients.class); | |
| 101 | + Patients patients = null; | |
| 40 | 102 | String bmi = patientWeight.getBmi(); |
| 41 | 103 | Map<Integer, Double> highMap = new LinkedHashMap<>(); |
| 42 | 104 | Map<Integer, Double> lowMap = new LinkedHashMap<>(); |
| 43 | 105 | setMapInfo(highMap, lowMap, bmi); |
| 44 | 106 | Map<String, String> dayWeights = patientWeight.getDayWeights(); |
| 45 | 107 | Map<String, Object> temp = new HashMap<>(); |
| 46 | - for (Map.Entry<String, String> entry : dayWeights.entrySet()) { | |
| 47 | - if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { | |
| 48 | - Integer week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())); | |
| 49 | - Double addWeight = getAddWeight(patientWeight.getBeforeWeight(), entry.getValue()); | |
| 50 | - Double low = lowMap.get(week); | |
| 51 | - Double high = highMap.get(week); | |
| 52 | - if(addWeight < low || addWeight > high) { | |
| 53 | - temp.put("username", patients.getUsername()); | |
| 54 | - temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
| 55 | - temp.put("parentId", patientWeight.getPatientId()); | |
| 56 | - temp.put("id", patientWeight.getId()); | |
| 57 | - temp.put("day", entry.getKey()); | |
| 58 | - temp.put("desc", addWeight < low ? "增重过少" : "增重过多"); | |
| 59 | - temp.put("beforeWeight", patientWeight.getBeforeWeight()); | |
| 60 | - temp.put("nowWeight", patientWeight.getNowWeight()); | |
| 61 | - temp.put("addWeight", addWeight); | |
| 62 | - temp.put("ckz", "(" + lowMap.get(0) + "~" + highMap.get(0) + ")"); | |
| 63 | - temp.put("type", ErrorPatientEnums.PATIENT_WEIGHT); | |
| 108 | + if(MapUtils.isNotEmpty(dayWeights)) { | |
| 109 | + for (Map.Entry<String, String> entry : dayWeights.entrySet()) { | |
| 110 | + if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { | |
| 111 | + patients = (patients == null ? mongoTemplate.findById(patientWeight.getPatientId(), Patients.class) : patients); | |
| 112 | + Integer week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())); | |
| 113 | + Double addWeight = getAddWeight(patientWeight.getBeforeWeight(), entry.getValue()); | |
| 114 | + Double low = lowMap.get(week); | |
| 115 | + Double high = highMap.get(week); | |
| 116 | + if(addWeight < low || addWeight > high) { | |
| 117 | + setTempInfo(patientWeight.getId() + ID_SEPARATOR + entry.getKey(), temp, patients, null, addWeight < low ? "增重过少" : "增重过多", | |
| 118 | + "(" + lowMap.get(0) + "~" + highMap.get(0) + ")", ErrorPatientEnums.PATIENT_WEIGHT); | |
| 119 | + temp.put("beforeWeight", patientWeight.getBeforeWeight()); | |
| 120 | + temp.put("nowWeight", patientWeight.getNowWeight()); | |
| 121 | + temp.put("addWeight", addWeight); | |
| 122 | + } | |
| 64 | 123 | } |
| 65 | 124 | } |
| 125 | + if(MapUtils.isNotEmpty(temp)) { | |
| 126 | + restList.add(temp); | |
| 127 | + } | |
| 66 | 128 | } |
| 67 | - if(MapUtils.isNotEmpty(temp)) { | |
| 68 | - restList.add(temp); | |
| 69 | - } | |
| 70 | 129 | } |
| 71 | 130 | |
| 131 | + /** 体温 */ | |
| 72 | 132 | for (TempModel tempModel : tempModels) { |
| 73 | 133 | Map<String, Object> temp = new HashMap<>(); |
| 74 | 134 | LinkedHashMap<String, Double> tempList = tempModel.getTempList(); |
| ... | ... | @@ -77,15 +137,8 @@ |
| 77 | 137 | if(DateUtil.parseYMD(entry.getKey()).getTime() >= yesterday.getTime()) { |
| 78 | 138 | if(entry.getValue() < 36D || entry.getValue() > 38.5D ) { |
| 79 | 139 | patients = (patients == null ? mongoTemplate.findById(tempModel.getParentId(), Patients.class) : patients); |
| 80 | - temp.put("username", patients.getUsername()); | |
| 81 | - temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
| 82 | - temp.put("parentId", tempModel.getParentId()); | |
| 83 | - temp.put("id", tempModel.getId()); | |
| 84 | - temp.put("day", entry.getKey()); | |
| 85 | - temp.put("desc", entry.getValue() < 36D ? "低热" : "高热"); | |
| 86 | - temp.put("temp", entry.getValue()); | |
| 87 | - temp.put("ckz", "(36-37.4)"); | |
| 88 | - temp.put("type", ErrorPatientEnums.TEMP); | |
| 140 | + setTempInfo(tempModel.getId() + ID_SEPARATOR + entry.getKey(), temp, patients, entry.getValue() + " °C", entry.getValue() < 36D ? "低热" : "高热", | |
| 141 | + "(36-37.4)", ErrorPatientEnums.TEMP); | |
| 89 | 142 | } |
| 90 | 143 | } |
| 91 | 144 | } |
| ... | ... | @@ -94,6 +147,32 @@ |
| 94 | 147 | } |
| 95 | 148 | } |
| 96 | 149 | return restList; |
| 150 | + } | |
| 151 | + | |
| 152 | + private void setTempInfo(String id, Map<String, Object> temp, Patients patients, String value, String desc, String ckz, ErrorPatientEnums errorPatientEnums) { | |
| 153 | + if(patients == null) return; | |
| 154 | + temp.put("id", id); | |
| 155 | + temp.put("username", patients.getUsername()); | |
| 156 | + temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
| 157 | + temp.put("parentId", patients.getId()); | |
| 158 | + temp.put("value", value); | |
| 159 | + temp.put("desc", desc); | |
| 160 | + temp.put("ckz", ckz); | |
| 161 | + temp.put("type", errorPatientEnums.getId()); | |
| 162 | + } | |
| 163 | + | |
| 164 | + private String getBpStatus(String ssy, String szy) { | |
| 165 | + String status = null; | |
| 166 | + if(StringUtils.isNotEmpty(ssy) && StringUtils.isNotEmpty(szy)) { | |
| 167 | + if(Double.parseDouble(ssy) < 90 || Double.parseDouble(szy) < 60) { | |
| 168 | + status = "低血压"; | |
| 169 | + } else if(Double.parseDouble(ssy) > 140 || Double.parseDouble(szy) < 90) { | |
| 170 | + status = "高血压"; | |
| 171 | + } else { | |
| 172 | + status = "正常"; | |
| 173 | + } | |
| 174 | + } | |
| 175 | + return status; | |
| 97 | 176 | } |
| 98 | 177 | |
| 99 | 178 | /** |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TempFacade.java
View file @
0b83231
| ... | ... | @@ -245,7 +245,7 @@ |
| 245 | 245 | if(patients != null) { |
| 246 | 246 | tempModel.setPid(patients.getPid()); |
| 247 | 247 | } |
| 248 | - mongoTemplate.save(tempModel); | |
| 248 | + tempService.addOneTemp(tempModel); | |
| 249 | 249 | } |
| 250 | 250 | return RespBuilder.buildSuccess(); |
| 251 | 251 | } |
| ... | ... | @@ -262,7 +262,9 @@ |
| 262 | 262 | restList.add(map); |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | - return RespBuilder.buildSuccess(restList); | |
| 265 | + Object[] objects = restList.toArray(); | |
| 266 | + CollectionUtils.reverseArray(objects); | |
| 267 | + return RespBuilder.buildSuccess(objects); | |
| 266 | 268 | } |
| 267 | 269 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java
View file @
0b83231
| ... | ... | @@ -51,13 +51,13 @@ |
| 51 | 51 | public BaseResponse addOrUpdate(Integer userId, BloodPressure bloodPressure) { |
| 52 | 52 | String hospitalId = autoMatchFacade.getHospitalId(userId); |
| 53 | 53 | Map<String, Object> temp = new LinkedHashMap<>(); |
| 54 | + bloodPressure.setModified(new Date()); | |
| 54 | 55 | temp.put("szy", bloodPressure.getSzy()); |
| 55 | 56 | temp.put("ssy", bloodPressure.getSsy()); |
| 56 | 57 | temp.put("pulse", bloodPressure.getPulse()); |
| 57 | 58 | temp.put("timestamp", DateUtil.getyyyy_MM_dd_hms(new Date())); |
| 58 | 59 | temp.put("hospitalId", hospitalId); |
| 59 | 60 | BloodPressure bp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(bloodPressure.getParentId()).and("yn").ne(0)), BloodPressure.class); |
| 60 | - bloodPressure.setModified(new Date()); | |
| 61 | 61 | if(bp == null) { |
| 62 | 62 | String parentId = mongoUtil.doHidePatient(bloodPressure.getParentId(), hospitalId); |
| 63 | 63 | bloodPressure.setParentId(parentId); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
0b83231
| ... | ... | @@ -230,7 +230,7 @@ |
| 230 | 230 | for (BloodSugar bloodSugar : bloodSugars) { |
| 231 | 231 | Map<String, Object> temp = new HashMap<>(); |
| 232 | 232 | temp.put("bloodSugar", bloodSugar.getBloodSugar()); |
| 233 | - temp.put("craeted", bloodSugar.getCreated()); | |
| 233 | + temp.put("craeted", DateUtil.getyyyy_MM_dd_hms(bloodSugar.getCreated())); | |
| 234 | 234 | temp.put("type", bloodSugar.getBloodSugarType()); |
| 235 | 235 | restList.add(temp); |
| 236 | 236 | } |