Commit 76ebedf37746896d6b6aa6885d8bd9629e56acfe
1 parent
1e535fea25
Exists in
master
and in
6 other branches
妊高症查询接口提交
Showing 5 changed files with 203 additions and 12 deletions
- platform-dal/src/main/java/com/lyms/platform/pojo/PihParameterModel.java
- platform-dal/src/main/java/com/lyms/platform/query/PihQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/pihController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PihService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PihServiceImpl.java
platform-dal/src/main/java/com/lyms/platform/pojo/PihParameterModel.java
View file @
76ebedf
... | ... | @@ -3,6 +3,8 @@ |
3 | 3 | |
4 | 4 | import org.springframework.data.mongodb.core.mapping.Document; |
5 | 5 | |
6 | +import java.util.Date; | |
7 | + | |
6 | 8 | @Document(collection = "lyms_pin_parameter") |
7 | 9 | public class PihParameterModel { |
8 | 10 | |
... | ... | @@ -34,6 +36,43 @@ |
34 | 36 | private String pid;//病人id |
35 | 37 | private String hospitalId;//医院id |
36 | 38 | private String IDCard;//病人身份证号 |
39 | + private Date created;//创建时间 | |
40 | + | |
41 | + private Date modified; //修改时间 | |
42 | + | |
43 | + private String yn; | |
44 | + | |
45 | + public String getIDCard() { | |
46 | + return IDCard; | |
47 | + } | |
48 | + | |
49 | + public void setIDCard(String IDCard) { | |
50 | + this.IDCard = IDCard; | |
51 | + } | |
52 | + | |
53 | + public Date getCreated() { | |
54 | + return created; | |
55 | + } | |
56 | + | |
57 | + public void setCreated(Date created) { | |
58 | + this.created = created; | |
59 | + } | |
60 | + | |
61 | + public Date getModified() { | |
62 | + return modified; | |
63 | + } | |
64 | + | |
65 | + public void setModified(Date modified) { | |
66 | + this.modified = modified; | |
67 | + } | |
68 | + | |
69 | + public String getYn() { | |
70 | + return yn; | |
71 | + } | |
72 | + | |
73 | + public void setYn(String yn) { | |
74 | + this.yn = yn; | |
75 | + } | |
37 | 76 | |
38 | 77 | public String getPid() { |
39 | 78 | return pid; |
platform-dal/src/main/java/com/lyms/platform/query/PihQuery.java
View file @
76ebedf
1 | +package com.lyms.platform.query; | |
2 | + | |
3 | +import com.lyms.platform.common.base.IConvertToNativeQuery; | |
4 | +import com.lyms.platform.common.dao.BaseQuery; | |
5 | +import com.lyms.platform.common.dao.operator.MongoCondition; | |
6 | +import com.lyms.platform.common.dao.operator.MongoOper; | |
7 | +import com.lyms.platform.common.dao.operator.MongoQuery; | |
8 | + | |
9 | +import java.util.Date; | |
10 | + | |
11 | +public class PihQuery extends BaseQuery implements IConvertToNativeQuery { | |
12 | + private String id; | |
13 | + | |
14 | + private String username;//姓名 | |
15 | + | |
16 | + private String age; | |
17 | + | |
18 | + private String week; | |
19 | + | |
20 | + private String riskLevelId;//高危因素等级 | |
21 | + | |
22 | + private String riskFactorId;//高危因素 | |
23 | + | |
24 | + private String blood;//血压 | |
25 | + | |
26 | + private String type; | |
27 | + | |
28 | + private Date created;//创建时间 | |
29 | + | |
30 | + private Date modified; //修改时间 | |
31 | + | |
32 | + private String hospitalId;//医院id | |
33 | + | |
34 | + @Override | |
35 | + public MongoQuery convertToQuery() { | |
36 | + MongoCondition condition = MongoCondition.newInstance(); | |
37 | + if (null != hospitalId) { | |
38 | + condition = condition.and("hospitalId", hospitalId, MongoOper.IS); | |
39 | + } | |
40 | + if (null != type) { | |
41 | + condition = condition.and("type", type, MongoOper.IS); | |
42 | + } | |
43 | + return condition.toMongoQuery(); | |
44 | + } | |
45 | + | |
46 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/pihController.java
View file @
76ebedf
1 | 1 | package com.lyms.platform.operate.web.controller; |
2 | 2 | |
3 | +import com.lyms.platform.common.annotation.TokenRequired; | |
3 | 4 | import com.lyms.platform.common.base.BaseController; |
5 | +import com.lyms.platform.common.base.LoginContext; | |
4 | 6 | import com.lyms.platform.common.result.BaseResponse; |
7 | +import com.lyms.platform.common.result.RespBuilder; | |
8 | +import com.lyms.platform.common.utils.StringUtils; | |
5 | 9 | import com.lyms.platform.operate.web.service.PihService; |
6 | 10 | import com.lyms.platform.pojo.PihParameterModel; |
7 | 11 | import org.springframework.beans.factory.annotation.Autowired; |
8 | 12 | import org.springframework.stereotype.Controller; |
9 | -import org.springframework.web.bind.annotation.RequestBody; | |
13 | +import org.springframework.util.Assert; | |
10 | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
11 | 15 | import org.springframework.web.bind.annotation.RequestMethod; |
12 | 16 | import org.springframework.web.bind.annotation.ResponseBody; |
13 | 17 | |
14 | -import javax.validation.Valid; | |
18 | +import javax.servlet.http.HttpServletRequest; | |
15 | 19 | |
16 | 20 | |
17 | 21 | @Controller |
18 | 22 | |
19 | 23 | |
20 | 24 | |
21 | 25 | |
... | ... | @@ -24,24 +28,31 @@ |
24 | 28 | |
25 | 29 | @ResponseBody |
26 | 30 | @RequestMapping(value = "/add", method = RequestMethod.POST) |
27 | - public void addPih(@Valid @RequestBody PihParameterModel parameterModel) { | |
31 | + public void addPih(PihParameterModel parameterModel) { | |
28 | 32 | pihService.addPih(parameterModel); |
29 | 33 | } |
30 | 34 | |
31 | 35 | |
32 | 36 | @RequestMapping(value = "/query", method = RequestMethod.GET) |
33 | 37 | @ResponseBody |
34 | - public BaseResponse queryAllPih() { | |
35 | - | |
36 | - | |
37 | - return null; | |
38 | + @TokenRequired | |
39 | + public BaseResponse queryAllPih(String key, Integer age, Integer weekEnd, Integer weekStart, String type, String no, Integer page, Integer limit, HttpServletRequest request) { | |
40 | + return pihService.queyAll(key, weekStart, weekEnd, age, type, no, page, limit, getUserId(request)); | |
38 | 41 | } |
39 | 42 | |
40 | 43 | @ResponseBody |
41 | - @RequestMapping(value = "/queyrInfo", method = RequestMethod.GET) | |
44 | + @RequestMapping(value = "/queryInfo", method = RequestMethod.GET) | |
42 | 45 | public BaseResponse query(String cardNo) { |
43 | - return pihService.queryInfo(cardNo); | |
46 | + if (StringUtils.isNotEmpty(cardNo)) { | |
47 | + return pihService.queryInfo(cardNo); | |
48 | + } | |
49 | + return RespBuilder.buildSuccess("请输入查询条件!"); | |
44 | 50 | } |
45 | 51 | |
52 | + protected Integer getUserId(HttpServletRequest request) { | |
53 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
54 | + Assert.notNull(loginState, "未登录"); | |
55 | + return loginState.getId(); | |
56 | + } | |
46 | 57 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/PihService.java
View file @
76ebedf
... | ... | @@ -7,5 +7,8 @@ |
7 | 7 | public void addPih(PihParameterModel parameterModel); |
8 | 8 | |
9 | 9 | public BaseResponse queryInfo(String cardNo); |
10 | + | |
11 | + public BaseResponse queyAll(String key, Integer weekStart, Integer weekEnd, Integer age, String type, String no, Integer page, Integer limit, Integer userId); | |
12 | + | |
10 | 13 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/PihServiceImpl.java
View file @
76ebedf
1 | 1 | package com.lyms.platform.operate.web.service.impl; |
2 | 2 | |
3 | +import com.alibaba.druid.proxy.jdbc.JdbcParameter; | |
4 | +import com.lyms.platform.biz.service.CommonService; | |
3 | 5 | import com.lyms.platform.common.result.BaseResponse; |
6 | +import com.lyms.platform.common.result.PageResult; | |
4 | 7 | import com.lyms.platform.common.result.RespBuilder; |
8 | +import com.lyms.platform.common.utils.DateUtil; | |
9 | +import com.lyms.platform.common.utils.StringUtils; | |
10 | +import com.lyms.platform.operate.web.facade.OrganizationGroupsFacade; | |
5 | 11 | import com.lyms.platform.operate.web.service.PihService; |
12 | +import com.lyms.platform.operate.web.utils.MongoUtil; | |
6 | 13 | import com.lyms.platform.pojo.Patients; |
7 | 14 | import com.lyms.platform.pojo.PihParameterModel; |
8 | 15 | import org.springframework.beans.factory.annotation.Autowired; |
16 | +import org.springframework.data.domain.Sort; | |
9 | 17 | import org.springframework.data.mongodb.core.MongoTemplate; |
10 | 18 | import org.springframework.data.mongodb.core.query.Criteria; |
11 | 19 | import org.springframework.data.mongodb.core.query.Query; |
12 | 20 | import org.springframework.stereotype.Service; |
13 | 21 | |
14 | -import java.util.HashMap; | |
15 | -import java.util.Map; | |
22 | +import java.util.*; | |
16 | 23 | |
17 | 24 | @Service |
18 | 25 | public class PihServiceImpl extends BaseServiceImpl implements PihService { |
19 | 26 | |
20 | 27 | |
... | ... | @@ -20,10 +27,20 @@ |
20 | 27 | @Autowired |
21 | 28 | private MongoTemplate mongoTemplate; |
22 | 29 | |
30 | + @Autowired | |
31 | + private OrganizationGroupsFacade groupsFacade; | |
32 | + | |
33 | + @Autowired | |
34 | + private CommonService commonService; | |
35 | + | |
36 | + @Autowired | |
37 | + private MongoUtil mongoUtil; | |
38 | + | |
23 | 39 | @Override |
24 | 40 | public void addPih(PihParameterModel parameterModel) { |
41 | + parameterModel.setYn("1"); | |
42 | + parameterModel.setCreated(new Date()); | |
25 | 43 | mongoTemplate.save(parameterModel); |
26 | - | |
27 | 44 | } |
28 | 45 | |
29 | 46 | @Override |
... | ... | @@ -40,6 +57,81 @@ |
40 | 57 | return RespBuilder.buildSuccess(map); |
41 | 58 | } |
42 | 59 | return RespBuilder.buildSuccess("没有此人信息"); |
60 | + } | |
61 | + | |
62 | + @Override | |
63 | + public BaseResponse queyAll(String key, Integer weekStart, Integer weekEnd, Integer age, String type, String vcCardNo, Integer page, Integer limit, Integer userId) { | |
64 | + boolean flag = false; | |
65 | + List<String> hospital = groupsFacade.findGroupHospital(userId, false); | |
66 | + Criteria criteria = Criteria.where("yn").is("1").and("hospitalId").in(hospital); | |
67 | + Criteria pCriteria = Criteria.where("yn").is(1).and("hospitalId").in(hospital); | |
68 | + if (org.apache.commons.lang.StringUtils.isNotBlank(key)) { | |
69 | + pCriteria.orOperator(Criteria.where("phone").regex(key), Criteria.where("username").regex(key), Criteria.where("vcCardNo").regex(key)); | |
70 | + flag = true; | |
71 | + } | |
72 | + if (weekStart != null && weekEnd != null) { | |
73 | + Date start = DateUtil.getWeekStart(weekEnd); | |
74 | + Date end = DateUtil.getWeekEnd(weekStart); | |
75 | + pCriteria.and("lastMenses").gt(start).lte(end); | |
76 | + flag = true; | |
77 | + } | |
78 | + if (age != null) { | |
79 | + Date start = DateUtil.getBeforeAge(age); | |
80 | + Date end = DateUtil.getBeforeAge(age + 1); | |
81 | + pCriteria.and("birth").gt(end).lte(start); | |
82 | + flag = true; | |
83 | + } | |
84 | + if (StringUtils.isNotEmpty(type)) { | |
85 | + criteria.and("parameterResult").is(type); | |
86 | + } | |
87 | + if (flag) { | |
88 | + List<Patients> pihParameter = mongoTemplate.find(Query.query(pCriteria), Patients.class); | |
89 | + List<String> ids = new ArrayList<>(); | |
90 | + if (com.lyms.platform.operate.web.utils.CollectionUtils.isNotEmpty(pihParameter)) { | |
91 | + for (Patients pih : pihParameter) { | |
92 | + ids.add(pih.getId()); | |
93 | + } | |
94 | + } | |
95 | + criteria.and("pid").in(ids); | |
96 | + } | |
97 | + PageResult pageResult = findMongoPage(PihParameterModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "modified")), page, limit); | |
98 | + List<PihParameterModel> pihParameterModelList = (List<PihParameterModel>) pageResult.getGrid(); | |
99 | + List<Map<String, Object>> restList = new ArrayList<>(); | |
100 | + for (PihParameterModel pihParameterModel : pihParameterModelList) { | |
101 | + Map<String, Object> map = new HashMap(); | |
102 | + Patients patients = mongoTemplate.findOne(Query.query(Criteria.where("_id").is(pihParameterModel.getPid())), Patients.class); | |
103 | + if (null != patients) { | |
104 | + map.put("id", pihParameterModel.getId()); | |
105 | + map.put("username", patients.getUsername()); | |
106 | + map.put("age", patients.getAge()); | |
107 | + map.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); | |
108 | + map.put("riskLevel", commonService.findRiskLevel(patients.getRiskLevelId())); | |
109 | + String rFactor = commonService.resloveFactor(patients.getRiskFactorId()); | |
110 | + if (patients.getoRiskFactor() != null && !"null".equals(patients.getoRiskFactor())) { | |
111 | + if (StringUtils.isNotEmpty(rFactor)) { | |
112 | + rFactor += "," + patients.getoRiskFactor(); | |
113 | + } else { | |
114 | + rFactor = patients.getoRiskFactor(); | |
115 | + } | |
116 | + } | |
117 | + map.put("riskFactor", rFactor); // 高危因素 | |
118 | + } | |
119 | + map.put("blood", pihParameterModel.getSsyBT() + "/" + pihParameterModel.getSzyBT() + "mmHg"); | |
120 | + if (StringUtils.isNotEmpty(pihParameterModel.getParameterResult())) | |
121 | + | |
122 | + if (pihParameterModel.getParameterResult().equals("1")) { | |
123 | + map.put("type", "阴性"); | |
124 | + } else if (pihParameterModel.getParameterResult().equals("2")) { | |
125 | + map.put("type", "阳性"); | |
126 | + } else if (pihParameterModel.getParameterResult().equals("3")) { | |
127 | + map.put("type", "可疑"); | |
128 | + } | |
129 | + map.put("time", DateUtil.getyyyy_MM_dd(pihParameterModel.getCreated())); | |
130 | + | |
131 | + restList.add(map); | |
132 | + } | |
133 | + pageResult.setGrid(restList); | |
134 | + return RespBuilder.buildSuccess(pageResult); | |
43 | 135 | } |
44 | 136 | |
45 | 137 | } |