Commit da2ce95cd296dad99ca6a006b0bf4ceb9c6a3a7d

Authored by wtt
1 parent 435a69150f

体成分分析列表、体成分分析报告

Showing 3 changed files with 444 additions and 102 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/VolumeComponentAnalysisModel.java View file @ da2ce95
... ... @@ -4,6 +4,8 @@
4 4 import com.lyms.platform.common.result.BaseModel;
5 5 import org.springframework.data.mongodb.core.mapping.Document;
6 6  
  7 +import java.util.Date;
  8 +
7 9 /**
8 10 * 体成分分析
9 11 */
10 12  
... ... @@ -13,8 +15,9 @@
13 15 private String id;
14 16 //医院id
15 17 private String hospitalId;
16   - //病人id
  18 + //病人档案id
17 19 private String patientId;
  20 + //病人id
18 21 private String pid;
19 22 //就诊卡号
20 23 private String vcCardNo;
... ... @@ -22,6 +25,13 @@
22 25 private String certNo;
23 26 //证件类型Id
24 27 private String certType;
  28 + //创建日期(测量日期)
  29 + private Date created;
  30 + // 孕前体重
  31 + private String beforeWeight;
  32 + //手机号码
  33 + private String phone;
  34 + private Integer yn;
25 35  
26 36  
27 37 private String parentId;
... ... @@ -35,7 +45,7 @@
35 45 private String sex;// 1;,                    //性别 (男1,女2)
36 46 private String height;// 178.5;,              //身高
37 47 private String birthYear;// 1985;,            //出生年份
38   - private String weight; // 72.5;,              //体重
  48 + private String weight; // 72.5;,              //体重(当前体重)
39 49 private String fat;// 23.1;,                 //脂肪
40 50 private String bone;// 3.8;,                //骨质
41 51 private String protein;// 18.6;,             //蛋白质
... ... @@ -76,8 +86,8 @@
76 86 private String rlMuscle;// 14.3;      //右下肢肌肉
77 87 private String weightMax; // 84.5;,    //体重正常范围的高值
78 88 private String weightMin; // 69.5;,    //体重正常范围的低值
79   - private String fatMax; // 22.5;,      //体重正常范围的高值
80   - private String fatMin; // 13.6;,      //体重正常范围的低值
  89 + private String fatMax; // 22.5;,      //脂肪正常范围的高值
  90 + private String fatMin; // 13.6;,      //脂肪正常范围的低值
81 91 private String boneMax; // 3.7;,    //骨质正常范围的高值
82 92 private String boneMin; // 3.1;,    //骨质正常范围的低值
83 93 private String proteinMax; // 22.5;,    //蛋白质正常范围的高值
... ... @@ -98,6 +108,38 @@
98 108 private String edemaMin; // 0.35;,    //水肿系数正常范围的低值
99 109 private String vfiMax; // 5;,    //内脏脂肪指数正常范围的高值
100 110 private String vfiMin; // 10;    //内脏脂肪指数正常范围的低值
  111 +
  112 + public Integer getYn() {
  113 + return yn;
  114 + }
  115 +
  116 + public void setYn(Integer yn) {
  117 + this.yn = yn;
  118 + }
  119 +
  120 + public Date getCreated() {
  121 + return created;
  122 + }
  123 +
  124 + public void setCreated(Date created) {
  125 + this.created = created;
  126 + }
  127 +
  128 + public String getBeforeWeight() {
  129 + return beforeWeight;
  130 + }
  131 +
  132 + public void setBeforeWeight(String beforeWeight) {
  133 + this.beforeWeight = beforeWeight;
  134 + }
  135 +
  136 + public String getPhone() {
  137 + return phone;
  138 + }
  139 +
  140 + public void setPhone(String phone) {
  141 + this.phone = phone;
  142 + }
