Commit 5c4c620320a594b4c9552e4f799501ff06aa2379

Authored by jiangjiazhi
1 parent d8676374f9

血压报告生成

Showing 9 changed files with 579 additions and 86 deletions

platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java View file @ 5c4c620
... ... @@ -14,14 +14,14 @@
14 14 import com.lyms.platform.common.dao.operator.MongoCondition;
15 15 import com.lyms.platform.common.dao.operator.MongoOper;
16 16 import com.lyms.platform.common.dao.operator.MongoQuery;
17   -import com.lyms.platform.common.enums.GroupEnums;
18   -import com.lyms.platform.common.enums.ServiceStatusEnums;
19   -import com.lyms.platform.common.enums.ServiceTypeEnums;
20   -import com.lyms.platform.common.enums.YnEnums;
  17 +import com.lyms.platform.common.enums.*;
21 18 import com.lyms.platform.common.pojo.SyncDataModel;
  19 +import com.lyms.platform.common.result.BaseModel;
22 20 import com.lyms.platform.common.utils.*;
23 21 import com.lyms.platform.pojo.*;
24 22 import com.lyms.platform.query.*;
  23 +import com.mongodb.BasicDBObject;
  24 +import com.mongodb.QueryBuilder;
25 25 import com.qiniu.util.Json;
26 26 import jxl.Cell;
27 27 import jxl.Sheet;
... ... @@ -38,6 +38,7 @@
38 38 import org.springframework.context.support.ClassPathXmlApplicationContext;
39 39  
40 40 import org.springframework.data.mongodb.core.MongoTemplate;
  41 +import org.springframework.data.mongodb.core.query.BasicQuery;
41 42 import org.springframework.data.mongodb.core.query.Criteria;
42 43 import org.springframework.data.mongodb.core.query.Query;
43 44 import org.springframework.data.mongodb.core.query.Update;
44 45  
45 46  
... ... @@ -1293,9 +1294,60 @@
1293 1294 }
1294 1295  
1295 1296 }
  1297 + /**
  1298 + *分类和type的映射关系
  1299 + **/
  1300 + private static Map<String,String> map = new HashMap<>();
  1301 + private static Map<String,String> map1 = new HashMap<>();
  1302 + private static Map<String,Integer> map2 = new HashMap<>();
  1303 + static {
  1304 + map.put("血压值正常无波动","00");
  1305 + map.put("血压波动异常血压值正常","01");
  1306 + map.put("血压值异常血压值异常但基本平稳","10");
  1307 + map.put("血压值异常波动异常","11");
1296 1308  
1297 1309  
  1310 + map1.put("1","合理运动");
  1311 + map1.put("2","运动指导");
  1312 + map1.put("3","心理指导");
  1313 + map1.put("4","自我监测");
  1314 + map1.put("5","用药指导");
1298 1315  
  1316 +
  1317 + map2.put("1", PloodPressureGuideCategoryTypeEnum.HELIYUNDONG.getId());
  1318 + map2.put("2",PloodPressureGuideCategoryTypeEnum.YUNDONGZHIDAO.getId());
  1319 + map2.put("3",PloodPressureGuideCategoryTypeEnum.XINLIZHIDAO.getId());
  1320 + map2.put("4",PloodPressureGuideCategoryTypeEnum.ZIWOJIANCE.getId());
  1321 + map2.put("5",PloodPressureGuideCategoryTypeEnum.YONGYAOZHIDAO.getId());
  1322 + }
  1323 +
  1324 + private static class KeyWord extends BaseModel{
  1325 + private String key;
  1326 + private String content;
  1327 +
  1328 + public KeyWord(String key, String content) {
  1329 + this.key = key;
  1330 + this.content = content;
  1331 + }
  1332 +
  1333 + public String getKey() {
  1334 + return key;
  1335 + }
  1336 +
  1337 + public void setKey(String key) {
  1338 + this.key = key;
  1339 + }
  1340 +
  1341 + public String getContent() {
  1342 + return content;
  1343 + }
  1344 +
  1345 + public void setContent(String content) {
  1346 + this.content = content;
  1347 + }
  1348 + }
  1349 +
  1350 +
