Commit 1d21235bdf730b8425838d8169d24ffd835f4efd

Authored by liquanyu
1 parent 5ff3888cf7

update

Showing 1 changed file with 97 additions and 2 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java View file @ 1d21235
... ... @@ -1115,7 +1115,7 @@
1115 1115  
1116 1116 double bmi = Double.parseDouble(patientWeight.getBmi());
1117 1117 //根据高危获取不同的卡路里计算公式
1118   - Map<String, String> kmap = computeKulServiceManager.getComputeKulByRisk(rid).getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()),
  1118 + Map<String, String> kmap = getComputeKul(Double.parseDouble(patientWeight.getBeforeWeight()),
1119 1119 Double.parseDouble(patientWeight.getNowWeight()), week, bmi, patientWeight.getBregmatic(), patientWeight.getBeforeHeight(), version);
1120 1120  
1121 1121  
... ... @@ -1139,7 +1139,7 @@
1139 1139 Map<String, Object> dinner2 = new LinkedHashMap<>(); // 晚加餐
1140 1140  
1141 1141 String nsArea = ReportConfig.getNSArea(basicConfig.getName());
1142   - WeightConfigModel configModel = patientWeightService.getWeightConfigBykcal(kmap, nsArea, rid);
  1142 + WeightConfigModel configModel = getWeightConfigBykcal(kmap, nsArea, rid);
1143 1143  
1144 1144 if (configModel != null) {
1145 1145 setData(breakfast, "早餐", configModel.getBreakfast());
... ... @@ -1168,6 +1168,101 @@
1168 1168 resp.setErrorcode(ResponseCode.SUCCESS.getCode());
1169 1169 resp.setErrormsg("成功");
1170 1170 return resp;
  1171 + }
  1172 +
  1173 +
  1174 + public WeightConfigModel getWeightConfigBykcal(Map<String, String> map, String northSouth, String risk) {
  1175 + if (map.get("kulStart") == null) {
  1176 + return null;
  1177 + }
  1178 + double kulStart = Double.valueOf(map.get("kulStart"));
  1179 + int k1 = ((int) kulStart / 100) * 100;
  1180 + double k2 = kulStart - k1;
  1181 + if (k2 > 50) {
  1182 + k1 += 100;
  1183 + }
  1184 +
  1185 + if (k1 < 1500) {
  1186 + k1 = 1500;
  1187 + } else if (k1 > 2800) {
  1188 + k1 = 2800;
  1189 + }
  1190 + Criteria criteria = null;
  1191 + if ("3".equals((String) map.get("type"))) {
  1192 + criteria = Criteria.where("kcal").is(k1).and("dietaryType").is(0);
  1193 + } else {
  1194 + criteria = Criteria.where("northSouth").is(northSouth).and("kcal").is(k1);
  1195 + }
  1196 + //如果传了高危因素id就按高危去查
  1197 + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(risk)) {
  1198 + criteria = criteria.and("riskId").in(risk).and("type").is("1");
  1199 + } else {
  1200 + criteria = criteria.and("type").is("0");
  1201 + }
  1202 + Query query = Query.query(criteria);
  1203 + WeightConfigModel weightConfigModel = mongoTemplate.findOne(query,
  1204 + WeightConfigModel.class);
  1205 + return weightConfigModel;
  1206 + }
  1207 +
  1208 +
  1209 + public Map<String, String> getComputeKul(double beforeWeight, double currentWeight, int week, double bmi, String bregmatic, String beforeHeight,String version) {
  1210 + Map<String, String> map = new HashMap<>();
  1211 + double kulStart = 0;
  1212 + double height = Double.valueOf(String.format("%.2f", Double.parseDouble(beforeHeight) / 100));
  1213 + //孕早期
  1214 + if (week <= 12) {
  1215 + kulStart = (new BigDecimal(Double.toString(height)).multiply(new BigDecimal(Double.toString(height))).doubleValue() * 21 + 1.5) * 30;
  1216 + }
  1217 + //孕中期 //孕晚期
  1218 + else if (week > 12) {
  1219 + //基础kcal值
  1220 + int basekul = (week > 12 && week <= 27) ? 340 : 450;
  1221 +
  1222 + String bmiStr = "";
  1223 +
  1224 + if (org.apache.commons.lang.StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) {
  1225 + if (bmi < 18.5) {
  1226 + bmiStr = "BMI<18.5孕" + week + "周";
  1227 + } else if (bmi <= 24.9 && bmi >= 18.5) {
  1228 + bmiStr = "BMI=18.5-24.9孕" + week + "周";
  1229 + } else if (bmi <= 29.9 && bmi >= 25) {
  1230 + bmiStr = "BMI=25-29.9孕" + week + "周";
  1231 + } else if (bmi >= 30) {
  1232 + bmiStr = "BMI≥30孕" + week + "周";
  1233 + }
  1234 + } else {
  1235 + if (bmi <= 24.9) {
  1236 + bmiStr = "BMI≤24.9孕" + week + "周";
  1237 + } else if (bmi <= 29.9 && bmi >= 25) {
  1238 + bmiStr = "BMI=25-29.9孕" + week + "周";
  1239 + } else if (bmi >= 30) {
  1240 + bmiStr = "BMI≥30孕" + week + "周";
  1241 + }
  1242 + }
  1243 +
  1244 + if (org.apache.commons.lang.StringUtils.isEmpty(bmiStr)) {
  1245 + return map;
  1246 + }
  1247 +
  1248 + String[] rangeWeight = null;
  1249 + if (org.apache.commons.lang.StringUtils.isEmpty(bregmatic) || "1".equals(bregmatic)) {
  1250 + rangeWeight = ReportConfig.getWeightRange(bmiStr).split("-");
  1251 + } else {
  1252 + rangeWeight = ReportConfig.getDWeightRange(bmiStr).split("-");
  1253 + }
  1254 +
  1255 + if (rangeWeight == null || rangeWeight.length != 2) {
  1256 + return map;
  1257 + }
  1258 +
  1259 + double addWeightEnd = Double.parseDouble(rangeWeight[1]);
  1260 +
  1261 + kulStart = (new BigDecimal(Double.toString(height)).multiply(new BigDecimal(Double.toString(height))).doubleValue() * 21 + addWeightEnd ) * 30+basekul;
  1262 + }
  1263 +
  1264 + map.put("kulStart", String.valueOf(kulStart));
  1265 + return map;
1171 1266 }
1172 1267  
1173 1268