From 86a5b44aabcb66045a386517ca2b6cc11bc7aa01 Mon Sep 17 00:00:00 2001 From: wangbo <184677810@qq.com> Date: Thu, 14 Mar 2019 15:35:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=93=E9=87=8D=E8=90=A5=E5=85=BB=E6=8A=A5?= =?UTF-8?q?=E5=91=8A=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyms/platform/biz/BasicConfigServiceTest.java | 9 +- .../web/service/impl/PatientWeightServiceImpl.java | 178 ++++++++++++++++----- 2 files changed, 144 insertions(+), 43 deletions(-) diff --git a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java index 3649834..bb56950 100644 --- a/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java +++ b/platform-biz-patient-service/src/main/java/com/lyms/platform/biz/BasicConfigServiceTest.java @@ -3116,6 +3116,7 @@ public class BasicConfigServiceTest { } Sheet s18 = wb.getSheet(18); + System.out.println(s18.getName() + " : "); int rows18 = s18.getRows(); if (rows18 > 0) { @@ -3125,6 +3126,12 @@ public class BasicConfigServiceTest { WeightReportModel weighReport = new WeightReportModel(); //0 健康教育之孕期相关 1 饮食 2 饮食之营养指南 3 运动 weighReport.setType(18); + weighReport.setgDMId("5aab6d3d422b03d4ad2bf83e"); + weighReport.setgDMName("妊娠期糖尿病(无需药物治疗)"); + weighReport.setoDIPId("5aab6d3e422b03d4ad2bf83f"); + weighReport.setoDIPName("糖尿病合并妊娠(无需药物治疗)"); + weighReport.setMedicationDiabetesID("de7468e6-1bb5-4fab-ae84-78857868409a"); + weighReport.setModerateAnemiaName("需药物治疗的糖尿病"); Cell[] cells = s18.getRow(i); if (cells.length > 0) { //遍历每行中的每列 @@ -3282,7 +3289,7 @@ public class BasicConfigServiceTest { weighReport.setType(22); weighReport.setHyperthyroidismNeedID("5aab6d40422b03d4ad2bf85f"); weighReport.setHyperthyroidismName("甲亢(需药物治疗)"); - Cell[] cells = s18.getRow(i); + Cell[] cells = s22.getRow(i); if (cells.length > 0) { //遍历每行中的每列 for (int j = 0; j < cells.length; j++) { diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java index 0400341..08553f2 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PatientWeightServiceImpl.java @@ -1958,10 +1958,9 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient @Override public BaseResponse getWeightsReport(String pid, Integer userId, String rid) { Map> series = new HashMap<>(); - Map> datas = new HashMap<>(); + Map> datas = new TreeMap<>(); PatientWeight patientWeight = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(pid)), PatientWeight.class); //1.获取该孕妇是否有推荐的高危项 - System.out.println("id" + patientWeight.getPatientId()); Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(patientWeight.getPatientId())), Patients.class); //1.1获取到这孕妇所有的高危因素id //1.2获取身高 @@ -1969,11 +1968,8 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient //获取体重 String weight = patientWeight.getBeforeWeight(); Double heights = Double.valueOf(height).doubleValue() / 100; - System.out.println("身高" + heights); int week = DateUtil.getWeek2(patients.getLastMenses(), new Date()); this.getAcuteHepatitis(heights, week); - System.out.println("热量值" + this.getAcuteHepatitis(heights, week)); - System.out.println("孕周:" + week); //获取胎数 String bregmatic = patientWeight.getBregmatic(); //获取bmi值 @@ -2019,26 +2015,21 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient //贫血/高血压计算规则 Integer gxyKcal = this.getRounding((int) this.getKcal(bregmatic, residualWeight, low, high, week, bmiD, patients, patientWeight, heights, 1.12)); String gxyKcalStr = gxyKcal + "kcal"; - System.out.println("贫血/高血压计算规则获取到热量值kcalss:" + gxyKcalStr); - //获取慢性肝炎的计算规则 Integer mxgyKcal = this.getRounding((int) this.getHepatitisKcal(patientWeight, bregmatic, residualWeight, low, high, bmiD, week)); String mxgyKcalStr = mxgyKcal + "kcal"; - System.out.println("获取慢性肝炎的计算规则热量值:" + mxgyKcalStr); - - //急性肝炎跟糖尿病的计算规则 + //急性肝炎计算规则 Integer kcal = getRounding((int) this.getAcuteHepatitis(heights, week)); String kcals = kcal + "kcal"; - System.out.println("急性肝炎跟糖尿病的计算规则热量值:" + kcals); - + //糖尿病计算规则 + Integer diabetesKcal = getDiabetesRounding((int) this.getAcuteHepatitis(heights, week)); + String diabetesKcalStr = diabetesKcal + "kcal"; //甲亢计算规则 Integer gkKcal = this.getRounding((int) this.getKcal(bregmatic, residualWeight, low, high, week, bmiD, patients, patientWeight, heights, 1.45)); String gkKcalStr = gkKcal + "kcal"; - System.out.println("甲亢获取到热量值kcalss:" + gkKcalStr); //甲减计算规则 Integer gjKcal = this.getRounding((int) this.getKcal(bregmatic, residualWeight, low, high, week, bmiD, patients, patientWeight, heights, 1.45)); String gjKcalStr = gjKcal + "kcal"; - System.out.println("甲减获取到热量值kcalss:" + gjKcalStr); //获取改孕妇的高危项 String risk = patients.getRiskLevelId(); if (risk.contains("eb146c03-b19f-4e28-b85f-fda574b2283b") || risk.contains("224b2329-cb82-4da3-a071-8527f8283aab")) { @@ -2050,6 +2041,7 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient Map data3 = new HashMap<>(); Map data4 = new HashMap<>(); Map data5 = new HashMap<>(); + Map data6 = new HashMap<>(); List reiskFactor = patients.getRiskFactorId(); List weightReport = mongoTemplate.findAll(WeightReportModel.class); //获取视图 @@ -2061,52 +2053,71 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient weights.put(DateUtil.getWeek2(patients.getLastMenses(), DateUtil.parseYMD(entry.getKey())), entry.getValue()); } } - for (WeightReportModel weightReportModel : weightReport) { - for (String reis : reiskFactor) { + for (String reis : reiskFactor) { + for (WeightReportModel weightReportModel : weightReport) { if (reis.equals(weightReportModel.getgDMId()) || reis.equals(weightReportModel.getoDIPId()) || reis.equals(weightReportModel.getMedicationDiabetesID())) { - //糖尿病 - datas.put("diabetes", this.getInfo(weights, data3, weightReportModel, patientWeight, patients, bmiD, week, kcals)); + //糖尿病diabetes + datas.put("1", this.getDiabetestInfo(weights, data3, weightReportModel, patientWeight, patients, bmiD, week, diabetesKcalStr)); } else if (reis.equals(weightReportModel.getGestationalHypertensionGHID()) || reis.equals(weightReportModel.getChronicHypertensionID())) { - //高血压 - datas.put("hypertension", this.getInfo(weights, data2, weightReportModel, patientWeight, patients, bmiD, week, gxyKcalStr)); + //高血压hypertension + datas.put("2", this.getInfo(weights, data2, weightReportModel, patientWeight, patients, bmiD, week, gxyKcalStr)); } else if (reis.equals(weightReportModel.getHyperthyroidismNeedID()) || reis.equals(weightReportModel.getHyperthyroidismID())) { - //甲亢 - datas.put("hyperthyroidism", this.getInfo(weights, data4, weightReportModel, patientWeight, patients, bmiD, week, gkKcalStr)); + //甲亢hyperthyroidism + datas.put("3", this.getDiabetestInfo(weights, data4, weightReportModel, patientWeight, patients, bmiD, week, gkKcalStr)); } else if (reis.equals(weightReportModel.getHypothyroidismID()) || reis.equals(weightReportModel.getyLCHypothyroidismID()) || reis.equals(weightReportModel.getHypothyroidismNeedID())) { - //甲减 - datas.put("hypothyroidism", this.getInfo(weights, data5, weightReportModel, patientWeight, patients, bmiD, week, gjKcalStr)); - } else if (reis.equals(weightReportModel.getDiseasesDigestiveSystemId()) || reis.equals(weightReportModel.getViralHepatitisId())) { - //急性肝炎 - datas.put("acuteHepatitis", this.getInfo(weights, data1, weightReportModel, patientWeight, patients, bmiD, week, kcals)); - - } else if (reis.equals(weightReportModel.getCirrhosis()) || reis.equals(weightReportModel.getLiverFunctionErrorId())) { - //慢性肝炎 - datas.put("chronicHepatitis", this.getInfo(weights, data1, weightReportModel, patientWeight, patients, bmiD, week, mxgyKcalStr)); + //甲减hypothyroidism + datas.put("4", this.getDiabetestInfo(weights, data5, weightReportModel, patientWeight, patients, bmiD, week, gjKcalStr)); } else if (reis.equals(weightReportModel.getAnemiaPregnancyId()) || reis.equals(weightReportModel.getMildAnemiaID()) || reis.equals(weightReportModel.getModerateAnemiaID()) || reis.equals(weightReportModel.getSevereAnemiaID()) || reis.equals(weightReportModel.getSevereAnemiaHBID()) || reis.equals(weightReportModel.getObstructiveAnemiaID())) { - //贫血 - datas.put("anemia", this.getInfo(weights, data0, weightReportModel, patientWeight, patients, bmiD, week, gjKcalStr)); + //贫血anemia + datas.put("5", this.getInfo(weights, data0, weightReportModel, patientWeight, patients, bmiD, week, gjKcalStr)); + } else if (reis.equals(weightReportModel.getDiseasesDigestiveSystemId()) || reis.equals(weightReportModel.getViralHepatitisId())) { + //急性肝炎acuteHepatitis + datas.put("6", this.getInfo(weights, data1, weightReportModel, patientWeight, patients, bmiD, week, kcals)); + } else if (reis.equals(weightReportModel.getCirrhosis()) || reis.equals(weightReportModel.getLiverFunctionErrorId())) { + //慢性肝炎chronicHepatitis + datas.put("7", this.getInfo(weights, data6, weightReportModel, patientWeight, patients, bmiD, week, mxgyKcalStr)); } } } } - if (datas.size() > 1) { - Map map = new HashMap(); - datas.put("tips", map); - map.put("info", "您当前情况存在两种及以上高危风险因素,需请您的主管医生结合临床实际情况对报告进行解读,并根据医生解读建议,指导日常营养膳食"); - } if (datas.size() == 0) { BaseResponse baseResponse = this.report(pid, userId, rid); return baseResponse; } - return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(datas); + + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(this.getFirstOrNull(datas)); + } + + private static String getKeyOrNull(Map map) { + String obj = null; + for (Map.Entry entry : map.entrySet()) { + obj = entry.getKey(); + if (obj != null) { + break; + } + } + return obj; } + //获取第一个map中数据值 + private static Object getFirstOrNull(Map> map) { + Object obj = null; + for (Map.Entry> entry : map.entrySet()) { + obj = entry.getValue(); + if (obj != null) { + break; + } + } + return obj; + } + + public Map getInfo(Map weights, Map data, WeightReportModel weightReportModel, PatientWeight patientWeight, Patients patients, double bmi, int week, String kcal) { - setReport(data, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(), patientWeight.getBregmatic()); + //setReport(data, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(), patientWeight.getBregmatic()); Map userMap = new HashMap(); userMap.put("userName", patients.getUsername()); userMap.put("age", patients.getAge()); @@ -2115,10 +2126,10 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient userMap.put("week", week); userMap.put("vcCardNo", patients.getVcCardNo()); userMap.put("phone", patients.getPhone()); - userMap.put("dueDate", patients.getDueDate()); + userMap.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); userMap.put("NowWeight", patientWeight.getNowWeight()); userMap.put("BeforeWeight", patientWeight.getBeforeWeight()); - userMap.put("riskFactor", "高危因素集合"); + userMap.put("riskFactor", patients.getRiskFactorId()); data.put("userInfo", userMap); Map map2 = new HashMap(); map2.put("guideTitle", weightReportModel.getGuideTitle()); @@ -2157,6 +2168,65 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient map1.put("proposalInfo", weightReportModel.getLaterSuggests()); } data.put("recipes", map1); + if (patients.getRiskFactorId().size() >= 2) { + Map map = new HashMap(); + map.put("tipsInfo", "您当前情况存在两种及以上高危风险因素,需请您的主管医生结合临床实际情况对报告进行解读,并根据医生解读建议,指导日常营养膳食"); + data.put("tips", map); + } + } + return data; + } + + public Map getDiabetestInfo(Map weights, Map data, WeightReportModel weightReportModel, PatientWeight patientWeight, Patients patients, double bmi, int week, String kcal) { + //setReport(data, weights, patientWeight.getBeforeWeight(), patientWeight.getBmi(), patientWeight.getDayWeights(), patientWeight.getBregmatic()); + Map userMap = new HashMap(); + userMap.put("userName", patients.getUsername()); + userMap.put("age", patients.getAge()); + userMap.put("height", patientWeight.getBeforeHeight()); + userMap.put("bmi", bmi); + userMap.put("week", week); + userMap.put("vcCardNo", patients.getVcCardNo()); + userMap.put("phone", patients.getPhone()); + userMap.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); + userMap.put("NowWeight", patientWeight.getNowWeight()); + userMap.put("BeforeWeight", patientWeight.getBeforeWeight()); + userMap.put("riskFactor", patients.getRiskFactorId()); + data.put("userInfo", userMap); + Map map2 = new HashMap(); + map2.put("guideTitle", weightReportModel.getGuideTitle()); + map2.put("guideInfo", weightReportModel.getGuideInfo()); + data.put("nutritionGuide", map2); + Map map3 = new HashMap(); + if (StringUtils.isNotEmpty(weightReportModel.getDietTitle()) && null != weightReportModel.getDietInfo()) { + map3.put("dietTitle", weightReportModel.getDietTitle()); + map3.put("dietInfo", weightReportModel.getDietInfo()); + data.put("dietaryRules", map3); + } + if (null != weightReportModel.getWeeks() && weightReportModel.getWeeks() == week) { + Map map = new HashMap(); + map.put("weeks", weightReportModel.getWeeks()); + map.put("becareful", weightReportModel.getBecareful()); + data.put("attentionWeek", map); + } + if (kcal.equals(weightReportModel.getKcal())) { + Map map1 = new HashMap(); + map1.put("kacl", weightReportModel.getKcal()); + map1.put("breakfast", weightReportModel.getBreakfast()); + map1.put("breakfastAdd", weightReportModel.getBreakfastAdd()); + map1.put("lunch", weightReportModel.getLunch()); + map1.put("lunchAdd", weightReportModel.getLunchAdd()); + map1.put("dinner", weightReportModel.getDinner()); + map1.put("dinnerAdd", weightReportModel.getDinnerAdd()); + map1.put("northSouth", weightReportModel.getNorthSouth()); + map1.put("proposalInfo", weightReportModel.getEarlySuggests()); + + + data.put("recipes", map1); + } + if (patients.getRiskFactorId().size() >= 2) { + Map map = new HashMap(); + map.put("tipsInfo", "您当前情况存在两种及以上高危风险因素,需请您的主管医生结合临床实际情况对报告进行解读,并根据医生解读建议,指导日常营养膳食"); + data.put("tips", map); } return data; } @@ -2173,6 +2243,29 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient return 0.0; } + public int getDiabetesRounding(Integer number) { + if (number <= 1200) { + return 1200; + } else if (number >= 2500) { + return 2500; + } + if (number / 10 % 10 >= 5) { + int g = 0; //s % 10; + int sw = 0;//s / 10 % 10; + int b = number / 100 % 10 + 1; + int q = number / 1000 % 10; + int num = q * 1000 + b * 100 + sw * 0 + g * 0; + return num; + } else { + int g = 0; //s % 10; + int sw = 0;//s / 10 % 10; + int b = number / 100 % 10; + int q = number / 1000 % 10; + int num = q * 1000 + b * 100 + sw * 0 + g * 0; + return num; + } + } + public int getRounding(Integer number) { if (number <= 1000) { return 1000; @@ -2685,4 +2778,5 @@ public class PatientWeightServiceImpl extends BaseServiceImpl implements Patient } return 0.0; } + } -- 1.8.3.1