1299 1351 //早产儿体重百分位数值表(男、女)
1300 1352 public static void zcet(String fileName)
1301 1353 {
1302 1354  
1303 1355  
1304 1356  
1305 1357  
1306 1358  
1307 1359  
1308 1360  
... ... @@ -1303,71 +1355,70 @@
1303 1355 Workbook wb = null;
1304 1356 try {
1305 1357 wb = Workbook.getWorkbook(file);
1306   - ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml");
  1358 + ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml");
1307 1359 MongoTemplate mongoTemplate
1308 1360 = (MongoTemplate) applicationContext.getBean("mongoTemplate");
1309 1361 mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray());
  1362 + if(wb.getSheets().length>0){
  1363 + for (int j1 = 0 ; j1 < wb.getSheets().length ; j1 ++)
  1364 + {
  1365 + Sheet s1 = wb.getSheet(j1);
  1366 + String type =map.get(s1.getName());
  1367 + System.out.println("sheet name -->>> type :"+map.get(s1.getName()));
  1368 + int rows1 = s1.getRows();
  1369 + if(rows1 > 0){
  1370 + //遍历每行
  1371 + for(int i = 1 ;i < rows1 ; i++){
  1372 + Cell[] cells = s1.getRow(i);
  1373 + if(cells.length > 0){
  1374 + //遍历每行中的每列
  1375 + for (int j = 1 ; j < cells.length ; j ++)
  1376 + {
  1377 + PloodPressureGuideModel bpModel=new PloodPressureGuideModel();
  1378 + bpModel.setYn(YnEnums.YES.getId());
  1379 + bpModel.setType(type);
  1380 + String week = cells[0].getContents().trim();
  1381 + String content = cells[j].getContents().trim();
  1382 + if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(content))
  1383 + {
  1384 + continue;
  1385 + }
  1386 + if(i>0){
1310 1387  
1311   - Sheet s1 = wb.getSheet(0);
1312   - int rows1 = s1.getRows();
1313   - if(rows1 > 0){
1314   - //遍历每行
1315   - for(int i = 0 ;i < rows1 ; i++){
1316   - System.out.println("rows="+i);
1317   - AwModel awModel = new AwModel();
1318   - awModel.setType(4);
1319   - Cell[] cells = s1.getRow(i);
1320   - if(cells.length > 0){
1321   - //遍历每行中的每列
1322   - for (int j = 0 ; j < cells.length ; j ++)
1323   - {
1324   - String str = cells[j].getContents().trim();
1325   - if (!com.lyms.platform.common.utils.StringUtils.isNotEmpty(str))
1326   - {
1327   - continue;
  1388 + KeyWord keyWord = new KeyWord(week+"_"+j+"_"+type,content);
  1389 +// System.out.println("keyWord :" +keyWord);
  1390 +
  1391 + convertToBean(keyWord,mongoTemplate);
  1392 + }
  1393 + }
1328 1394 }
1329   - switch (j)
1330   - {
1331   - case 0:
1332   - awModel.setWeek(Integer.valueOf(str));
1333   - continue;
1334   - case 1:
1335   - awModel.setRthreeDs(Double.valueOf(str)/1000);
1336   - continue;
1337   - case 2:
1338   - awModel.setRtwoDs(Double.valueOf(str)/1000);
1339   - continue;
1340   - case 3:
1341   - awModel.setRoneDs(Double.valueOf(str)/1000);
1342   - continue;
1343   - case 4:
1344   - awModel.setMiddleDs(Double.valueOf(str)/1000);
1345   - continue;
1346   - case 5:
1347   - awModel.setPoneDs(Double.valueOf(str)/1000);
1348   - continue;
1349   - case 6:
1350   - awModel.setPtwoDs(Double.valueOf(str)/1000);
1351   - continue;
1352   - case 7:
1353   - awModel.setPthreeDs(Double.valueOf(str)/1000);
1354   - continue;
1355   - case 8:
1356   - awModel.setSex(Integer.valueOf(str));
1357   - continue;
1358   - }
1359 1395 }
1360 1396 }
1361   - mongoTemplate.save(awModel);
1362 1397 }
1363 1398 }
1364 1399  
  1400 +
1365 1401 } catch (IOException e) {
1366 1402 e.printStackTrace();
1367 1403 } catch (BiffException e) {
1368 1404 e.printStackTrace();
1369 1405 }
  1406 + }
1370 1407  
  1408 + private static void convertToBean(KeyWord keyWord,MongoTemplate mongoTemplate){
  1409 + if(StringUtils.isNotEmpty(keyWord.getKey())){
  1410 + String[] k =keyWord.getKey().split("_");
  1411 + PloodPressureGuideModel pressureGuideModel =new PloodPressureGuideModel();
  1412 + pressureGuideModel.setYn(YnEnums.YES.getId());
  1413 + pressureGuideModel.setType(k[2]);
  1414 + pressureGuideModel.setCategory(map1.get(k[1]));
  1415 + pressureGuideModel.setOrder(1);
  1416 + pressureGuideModel.setCategoryType(map2.get(k[1]));
  1417 + pressureGuideModel.setWeek(Integer.valueOf(k[0]));
  1418 + pressureGuideModel.setContent(keyWord.getContent());
  1419 + System.out.println(pressureGuideModel);
  1420 +// mongoTemplate.save(pressureGuideModel);
  1421 + }
1371 1422 }
1372 1423  
1373 1424  
... ... @@ -1377,7 +1428,20 @@
1377 1428 // weightFood("F:\\体重与营养管理\\体重与营养管理第三版(北方)改标红“、冰淇淋”-晓萌.xls");
1378 1429 // bloodSugar("F:\\血糖报告\\血糖报告\\血糖报告基础数据格式(2).xls");
1379 1430  
1380   - zcet("F:\\儿童发育\\早产儿体重百分位数值表(男女).xls");
  1431 + zcet("D:\\doc\\高血压报告20180813模板.xls");
  1432 +
  1433 +
  1434 + /* ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:/spring/applicationContext_biz_patient1.xml");
  1435 + MongoTemplate mongoTemplate
  1436 + = (MongoTemplate) applicationContext.getBean("mongoTemplate");
  1437 + mongoTemplate.getDb().authenticate("platform", "platform123".toCharArray());
  1438 +
  1439 + QueryBuilder queryBuilder = new QueryBuilder();
  1440 + BasicDBObject fieldsObject=new BasicDBObject();
  1441 + fieldsObject.put("_id", 1);
  1442 + fieldsObject.put("category", 1);
  1443 + BasicQuery query=new BasicQuery(queryBuilder.get(),fieldsObject);
  1444 + System.out.println(mongoTemplate.find(query, Guidelines.class).get(0));*/
1381 1445 }
1382 1446  
1383 1447 public static void addBaby(ApplicationContext applicationContext) {
platform-common/src/main/java/com/lyms/platform/common/enums/PloodPressureGuideCategoryTypeEnum.java View file @ 5c4c620
  1 +package com.lyms.platform.common.enums;
  2 +
  3 +/**
  4 + * 血压指导类型
  5 + * <p>
  6 + * 详细描述
  7 + * <p>
  8 + * 示例代码
  9 + * <pre>
  10 + * </pre/>
  11 + *
  12 + * @author JIAZHI.JIANG
  13 + * @version BME V100R001 2018/8/21 0021
  14 + * @since BME V100R001C40B104
  15 + */
  16 +public enum PloodPressureGuideCategoryTypeEnum {
  17 +
  18 +
  19 + // 合理运动
  20 + HELIYUNDONG(1),
  21 + // 运动指导
  22 + YUNDONGZHIDAO(2),
  23 + // 心理指导
  24 + XINLIZHIDAO(3),
  25 + // 自我监测
  26 + ZIWOJIANCE(4),
  27 + //用药指导
  28 + YONGYAOZHIDAO(5);
  29 +
  30 + private PloodPressureGuideCategoryTypeEnum(Integer id) {
  31 + this.id = id;
  32 + }
  33 +
  34 + public Integer getId() {
  35 + return id;
  36 + }
  37 +
  38 + private Integer id;
  39 +}
platform-dal/src/main/java/com/lyms/platform/pojo/BpReportModel.java View file @ 5c4c620
  1 +package com.lyms.platform.pojo;
  2 +
  3 +
  4 +import com.lyms.platform.common.result.BaseModel;
  5 +import org.springframework.data.mongodb.core.mapping.Document;
  6 +
  7 +import java.util.Date;
  8 +
  9 +/**
  10 + * 血压报告模型
  11 + * <p>
  12 + * 详细描述
  13 + * <p>
  14 + * 示例代码
  15 + * <pre>
  16 + * </pre/>
  17 + *
  18 + * @author JIAZHI.JIANG
  19 + * @version BME V100R001 2018-08-23 10:26
  20 + * @since BME V100R001C40B104
  21 + */
  22 +@Document(collection = "lyms_bp_report")
  23 +public class BpReportModel extends BaseModel{
  24 +
  25 + private String pid;
  26 + private Date created;
  27 + private String id;
  28 + private String title;
  29 + private Integer week;
  30 + //类型 血压值正常,血压波动正常
  31 + private String type;
  32 + //测评评估
  33 + private String assess;
  34 + //测评次数
  35 + private Integer count;
  36 + //大于90mmHg次数 或者 大于140次数 血压值异常次数
  37 + private String bpValExp;
  38 + //血压波动次数
  39 + private String bpWaveCount;
  40 + //指导
  41 + private String guide;
  42 +
  43 + public String getType() {
  44 + return type;
  45 + }
  46 +
  47 + public void setType(String type) {
  48 + this.type = type;
  49 + }
  50 +
  51 + public String getPid() {
  52 + return pid;
  53 + }
  54 +
  55 + public void setPid(String pid) {
  56 + this.pid = pid;
  57 + }
  58 +
  59 + public Date getCreated() {
  60 + return created;
  61 + }
  62 +
  63 + public void setCreated(Date created) {
  64 + this.created = created;
  65 + }
  66 +
  67 + public String getId() {
  68 + return id;
  69 + }
  70 +
  71 + public void setId(String id) {
  72 + this.id = id;
  73 + }
  74 +
  75 + public String getTitle() {
  76 + return title;
  77 + }
  78 +
  79 + public void setTitle(String title) {
  80 + this.title = title;
  81 + }
  82 +
  83 + public Integer getWeek() {
  84 + return week;
  85 + }
  86 +
  87 + public void setWeek(Integer week) {
  88 + this.week = week;
  89 + }
  90 +
  91 + public String getAssess() {
  92 + return assess;
  93 + }
  94 +
  95 + public void setAssess(String assess) {
  96 + this.assess = assess;
  97 + }
  98 +
  99 + public Integer getCount() {
  100 + return count;
  101 + }
  102 +
  103 + public void setCount(Integer count) {
  104 + this.count = count;
  105 + }
  106 +
  107 + public String getBpValExp() {
  108 + return bpValExp;
  109 + }
  110 +
  111 + public void setBpValExp(String bpValExp) {
  112 + this.bpValExp = bpValExp;
  113 + }
  114 +
  115 + public String getBpWaveCount() {
  116 + return bpWaveCount;
  117 + }
  118 +
  119 + public void setBpWaveCount(String bpWaveCount) {
  120 + this.bpWaveCount = bpWaveCount;
  121 + }
  122 +
  123 + public String getGuide() {
  124 + return guide;
  125 + }
  126 +
  127 + public void setGuide(String guide) {
  128 + this.guide = guide;
  129 + }
  130 +}
platform-dal/src/main/java/com/lyms/platform/pojo/PloodPressureGuideModel.java View file @ 5c4c620
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.common.result.BaseModel;
  4 +import org.slf4j.Logger;
  5 +import org.slf4j.LoggerFactory;
  6 +import org.springframework.data.mongodb.core.mapping.Document;
  7 +
  8 +
  9 +/**
  10 + * 血压指导
  11 + * <p>
  12 + * 详细描述
  13 + * <p>
  14 + * 示例代码
  15 + * <pre>
  16 + * </pre/>
  17 + *
  18 + * @link com.lyms.platform.common.enums.PloodPressureGuideCategoryTypeEnum
  19 + * @author JIAZHI.JIANG
  20 + * @version BME V100R001 2018-08-21 16:32
  21 + * @since BME V100R001C40B104
  22 + */
  23 +@Document(collection = "lyms_bpguide")
  24 +public class PloodPressureGuideModel extends BaseModel {
  25 +
  26 +
  27 + /* 血压值正常/异常 0/1
  28 + 血压波动正常/异常 0/1
  29 +
  30 +
  31 + 血压值正常无波动 00
  32 + 血压波动异常,血压值正常 10
  33 + 血压值异常(血压值异常但基本平稳) 01
  34 + 血压值异常,波动异常 11*/
  35 + private String type;
  36 + //孕周
  37 + private Integer week;
  38 + //分类
  39 + private String category;
  40 + //内容
  41 + private String content;
  42 + //是否有效
  43 + private Integer yn;
  44 + //PloodPressureGuideCategoryTypeEnum
  45 + private Integer categoryType;
  46 +
  47 + //排序字段
  48 + private Integer order;
  49 +
  50 + public Integer getOrder() {
  51 + return order;
  52 + }
  53 +
  54 + public void setOrder(Integer order) {
  55 + this.order = order;
  56 + }
  57 +
  58 + public String getType() {
  59 + return type;
  60 + }
  61 +
  62 + public void setType(String type) {
  63 + this.type = type;
  64 + }
  65 +
  66 + public Integer getWeek() {
  67 + return week;
  68 + }
  69 +
  70 + public void setWeek(Integer week) {
  71 + this.week = week;
  72 + }
  73 +
  74 + public String getCategory() {
  75 + return category;
  76 + }
  77 +
  78 + public void setCategory(String category) {
  79 + this.category = category;
  80 + }
  81 +
  82 + public String getContent() {
  83 + return content;
  84 + }
  85 +
  86 + public void setContent(String content) {
  87 + this.content = content;
  88 + }
  89 +
  90 + public Integer getYn() {
  91 + return yn;
  92 + }
  93 +
  94 + public void setYn(Integer yn) {
  95 + this.yn = yn;
  96 + }
  97 +
  98 + public Integer getCategoryType() {
  99 + return categoryType;
  100 + }
  101 +
  102 + public void setCategoryType(Integer categoryType) {
  103 + this.categoryType = categoryType;
  104 + }
  105 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BloodPressureController.java View file @ 5c4c620
... ... @@ -8,10 +8,7 @@
8 8 import com.lyms.platform.pojo.BloodPressure;
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;
... ... @@ -59,5 +56,35 @@
59 56 return RespBuilder.buildSuccess(bloodPressureService.getAppInfo(parentId));
60 57 }
61 58  
  59 +
  60 + /**
  61 + * 获取某个人的血压列表报告
  62 + *
  63 + * @param pid
  64 + * @return
  65 + */
  66 + @ResponseBody
  67 + @RequestMapping(value = "/app/list/{pid}", method = RequestMethod.GET)
  68 + public BaseResponse getReportList(@PathVariable String pid) {
  69 + return null;
  70 + }
  71 +
  72 + /**
  73 + * 获取某个人的血压列表报告
  74 + *
  75 + * @param type
  76 + 血压值正常无波动 00
  77 + 血压波动异常,血压值正常 10
  78 + 血压值异常(血压值异常但基本平稳) 01
  79 + 血压值异常,波动异常 11
  80 + * @param week 孕周
  81 + * @return
  82 + */
  83 + @ResponseBody
  84 + @RequestMapping(value = "/app/report", method = RequestMethod.GET)
  85 + public BaseResponse getReportDetail(@RequestParam("type") String type,
  86 + @RequestParam("week") String week) {
  87 + return null;
  88 + }
62 89 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/TestController.java View file @ 5c4c620
... ... @@ -2356,7 +2356,12 @@
2356 2356 return null;
2357 2357 }
2358 2358  
2359   -
  2359 + @RequestMapping(value="/bp/report")
  2360 + @ResponseBody
  2361 + public String bpReportTrigger(){
  2362 + bloodPressureService.generateBpReport();
  2363 + return "ss";
  2364 + }
2360 2365  
2361 2366 @Autowired
2362 2367 private PatientServiceService patientServiceService;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodPressureService.java View file @ 5c4c620
... ... @@ -22,5 +22,7 @@
22 22 BaseResponse wxAdd(BloodPressure bloodPressure, boolean flag);
23 23  
24 24 BaseResponse initPatientWeight();
  25 +
  26 + void generateBpReport();
25 27 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodPressureServiceImpl.java View file @ 5c4c620
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.biz.service.BloodPressureService;
6 6 import com.lyms.platform.biz.service.CommonService;
7 7 import com.lyms.platform.biz.service.PatientWeightService2;
  8 +import com.lyms.platform.biz.service.PatientsService;
8 9 import com.lyms.platform.common.enums.YnEnums;
9 10 import com.lyms.platform.common.result.BaseResponse;
10 11 import com.lyms.platform.common.result.PageResult;
11 12  
... ... @@ -18,8 +19,11 @@
18 19 import com.lyms.platform.operate.web.utils.CollectionUtils;
19 20 import com.lyms.platform.operate.web.utils.MongoUtil;
20 21 import com.lyms.platform.pojo.BloodPressure;
  22 +import com.lyms.platform.pojo.BpReportModel;
21 23 import com.lyms.platform.pojo.PatientWeight;
22 24 import com.lyms.platform.pojo.Patients;
  25 +import com.lyms.platform.query.PatientsQuery;
  26 +import org.apache.commons.lang.math.NumberUtils;
23 27 import org.springframework.beans.factory.annotation.Autowired;
24 28 import org.springframework.data.domain.Sort;
25 29 import org.springframework.data.mongodb.core.MongoTemplate;
... ... @@ -29,7 +33,7 @@
29 33  
30 34 import java.util.*;
31 35  
32   -@Service
  36 +@Service("bloodPressureService")
33 37 public class BloodPressureServiceImpl extends BaseServiceImpl implements IBloodPressureService {
34 38  
35 39 @Autowired
36 40  
37 41  
... ... @@ -54,8 +58,106 @@
54 58 private PatientWeightService2 patientWeightService2;
55 59 @Autowired
56 60 private OrganizationGroupsFacade groupsFacade;
  61 + @Autowired
  62 + private PatientsService patientService;
57 63  
  64 + private static Map<String,String> typeGuideMap =new HashMap<>();
  65 + static {
  66 + typeGuideMap.put("00","在这周你的血压值和血压波动均在正常范围之内,但是也需要注意饮食和运动。高油高盐饮食以及体重过重都会增加患妊娠期高血压的风险。此外保持心理平衡也是减少患妊高症的关键因素之一。");
  67 + typeGuideMap.put("11","在这周你的血压值在正常范围之内,但血压波动情况异常,在饮食、运动等方面都需要注意。由于血压的不稳定,在心理上你也承受着一定的压力,在这份报告中将根据你的血压值和血压波动情况建议你下一周的饮食和运动方式以及心理疏导。");
  68 + typeGuideMap.put("10","在这周你的血压值在异常范围但血压的波动情况良好没有较大的起伏。因此在饮食、运动等方面都需要注意。由于血压值的异常,在心理上你也承受着一定的压力,在这份报告中将根据你的血压值和血压波动情况建议你下一周的饮食和运动方式以及心理疏导。");
  69 + typeGuideMap.put("01","在这周你的血压值正常,但是血压波动幅度较大。在降压的同时也要保持血压波动的平稳。血压波动异常可由多种原因导致,你需要合理饮食、适当运动、保持心理平衡等以保持血压的平稳。");
  70 + }
58 71  
  72 + /**
  73 + * 生成血压报告
  74 + */
  75 + public void generateBpReport() {
  76 + PatientsQuery patientsQuery1 = new PatientsQuery();
  77 + patientsQuery1.setYn(YnEnums.YES.getId());
  78 + patientsQuery1.setType(1);
  79 + for (int i = 6; i <= 41; i++) {
  80 +// System.out.println(DateUtil.getYmd(DateUtil.addDay(new Date(), -(i+1))));
  81 +
  82 + Date start = DateUtil.addDay(DateUtil.formatDate(new Date()), -(i * 7 + 1));
  83 + patientsQuery1.setLastMensesEnd(new Date(start.getTime() + 86399990L));
  84 + patientsQuery1.setLastMensesStart(start);
  85 +
  86 + List<Patients> patientses = patientService.queryPatient(patientsQuery1);
  87 + if (CollectionUtils.isNotEmpty(patientses)) {
  88 + for (Patients patients : patientses) {
  89 + //单个处理
  90 + doExecuteBpReport(patients, i);
  91 + }
  92 + }
  93 + }
  94 + }
  95 +
  96 + private void doExecuteBpReport(Patients patients, Integer week) {
  97 +
  98 + BloodPressure bp = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patients.getPid())), BloodPressure.class);
  99 + if (null == bp) {
  100 + return;
  101 + }
  102 + //大于90 或者大于 140都算一次异常血压值
  103 + int szyInt = 90, ssyInt = 140;
  104 + if (null != bp.getInfos() && !bp.getInfos().isEmpty()) {
  105 + BpReportModel report = new BpReportModel();
  106 + report.setPid(patients.getPid());
  107 + report.setTitle("孕" + week + "周血压报告");
  108 + report.setWeek(week);
  109 + report.setAssess(bp.getInfos().size() >= 5 ? "良好" : "不达标");
  110 + report.setCount(bp.getInfos().size());
  111 + report.setCreated(new Date());
  112 + Set<Map.Entry<String, Map<String, Object>>> set = bp.getInfos().entrySet();
  113 +
  114 + List<String> keys = new ArrayList<>(bp.getInfos().keySet());
  115 + int count = 0, bpcount = 0,
  116 + index = 0;
  117 + String countType="0",bpCountType="0";
  118 + if (!set.isEmpty()) {
  119 + for (Map.Entry<String, Map<String, Object>> entry : set) {
  120 + Map<String, Object> entryMap = entry.getValue();
  121 + if (null != entryMap && !entryMap.isEmpty()) {
  122 + //计算血压异常次数
  123 + String szy = entryMap.get("szy").toString();//小的
  124 + String ssy = entryMap.get("ssy").toString();//大的
  125 + if (NumberUtils.toInt(szy, 0) > szyInt || NumberUtils.toInt(ssy, 0) > ssyInt) {
  126 + ++count;
  127 + }
  128 +
  129 + if (++index > keys.size() - 1) {
  130 + //计算血压波动异常次数
  131 + String mapKey = keys.get(index);
  132 +
  133 + Map<String, Object> map = bp.getInfos().get(mapKey);
  134 +
  135 + String szy1 = map.get("szy").toString();//小的
  136 + String ssy1 = map.get("ssy").toString();//大的
  137 + //血压波动异常次数
  138 + if (Math.abs(NumberUtils.toInt(szy1, 0) - NumberUtils.toInt(szy, 0)) > 20 || Math.abs(NumberUtils.toInt(ssy1, 0) - NumberUtils.toInt(ssy, 0)) > 30) {
  139 + ++bpcount;
  140 + }
  141 + }
  142 + }
  143 + if(bpcount>3){
  144 + bpCountType="1";
  145 + }
  146 +
  147 + if(count>3){
  148 + countType="1";
  149 + }
  150 + }
  151 + }
  152 + report.setType(countType+bpCountType);
  153 + report.setGuide(typeGuideMap.get(report.getType()));
  154 + report.setBpWaveCount(String.valueOf(bpcount));
  155 + report.setBpValExp(String.valueOf(count));
  156 +
  157 + mongoTemplate.save(report);
  158 + }
  159 + }
  160 +