101 143  
102 144 public static long getSerialVersionUID() {
103 145 return serialVersionUID;
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/VolumeComponentAnalysisController.java View file @ da2ce95
... ... @@ -14,6 +14,7 @@
14 14  
15 15 import javax.servlet.http.HttpServletRequest;
16 16 import javax.validation.Valid;
  17 +import java.text.ParseException;
17 18  
18 19 /**
19 20 * 体成分分析
... ... @@ -59,9 +60,8 @@
59 60 @RequestMapping(value = "/queryComponentAnalysis", method = RequestMethod.GET)
60 61 @ResponseBody
61 62 @TokenRequired
62   - public BaseObjectResponse queryComponentAnalysis(String key, String vcCardNo, Integer stateWeek, Integer endWeek, Integer age,
63   - Integer fetusNumber, Integer page, Integer limit, HttpServletRequest request) {
64   - return volumeComponentAnalysisFacade.queryComponentAnalysis(page, limit, key, vcCardNo, stateWeek, endWeek, age, fetusNumber, getUserId(request));
  63 + public BaseObjectResponse queryComponentAnalysis(String key, String start ,String end ,Integer page, Integer limit, HttpServletRequest request) throws ParseException {
  64 + return volumeComponentAnalysisFacade.queryComponentAnalysis(page, limit, key, start, end, getUserId(request));
65 65 }
66 66  
67 67 /**
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/VolumeComponentAnalysisFacade.java View file @ da2ce95
1 1 package com.lyms.platform.operate.web.facade;
2 2  
  3 +import com.alibaba.druid.util.StringUtils;
3 4 import com.lyms.platform.common.constants.ErrorCodeConstants;
4 5 import com.lyms.platform.common.enums.YnEnums;
5 6 import com.lyms.platform.common.result.BaseObjectResponse;
... ... @@ -7,6 +8,8 @@
7 8 import com.lyms.platform.common.result.PageResult;
8 9 import com.lyms.platform.common.result.RespBuilder;
9 10 import com.lyms.platform.common.utils.DateUtil;
  11 +import com.lyms.platform.common.utils.MongoConvertHelper;
  12 +import com.lyms.platform.common.utils.ReflectionUtils;
10 13 import com.lyms.platform.operate.web.service.PatientWeightService;
11 14 import com.lyms.platform.operate.web.service.impl.BaseServiceImpl;
12 15 import com.lyms.platform.operate.web.service.impl.ComputeKulServiceManager;
13 16  
14 17  
... ... @@ -14,13 +17,17 @@
14 17 import com.lyms.platform.pojo.Patients;
15 18 import com.lyms.platform.pojo.TemporaryUserModel;
16 19 import com.lyms.platform.pojo.VolumeComponentAnalysisModel;
  20 +import org.apache.poi.util.StringUtil;
17 21 import org.springframework.beans.factory.annotation.Autowired;
18 22 import org.springframework.data.domain.Sort;
19 23 import org.springframework.data.mongodb.core.MongoTemplate;
20 24 import org.springframework.data.mongodb.core.query.Criteria;
21 25 import org.springframework.data.mongodb.core.query.Query;
  26 +import org.springframework.data.mongodb.core.query.Update;
22 27 import org.springframework.stereotype.Component;
23 28  
  29 +import java.text.ParseException;
  30 +import java.text.SimpleDateFormat;
24 31 import java.util.*;
25 32  
26 33 @Component
... ... @@ -41,7 +48,23 @@
41 48 private PatientWeightService patientWeightService;
42 49  
43 50 public BaseObjectResponse addComponentAnalysis(VolumeComponentAnalysisModel volume) {
44   - mongoTemplate.insert(volume);
  51 + //20200204 李泉渝 @涛涛 同一天多次测量就是修改
  52 + List<VolumeComponentAnalysisModel> vc = mongoTemplate.find(Query.query(Criteria.where("patientId").is(volume.getPatientId())
  53 + .and("pid").is(volume.getPid())
  54 + .and("certNo").is(volume.getCertNo())
  55 + .and("created").is(volume.getCreated())
  56 + ), VolumeComponentAnalysisModel.class);
  57 + if(vc.isEmpty()){
  58 + volume.setCreated(new Date());
  59 + volume.setYn(YnEnums.YES.getId());
  60 + mongoTemplate.insert(volume);
  61 + }else {
  62 + volume.setCreated(new Date());
  63 + volume.setYn(YnEnums.YES.getId());
  64 + Update update = MongoConvertHelper.convertToNativeUpdate(ReflectionUtils.getUpdateField(volume));
  65 + mongoTemplate.updateFirst(Query.query(Criteria.where("id").is(vc.get(0).getId())), update, VolumeComponentAnalysisModel.class);
  66 + }
  67 +
45 68 BaseObjectResponse objectResponse = new BaseObjectResponse();
46 69 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
47 70 objectResponse.setErrormsg("成功");
48 71  
... ... @@ -51,8 +74,49 @@
51 74  
52 75 /**
53 76 * 查询体成分分析列表信息
  77 + *
  78 + * 需求:
  79 + 搜索条件: 查询号(身份证号,手机号,姓名) 测量日期
  80 + 显示列:姓名 身份证号 手机号码 身高 孕前体重 当前体重 测量日期
54 81 */
55   - public BaseObjectResponse queryComponentAnalysis(Integer page, Integer limit, String key, String vcCardNo, Integer stateWeek, Integer endWeek, Integer age,
  82 + public BaseObjectResponse queryComponentAnalysis(Integer page, Integer limit, String key,String start ,String end , Integer userId) throws ParseException {
  83 +
  84 + List<String> hospital = groupsFacade.findGroupHospital(userId, false);
  85 + Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in(hospital);
  86 +// Criteria criteria = Criteria.where("yn").ne("0").and("hospitalId").in("211");
  87 + //查询号(身份证号,手机号,姓名)
  88 + if(!StringUtils.isEmpty(key)){
  89 + criteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("name").regex(key), Criteria.where("certNo").regex(key));
  90 + }
  91 + //测量日期
  92 + if (!StringUtils.isEmpty(start) && !StringUtils.isEmpty(end) ) {
  93 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  94 + Date start1 = simpleDateFormat.parse(start);
  95 + Date end1 = simpleDateFormat.parse(end);
  96 + criteria.and("created").gt(start1).lte(end1);
  97 + }
  98 + PageResult pageResult = findMongoPage(VolumeComponentAnalysisModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "created")), page, limit);
  99 + List<VolumeComponentAnalysisModel> bloodSugars = (List<VolumeComponentAnalysisModel>) pageResult.getGrid();
  100 + List<Map> list = new ArrayList();
  101 + for (VolumeComponentAnalysisModel temporaryUser : bloodSugars) {
  102 + Map<String, Object> map = new HashMap<>();
  103 + // 身份证号 手机号码 身高 孕前体重 当前体重 测量日期
  104 + map.put("id", temporaryUser.getId());
  105 + map.put("name", temporaryUser.getName());
  106 + map.put("certNo", temporaryUser.getCertNo() );
  107 + map.put("phone", temporaryUser.getPhone());
  108 + map.put("height", temporaryUser.getHeight());
  109 + map.put("beforeWeight", temporaryUser.getBeforeWeight());
  110 + map.put("weight", temporaryUser.getWeight());
  111 + map.put("created", DateUtil.getyyyy_MM_dd(temporaryUser.getCreated()));
  112 + list.add(map);
  113 + }
  114 + pageResult.setGrid(list);
  115 +
  116 + return RespBuilder.buildSuccess(pageResult);
  117 + }
  118 +
  119 + /* public BaseObjectResponse queryComponentAnalysis(Integer page, Integer limit, String key, String vcCardNo, Integer stateWeek, Integer endWeek, Integer age,
56 120 Integer fetusNumber, Integer userId) {
57 121 mongoTemplate.find(Query.query(Criteria.where("").is(1)), VolumeComponentAnalysisModel.class);
58 122 boolean flag = false;
59 123  
... ... @@ -95,8 +159,24 @@
95 159 }
96 160 pageResult.setGrid(list);
97 161 return RespBuilder.buildSuccess(pageResult);
  162 + }*/
  163 + public BaseResponse compositionReport(String id, Integer userId) {
  164 + List<Map<String, Object>> data = new ArrayList();
  165 + String hospitalId = autoMatchFacade.getHospitalId(userId);
  166 + VolumeComponentAnalysisModel volumeComponentAnalysisModel = mongoTemplate.findById(id, VolumeComponentAnalysisModel.class);
  167 + if (volumeComponentAnalysisModel != null) {
  168 + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(volumeComponentAnalysisModel.getPatientId()).and("yn").is(YnEnums.YES.getId()).and("hospitalId").is(hospitalId)), Patients.class);
  169 + if (patients != null) {
  170 + data = setData(patients, volumeComponentAnalysisModel);
  171 + }
  172 + }
  173 + BaseObjectResponse objectResponse = new BaseObjectResponse();
  174 + objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);
  175 + objectResponse.setErrormsg("成功");
  176 + objectResponse.setData(data);
  177 + return objectResponse;
