Commit 9ea10ca75a28660168d662bc18f669e36ab756ce
1 parent
7d27e2670b
Exists in
master
and in
6 other branches
血糖
Showing 5 changed files with 283 additions and 7 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/BloodSugar.java
- platform-dal/src/main/java/com/lyms/platform/query/BloodSugarQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BloodSugarController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodSugarService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
platform-dal/src/main/java/com/lyms/platform/pojo/BloodSugar.java
View file @
9ea10ca
... | ... | @@ -65,6 +65,28 @@ |
65 | 65 | //当前孕周 |
66 | 66 | private Integer currentWeek; |
67 | 67 | |
68 | + //0 未推送 1已经推送 | |
69 | + private Integer exceptionSend; | |
70 | + | |
71 | + //0 未推送 1已经推送 | |
72 | + private Integer sevenSend; | |
73 | + | |
74 | + public Integer getExceptionSend() { | |
75 | + return exceptionSend; | |
76 | + } | |
77 | + | |
78 | + public void setExceptionSend(Integer exceptionSend) { | |
79 | + this.exceptionSend = exceptionSend; | |
80 | + } | |
81 | + | |
82 | + public Integer getSevenSend() { | |
83 | + return sevenSend; | |
84 | + } | |
85 | + | |
86 | + public void setSevenSend(Integer sevenSend) { | |
87 | + this.sevenSend = sevenSend; | |
88 | + } | |
89 | + | |
68 | 90 | public Integer getCurrentWeek() { |
69 | 91 | return currentWeek; |
70 | 92 | } |
platform-dal/src/main/java/com/lyms/platform/query/BloodSugarQuery.java
View file @
9ea10ca
... | ... | @@ -19,11 +19,17 @@ |
19 | 19 | |
20 | 20 | private String id; |
21 | 21 | private String parentId; |
22 | + private List<String> parentIds; | |
22 | 23 | private String pid; |
23 | 24 | private Boolean isExistReportDate; |
24 | 25 | private Date createdStart; |
25 | 26 | private Date createdEnd; |
27 | + //0 未推送 1已经推送 | |
28 | + private Integer exceptionSend; | |
26 | 29 | |
30 | + //0 未推送 1已经推送 | |
31 | + private Integer sevenSend; | |
32 | + | |
27 | 33 | @Override |
28 | 34 | public MongoQuery convertToQuery() { |
29 | 35 | MongoCondition condition = MongoCondition.newInstance(); |
... | ... | @@ -35,6 +41,38 @@ |
35 | 41 | if(StringUtils.isNotEmpty(parentId)){ |
36 | 42 | condition = condition.and("parentId", parentId, MongoOper.IS); |
37 | 43 | } |
44 | + | |
45 | + if(CollectionUtils.isNotEmpty(parentIds)){ | |
46 | + condition = condition.and("parentId", parentIds, MongoOper.IN); | |
47 | + } | |
48 | + | |
49 | + if(exceptionSend != null){ | |
50 | + if (exceptionSend == 0) | |
51 | + { | |
52 | + MongoCondition con1 = MongoCondition.newInstance("exceptionSend", exceptionSend, MongoOper.IS); | |
53 | + MongoCondition con = MongoCondition.newInstance("exceptionSend", false, MongoOper.EXISTS); | |
54 | + condition = condition.orCondition(new MongoCondition[]{con1, con}); | |
55 | + } | |
56 | + else | |
57 | + { | |
58 | + condition = condition.and("exceptionSend", exceptionSend, MongoOper.IS); | |
59 | + } | |
60 | + | |
61 | + } | |
62 | + | |
63 | + if(sevenSend != null){ | |
64 | + if (sevenSend == 0) | |
65 | + { | |
66 | + MongoCondition con1 = MongoCondition.newInstance("sevenSend", sevenSend, MongoOper.IS); | |
67 | + MongoCondition con = MongoCondition.newInstance("sevenSend", false, MongoOper.EXISTS); | |
68 | + condition = condition.orCondition(new MongoCondition[]{con1, con}); | |
69 | + } | |
70 | + else | |
71 | + { | |
72 | + condition = condition.and("sevenSend", sevenSend, MongoOper.IS); | |
73 | + } | |
74 | + } | |
75 | + | |
38 | 76 | if(StringUtils.isNotEmpty(pid)){ |
39 | 77 | condition = condition.and("pid", pid, MongoOper.IS); |
40 | 78 | } |
... | ... | @@ -67,6 +105,29 @@ |
67 | 105 | return condition.toMongoQuery(); |
68 | 106 | } |
69 | 107 | |
108 | + public Integer getExceptionSend() { | |
109 | + return exceptionSend; | |
110 | + } | |
111 | + | |
112 | + public void setExceptionSend(Integer exceptionSend) { | |
113 | + this.exceptionSend = exceptionSend; | |
114 | + } | |
115 | + | |
116 | + public Integer getSevenSend() { | |
117 | + return sevenSend; | |
118 | + } | |
119 | + | |
120 | + public void setSevenSend(Integer sevenSend) { | |
121 | + this.sevenSend = sevenSend; | |
122 | + } | |
123 | + | |
124 | + public List<String> getParentIds() { | |
125 | + return parentIds; | |
126 | + } | |
127 | + | |
128 | + public void setParentIds(List<String> parentIds) { | |
129 | + this.parentIds = parentIds; | |
130 | + } | |
70 | 131 | |
71 | 132 | public String getId() { |
72 | 133 | return id; |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BloodSugarController.java
View file @
9ea10ca
... | ... | @@ -8,10 +8,7 @@ |
8 | 8 | import com.lyms.platform.pojo.BloodSugar; |
9 | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | 10 | import org.springframework.stereotype.Controller; |
11 | -import org.springframework.web.bind.annotation.PathVariable; | |
12 | -import org.springframework.web.bind.annotation.RequestMapping; | |
13 | -import org.springframework.web.bind.annotation.RequestMethod; | |
14 | -import org.springframework.web.bind.annotation.ResponseBody; | |
11 | +import org.springframework.web.bind.annotation.*; | |
15 | 12 | |
16 | 13 | import javax.servlet.http.HttpServletRequest; |
17 | 14 | import java.util.Date; |
... | ... | @@ -124,7 +121,13 @@ |
124 | 121 | public BaseResponse getSysBloodSugarReport(@PathVariable String patientId |
125 | 122 | ,HttpServletRequest httpServletRequest) { |
126 | 123 | LoginContext loginState = (LoginContext) httpServletRequest.getAttribute("loginContext"); |
127 | - return bloodSugarService.getSysBloodSugarReport(patientId,loginState.getId()); | |
124 | + return bloodSugarService.getSysBloodSugarReport(patientId, loginState.getId()); | |
125 | + } | |
126 | + | |
127 | + @ResponseBody | |
128 | + @RequestMapping(value = "/getBloodSugars/{doctorId}/{type}/{status}", method = RequestMethod.GET) | |
129 | + public BaseResponse getBloodSugars(@PathVariable String doctorId,@PathVariable Integer type,@PathVariable Integer status,@RequestParam(required = false) String keyword) { | |
130 | + return bloodSugarService.getBloodSugars(doctorId, type, status, keyword); | |
128 | 131 | } |
129 | 132 | |
130 | 133 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodSugarService.java
View file @
9ea10ca
... | ... | @@ -31,5 +31,7 @@ |
31 | 31 | BaseResponse addWeightInfo(String id, String beforeWeight, String currentWeight); |
32 | 32 | |
33 | 33 | BaseResponse getSysBloodSugarReport(String patientId,Integer userId); |
34 | + | |
35 | + BaseResponse getBloodSugars(String doctorId, Integer type, Integer status, String keyword); | |
34 | 36 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
9ea10ca
... | ... | @@ -3,8 +3,10 @@ |
3 | 3 | import com.alibaba.fastjson.JSONArray; |
4 | 4 | import com.alibaba.fastjson.JSONObject; |
5 | 5 | import com.lyms.platform.biz.service.*; |
6 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
6 | 7 | import com.lyms.platform.common.enums.BloodSugarEnums; |
7 | 8 | import com.lyms.platform.common.enums.BloodSugarEnums2; |
9 | +import com.lyms.platform.common.enums.PatientSerEnums; | |
8 | 10 | import com.lyms.platform.common.enums.YnEnums; |
9 | 11 | import com.lyms.platform.common.result.*; |
10 | 12 | import com.lyms.platform.common.utils.DateUtil; |
11 | 13 | |
12 | 14 | |
... | ... | @@ -21,11 +23,15 @@ |
21 | 23 | import com.lyms.platform.operate.web.utils.MongoUtil; |
22 | 24 | import com.lyms.platform.operate.web.utils.ReportConfig; |
23 | 25 | import com.lyms.platform.permission.model.Organization; |
26 | +import com.lyms.platform.permission.model.PatientService; | |
27 | +import com.lyms.platform.permission.model.PatientServiceQuery; | |
24 | 28 | import com.lyms.platform.permission.service.OrganizationService; |
29 | +import com.lyms.platform.permission.service.PatientServiceService; | |
25 | 30 | import com.lyms.platform.pojo.*; |
26 | 31 | import com.lyms.platform.query.AntExChuQuery; |
27 | 32 | import com.lyms.platform.query.AntExRecordQuery; |
28 | 33 | import com.lyms.platform.query.BloodSugarQuery; |
34 | +import com.lyms.platform.query.PatientsQuery; | |
29 | 35 | import org.apache.commons.collections.MapUtils; |
30 | 36 | import org.apache.commons.collections.map.HashedMap; |
31 | 37 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -74,6 +80,9 @@ |
74 | 80 | private AntenatalExaminationService antenatalExaminationService; |
75 | 81 | |
76 | 82 | @Autowired |
83 | + private PatientServiceService patientServiceService; | |
84 | + | |
85 | + @Autowired | |
77 | 86 | private ComputeKulServiceManager computeKulServiceManager; |
78 | 87 | |
79 | 88 | @Autowired |
... | ... | @@ -374,7 +383,7 @@ |
374 | 383 | } |
375 | 384 | } |
376 | 385 | if(flag) { |
377 | - weekMap.put("value", "--"); | |
386 | + weekMap.put("value", ""); | |
378 | 387 | } |
379 | 388 | weekAvgMap.add(weekMap); |
380 | 389 | } |
... | ... | @@ -413,7 +422,7 @@ |
413 | 422 | } |
414 | 423 | } |
415 | 424 | if(flag) { |
416 | - monthMap.put("value", "--"); | |
425 | + monthMap.put("value", ""); | |
417 | 426 | } |
418 | 427 | monthAvgMap.add(monthMap); |
419 | 428 | } |
... | ... | @@ -1192,6 +1201,185 @@ |
1192 | 1201 | private void setData(Map<String, Object> map, String key, String value) { |
1193 | 1202 | map.put("id", key); |
1194 | 1203 | map.put("name", value); |
1204 | + } | |
1205 | + | |
1206 | + | |
1207 | + @Override | |
1208 | + public BaseResponse getBloodSugars(String doctorId, Integer type, Integer status, String keyword) { | |
1209 | + List<Map> datas = new ArrayList<>(); | |
1210 | + List<String> pids = new ArrayList<>(); | |
1211 | + if (org.apache.commons.lang.StringUtils.isNotEmpty(keyword)) | |
1212 | + { | |
1213 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
1214 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
1215 | + patientsQuery.setQueryNo(keyword); | |
1216 | + patientsQuery.setType(1); | |
1217 | + List<Patients> pats = patientsService.queryPatient(patientsQuery); | |
1218 | + if (CollectionUtils.isNotEmpty(pats)) | |
1219 | + { | |
1220 | + for (Patients pat : pats) | |
1221 | + { | |
1222 | + pids.add(pat.getId()); | |
1223 | + } | |
1224 | + } | |
1225 | + else | |
1226 | + { | |
1227 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
1228 | + } | |
1229 | + } | |
1230 | + | |
1231 | + | |
1232 | + PatientServiceQuery patientQuery = new PatientServiceQuery(); | |
1233 | + patientQuery.setSerDoct(doctorId); | |
1234 | + patientQuery.setSerType(PatientSerEnums.SerTypeEnums.xt.getId()); | |
1235 | + patientQuery.setSerStatus(1); | |
1236 | + if (CollectionUtils.isNotEmpty(pids)) | |
1237 | + { | |
1238 | + patientQuery.setParentIds((String[]) pids.toArray(new String[pids.size()])); | |
1239 | + } | |
1240 | + List<PatientService> list = patientServiceService.queryPatientService(patientQuery); | |
1241 | + List<String> patientIds = new ArrayList<>(); | |
1242 | + | |
1243 | + if (CollectionUtils.isNotEmpty(list)) | |
1244 | + { | |
1245 | + for (PatientService ps : list) | |
1246 | + { | |
1247 | + Patients pat = patientsService.findOnePatientById(ps.getParentid()); | |
1248 | + if (pat != null && pat.getType() == 1) | |
1249 | + { | |
1250 | + patientIds.add(ps.getParentid()); | |
1251 | + } | |
1252 | + } | |
1253 | + } | |
1254 | + | |
1255 | + BloodSugarQuery bloodSugarQuery = new BloodSugarQuery(); | |
1256 | + bloodSugarQuery.setParentIds(patientIds); | |
1257 | + //七天没有记录的 | |
1258 | + if (type == 1) | |
1259 | + { | |
1260 | + bloodSugarQuery.setCreatedEnd(DateUtil.addDay(new Date(),-7)); | |
1261 | + if (status != null && status == 1) | |
1262 | + { | |
1263 | + bloodSugarQuery.setSevenSend(status); | |
1264 | + } | |
1265 | + else if (status != null && status == 0) | |
1266 | + { | |
1267 | + bloodSugarQuery.setSevenSend(status); | |
1268 | + } | |
1269 | + } | |
1270 | + //大于等于连续3次异常的 | |
1271 | + else if (type == 2) | |
1272 | + { | |
1273 | + if (status != null && status == 1) | |
1274 | + { | |
1275 | + bloodSugarQuery.setExceptionSend(status); | |
1276 | + } | |
1277 | + else if (status != null && status == 0) | |
1278 | + { | |
1279 | + bloodSugarQuery.setExceptionSend(status); | |
1280 | + } | |
1281 | + } | |
1282 | + | |
1283 | + List<BloodSugar> bloodSugars = bloodSugarService.queryBloodSugarList(bloodSugarQuery,Sort.Direction.DESC, "created"); | |
1284 | + | |
1285 | + Map<String, List<BloodSugar>> listMap = new HashMap<>(); | |
1286 | + | |
1287 | + if (CollectionUtils.isNotEmpty(bloodSugars)) | |
1288 | + { | |
1289 | + for (BloodSugar bloodSugar : bloodSugars) | |
1290 | + { | |
1291 | + List<BloodSugar> bss = listMap.get(bloodSugar.getParentId()); | |
1292 | + if (CollectionUtils.isEmpty(bss)) | |
1293 | + { | |
1294 | + bss = new ArrayList<>(); | |
1295 | + } | |
1296 | + bss.add(bloodSugar); | |
1297 | + listMap.put(bloodSugar.getParentId(),bss); | |
1298 | + } | |
1299 | + } | |
1300 | + if (listMap.size() > 0) | |
1301 | + { | |
1302 | + for (String key : listMap.keySet()) | |
1303 | + { | |
1304 | + List<BloodSugar> sugarList = listMap.get(key); | |
1305 | + if (CollectionUtils.isNotEmpty(sugarList)) | |
1306 | + { | |
1307 | + Map map = new HashMap(); | |
1308 | + BloodSugar bloodSugar1 = sugarList.get(0); | |
1309 | + if (type == 2) | |
1310 | + { | |
1311 | + | |
1312 | + boolean isContinue = false; | |
1313 | + Map<String, List<BloodSugar>> maps = new HashMap<>(); | |
1314 | + if (CollectionUtils.isNotEmpty(sugarList)) | |
1315 | + { | |
1316 | + for (BloodSugar bloodSugar : sugarList) | |
1317 | + { | |
1318 | + List<BloodSugar> bss = maps.get(bloodSugar.getCreatYmdDate()); | |
1319 | + if (CollectionUtils.isEmpty(bss)) | |
1320 | + { | |
1321 | + bss = new ArrayList<>(); | |
1322 | + } | |
1323 | + bss.add(bloodSugar); | |
1324 | + maps.put(bloodSugar.getCreatYmdDate(),bss); | |
1325 | + } | |
1326 | + } | |
1327 | + maps = sortMapByKey(maps); | |
1328 | + if (maps.size() > 0) { | |
1329 | + int count = 0; | |
1330 | + for (String key1 : maps.keySet()) { | |
1331 | + List<BloodSugar> bss = maps.get(key1); | |
1332 | + if (CollectionUtils.isNotEmpty(bss)) | |
1333 | + { | |
1334 | + for (BloodSugar bs : bss) | |
1335 | + { | |
1336 | + int result = getBloodSugarStatus(bs.getBloodSugarType(),Float.parseFloat(bs.getBloodSugar())); | |
1337 | + if (result != 0) | |
1338 | + { | |
1339 | + count++; | |
1340 | + break; | |
1341 | + } | |
1342 | + } | |
1343 | + } | |
1344 | + if (count >= 3) | |
1345 | + { | |
1346 | + isContinue = true; | |
1347 | + break; | |
1348 | + } | |
1349 | + } | |
1350 | + } | |
1351 | + | |
1352 | + if (!isContinue) | |
1353 | + { | |
1354 | + continue; | |
1355 | + } | |
1356 | + } | |
1357 | + else if (type == 1) | |
1358 | + { | |
1359 | + BloodSugarQuery bloodSugarQuery1 = new BloodSugarQuery(); | |
1360 | + bloodSugarQuery1.setParentId(bloodSugar1.getParentId()); | |
1361 | + bloodSugarQuery1.setCreatedStart(DateUtil.addDay(new Date(), -7)); | |
1362 | + List<BloodSugar> list1 = bloodSugarService.queryBloodSugarList(bloodSugarQuery1,Sort.Direction.DESC, "created"); | |
1363 | + if (CollectionUtils.isNotEmpty(list1)) | |
1364 | + { | |
1365 | + continue; | |
1366 | + } | |
1367 | + } | |
1368 | + | |
1369 | + Patients patients = patientsService.findOnePatientById(bloodSugar1.getParentId()); | |
1370 | + | |
1371 | + map.put("patientId",patients != null ? patients.getId() : ""); | |
1372 | + map.put("name",patients != null ? patients.getUsername() : ""); | |
1373 | + map.put("age",patients != null ? DateUtil.getAge(patients.getBirth(), bloodSugar1.getCreated()): ""); | |
1374 | + map.put("week",patients != null ? DateUtil.getWeekDesc(patients.getLastMenses(), bloodSugar1.getCreated()): ""); | |
1375 | + map.put("bloodSugar",bloodSugar1.getBloodSugar()); | |
1376 | + map.put("days",DateUtil.getDays(bloodSugar1.getCreated(), new Date())); | |
1377 | + map.put("phone",patients.getPhone()); | |
1378 | + datas.add(map); | |
1379 | + } | |
1380 | + } | |
1381 | + } | |
1382 | + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); | |
1195 | 1383 | } |
1196 | 1384 | |
1197 | 1385 | } |