Commit f0835e96f983192152912c93f8f5554c28e678a9
1 parent
a2f74831b8
Exists in
master
and in
6 other branches
update
Showing 4 changed files with 299 additions and 0 deletions
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/IndividualCaseController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/IndividualCaseResult.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IndividualCaseService.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/IndividualCaseServiceImpl.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/IndividualCaseController.java
View file @
f0835e9
1 | +package com.lyms.platform.operate.web.controller; | |
2 | + | |
3 | +import org.springframework.beans.factory.annotation.Autowired; | |
4 | +import org.springframework.stereotype.Controller; | |
5 | +import org.springframework.web.bind.annotation.RequestMapping; | |
6 | +import org.springframework.web.bind.annotation.RequestMethod; | |
7 | +import org.springframework.web.bind.annotation.ResponseBody; | |
8 | + | |
9 | +import com.lyms.platform.common.annotation.TokenRequired; | |
10 | +import com.lyms.platform.common.base.BaseController; | |
11 | +import com.lyms.platform.common.result.BaseResponse; | |
12 | +import com.lyms.platform.operate.web.service.IndividualCaseService; | |
13 | + | |
14 | +/** | |
15 | + * @author dongqin | |
16 | + * @description 个案 | |
17 | + * @date 15:59 2019/11/21 | |
18 | + **/ | |
19 | +@Controller | |
20 | +@RequestMapping("/individualCase") | |
21 | +public class IndividualCaseController extends BaseController { | |
22 | + | |
23 | + @Autowired | |
24 | + IndividualCaseService service; | |
25 | + | |
26 | + /** | |
27 | + * 产前妊娠风险评估记录 | |
28 | + * | |
29 | + * @param pid | |
30 | + * @return | |
31 | + */ | |
32 | + @RequestMapping(method = RequestMethod.GET, value = "/highRiskList") | |
33 | + @ResponseBody | |
34 | + @TokenRequired | |
35 | + public BaseResponse highRiskList(String pid) { | |
36 | + return service.highRiskList(pid); | |
37 | + } | |
38 | + | |
39 | + | |
40 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/IndividualCaseResult.java
View file @
f0835e9
1 | +package com.lyms.platform.operate.web.result; | |
2 | + | |
3 | +import java.io.Serializable; | |
4 | +import java.util.List; | |
5 | + | |
6 | +/** | |
7 | + * @author dongqin | |
8 | + * @description | |
9 | + * @date 13:50 2019/11/22 | |
10 | + **/ | |
11 | +public class IndividualCaseResult<T> implements Serializable { | |
12 | + | |
13 | + private static final long serialVersionUID = 1634160181617894592L; | |
14 | + | |
15 | + private String name; | |
16 | + | |
17 | + private String idCard; | |
18 | + | |
19 | + private String doctorStr; | |
20 | + | |
21 | + private List<T> list; | |
22 | + | |
23 | + private String highRiskDesc; | |
24 | + | |
25 | + private String timeAxisStr; | |
26 | + | |
27 | + public String getTimeAxisStr() { | |
28 | + return timeAxisStr; | |
29 | + } | |
30 | + | |
31 | + public void setTimeAxisStr(String timeAxisStr) { | |
32 | + this.timeAxisStr = timeAxisStr; | |
33 | + } | |
34 | + | |
35 | + public List<T> getList() { | |
36 | + return list; | |
37 | + } | |
38 | + | |
39 | + public void setList(List<T> list) { | |
40 | + this.list = list; | |
41 | + } | |
42 | + | |
43 | + public String getName() { | |
44 | + return name; | |
45 | + } | |
46 | + | |
47 | + public void setName(String name) { | |
48 | + this.name = name; | |
49 | + } | |
50 | + | |
51 | + public String getIdCard() { | |
52 | + return idCard; | |
53 | + } | |
54 | + | |
55 | + public void setIdCard(String idCard) { | |
56 | + this.idCard = idCard; | |
57 | + } | |
58 | + | |
59 | + public String getDoctorStr() { | |
60 | + return doctorStr; | |
61 | + } | |
62 | + | |
63 | + public void setDoctorStr(String doctorStr) { | |
64 | + this.doctorStr = doctorStr; | |
65 | + } | |
66 | + | |
67 | + public String getHighRiskDesc() { | |
68 | + return highRiskDesc; | |
69 | + } | |
70 | + | |
71 | + public void setHighRiskDesc(String highRiskDesc) { | |
72 | + this.highRiskDesc = highRiskDesc; | |
73 | + } | |
74 | + | |
75 | + public static class Infos { | |
76 | + private String level; | |
77 | + private String name; | |
78 | + private String desc; | |
79 | + | |
80 | + public String getDesc() { | |
81 | + return desc; | |
82 | + } | |
83 | + | |
84 | + public void setDesc(String desc) { | |
85 | + this.desc = desc; | |
86 | + } | |
87 | + | |
88 | + public String getLevel() { | |
89 | + return level; | |
90 | + } | |
91 | + | |
92 | + public void setLevel(String level) { | |
93 | + this.level = level; | |
94 | + } | |
95 | + | |
96 | + public String getName() { | |
97 | + return name; | |
98 | + } | |
99 | + | |
100 | + public void setName(String name) { | |
101 | + this.name = name; | |
102 | + } | |
103 | + } | |
104 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/IndividualCaseService.java
View file @
f0835e9
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/IndividualCaseServiceImpl.java
View file @
f0835e9
1 | +package com.lyms.platform.operate.web.service.impl; | |
2 | + | |
3 | +import java.util.Date; | |
4 | +import java.util.LinkedList; | |
5 | +import java.util.List; | |
6 | +import java.util.Map; | |
7 | + | |
8 | +import org.springframework.beans.factory.annotation.Autowired; | |
9 | +import org.springframework.data.domain.Sort; | |
10 | +import org.springframework.data.mongodb.core.MongoTemplate; | |
11 | +import org.springframework.data.mongodb.core.query.Criteria; | |
12 | +import org.springframework.data.mongodb.core.query.Query; | |
13 | +import org.springframework.stereotype.Service; | |
14 | + | |
15 | +import com.lyms.platform.biz.service.HosptialHighRiskService; | |
16 | +import com.lyms.platform.common.result.BaseResponse; | |
17 | +import com.lyms.platform.common.utils.DateUtil; | |
18 | +import com.lyms.platform.common.utils.JsonUtil; | |
19 | +import com.lyms.platform.common.utils.StringUtils; | |
20 | +import com.lyms.platform.operate.web.result.IndividualCaseResult; | |
21 | +import com.lyms.platform.operate.web.service.IndividualCaseService; | |
22 | +import com.lyms.platform.operate.web.utils.CollectionUtils; | |
23 | +import com.lyms.platform.operate.web.utils.ResolveUtils; | |
24 | +import com.lyms.platform.permission.model.Users; | |
25 | +import com.lyms.platform.permission.service.UsersService; | |
26 | +import com.lyms.platform.pojo.AntExChuModel; | |
27 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
28 | +import com.lyms.platform.pojo.BasicConfig; | |
29 | +import com.lyms.platform.pojo.HosptialHighRisk; | |
30 | +import com.lyms.platform.pojo.Patients; | |
31 | +import com.lyms.platform.pojo.PersonModel; | |
32 | + | |
33 | +@Service | |
34 | +public class IndividualCaseServiceImpl implements IndividualCaseService { | |
35 | + | |
36 | + @Autowired | |
37 | + private MongoTemplate mongoTemplate; | |
38 | + | |
39 | + @Autowired | |
40 | + private UsersService usersService; | |
41 | + | |
42 | + @Autowired | |
43 | + private HosptialHighRiskService hosptialHighRiskService; | |
44 | + | |
45 | + /** | |
46 | + * 产前妊娠风险评估记录 | |
47 | + * | |
48 | + * @param personId | |
49 | + * @return | |
50 | + */ | |
51 | + @Override | |
52 | + public BaseResponse highRiskList(String personId) { | |
53 | + | |
54 | + List<IndividualCaseResult> results = new LinkedList<>(); | |
55 | + List<PersonModel> personModels = mongoTemplate.find(Query.query(Criteria.where("id").is(personId)), PersonModel.class); | |
56 | + if (CollectionUtils.isNotEmpty(personModels)) { | |
57 | + List<Patients> patients = mongoTemplate.find(Query.query(Criteria.where("pid").is(personId)).with(new Sort(Sort.Direction.ASC, "created")), Patients.class); | |
58 | + if (CollectionUtils.isNotEmpty(patients)) { | |
59 | + Patients patient = patients.get(0); | |
60 | + String patientId = patient.getId(); | |
61 | + List<AntExChuModel> antExChuModels = mongoTemplate.find(Query.query(Criteria.where("parentId").is(patientId)), AntExChuModel.class); | |
62 | + if (CollectionUtils.isNotEmpty(antExChuModels)) { | |
63 | + AntExChuModel antExChuModel = antExChuModels.get(0); | |
64 | + String highRisks = antExChuModel.getHighrisk(); | |
65 | + String otherHighRisk = antExChuModel.getOtherHighRisk(); | |
66 | + IndividualCaseResult<IndividualCaseResult.Infos> result = getInfosIndividualCaseResult(patient, antExChuModel.getProdDoctor(), highRisks, antExChuModel.getHighriskDesc(), otherHighRisk, antExChuModel.getCheckTime()); | |
67 | + results.add(result); | |
68 | + | |
69 | + } | |
70 | + List<AntenatalExaminationModel> antenatalExaminationModels = mongoTemplate.find(Query.query(Criteria.where("parentId").is(patientId)).with(new Sort(Sort.Direction.ASC, "created")), AntenatalExaminationModel.class); | |
71 | + if (CollectionUtils.isNotEmpty(antenatalExaminationModels)) { | |
72 | + for (AntenatalExaminationModel examinationModel : antenatalExaminationModels) { | |
73 | + String riskFactors = examinationModel.getRiskFactor(); | |
74 | + String otherRisk = examinationModel.getOtherRisk(); | |
75 | + IndividualCaseResult<IndividualCaseResult.Infos> result = getInfosIndividualCaseResult(patient, examinationModel.getCheckDoctor(), riskFactors, examinationModel.getHighriskDesc(), otherRisk, examinationModel.getCheckDate()); | |
76 | + results.add(result); | |
77 | + | |
78 | + } | |
79 | + } | |
80 | + BaseResponse baseResponse = new BaseResponse(); | |
81 | + baseResponse.setObject(results); | |
82 | + return baseResponse; | |
83 | + | |
84 | + } | |
85 | + } | |
86 | + return new BaseResponse(); | |
87 | + } | |
88 | + | |
89 | + /** | |
90 | + * 组装返回至前端对象 | |
91 | + * | |
92 | + * @param patient 建档对象 | |
93 | + * @param doctor 产检医生id | |
94 | + * @param highRisks 高危ids | |
95 | + * @param highRiskDesc 高危说明 | |
96 | + * @param otherHighRisk 自定义高危 | |
97 | + * @param checkTime 产检时间 | |
98 | + * @return | |
99 | + */ | |
100 | + private IndividualCaseResult<IndividualCaseResult.Infos> getInfosIndividualCaseResult(Patients patient, String doctor, String highRisks, String highRiskDesc, String otherHighRisk, Date checkTime) { | |
101 | + List<String> list = JsonUtil.toList(highRisks, String.class); | |
102 | + IndividualCaseResult<IndividualCaseResult.Infos> result = new IndividualCaseResult<>(); | |
103 | + result.setName(patient.getUsername()); | |
104 | + result.setIdCard(patient.getCardNo()); | |
105 | + Users users = usersService.getUsers(Integer.parseInt(doctor)); | |
106 | + result.setDoctorStr(users.getName()); | |
107 | + result.setHighRiskDesc(highRiskDesc); | |
108 | + if (checkTime != null) { | |
109 | + result.setTimeAxisStr(DateUtil.getyyyy_MM_dd(checkTime)); | |
110 | + } | |
111 | + List<IndividualCaseResult.Infos> infos = new LinkedList<>(); | |
112 | + for (String higRisk : list) { | |
113 | + IndividualCaseResult.Infos info = new IndividualCaseResult.Infos(); | |
114 | + BasicConfig basicConfig = mongoTemplate.findOne(Query.query(Criteria.where("id").is(higRisk)), BasicConfig.class); | |
115 | + info.setName(basicConfig.getName()); | |
116 | + BasicConfig typeConfig = mongoTemplate.findOne(Query.query(Criteria.where("id").is(basicConfig.getParentId())), BasicConfig.class); | |
117 | + info.setLevel(typeConfig.getWeight().toString()); | |
118 | + info.setDesc(typeConfig.getName()); | |
119 | + infos.add(info); | |
120 | + } | |
121 | + if (StringUtils.isNotEmpty(otherHighRisk)) { | |
122 | + List<Map<String, Object>> mapList = new LinkedList<>(); | |
123 | + List<Map<String, Object>> maps = ResolveUtils.queryOtherRisk(otherHighRisk, mapList); | |
124 | + for (Map<String, Object> map : maps) { | |
125 | + // {"fxysu":"123123","fyyse":"49a36aea-c5b6-4162-87d2-9eb3c6ec00c2","fxpf":"5769f0640cf2d37f034793a3","otherId":"5a5872d2c07de7aba3b5f505"} | |
126 | + String otherId = map.get("otherId").toString(); | |
127 | + HosptialHighRisk hosptialHighRisk = hosptialHighRiskService.getOneHosptialHighRiskById(otherId); | |
128 | + BasicConfig basicConfig = mongoTemplate.findOne(Query.query(Criteria.where("id").is(hosptialHighRisk.getColor())), BasicConfig.class); | |
129 | + IndividualCaseResult.Infos info = new IndividualCaseResult.Infos(); | |
130 | + info.setName(hosptialHighRisk.getName()); | |
131 | + info.setLevel(basicConfig.getWeight().toString()); | |
132 | + info.setDesc(basicConfig.getName()); | |
133 | + infos.add(info); | |
134 | + } | |
135 | + } | |
136 | + result.setList(infos); | |
137 | + return result; | |
138 | + } | |
139 | + | |
140 | + | |
141 | +} |