98 178 }
99   -
  179 +/*
100 180 public BaseResponse compositionReport(String id, Integer userId) {
101 181 List<Map<String, Object>> data = new ArrayList();
102 182 String hospitalId = autoMatchFacade.getHospitalId(userId);
103 183  
104 184  
105 185  
106 186  
107 187  
108 188  
109 189  
110 190  
111 191  
112 192  
113 193  
114 194  
115 195  
116 196  
117 197  
118 198  
119 199  
... ... @@ -113,87 +193,216 @@
113 193 objectResponse.setData(data);
114 194 return objectResponse;
115 195 }
  196 +*/
116 197  
117 198 public List<Map<String, Object>> setData(Patients patients, VolumeComponentAnalysisModel volumeComponentAnalysisModel) {
  199 +
  200 + //第一页开始
118 201 List<Map<String, Object>> data = new ArrayList<>();
119   - Map<String, Object> userMap = new HashMap<>();
120 202 //用户基本信息
  203 + Map<String, Object> userMap = new HashMap<>();
121 204 userMap.put("username", patients.getUsername());
122 205 userMap.put("age", patients.getAge());
123 206 userMap.put("height", volumeComponentAnalysisModel.getHeight());
124   - userMap.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date()));
125   - userMap.put("kacl", "能量值");
126   - userMap.put("bmi", "bmi值");
127   - userMap.put("yqWeight", "孕前体重");
128   - userMap.put("weight", volumeComponentAnalysisModel.getWeight());
  207 + userMap.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date()));//孕周
  208 + //获取bmi值
  209 + double bmi = Double.valueOf(patientWeightService.getBmi(
  210 + volumeComponentAnalysisModel.getWeight(),//当前体重
  211 + volumeComponentAnalysisModel.getHeight()));//当前身高^
  212 + //计算热量值
  213 + Map<String, String> kmap = computeKulServiceManager.getComputeKulByRisk("").getComputeKul(
  214 + Double.parseDouble(volumeComponentAnalysisModel.getBeforeWeight()),//孕前体重
  215 + Double.parseDouble(volumeComponentAnalysisModel.getWeight()),//当前体重
  216 + DateUtil.getWeek(patients.getLastMenses(), new Date()),//孕周
  217 + bmi,//bmi
  218 + "1",//1单胎
  219 + volumeComponentAnalysisModel.getHeight(),//孕前身高(当前身高^)
  220 + "0");//默认0
  221 + userMap.put("kacl", kmap.get("kulStart"));//能量值
  222 + userMap.put("bmi",volumeComponentAnalysisModel.getBmi());//bmi值
  223 + userMap.put("yqWeight", volumeComponentAnalysisModel.getBeforeWeight());//孕前体重
  224 + userMap.put("currentWeight", volumeComponentAnalysisModel.getWeight());//当前体重
129 225 data.add(userMap);
  226 +
130 227 //人体成分分析信息
131 228 Map<String, Object> componentInfo = new HashMap<>();
132   -
133   - componentInfo.put("icw", volumeComponentAnalysisModel.getIcw());
134   - componentInfo.put("ecw", volumeComponentAnalysisModel.getEcw());
135   - componentInfo.put("protein", volumeComponentAnalysisModel.getProtein());
136   - componentInfo.put("inorganicSalt", volumeComponentAnalysisModel.getBone());//无机盐
137   - componentInfo.put("fat", volumeComponentAnalysisModel.getFat());
138   - componentInfo.put("waterContent", Double.valueOf(volumeComponentAnalysisModel.getIcw() + Double.valueOf(volumeComponentAnalysisModel.getEcw())));
139   - componentInfo.put("muscle", volumeComponentAnalysisModel.getMuscle());
140   - componentInfo.put("weight", volumeComponentAnalysisModel.getWeight());
  229 +// componentInfo.put("water", Double.valueOf(volumeComponentAnalysisModel.getIcw() + Double.valueOf(volumeComponentAnalysisModel.getEcw())));
  230 + componentInfo.put("water",volumeComponentAnalysisModel.getWater());//身体总水分
  231 + componentInfo.put("waterMax",volumeComponentAnalysisModel.getWaterMax());//身体总 水分正常范围的高值
  232 + componentInfo.put("waterMin",volumeComponentAnalysisModel.getWaterMax());//身体总 水分正常范围的低值
  233 + componentInfo.put("icw", volumeComponentAnalysisModel.getIcw());//细胞内液
  234 + Map<String, String> componentMap = rangeMap(DateUtil.getWeek2(patients.getLastMenses(), new Date()),//孕周
  235 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),//体重
  236 + "xbny");
  237 + componentInfo.put("icwMax", componentMap.get("max"));//细胞内液高值
  238 + componentInfo.put("icwMin", componentMap.get("min"));//细胞内液低值
  239 + componentInfo.put("ecw", volumeComponentAnalysisModel.getEcw());//细胞外液
  240 + Map<String, String> componentMap1 = rangeMap(DateUtil.getWeek2(patients.getLastMenses(), new Date()),//孕周
  241 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),//体重
  242 + "xbwy");
  243 + componentInfo.put("ecwMax", componentMap1.get("max"));//细胞外液高值
  244 + componentInfo.put("ecwMin", componentMap1.get("min"));//细胞外液低值
  245 + componentInfo.put("muscle", volumeComponentAnalysisModel.getMuscle());//肌肉
  246 + componentInfo.put("muscleMax", volumeComponentAnalysisModel.getMuscleMax());//肌肉正常范围的高值
  247 + componentInfo.put("muscleMin", volumeComponentAnalysisModel.getMuscleMin());//肌肉正常范围的低值
  248 + componentInfo.put("lbm", volumeComponentAnalysisModel.getLbm());//瘦体重(去脂体重)
  249 + componentInfo.put("weight", volumeComponentAnalysisModel.getWeight());//体重
  250 + componentInfo.put("protein", volumeComponentAnalysisModel.getProtein());//蛋白质
  251 + componentInfo.put("proteinMax", volumeComponentAnalysisModel.getProtein());//蛋白质正常范围的高值
  252 + componentInfo.put("proteinMin", volumeComponentAnalysisModel.getProtein());//蛋白质正常范围的低值
  253 + componentInfo.put("bone", volumeComponentAnalysisModel.getBone());//骨质
  254 + componentInfo.put("boneMax", volumeComponentAnalysisModel.getBone());//骨质正常范围的高值
  255 + componentInfo.put("boneMin", volumeComponentAnalysisModel.getBone());//骨质正常范围的低值
  256 + componentInfo.put("fat", volumeComponentAnalysisModel.getFat());//脂肪
  257 + componentInfo.put("fatMax", volumeComponentAnalysisModel.getFatMax());//脂肪正常范围的高值
  258 + componentInfo.put("fatMin", volumeComponentAnalysisModel.getFatMin());//脂肪正常范围的低值
