Commit b6a7cc45a21f8a17f4b8288bddd53499393b548e
1 parent
bd63623e05
Exists in
master
and in
1 other branch
update
Showing 5 changed files with 308 additions and 6 deletions
- platform-dal/src/main/java/com/lyms/platform/query/ResidentsArchiveQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PremaritalCheckupController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ResidentArchivesRegionController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ResidentsArchiveController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ResidentsFacade.java
platform-dal/src/main/java/com/lyms/platform/query/ResidentsArchiveQuery.java
View file @
b6a7cc4
... | ... | @@ -8,7 +8,9 @@ |
8 | 8 | import org.apache.commons.lang.StringUtils; |
9 | 9 | import org.springframework.data.mongodb.core.query.Criteria; |
10 | 10 | |
11 | +import javax.validation.constraints.Min; | |
11 | 12 | import java.util.Date; |
13 | +import java.util.List; | |
12 | 14 | |
13 | 15 | /** |
14 | 16 | * Created by Administrator on 2016/11/9 0009. |
... | ... | @@ -102,6 +104,12 @@ |
102 | 104 | |
103 | 105 | private String publishName; |
104 | 106 | |
107 | + //年龄 | |
108 | + private Integer ageMin; | |
109 | + private Integer ageMax; | |
110 | + | |
111 | + private List<String> hospitalIds; | |
112 | + | |
105 | 113 | @Override |
106 | 114 | public MongoQuery convertToQuery() { |
107 | 115 | MongoCondition condition = MongoCondition.newInstance(); |
... | ... | @@ -111,6 +119,9 @@ |
111 | 119 | if (StringUtils.isNotBlank(username)) { |
112 | 120 | condition = condition.and("username", username, MongoOper.LIKE); |
113 | 121 | } |
122 | + if (hospitalIds!=null) { | |
123 | + condition = condition.and("hospitalId", hospitalIds, MongoOper.IN); | |
124 | + } | |
114 | 125 | if (StringUtils.isNotBlank(phone)) { |
115 | 126 | condition = condition.and("phone", phone, MongoOper.IS); |
116 | 127 | } |
117 | 128 | |
... | ... | @@ -155,10 +166,45 @@ |
155 | 166 | c1 = c1.lte(birthdayEnd); |
156 | 167 | } |
157 | 168 | } |
169 | + if (null!=ageMin){ | |
170 | + c1 = Criteria.where("age").gte(ageMin); | |
171 | + } | |
172 | + if(null!=ageMax){ | |
173 | + if (null==c1) { | |
174 | + c1 = Criteria.where("age").lte(ageMax); | |
175 | + } else { | |
176 | + c1 = c1.lte(ageMax); | |
177 | + } | |
178 | + } | |
179 | + | |
158 | 180 | if (c1!=null) { |
159 | 181 | condition = condition.andCondition(new MongoCondition(c1)); |
160 | 182 | } |
161 | 183 | return condition.toMongoQuery(); |
184 | + } | |
185 | + | |
186 | + public List<String> getHospitalIds() { | |
187 | + return hospitalIds; | |
188 | + } | |
189 | + | |
190 | + public void setHospitalIds(List<String> hospitalIds) { | |
191 | + this.hospitalIds = hospitalIds; | |
192 | + } | |
193 | + | |
194 | + public Integer getAgeMin() { | |
195 | + return ageMin; | |
196 | + } | |
197 | + | |
198 | + public void setAgeMin(Integer ageMin) { | |
199 | + this.ageMin = ageMin; | |
200 | + } | |
201 | + | |
202 | + public Integer getAgeMax() { | |
203 | + return ageMax; | |
204 | + } | |
205 | + | |
206 | + public void setAgeMax(Integer ageMax) { | |
207 | + this.ageMax = ageMax; | |
162 | 208 | } |
163 | 209 | |
164 | 210 | public Integer getAge() { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PremaritalCheckupController.java
View file @
b6a7cc4
... | ... | @@ -41,7 +41,7 @@ |
41 | 41 | @TokenRequired |
42 | 42 | public BaseResponse addOrUpdatePremaritalCheckup(@RequestBody PremaritalCheckupAddRequest addRequest, |
43 | 43 | HttpServletRequest request){ |
44 | - //获取当前登录用户ID | |
44 | +// 获取当前登录用户ID | |
45 | 45 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
46 | 46 | |
47 | 47 | return premaritalCheckupFacade.addPremaritalCheckup(addRequest , loginState.getId()); |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ResidentArchivesRegionController.java
View file @
b6a7cc4
... | ... | @@ -4,7 +4,9 @@ |
4 | 4 | import com.lyms.platform.common.base.BaseController; |
5 | 5 | import com.lyms.platform.common.base.LoginContext; |
6 | 6 | import com.lyms.platform.common.result.BaseResponse; |
7 | +import com.lyms.platform.operate.web.facade.ResidentsFacade; | |
7 | 8 | import com.lyms.platform.operate.web.request.ResidentsArchiveQueryRequest; |
9 | +import org.springframework.beans.factory.annotation.Autowired; | |
8 | 10 | import org.springframework.stereotype.Controller; |
9 | 11 | import org.springframework.web.bind.annotation.RequestMapping; |
10 | 12 | import org.springframework.web.bind.annotation.RequestMethod; |
11 | 13 | |
12 | 14 | |
... | ... | @@ -22,13 +24,22 @@ |
22 | 24 | @Controller |
23 | 25 | public class ResidentArchivesRegionController extends BaseController{ |
24 | 26 | |
25 | - @RequestMapping(value = "/r", method = RequestMethod.GET) | |
27 | + @Autowired | |
28 | + private ResidentsFacade residentsFacade; | |
29 | + | |
30 | + /** | |
31 | + * 妇女健康档案管理 | |
32 | + * | |
33 | + * @param queryRequest | |
34 | + * @param request | |
35 | + * @return | |
36 | + */ | |
37 | + @RequestMapping(value = "/regionalWomenList", method = RequestMethod.GET) | |
26 | 38 | @ResponseBody |
27 | 39 | @TokenRequired |
28 | - public BaseResponse queryAllPuerpera(@Valid ResidentsArchiveQueryRequest queryRequest,HttpServletRequest request) { | |
40 | + public BaseResponse queryAllResidents(@Valid ResidentsArchiveQueryRequest queryRequest,HttpServletRequest request) { | |
29 | 41 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
30 | -// return residentsArchiveFacade.queryResidentsArchives(residentsArchiveQueryRequest,loginState.getId(),"true"); | |
31 | - return null; | |
42 | + return residentsFacade.queryResidentsArchives(queryRequest,loginState.getId()); | |
32 | 43 | } |
33 | 44 | |
34 | 45 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/ResidentsArchiveController.java
View file @
b6a7cc4
... | ... | @@ -121,7 +121,7 @@ |
121 | 121 | @RequestMapping(value = "/residentsArchiveList", method = RequestMethod.GET) |
122 | 122 | @ResponseBody |
123 | 123 | @TokenRequired |
124 | - public BaseResponse queryAllPuerpera(@Valid ResidentsArchiveQueryRequest residentsArchiveQueryRequest,HttpServletRequest request) { | |
124 | + public BaseResponse queryAllResidents(@Valid ResidentsArchiveQueryRequest residentsArchiveQueryRequest,HttpServletRequest request) { | |
125 | 125 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
126 | 126 | return residentsArchiveFacade.queryResidentsArchives(residentsArchiveQueryRequest,loginState.getId(),"true"); |
127 | 127 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/ResidentsFacade.java
View file @
b6a7cc4
1 | +package com.lyms.platform.operate.web.facade; | |
2 | + | |
3 | +import com.lyms.platform.biz.service.*; | |
4 | +import com.lyms.platform.common.constants.ErrorCodeConstants; | |
5 | +import com.lyms.platform.common.enums.YnEnums; | |
6 | +import com.lyms.platform.common.result.BaseListResponse; | |
7 | +import com.lyms.platform.common.result.BaseObjectResponse; | |
8 | +import com.lyms.platform.common.result.BaseResponse; | |
9 | +import com.lyms.platform.common.utils.DateUtil; | |
10 | +import com.lyms.platform.operate.web.request.ResidentsArchiveQueryRequest; | |
11 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
12 | +import com.lyms.platform.permission.model.Organization; | |
13 | +import com.lyms.platform.permission.model.OrganizationQuery; | |
14 | +import com.lyms.platform.permission.service.OrganizationService; | |
15 | +import com.lyms.platform.pojo.AntExChuModel; | |
16 | +import com.lyms.platform.pojo.DataPermissionsModel; | |
17 | +import com.lyms.platform.pojo.Patients; | |
18 | +import com.lyms.platform.pojo.ResidentsArchiveModel; | |
19 | +import com.lyms.platform.query.AntExChuQuery; | |
20 | +import com.lyms.platform.query.DataPermissionsModelQuery; | |
21 | +import com.lyms.platform.query.PatientsQuery; | |
22 | +import com.lyms.platform.query.ResidentsArchiveQuery; | |
23 | +import org.apache.commons.collections.CollectionUtils; | |
24 | +import org.apache.commons.lang.StringUtils; | |
25 | +import org.springframework.beans.factory.annotation.Autowired; | |
26 | +import org.springframework.stereotype.Component; | |
27 | + | |
28 | +import java.util.*; | |
29 | + | |
30 | +/** | |
31 | + * Created by Administrator on 2016/12/20 0020. | |
32 | + */ | |
33 | +@Component | |
34 | +public class ResidentsFacade { | |
35 | + | |
36 | + @Autowired | |
37 | + private OrganizationService organizationService; | |
38 | + @Autowired | |
39 | + private AutoMatchFacade autoMatchFacade; | |
40 | + @Autowired | |
41 | + private DataPermissionService dataPermissionService; | |
42 | + @Autowired | |
43 | + private ResidentsArchiveService residentsArchiveService; | |
44 | + @Autowired | |
45 | + private BasicConfigService basicConfigService; | |
46 | + @Autowired | |
47 | + private PatientsService patientsService; | |
48 | + @Autowired | |
49 | + private AntenatalExaminationService antenatalExaminationService; | |
50 | + | |
51 | + | |
52 | + | |
53 | + /** | |
54 | + * 妇女健康档案管理 | |
55 | + * | |
56 | + * @param request | |
57 | + * @param userId | |
58 | + * @return | |
59 | + */ | |
60 | + public BaseResponse queryResidentsArchives(ResidentsArchiveQueryRequest request,Integer userId){ | |
61 | + | |
62 | + /* | |
63 | + 记录孕次,用查询出来的妇女身份证,去patients表中查询是否建档,如果已经建档,孕次返回默认1,如果有初诊记录,返回初诊中的孕次, | |
64 | + 如果没有建档,返回 "-" | |
65 | + */ | |
66 | + ResidentsArchiveQuery query = new ResidentsArchiveQuery(); | |
67 | + query.setPage(request.getPage()); | |
68 | + query.setLimit(request.getLimit()); | |
69 | + query.setNeed("y"); | |
70 | + query.setYn(YnEnums.YES.getId()); | |
71 | + | |
72 | + //出生日期范围查询 | |
73 | + if(StringUtils.isNotEmpty(request.getBirthday())){ | |
74 | + String[] dates = request.getBirthday().split(" - "); | |
75 | + query.setBirthdayStart(DateUtil.parseYMD(dates[0])); | |
76 | + if(dates.length>=2){ | |
77 | + Date date= DateUtil.parseYMD(dates[1]); | |
78 | + if(null!=date){ | |
79 | + long d = date.getTime() + 86398000; | |
80 | + date = new Date(d); | |
81 | + } | |
82 | + query.setBirthdayEnd(date); | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + //年龄范围查询 | |
87 | + if (StringUtils.isNotEmpty(request.getAge())){ | |
88 | + String[] ages = request.getAge().split(" - "); | |
89 | + query.setAgeMin(Integer.parseInt(ages[0])); | |
90 | + if (ages.length>=2){ | |
91 | + Integer ageMax = Integer.parseInt(ages[1]); | |
92 | + query.setAgeMax(ageMax); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + //户籍地 | |
97 | + query.setProvinceRegisterId(request.getProvinceRegisterId()); | |
98 | + query.setCityRegisterId(request.getCityRegisterId()); | |
99 | + query.setAreaRegisterId(request.getAreaRegisterId()); | |
100 | + | |
101 | + //居住地 | |
102 | + query.setProvinceId(request.getProvinceId()); | |
103 | + query.setCityId(request.getCityId()); | |
104 | + query.setAreaId(request.getAreaId()); | |
105 | + | |
106 | + List<Map<String,Object>> list = new ArrayList<>(); | |
107 | + | |
108 | + List<Organization> organizationList = null; | |
109 | + //建档机构 | |
110 | + | |
111 | + List<String> hospitalList = null; | |
112 | + if (userId!=null){ | |
113 | + hospitalList = new ArrayList<>(); | |
114 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
115 | + if(null!=hospital){ | |
116 | + //当前用户本院 | |
117 | + hospitalList.add(hospital); | |
118 | + } | |
119 | + | |
120 | + //查询用户是否有区域权限 | |
121 | + DataPermissionsModelQuery dataPermissionsModelQuery = new DataPermissionsModelQuery(); | |
122 | + dataPermissionsModelQuery.setUserId(userId); | |
123 | + List<DataPermissionsModel> permissionsModels = dataPermissionService.queryPermission(dataPermissionsModelQuery); | |
124 | + if (CollectionUtils.isNotEmpty(permissionsModels)) { | |
125 | + Set<String> set = permissionsModels.get(0).getData().keySet(); | |
126 | + Iterator<String> it = set.iterator(); | |
127 | + while (it.hasNext()) { | |
128 | + String id = it.next(); | |
129 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) { | |
130 | + hospitalList.add(id); | |
131 | + } | |
132 | + } | |
133 | + } | |
134 | + | |
135 | + //指定医院 | |
136 | + if (StringUtils.isNotEmpty(request.getHospitalId())){ | |
137 | + List<String> orgId = new ArrayList<>(); | |
138 | + orgId.add(request.getHospitalId()); | |
139 | + hospitalList.retainAll(orgId); | |
140 | + } | |
141 | + | |
142 | + //省市区筛选机构 | |
143 | + if (StringUtils.isNotEmpty(request.getBuildProvinceId()) || StringUtils.isNotEmpty(request.getBuildCityId()) || | |
144 | + StringUtils.isNotEmpty(request.getBuildAreaId())){ | |
145 | + OrganizationQuery organizationQuery = new OrganizationQuery(); | |
146 | + organizationQuery.setYn(YnEnums.YES.getId()); | |
147 | + organizationQuery.setProvinceId(request.getBuildProvinceId()); | |
148 | + organizationQuery.setCityId(request.getBuildCityId()); | |
149 | + organizationQuery.setAreaId(request.getBuildAreaId()); | |
150 | + organizationList = new ArrayList<>(); | |
151 | + organizationList = organizationService.queryHospitals(organizationQuery); | |
152 | + } | |
153 | + if (organizationList!=null){ | |
154 | + List<String> orgId = new ArrayList<>(); | |
155 | + if (CollectionUtils.isNotEmpty(organizationList)) { | |
156 | + for (Organization org : organizationList) { | |
157 | + if (null != org.getId()) { | |
158 | + orgId.add(org.getId() + ""); | |
159 | + } | |
160 | + } | |
161 | + } | |
162 | + hospitalList.retainAll(orgId); | |
163 | + } | |
164 | + | |
165 | + query.setHospitalIds(hospitalList); | |
166 | + } | |
167 | + | |
168 | + List<ResidentsArchiveModel> modelList = residentsArchiveService.queryResident(query); | |
169 | + if (CollectionUtils.isNotEmpty(modelList)){ | |
170 | + for (ResidentsArchiveModel model : modelList){ | |
171 | + Map<String,Object> map = new HashMap<>(); | |
172 | + map.put("username",model.getUsername()); | |
173 | + map.put("certificateNum",model.getCertificateNum()); | |
174 | + map.put("age",DateUtil.getAge(model.getBirthday())); | |
175 | + map.put("householdRegister", CommonsHelper.getResidence(model.getProvinceRegisterId(), model.getCityId(), | |
176 | + model.getAreaRegisterId(), model.getStreetRegisterId(), model.getAddressRegister(), basicConfigService)); | |
177 | + map.put("Residence", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(), model.getAreaId(), | |
178 | + model.getStreetId(), model.getAddress(), basicConfigService)); | |
179 | + map.put("mod",referMod(model.getHospitalId(),model.getCertificateNum())); | |
180 | + | |
181 | + String name = null; | |
182 | + if (StringUtils.isNotEmpty(model.getHospitalId())){ | |
183 | + Organization organization = organizationService.getOrganization(Integer.parseInt(model.getHospitalId())); | |
184 | + if (organization!=null){ | |
185 | + name = organization.getName(); | |
186 | + } | |
187 | + } | |
188 | + map.put("hospitalName",name); | |
189 | + | |
190 | + list.add(map); | |
191 | + } | |
192 | + } | |
193 | + return new BaseListResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(list); | |
194 | + } | |
195 | + | |
196 | + //查询孕次 | |
197 | + public String referMod(String hospitalId,String cardNo){ | |
198 | + | |
199 | + if (StringUtils.isEmpty(hospitalId) || StringUtils.isEmpty(cardNo)){ | |
200 | + return ""; | |
201 | + } | |
202 | + | |
203 | + PatientsQuery patientsQuery = new PatientsQuery(); | |
204 | + patientsQuery.setYn(YnEnums.YES.getId()); | |
205 | + patientsQuery.setHospitalId(hospitalId); | |
206 | + patientsQuery.setCardNo(cardNo); | |
207 | + List<Patients> patientsList = patientsService.queryPatient1(patientsQuery, "created"); | |
208 | + | |
209 | + Patients patients = null; | |
210 | + | |
211 | + if (CollectionUtils.isNotEmpty(patientsList)){ | |
212 | + patients = new Patients(); | |
213 | + patients = patientsList.get(0); | |
214 | + } | |
215 | + | |
216 | + //如果没有在patients中,直接返回 - | |
217 | + if (patients==null){ | |
218 | + return "-"; | |
219 | + } | |
220 | + | |
221 | + AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
222 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
223 | + antExChuQuery.setHospitalId(patients.getHospitalId()); | |
224 | + antExChuQuery.setParentId(patients.getId()); | |
225 | + List<AntExChuModel> antExChuModelList = antenatalExaminationService.queryAntExChu(antExChuQuery); | |
226 | + | |
227 | + AntExChuModel antExChuModel = null; | |
228 | + | |
229 | + if (CollectionUtils.isNotEmpty(antExChuModelList)){ | |
230 | + antExChuModel = new AntExChuModel(); | |
231 | + antExChuModel = antExChuModelList.get(0); | |
232 | + } | |
233 | + | |
234 | + String num = "1"; | |
235 | + //已经建档,但没有做初诊,默认返回 1 | |
236 | + if (antExChuModel==null){ | |
237 | + return num; | |
238 | + } | |
239 | + if (antExChuModel.getPregnancyTimes()!=null){ | |
240 | + num = String.valueOf(antExChuModel.getPregnancyTimes()); | |
241 | + } | |
242 | + return num; | |
243 | + } | |
244 | + | |
245 | +} |