diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java index cf74e0f..712a9d4 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java @@ -1078,9 +1078,7 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga @Override public BaseResponse getSysBloodSugarReport(String patientId, Integer userId, String lsbId, String doctorId) { - String version = null; BaseObjectResponse resp = new BaseObjectResponse(); - Patients patients = patientsService.findOnePatientById(patientId); //判断开通血糖服务没有 @@ -1114,33 +1112,31 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("patientId").is(patientId)), PatientWeight.class); - if (patientWeight == null) { - resp.setErrorcode(ResponseCode.DATA_ERROR.getCode()); - resp.setErrormsg("没有体重测量记录"); - return resp; + AntExChuModel chuModel = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patients.getPid()).and("yn").ne("0")).with(new Sort(Sort.Direction.DESC, "created")), AntExChuModel.class); + if (chuModel != null && StringUtils.isNotEmpty(chuModel.getHeight()) && StringUtils.isNotEmpty(chuModel.getWeight())) { + patientWeight = new PatientWeight(); + patientWeight.setBeforeHeight(StringUtils.isNotEmpty(chuModel.getHeight()) ? chuModel.getHeight() : ""); + patientWeight.setNowWeight(StringUtils.isNotEmpty(chuModel.getWeight()) ? chuModel.getWeight() : ""); + patientWeight.setBeforeWeight(StringUtils.isNotEmpty(chuModel.getYqWeight()) ? chuModel.getYqWeight() : ""); + patientWeight.setBmi(patientWeightService.getBmi(chuModel.getYqWeight(), chuModel.getHeight())); + } } - Map dayWeights = patientWeight.getDayWeights(); - - //当天没有体重测量 - if (!(dayWeights != null && dayWeights.size() > 0 && StringUtils.isNotEmpty(dayWeights.get(DateUtil.getyyyy_MM_dd(new Date()))))) { + if (patientWeight == null) { resp.setErrorcode(ResponseCode.DATA_ERROR.getCode()); - resp.setErrormsg("当天没有测量体重,不能出报告"); + resp.setErrormsg("没有体重测量记录,不能出报告"); return resp; } - String rid = ""; - int week = DateUtil.getWeek(patients.getLastMenses(), new Date()); - if (week < 6) { resp.setErrorcode(ResponseCode.DATA_ERROR.getCode()); resp.setErrormsg("小于6孕周,不能出报告"); return resp; } - Map data = new HashMap(); + Map data = new HashMap(); List bloodSugars = mongoTemplate.find(Query.query(Criteria.where("pid").is(patients.getPid()).and("created").gt(DateUtil.getYMDTime())), BloodSugar.class); if (CollectionUtils.isNotEmpty(bloodSugars)) @@ -1154,7 +1150,7 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga data.put("bloodData",bloodData); } - + String rid = ""; //妊娠期糖尿病(无需药物治疗) //糖尿病合并妊娠(无需药物治疗) if (risks.contains("5aab6d3d422b03d4ad2bf83e") && (risks.contains("5aab6d3e422b03d4ad2bf83f") //需药物治疗的糖尿病 @@ -1167,22 +1163,20 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga rid = "5aab6d3d422b03d4ad2bf83e"; } - data.put("riskType", (risks.contains("5aab6d3d422b03d4ad2bf83e") || risks.contains("5aab6d3e422b03d4ad2bf83f")) ? "1" : "2"); //1 无需药物治疗 2 需要药物治疗 + data.put("needType", (risks.contains("5aab6d3d422b03d4ad2bf83e") || risks.contains("5aab6d3e422b03d4ad2bf83f")) ? 1 : 2); //1 无需药物治疗 2 需要药物治疗 data.put("riskType", (risks.contains("5aab6d3d422b03d4ad2bf83e") || risks.contains("de7468e6-1bb5-4fab-ae84-78857868409a")) ? 1 : 2 ); //1 妊娠期糖尿病 2 糖尿病合并妊娠 double bmi = Double.parseDouble(patientWeight.getBmi()); //根据高危获取不同的卡路里计算公式 - double kcal = getComputeKcal(Double.parseDouble(patientWeight.getBeforeWeight()), - Double.parseDouble(patientWeight.getNowWeight()), week, bmi, patientWeight.getBregmatic(), patientWeight.getBeforeHeight(), version); + double kcal = getComputeKcal(week, bmi, patientWeight.getBeforeHeight()); data.put("bmi", bmi); + data.put("kcal", kcal); + data.put("beforeWeight", patientWeight.getBeforeWeight()); + data.put("nowWeight", patientWeight.getNowWeight()); + data.put("beforeHeight", patientWeight.getBeforeHeight()); + - String weekYyzl = ""; - WeightConfigModel weightConfigModel = patientWeightService.getWeightConfigByWeek(week); - if (weightConfigModel != null) { - weekYyzl = weightConfigModel.getWeekContent(); - } - data.put("weekYyzl", weekYyzl); String hospitalId = autoMatchFacade.getHospitalId(userId); Organization org = organizationService.getOrganization(Integer.parseInt(hospitalId)); @@ -1260,38 +1254,25 @@ public class BloodSugarServiceImpl extends BaseServiceImpl implements IBloodSuga 孕晚期(28到42)热量+400 ③计算出来后所有人不能超过2300,超过的按照2300给热量;孕晚期(28到42)不能低于1800,低于1800的按1800给热量。 ④计算出的热量四舍五入。 - * @param beforeWeight - * @param currentWeight - * @param week - * @param bmi - * @param bregmatic - * @param beforeHeight - * @param version + * @param week 孕周 + * @param bmi bmi值 + * @param beforeHeight 孕前生高 * @return */ - public double getComputeKcal(double beforeWeight, double currentWeight, int week, double bmi, String bregmatic, String beforeHeight,String version) { + public double getComputeKcal(int week, double bmi, String beforeHeight) { //系数 int coefficient = 25; - if (bmi < 18.5) - { - coefficient = 35; - } - else if (bmi >=25 ) - { - coefficient = 20; - } - + coefficient = bmi < 18.5 ? 35 : (bmi >=25 ? 20 : coefficient); double kcal = (Double.parseDouble(beforeHeight) - 105) * coefficient; - if(week >= 12 && week < 28) { - kcal+=200; + kcal += 200; } else if (week >= 28) { - kcal+=400; + kcal += 400; kcal = kcal < 1800 ? 1800 : kcal; } if (kcal > 2300)