141 259 data.add(componentInfo);
  260 +
  261 + //体型判定(体型判定2赋值)
  262 + Map<String, Object> somatotype = new HashMap<>();
  263 +
142 264 //基本评估
143 265 Map<String, Object> basicInfo = new HashMap<>();
144   - basicInfo.put("weight", volumeComponentAnalysisModel.getWeight());
145   - basicInfo.put("muscle", volumeComponentAnalysisModel.getMuscle());
146   - basicInfo.put("pbf", volumeComponentAnalysisModel.getPbf());
147   - basicInfo.put("bone", volumeComponentAnalysisModel.getBone());
148   - basicInfo.put("smm", volumeComponentAnalysisModel.getSmm());
  266 + basicInfo.put("basicWeight", volumeComponentAnalysisModel.getWeight());//体重
  267 + basicInfo.put("basicWeightMax", volumeComponentAnalysisModel.getWeightMax());//体重正常范围的高值
  268 + basicInfo.put("basicWeightMin", volumeComponentAnalysisModel.getWeightMin());//体重正常范围的低值
  269 + basicInfo.put("basicMuscle", volumeComponentAnalysisModel.getMuscle());//肌肉
  270 + basicInfo.put("basicMuscleMax", volumeComponentAnalysisModel.getMuscleMax());//肌肉正常范围的高值
  271 + basicInfo.put("basicMuscleMin", volumeComponentAnalysisModel.getMuscleMin());//肌肉正常范围的低值
  272 + basicInfo.put("basicPbf", volumeComponentAnalysisModel.getPbf());//体脂百分比
  273 + basicInfo.put("basicPbfMax", volumeComponentAnalysisModel.getPbf());//体脂率正常范围的高值
  274 + basicInfo.put("basicPbfMin", volumeComponentAnalysisModel.getPbf());//体脂率正常范围的低值
  275 + basicInfo.put("basicBone", volumeComponentAnalysisModel.getBone());//骨质
  276 + basicInfo.put("basicBoneMax", volumeComponentAnalysisModel.getBone());//骨质正常范围的高值
  277 + basicInfo.put("basicBoneMin", volumeComponentAnalysisModel.getBone());//骨质正常范围的低值
  278 + basicInfo.put("basicWater",volumeComponentAnalysisModel.getWater());//身体总水分
  279 + basicInfo.put("basicWaterMax",volumeComponentAnalysisModel.getWaterMax());//身体总 水分正常范围的高值
  280 + basicInfo.put("basicWaterMin",volumeComponentAnalysisModel.getWaterMax());//身体总 水分正常范围的低值
  281 + basicInfo.put("basicSmm", volumeComponentAnalysisModel.getSmm());//骨骼肌
  282 + basicInfo.put("basicSmmMax", volumeComponentAnalysisModel.getSmmMax());//骨骼肌正常范围的高值
  283 + basicInfo.put("basicSmmMin", volumeComponentAnalysisModel.getSmmMin());//骨骼肌正常范围的低值
  284 + basicInfo.put("basicBmi", volumeComponentAnalysisModel.getBmi());//体质指数
  285 + basicInfo.put("basicBmiMax", volumeComponentAnalysisModel.getBmiMax());//体质指数正常范围的高值
  286 + basicInfo.put("basicBmiMin", volumeComponentAnalysisModel.getBmiMin());//体质指数正常范围的低值
  287 + basicInfo.put("basicWhr", volumeComponentAnalysisModel.getWhr());//腰臀比(2位小数)
  288 + basicInfo.put("basicWhrMax", volumeComponentAnalysisModel.getWhrMax());//腰臀比正常范围的高值
  289 + basicInfo.put("basicWhrMin", volumeComponentAnalysisModel.getWhrMin());//腰臀比正常范围的低值
