Commit 5a9ea04b9ec4b148e1982f496c009c79c66a6248

Authored by liquanyu
1 parent 50d3dc2022

update code

Showing 6 changed files with 246 additions and 0 deletions

platform-dal/src/main/java/com/lyms/platform/beans/SerialIdEnum.java View file @ 5a9ea04
... ... @@ -96,6 +96,7 @@
96 96 TemporaryWeightModel("TemporaryWeightModel", 97531049591L),
97 97 TemporaryBloodModel("TemporaryBloodModel", 97541049591L),
98 98 TemporaryBloodSugarModel("TemporaryWeightModel", 97551049591L),
  99 + DiabetesRecordModel("DiabetesRecordModel", 97551349591L),
99 100 BabyEyeCheck("BabyEyeCheck", 97521039591L),
100 101 WxMeasureInfoModel("WxMeasureInfoModel", 3394363185022868106L),
101 102 TemporaryUserModel("TemporaryUserModel", 3394363185022868107L),
platform-dal/src/main/java/com/lyms/platform/pojo/DiabetesRecordModel.java View file @ 5a9ea04
  1 +package com.lyms.platform.pojo;
  2 +
  3 +import com.lyms.platform.beans.SerialIdEnum;
  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 + */
  12 +@Document(collection = "lyms_diabetes_record")
  13 +public class DiabetesRecordModel extends BaseModel {
  14 + private static final long serialVersionUID = SerialIdEnum.DiabetesRecordModel.getCid();
  15 + private String id;
  16 +
  17 + private String patientId;
  18 +
  19 + private String hospitalId;
  20 +
  21 + private String pid;
  22 + //药物
  23 + private String medicine;
  24 +
  25 + private String breakfast;//早餐
  26 + private String breakfastAdd;//上午加餐
  27 + private String lunch;//午餐
  28 + private String lunchAdd;//下午加餐
  29 + private String dinner;//晚餐
  30 + private String dinnerAdd;//晚加餐
  31 +
  32 + private String sports; //运动
  33 +
  34 + private Date created;
  35 +
  36 + private Date modified;
  37 +
  38 + public String getId() {
  39 + return id;
  40 + }
  41 +
  42 + public void setId(String id) {
  43 + this.id = id;
  44 + }
  45 +
  46 + public String getPatientId() {
  47 + return patientId;
  48 + }
  49 +
  50 + public void setPatientId(String patientId) {
  51 + this.patientId = patientId;
  52 + }
  53 +
  54 + public String getHospitalId() {
  55 + return hospitalId;
  56 + }
  57 +
  58 + public void setHospitalId(String hospitalId) {
  59 + this.hospitalId = hospitalId;
  60 + }
  61 +
  62 + public String getPid() {
  63 + return pid;
  64 + }
  65 +
  66 + public void setPid(String pid) {
  67 + this.pid = pid;
  68 + }
  69 +
  70 + public String getMedicine() {
  71 + return medicine;
  72 + }
  73 +
  74 + public void setMedicine(String medicine) {
  75 + this.medicine = medicine;
  76 + }
  77 +
  78 + public String getBreakfast() {
  79 + return breakfast;
  80 + }
  81 +
  82 + public void setBreakfast(String breakfast) {
  83 + this.breakfast = breakfast;
  84 + }
  85 +
  86 + public String getBreakfastAdd() {
  87 + return breakfastAdd;
  88 + }
  89 +
  90 + public void setBreakfastAdd(String breakfastAdd) {
  91 + this.breakfastAdd = breakfastAdd;
  92 + }
  93 +
  94 + public String getLunch() {
  95 + return lunch;
  96 + }
  97 +
  98 + public void setLunch(String lunch) {
  99 + this.lunch = lunch;
  100 + }
  101 +
  102 + public String getLunchAdd() {
  103 + return lunchAdd;
  104 + }
  105 +
  106 + public void setLunchAdd(String lunchAdd) {
  107 + this.lunchAdd = lunchAdd;
  108 + }
  109 +
  110 + public String getDinner() {
  111 + return dinner;
  112 + }
  113 +
  114 + public void setDinner(String dinner) {
  115 + this.dinner = dinner;
  116 + }
  117 +
  118 + public String getDinnerAdd() {
  119 + return dinnerAdd;
  120 + }
  121 +
  122 + public void setDinnerAdd(String dinnerAdd) {
  123 + this.dinnerAdd = dinnerAdd;
  124 + }
  125 +
  126 + public String getSports() {
  127 + return sports;
  128 + }
  129 +
  130 + public void setSports(String sports) {
  131 + this.sports = sports;
  132 + }
  133 +
  134 + public Date getCreated() {
  135 + return created;
  136 + }
  137 +
  138 + public void setCreated(Date created) {
  139 + this.created = created;
  140 + }
  141 +
  142 + public Date getModified() {
  143 + return modified;
  144 + }
  145 +
  146 + public void setModified(Date modified) {
  147 + this.modified = modified;
  148 + }
  149 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/BloodSugarController.java View file @ 5a9ea04
... ... @@ -6,6 +6,7 @@
6 6 import com.lyms.platform.common.result.BaseResponse;
7 7 import com.lyms.platform.operate.web.service.IBloodSugarService;
8 8 import com.lyms.platform.pojo.BloodSugar;
  9 +import com.lyms.platform.pojo.DiabetesRecordModel;
9 10 import org.springframework.beans.factory.annotation.Autowired;
10 11 import org.springframework.stereotype.Controller;
11 12 import org.springframework.web.bind.annotation.*;
... ... @@ -137,6 +138,27 @@
137 138 public BaseResponse getBloodSugars(@PathVariable String doctorId,@PathVariable Integer type,@PathVariable Integer status,@RequestParam(required = false) String keyword) {
138 139 return bloodSugarService.getBloodSugars(doctorId, type, status, keyword);
139 140 }
  141 +
  142 +
  143 + /**
  144 + * 添加小程序糖尿病用药情况
  145 + * @param model
  146 + * @param request
  147 + * @return
  148 + */
  149 + @ResponseBody
  150 + @RequestMapping(value = "/addDiabetesRecord",method = RequestMethod.POST)
  151 + public BaseResponse addDiabetesRecord(@RequestBody DiabetesRecordModel model, HttpServletRequest request) {
  152 + return bloodSugarService.addDiabetesRecord(model);
  153 + }
  154 +
  155 +
  156 + @ResponseBody
  157 + @RequestMapping(value = "/queryDiabetesRecord/{patientId}",method = RequestMethod.GET)
  158 + public BaseResponse queryDiabetesRecord(@PathVariable String patientId, HttpServletRequest request) {
  159 + return bloodSugarService.queryDiabetesRecord(patientId);
  160 + }
  161 +
140 162  
141 163 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/DiabetesRecordResult.java View file @ 5a9ea04
  1 +package com.lyms.platform.operate.web.result;
  2 +
  3 +import com.lyms.platform.pojo.DiabetesRecordModel;
  4 +
  5 +/**
  6 + * Created by Administrator on 2020/2/17.
  7 + */
  8 +public class DiabetesRecordResult extends DiabetesRecordModel{
  9 +
  10 + private String createdStr;
  11 +
  12 + public String getCreatedStr() {
  13 + return createdStr;
  14 + }
  15 +
  16 + public void setCreatedStr(String createdStr) {
  17 + this.createdStr = createdStr;
  18 + }
  19 +}
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IBloodSugarService.java View file @ 5a9ea04
... ... @@ -2,6 +2,7 @@
2 2  
3 3 import com.lyms.platform.common.result.BaseResponse;
4 4 import com.lyms.platform.pojo.BloodSugar;
  5 +import com.lyms.platform.pojo.DiabetesRecordModel;
5 6  
6 7 import java.util.Date;
7 8 import java.util.List;
... ... @@ -36,5 +37,9 @@
36 37 BaseResponse getBloodSugars(String doctorId, Integer type, Integer status, String keyword);
37 38  
38 39 public BaseResponse notify( List<String> patientIds, Integer type);
  40 +
  41 + BaseResponse addDiabetesRecord(DiabetesRecordModel model);
  42 +
  43 + BaseResponse queryDiabetesRecord(String patientId);
39 44 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java View file @ 5a9ea04
... ... @@ -7,10 +7,12 @@
7 7 import com.lyms.platform.common.constants.ErrorCodeConstants;
8 8 import com.lyms.platform.common.enums.*;
9 9 import com.lyms.platform.common.result.*;
  10 +import com.lyms.platform.common.utils.BeanUtils;
10 11 import com.lyms.platform.common.utils.DateUtil;
11 12 import com.lyms.platform.common.utils.EnumUtil;
12 13 import com.lyms.platform.common.utils.StringUtils;
13 14 import com.lyms.platform.operate.web.facade.*;
  15 +import com.lyms.platform.operate.web.result.DiabetesRecordResult;
14 16 import com.lyms.platform.operate.web.service.IBloodSugarService;
15 17 import com.lyms.platform.operate.web.service.PatientWeightService;
16 18 import com.lyms.platform.operate.web.utils.CollectionUtils;
... ... @@ -39,6 +41,7 @@
39 41 import org.springframework.data.mongodb.core.query.Update;
40 42 import org.springframework.stereotype.Service;
41 43  
  44 +import java.lang.reflect.InvocationTargetException;
42 45 import java.math.BigDecimal;
43 46 import java.util.*;
44 47  
... ... @@ -1527,5 +1530,52 @@
1527 1530 return count;
1528 1531 }
1529 1532  
  1533 +
  1534 +
  1535 + @Override
  1536 + public BaseResponse addDiabetesRecord(DiabetesRecordModel model) {
  1537 + model.setCreated(new Date());
  1538 + model.setModified(new Date());
  1539 +
  1540 + if (model.getPatientId() != null)
  1541 + {
  1542 + Patients pat = patientsService.findOnePatientById(model.getPatientId());
  1543 + if (pat != null)
  1544 + {
  1545 + model.setPid(pat.getPid());
  1546 + }
  1547 + }
  1548 + mongoTemplate.save(model);
  1549 +
  1550 + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  1551 + }
  1552 +
  1553 +
  1554 + @Override
  1555 + public BaseResponse queryDiabetesRecord(String patientId) {
  1556 + Patients pat = patientsService.findOnePatientById(patientId);
  1557 + List<DiabetesRecordResult> list = new ArrayList<>();
  1558 + if (pat != null)
  1559 + {
  1560 + List<DiabetesRecordModel> recordModels = mongoTemplate.find(Query.query(Criteria.where("pid").is(pat.getPid())), DiabetesRecordModel.class);
  1561 + if (CollectionUtils.isNotEmpty(recordModels))
  1562 + {
  1563 + for(DiabetesRecordModel model : recordModels)
  1564 + {
  1565 + DiabetesRecordResult result = new DiabetesRecordResult();
  1566 + try {
  1567 + org.apache.commons.beanutils.BeanUtils.copyProperties(model,result);
  1568 + result.setCreatedStr(DateUtil.getyyyy_MM_dd(model.getCreated()));
  1569 + list.add(result);
  1570 + } catch (IllegalAccessException e) {
  1571 + e.printStackTrace();
  1572 + } catch (InvocationTargetException e) {
  1573 + e.printStackTrace();
  1574 + }
  1575 + }
  1576 + }
  1577 + }
  1578 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(list);
  1579 + }
1530 1580 }