59 161 public BaseResponse addOrUpdate(Integer userId, BloodPressure bloodPressure) {
60 162 String hospitalId = autoMatchFacade.getHospitalId(userId);
61 163 Map<String, Object> temp = new LinkedHashMap<>();
62 164  
... ... @@ -68,10 +170,10 @@
68 170 // BloodPressure bp = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(bloodPressure.getParentId()).and("yn").ne(0)), BloodPressure.class);
69 171 Patients p = mongoTemplate.findById(bloodPressure.getParentId(), Patients.class);
70 172 BloodPressure bp = null;
71   - if(p != null) {
  173 + if (p != null) {
72 174 bp = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(p.getPid())), BloodPressure.class);
73 175 }
74   - if(bp == null) {
  176 + if (bp == null) {
75 177 String parentId = mongoUtil.doHidePatient(bloodPressure.getParentId(), hospitalId);
76 178 bloodPressure.setPid(mongoUtil.getPid(parentId));
77 179 bloodPressure.setParentId(parentId);
78 180  
79 181  
80 182  
81 183  
82 184  
... ... @@ -102,30 +204,30 @@
102 204 List<String> hospitalIds = groupsFacade.findGroupHospital(userId, false);
103 205 Criteria criteria = Criteria.where("yn").is(1).and("hospitalId").in(hospitalIds);
104 206 Criteria pCriteria = Criteria.where("yn").is(1).and("hospitalId").in(hospitalIds);
105   - if(StringUtils.isNotEmpty(key)) {
  207 + if (StringUtils.isNotEmpty(key)) {
106 208 flag = true;
107 209 pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("cardNo").is(key));
108 210 }
109   - if(StringUtils.isNotEmpty(vcCardNo)) {
  211 + if (StringUtils.isNotEmpty(vcCardNo)) {
110 212 flag = true;
111 213 pCriteria.and("vcCardNo").is(vcCardNo);
112 214 }
113   - if(weekStart != null && weekEnd != null) {
  215 + if (weekStart != null && weekEnd != null) {
114 216 Date start = DateUtil.getWeekStart(weekEnd);
115 217 Date end = DateUtil.getWeekEnd(weekStart);
116 218 pCriteria.and("lastMenses").gt(start).lte(end);
117 219 flag = true;
118 220 }
119   - if(age != null) {
  221 + if (age != null) {
120 222 Date start = DateUtil.getBeforeAge(age);
121 223 Date end = DateUtil.getBeforeAge(age + 1);
122 224 pCriteria.and("birth").gt(end).lte(start);
123 225 flag = true;
124 226 }
125   - if(flag) {
  227 + if (flag) {
126 228 List<Patients> patients = mongoTemplate.find(Query.query(pCriteria), Patients.class);
127 229 List<String> ids = new ArrayList<>();
128   - if(CollectionUtils.isNotEmpty(patients)) {
  230 + if (CollectionUtils.isNotEmpty(patients)) {
129 231 for (Patients patient : patients) {
130 232 // ids.add(patient.getId());
131 233 ids.add(patient.getPid());
... ... @@ -142,7 +244,7 @@
142 244 Map<String, Object> temp = new HashMap<>();
143 245 Patients p = mongoTemplate.findById(bloodPressure.getParentId(), Patients.class);
144 246 temp.put("id", bloodPressure.getId());
145   - if(p != null) {
  247 + if (p != null) {
146 248 temp.put("username", p.getUsername());
147 249 temp.put("time", DateUtil.getyyyy_MM_dd(bloodPressure.getModified()));
148 250 temp.put("age", DateUtil.getAge(p.getBirth()));
... ... @@ -150,11 +252,10 @@
150 252 temp.put("riskLevel", commonService.findRiskLevel(p.getRiskLevelId())); //高危等级(颜色)
151 253  
152 254 String rFactor = commonService.resloveFactor(p.getRiskFactorId());
153   - if (p.getoRiskFactor() != null && !"null".equals(p.getoRiskFactor()))
154   - {
155   - if(StringUtils.isNotEmpty(rFactor)){
156   - rFactor+=","+p.getoRiskFactor();
157   - }else{
  255 + if (p.getoRiskFactor() != null && !"null".equals(p.getoRiskFactor())) {
  256 + if (StringUtils.isNotEmpty(rFactor)) {
  257 + rFactor += "," + p.getoRiskFactor();
  258 + } else {
158 259 rFactor = p.getoRiskFactor();
159 260 }
160 261 }
161 262  
... ... @@ -178,14 +279,14 @@
178 279 public BaseResponse info(String id, Date startDate) {
179 280 BloodPressure bloodPressure = mongoTemplate.findById(id, BloodPressure.class);
180 281 List<Map<String, Object>> xyInfos = new ArrayList<>();
181   - List<Integer> szyMin = Arrays.asList( 60, 60, 60, 60, 60, 60, 60);
  282 + List<Integer> szyMin = Arrays.asList(60, 60, 60, 60, 60, 60, 60);
182 283 List<Integer> ssyMax = Arrays.asList(140, 140, 140, 140, 140, 140, 140);
183 284 List<Object> ssy = new ArrayList<>();
184 285 List<Object> szy = new ArrayList<>();
185 286 List<Object> pulse = new ArrayList<>();
186 287 List<String> xAxis = new ArrayList<>();
187   - if(bloodPressure != null) {
188   - List<String> betweenDay = DateUtil.getBetweenDay(startDate,7);
  288 + if (bloodPressure != null) {
  289 + List<String> betweenDay = DateUtil.getBetweenDay(startDate, 7);
189 290 CollectionUtils.reverse(betweenDay);
190 291 Map<String, Map<String, Object>> infos = bloodPressure.getInfos();
191 292 for (String date : betweenDay) {
... ... @@ -209,8 +310,8 @@
209 310 public List<Map<String, Object>> getAppInfo(String parentId) {
210 311 List<BloodPressure> bloodPressure = mongoTemplate.find(Query.query(Criteria.where("pid").is(parentId)), BloodPressure.class);
211 312 List<Map<String, Object>> restList = new ArrayList<>();
212   - if(CollectionUtils.isNotEmpty(bloodPressure)) {
213   - for(BloodPressure b:bloodPressure){
  313 + if (CollectionUtils.isNotEmpty(bloodPressure)) {
  314 + for (BloodPressure b : bloodPressure) {
214 315 Map<String, Map<String, Object>> infos = b.getInfos();
215 316 Object[] keys = infos.keySet().toArray();
216 317 CollectionUtils.reverseArray(keys);
217 318  
... ... @@ -251,11 +352,11 @@
251 352  
252 353 Patients p = mongoTemplate.findById(bloodPressure.getParentId(), Patients.class);
253 354 BloodPressure bp = null;
254   - if(p != null) {
  355 + if (p != null) {
255 356 bp = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(p.getPid())), BloodPressure.class);
256 357 }
257 358 bloodPressure.setModified(new Date());
258   - if(bp == null) {
  359 + if (bp == null) {
259 360 String parentId = mongoUtil.doHidePatient(bloodPressure.getParentId(), hospitalId);
260 361 bloodPressure.setParentId(parentId);
261 362 bloodPressure.setYn(YnEnums.YES.getId());
... ... @@ -266,7 +367,7 @@
266 367 infos.put(DateUtil.getyyyy_MM_dd(new Date()), temp);
267 368 bloodPressure.setInfos(infos);
268 369 bloodPressure.setPid(mongoUtil.getPid(parentId));
269   - if(!flag) {
  370 + if (!flag) {
270 371 bloodPressureService.add(bloodPressure);
271 372 } else {
272 373 mongoTemplate.save(bloodPressure);
273 374  
274 375  
... ... @@ -291,13 +392,15 @@
291 392 return RespBuilder.buildSuccess();
292 393 }
293 394  
294   - /** 产品改了 说以收缩压为主 */
  395 + /**
  396 + * 产品改了 说以收缩压为主
  397 + */
295 398 private String getPulseStatus(String ssy, String szy) {
296 399 String status = "";
297   - if(StringUtils.isNotEmpty(ssy)) {
298   - if(Double.parseDouble(ssy) < 90) {
  400 + if (StringUtils.isNotEmpty(ssy)) {
  401 + if (Double.parseDouble(ssy) < 90) {
299 402 status = "低血压";
300   - } else if(Double.parseDouble(ssy) > 140) {
  403 + } else if (Double.parseDouble(ssy) > 140) {
301 404 status = "高血压";
302 405 } else {
303 406 status = "正常";
platform-operate-api/src/main/resources/spring/applicationContext-quartz.xml View file @ 5c4c620
... ... @@ -282,7 +282,23 @@
282 282 </bean>
283 283  
284 284  
  285 + <!-- 孕妇学校定时任务 -->
  286 + <bean id="generateBpReport" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  287 + <!-- 要调用的bean -->
  288 + <property name="targetObject" ref="bloodPressureService"></property>
  289 + <!-- 要调用的Method -->
  290 + <property name="targetMethod" value="generateBpReport"></property>
  291 + <!-- 是否并发,false表示 如果发生错误也不影响下一次的调用 -->
  292 + <property name="concurrent" value="false"></property>
  293 + </bean>
285 294  
  295 + <bean id="bpReportTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
  296 + <property name="jobDetail" ref="generateBpReport"></property>
  297 + <property name="cronExpression" value="0 0 20 * * ?"></property>
  298 + </bean>
  299 +
  300 +
  301 +
286 302 <!-- 总调度,用于启动定时器 -->
287 303 <bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
288 304 <property name="triggers" >
... ... @@ -298,6 +314,8 @@
298 314 <ref bean="dandleAutoReachDueTrigger"/>
299 315 <!--处理产后复查、产后追访数据显示及自动流转-->
300 316 <ref bean="firstDandleAutoReachDueTrigger" />
  317 + <!--血压报告触发器 -->
  318 + <ref bean="bpReportTrigger" />
301 319 <!-- 承德公共卫生接口-->
302 320 <!--<ref bean="cdGongWeiTrigger"/>-->
303 321 <!--乐陵住院系统同步-->