149 290 data.add(basicInfo);
  291 +
  292 + //体重管理
  293 + Map<String, Object> weightManagement = new HashMap<>();
  294 + weightManagement.put("standardWeight",volumeComponentAnalysisModel.getStandardWeight());//标准体重
  295 + weightManagement.put("weightControl",volumeComponentAnalysisModel.getWeightControl());//体重控制
  296 + weightManagement.put("fatControl",volumeComponentAnalysisModel.getFatControl());//脂肪控制量
  297 + weightManagement.put("muscleControl",volumeComponentAnalysisModel.getMuscleControl());//肌肉控制量
  298 + data.add(weightManagement);
  299 +
150 300 //内脏脂肪分析
151 301 Map<String, Object> viscusInfo = new HashMap<>();
152   - viscusInfo.put("trFat", volumeComponentAnalysisModel.getTrFat());
153   - viscusInfo.put("visceralLevel", volumeComponentAnalysisModel.getVfi());
  302 + viscusInfo.put("viscusTrFat", volumeComponentAnalysisModel.getTrFat());//躯干脂肪量 总量
  303 + viscusInfo.put("viscusVfi", volumeComponentAnalysisModel.getVfi());//内脏脂肪水平(内脏脂肪指数)
154 304 data.add(viscusInfo);
155   - //营养评估
156   - Map<String, Object> basalMetabolismInfo = new HashMap<>();
157   - basalMetabolismInfo.put("bmr", volumeComponentAnalysisModel.getBmr());
158   - basalMetabolismInfo.put("protein", range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
159   - Double.valueOf(volumeComponentAnalysisModel.getWeight()), Double.valueOf(volumeComponentAnalysisModel.getProtein()), "dbz"));
160   - basalMetabolismInfo.put("fat", range(DateUtil.getWeek(patients.getLastMenses(), new Date()), Double.valueOf(volumeComponentAnalysisModel.getWeight()),
161   - Double.valueOf(volumeComponentAnalysisModel.getFat()), "zf"));
162   - basalMetabolismInfo.put("wjy", range(DateUtil.getWeek(patients.getLastMenses(), new Date()), Double.valueOf(volumeComponentAnalysisModel.getWeight()),
163   - Double.valueOf(volumeComponentAnalysisModel.getBone()), "wjy"));
164   - data.add(basalMetabolismInfo);
  305 +
  306 + //水肿分析
  307 + Map<String, Object> edemaAnalysis = new HashMap<>();
  308 + if(!StringUtils.isEmpty(volumeComponentAnalysisModel.getWater()) && !StringUtils.isEmpty(volumeComponentAnalysisModel.getWeight()) ){
  309 + String water = volumeComponentAnalysisModel.getWater();//水分
  310 + String weight = volumeComponentAnalysisModel.getWeight();//体重
  311 + double waterd = Double.parseDouble(water);
  312 + double weightd = Double.parseDouble(weight);
  313 + double moistureRate = weightd / waterd;
  314 + edemaAnalysis.put("moistureRate", moistureRate);//身体水分率
  315 + }
  316 + edemaAnalysis.put("edema", volumeComponentAnalysisModel.getEdema());//水肿系数
  317 + edemaAnalysis.put("edemaMax", volumeComponentAnalysisModel.getEdemaMax());//水肿系数正常范围的高值
  318 + edemaAnalysis.put("edemaMin", volumeComponentAnalysisModel.getEdemaMin());//水肿系数正常范围的低值
  319 + if(!StringUtils.isEmpty(volumeComponentAnalysisModel.getEdema())
  320 + && !StringUtils.isEmpty(volumeComponentAnalysisModel.getEdemaMax())
  321 + && !StringUtils.isEmpty(volumeComponentAnalysisModel.getEdemaMin()) ){
  322 + String edema = volumeComponentAnalysisModel.getEdema();
  323 + double edemad = Double.parseDouble(edema);
  324 + String edemaMax = volumeComponentAnalysisModel.getEdemaMax();
  325 + double edemaMaxd = Double.parseDouble(edemaMax);
  326 + String edemaMin = volumeComponentAnalysisModel.getEdemaMin();
  327 + double edemaMind = Double.parseDouble(edemaMin);
  328 + if(edemad < edemaMind){
  329 + edemaAnalysis.put("gzf", 1);//1干燥 正常浮肿
  330 + }else if(edemad < edemaMaxd){
  331 + edemaAnalysis.put("gzf", 2);//2浮肿 干燥正常
  332 + }else if((edemad > edemaMind) && edemad < edemaMaxd){
  333 + edemaAnalysis.put("gzf", 0);//0正常 浮肿干燥
  334 + }else {
  335 + edemaAnalysis.put("gzf", null);
  336 + }
  337 + }
  338 + edemaAnalysis.put("icw", volumeComponentAnalysisModel.getIcw());//细胞内液
  339 + edemaAnalysis.put("ecw", volumeComponentAnalysisModel.getEcw());//细胞外液
  340 + data.add(edemaAnalysis);
  341 +
  342 + //肥胖分析
  343 + Map<String, Object> obesityAnalysis = new HashMap<>();
  344 + if(bmi <18.5 ){
  345 + obesityAnalysis.put("obesity", 1);//体重较轻1
  346 + }else if(bmi > 18.5 && bmi < 24.9){
  347 + obesityAnalysis.put("obesity", 2);//正常2
  348 + }else if(bmi > 25 && bmi < 29.9){
  349 + obesityAnalysis.put("obesity", 3);//超重3
  350 + }else if(bmi >= 30){
  351 + obesityAnalysis.put("obesity", 4);//肥胖4
  352 + }
  353 + data.add(obesityAnalysis);
  354 +
165 355 //节段分析
166 356 Map<String, Object> limbsInfo = new HashMap<>();
167   - limbsInfo.put("trWater", volumeComponentAnalysisModel.getTrWater());//躯干水分
168   - limbsInfo.put("laWater", volumeComponentAnalysisModel.getLaWater());//左上肢水分
169   - limbsInfo.put("raWater", volumeComponentAnalysisModel.getRaWater());//右上肢水分
170   - limbsInfo.put("llWater", volumeComponentAnalysisModel.getLlWater());//左下肢水分
171   - limbsInfo.put("rlWater", volumeComponentAnalysisModel.getRlWater());//右下肢水分
172   -
173   - limbsInfo.put("trFat", volumeComponentAnalysisModel.getTrFat());
174   - limbsInfo.put("laFat", volumeComponentAnalysisModel.getLaFat());
175   - limbsInfo.put("raFat", volumeComponentAnalysisModel.getRaFat());
176   - limbsInfo.put("llFat", volumeComponentAnalysisModel.getLlFat());
177   - limbsInfo.put("rlFat", volumeComponentAnalysisModel.getRlFat());
  357 + limbsInfo.put("limbsTrWater", volumeComponentAnalysisModel.getTrWater());//躯干水分
  358 + limbsInfo.put("limbsLaWater", volumeComponentAnalysisModel.getLaWater());//左上肢水分
  359 + limbsInfo.put("limbsRaWater", volumeComponentAnalysisModel.getRaWater());//右上肢水分
  360 + limbsInfo.put("limbsLlWater", volumeComponentAnalysisModel.getLlWater());//左下肢水分
  361 + limbsInfo.put("limbsRlWater", volumeComponentAnalysisModel.getRlWater());//右下肢水分
  362 + limbsInfo.put("limbsTrFat", volumeComponentAnalysisModel.getTrFat());//躯干脂肪
  363 + limbsInfo.put("limbsLaFat", volumeComponentAnalysisModel.getLaFat());//左上肢脂肪
  364 + limbsInfo.put("limbsRaFat", volumeComponentAnalysisModel.getRaFat());//右上肢脂肪
  365 + limbsInfo.put("limbsLlFat", volumeComponentAnalysisModel.getLlFat());//左下肢脂肪
  366 + limbsInfo.put("limbsRlFat", volumeComponentAnalysisModel.getRlFat());//右下肢脂肪
178 367 data.add(limbsInfo);
179   - //报告内容
180   - double bmi = Double.valueOf(patientWeightService.getBmi("65", "175"));
181   - //计算热量值
182   - Map<String, String> kmap = computeKulServiceManager.getComputeKulByRisk("").getComputeKul(56.5,
183   - Double.parseDouble(volumeComponentAnalysisModel.getWeight()), DateUtil.getWeek(patients.getLastMenses(), new Date()),
184   - bmi, "1", "175", "0");
  368 +
  369 + //营养评估
  370 + Map<String, Object> nutritionalAssessment = new HashMap<>();
  371 + nutritionalAssessment.put("nutritionalBmr", volumeComponentAnalysisModel.getBmr());//基础代谢
  372 + nutritionalAssessment.put("protein", range(DateUtil.getWeek2(patients.getLastMenses(), new Date()),//孕周
  373 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),//体重
  374 + Double.valueOf(volumeComponentAnalysisModel.getProtein()),//蛋白质
  375 + "dbz"));
  376 + nutritionalAssessment.put("fat", range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
  377 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),
  378 + Double.valueOf(volumeComponentAnalysisModel.getFat()),
  379 + "zf"));
  380 + nutritionalAssessment.put("wjy", range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
  381 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),
  382 + Double.valueOf(volumeComponentAnalysisModel.getBone()),
  383 + "wjy"));
  384 + data.add(nutritionalAssessment);
  385 + //第一页结束
  386 +
  387 + //第二、三页开始
185 388 //获取体质
186 389 String tz = range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
187   - Double.valueOf(volumeComponentAnalysisModel.getWeight()), Double.valueOf(volumeComponentAnalysisModel.getProtein()), "zf");
  390 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),
  391 + Double.valueOf(volumeComponentAnalysisModel.getProtein()),
  392 + "zf");
188 393 //肌肉的计算规则
189 394 String jr = range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
190   - Double.valueOf(volumeComponentAnalysisModel.getWeight()), Double.valueOf(volumeComponentAnalysisModel.getProtein()), "zf");
191   -
  395 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),
  396 + Double.valueOf(volumeComponentAnalysisModel.getProtein()),
  397 + "jr");
192 398 //无机盐
193   - String wjy = range(DateUtil.getWeek(patients.getLastMenses(), new Date()), Double.valueOf(volumeComponentAnalysisModel.getWeight()),
194   - Double.valueOf(volumeComponentAnalysisModel.getBone()), "wjy");
  399 + String wjy = range(DateUtil.getWeek(patients.getLastMenses(), new Date()),
  400 + Double.valueOf(volumeComponentAnalysisModel.getWeight()),
  401 + Double.valueOf(volumeComponentAnalysisModel.getBone()),
  402 + "wjy");
195 403  
196 404 double kulStart = Double.valueOf(kmap.get("kulStart"));
  405 + System.out.println("kulStart: "+kulStart);
197 406 int k1 = ((int) kulStart / 100) * 100;
198 407 double k2 = kulStart - k1;
199 408 if (k2 > 50) {
200 409  
201 410  
202 411  
203 412  
204 413  
... ... @@ -207,28 +416,22 @@
207 416 }
208 417 String type = null;
209 418 String evaluationType = null;
210   - //低体脂低肌肉
211   - if ("不足".equals(tz) && "不足".equals(jr)) {
  419 + if ("不足".equals(tz) && "低肌肉".equals(jr)) {//低体脂低肌肉(3、体脂不足肌肉不足:)
212 420 type = "5";
213 421 evaluationType = "3";
214   - //超体制底肌肉
215   - } else if ("过量".equals(tz) && "不足".equals(jr)) {
  422 + } else if ("过量".equals(tz) && "低肌肉".equals(jr)) {//超体制底肌肉(4、体脂过量肌肉不足:)
216 423 type = "3";
217 424 evaluationType = "4";
218   - //低肌肉
219   - } else if ("正常".equals(tz) && "不足".equals(jr)) {
  425 + } else if ("低肌肉".equals(jr)) {//低肌肉(5、肌肉不足:)
220 426 type = "2";
221 427 evaluationType = "5";
222   - //低体脂
223   - } else if ("不足".equals(tz) && "正常".equals(jr)) {
  428 + } else if ("不足".equals(tz)) {//低体脂(2、体脂不足:)
224 429 type = "4";
225 430 evaluationType = "2";
226   - //超体制
227   - } else if ("过量".equals(tz) && "正常".equals(jr)) {
  431 + } else if ("过量".equals(tz)) {//超体制(1、体脂过量:)
228 432 type = "1";
229 433 evaluationType = "1";
230   - //正常
231   - } else {
  434 + } else {//正常
232 435 type = "6";
233 436 evaluationType = "8";
234 437 }
235 438  
236 439  
237 440  
238 441  
239 442  
... ... @@ -237,24 +440,58 @@
237 440 } else if ("不足".equals(wjy)) {
238 441 evaluationType = "6";
239 442 }
  443 + //体型判定2 star
  444 + if ("过量".equals(tz) && "低肌肉".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  445 + somatotype.put("somatotype","1");//隐形肥胖型
  446 + } else if ("过量".equals(tz) && "正常".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  447 + somatotype.put("somatotype","2");//脂肪过多型
  448 + }else if (bmi>=30) {
  449 + somatotype.put("somatotype","3");//肥胖型
  450 + }else if ("正常".equals(tz) && "低肌肉".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  451 + somatotype.put("somatotype","4");//肌肉不足型
  452 + }else if ("正常".equals(tz) && "正常".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  453 + somatotype.put("somatotype","5");//健康匀称型
  454 + }else if ("正常".equals(tz) && "肌肉过量".equals(jr) && (bmi>25 && bmi<29.9)) {
  455 + somatotype.put("somatotype","6");//超重肌肉型
  456 + }else if (bmi < 18.5) {
  457 + somatotype.put("somatotype","7");//消瘦型
  458 + }else if ("不足".equals(tz) && "正常".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  459 + somatotype.put("somatotype","8");//低脂肪型
  460 + }else if ("不足".equals(tz) && "肌肉过量".equals(jr) && (bmi>18.5 && bmi<24.9)) {
  461 + somatotype.put("somatotype","9");//运动员型
  462 + }
  463 + data.add(somatotype);
  464 + //体型判定2 end
240 465  
  466 + Integer week = DateUtil.getWeek(patients.getLastMenses());
  467 + //计算孕期
  468 + Integer pregnancy=0;
  469 + if (week <= 12) {
  470 + pregnancy = 0;
  471 + } else if (week >= 13 && week <= 28) {
  472 + pregnancy = 1;
  473 + } else if (week >= 28 && week <= 40) {
  474 + pregnancy = 2;
  475 + }
241 476 //报告内容
242   - BodyMassAnalysisModel bodyMassAnalysisModel = mongoTemplate.findOne(Query.query(Criteria.where("type").is(type).and("kcal").is(k1)), BodyMassAnalysisModel.class);
243   - //食谱
  477 + BodyMassAnalysisModel bodyMassAnalysisModel = mongoTemplate.findOne(
  478 + Query.query(Criteria.where("type").is(type).and("kcal").is(k1).and("pregnancy").is(pregnancy)),
  479 + BodyMassAnalysisModel.class);
  480 + //列举食谱
244 481 if (null != bodyMassAnalysisModel) {
245 482 Map<String, Object> recipesInfo = new HashMap<>();
246   - recipesInfo.put("breakfast", bodyMassAnalysisModel.getBreakfast());
247   - recipesInfo.put("breakfastAdd", bodyMassAnalysisModel.getBreakfastAdd());
248   - recipesInfo.put("lunch", bodyMassAnalysisModel.getLunch());
249   - recipesInfo.put("lunchAdd", bodyMassAnalysisModel.getLunchAdd());
250   - recipesInfo.put("dinner", bodyMassAnalysisModel.getDinner());
251   - recipesInfo.put("dinnerAdd", bodyMassAnalysisModel.getDinnerAdd());
  483 + recipesInfo.put("breakfast", bodyMassAnalysisModel.getBreakfast());//早餐
  484 + recipesInfo.put("breakfastAdd", bodyMassAnalysisModel.getBreakfastAdd());//上午加餐
  485 + recipesInfo.put("lunch", bodyMassAnalysisModel.getLunch());//午餐
  486 + recipesInfo.put("lunchAdd", bodyMassAnalysisModel.getLunchAdd());//下午加餐
  487 + recipesInfo.put("dinner", bodyMassAnalysisModel.getDinner());//晚餐
  488 + recipesInfo.put("dinnerAdd", bodyMassAnalysisModel.getDinnerAdd());//晚加餐
252 489 data.add(recipesInfo);
253   - Integer week = DateUtil.getWeek(patients.getLastMenses());
  490 +
254 491 //膳食结构
255 492 Map<String, Object> dietInfo = new HashMap<>();
256 493 if (week <= 12) {
257   - dietInfo.put("diet", bodyMassAnalysisModel.getEarlySuggests());
  494 + dietInfo.put("diet", bodyMassAnalysisModel.getEarlySuggests());//膳食
258 495 } else if (week >= 13 && week <= 28) {
259 496 dietInfo.put("diet", bodyMassAnalysisModel.getMiddleSuggests());
260 497 } else if (week >= 28 && week <= 40) {
261 498  
262 499  
... ... @@ -273,15 +510,23 @@
273 510 recipeRulesInfo.put("recipesRule", nutrition.getRecipesRule());
274 511 data.add(recipeRulesInfo);
275 512 }
  513 + //第二、三页结束
276 514  
277 515 return data;
278 516 }
279 517  
280   - private String range(Integer week, double weight, double value, String type) {
  518 + /**
  519 + *
  520 + * @param week 孕周
  521 + * @param weight 体重
  522 + * @param value 蛋白质
  523 + * @param type dbz类型
  524 + * @return
  525 + */
  526 + private String range(Integer week, double weight, double value, String type) {
281 527 //孕早期
282 528 if (week >= 0 && week <= 12) {
283   - //蛋白质
284   - if ("dbz".equals(type)) {
  529 + if ("dbz".equals(type)) {//蛋白质
285 530 double d = weight * 0.13;//最低
286 531 double c = weight * 0.17;//最高
287 532 if (value < d) {
288 533  
289 534  
290 535  
291 536  
... ... @@ -289,17 +534,17 @@
289 534 } else {
290 535 return "正常";
291 536 }
292   - } else if ("zf".equals(type)) {
  537 + } else if ("zf".equals(type)) {//脂肪
293 538 double b = weight * 21.4;
294 539 double c = weight * 0.35;
295 540 if (value < b) {
296   - return "不足";
  541 + return "不足";//体成分分析体型判定--体脂不足
297 542 } else if (value > c) {
298   - return "过量";
  543 + return "过量";//体成分分析体型判定--体脂过量
299 544 } else {
300   - return "正常";
  545 + return "正常";//体成分分析体型判定--体脂正常
301 546 }
302   - } else if ("wjy".equals(type)) {
  547 + } else if ("wjy".equals(type)) {//无机盐
303 548 double b = weight * 0.033;
304 549 double c = weight * 0.047;
305 550 if (value < b) {
306 551  
307 552  
308 553  
... ... @@ -313,13 +558,16 @@
313 558 double b = weight * 0.65;
314 559 double c = weight * 0.8;
315 560 if (value < b) {
316   - return "低肌肉";
  561 + return "低肌肉";//体成分分析体型判定--肌肉不足
  562 + }if (value > c) {
  563 + return "肌肉过量";//体成分分析体型判定--肌肉过量
317 564 } else {
318   - return "正常";
  565 + return "正常";//体成分分析体型判定--肌肉正常范围内
319 566 }
320 567 }
  568 +
321 569 //孕中期
322   - } else if (week >= 13 && week <= 28) {
  570 + } else if (week >= 13 && week <= 28) {//蛋白质
323 571 if ("dbz".equals(type)) {
324 572 double d = weight * 0.15;
325 573 double c = weight * 0.18;
... ... @@ -328,7 +576,7 @@
328 576 } else {
329 577 return "正常";
330 578 }
331   - } else if ("zf".equals(type)) {
  579 + } else if ("zf".equals(type)) {//脂肪
332 580 double b = weight * 21.4;
333 581 double c = weight * 0.35;
334 582 if (value < b) {
... ... @@ -338,7 +586,7 @@
338 586 } else {
339 587 return "正常";
340 588 }
341   - } else if ("wjy".equals(type)) {
  589 + } else if ("wjy".equals(type)) {//无机盐
342 590 double b = weight * 0.034;
343 591 double c = weight * 0.048;
344 592 if (value < b) {
... ... @@ -358,7 +606,7 @@
358 606 }
359 607 }
360 608 //孕晚期
361   - } else if (week >= 29 && week <= 40) {
  609 + } else if (week >= 29 && week <= 40) {//蛋白质
362 610 if ("dbz".equals(type)) {
363 611 double b = weight * 15.78;
364 612 double c = weight * 19.2;
... ... @@ -367,7 +615,7 @@
367 615 } else {
368 616 return "正常";
369 617 }
370   - } else if ("zf".equals(type)) {
  618 + } else if ("zf".equals(type)) {//脂肪
371 619 double b = weight * 0.25;
372 620 double c = weight * 0.35;
373 621 if (value < b) {
... ... @@ -377,7 +625,7 @@
377 625 } else {
378 626 return "正常";
379 627 }
380   - } else if ("wjy".equals(type)) {
  628 + } else if ("wjy".equals(type)) {//无机盐
381 629 double b = weight * 0.035;
382 630 double c = weight * 0.055;
383 631 if (value < b) {
... ... @@ -398,6 +646,58 @@
398 646 }
399 647 }
400 648 return "";
  649 + }
  650 + /**
  651 + *
  652 + * @param week 孕周
  653 + * @param weight 体重
  654 + * @param type xbny 细胞内液含量正常范围 类型
  655 + * @return
  656 + */
  657 + private Map<String,String> rangeMap(Integer week, double weight, String type) {
  658 + Map<String, String> map = new HashMap<>();
  659 + //孕早期
  660 + if (week >= 0 && week <= 12) {
  661 + if ("xbny".equals(type)) {//细胞内液含量正常范围
  662 + double min = weight * 0.175;
  663 + double max = weight * 0.188;
  664 + map.put("min", Double.toString(min));
  665 + map.put("max", Double.toString(max));
  666 + }else if ("xbwy".equals(type)) {//细胞外液体含量正常范围
  667 + double min = weight * 0.12;
  668 + double max = weight * 0.16;
  669 + map.put("min", Double.toString(min));
  670 + map.put("max", Double.toString(max));
  671 + }
  672 + //孕中期
  673 + } else if (week >= 13 && week <= 28) {//蛋白质
  674 + if ("xbny".equals(type)) {
  675 + double min = weight * 0.175;
  676 + double max = weight * 0.188;
  677 + map.put("min", Double.toString(min));
  678 + map.put("max", Double.toString(max));
  679 + }else if ("xbwy".equals(type)) {
  680 + double min = weight * 0.13;
  681 + double max = weight * 0.17;
  682 + map.put("min", Double.toString(min));
  683 + map.put("max", Double.toString(max));
  684 + }
  685 + //孕晚期
  686 + } else if (week >= 29 && week <= 40) {//蛋白质
  687 + if ("xbny".equals(type)) {
  688 + double min = weight * 0.175;
  689 + double max = weight * 0.188;
  690 + map.put("min", Double.toString(min));
  691 + map.put("max", Double.toString(max));
  692 + }else if ("xbwy".equals(type)) {
  693 + double min = weight * 0.15;
  694 + double max = weight * 0.18;
  695 + map.put("min", Double.toString(min));
  696 + map.put("max", Double.toString(max));
  697 + }
  698 +
  699 + }
  700 + return map;
401 701 }
402 702 }