Commit dff86c41afa702968123f3a3962693c4ccb7cd9c
1 parent
c6d9f9d08d
Exists in
dev
#fix:新增产检统计
Showing 4 changed files with 283 additions and 0 deletions
- platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java
- platform-dal/src/main/java/com/lyms/platform/query/AntExQuery.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
platform-dal/src/main/java/com/lyms/platform/query/AntExChuQuery.java
View file @
dff86c4
| ... | ... | @@ -24,6 +24,8 @@ |
| 24 | 24 | private String hospitalId; |
| 25 | 25 | private Date end; |
| 26 | 26 | |
| 27 | + private String isNextCheckTime; | |
| 28 | + private Date nextCheckTimeLte; | |
| 27 | 29 | private Date nextCheckTime; |
| 28 | 30 | private Date nextCheckTimeStart; |
| 29 | 31 | private Date nextCheckTimeEnd; |
| ... | ... | @@ -299,6 +301,22 @@ |
| 299 | 301 | this.id = id; |
| 300 | 302 | } |
| 301 | 303 | |
| 304 | + public String getIsNextCheckTime() { | |
| 305 | + return isNextCheckTime; | |
| 306 | + } | |
| 307 | + | |
| 308 | + public void setIsNextCheckTime(String isNextCheckTime) { | |
| 309 | + this.isNextCheckTime = isNextCheckTime; | |
| 310 | + } | |
| 311 | + | |
| 312 | + public Date getNextCheckTimeLte() { | |
| 313 | + return nextCheckTimeLte; | |
| 314 | + } | |
| 315 | + | |
| 316 | + public void setNextCheckTimeLte(Date nextCheckTimeLte) { | |
| 317 | + this.nextCheckTimeLte = nextCheckTimeLte; | |
| 318 | + } | |
| 319 | + | |
| 302 | 320 | @Override |
| 303 | 321 | public MongoQuery convertToQuery() { |
| 304 | 322 | MongoCondition condition = MongoCondition.newInstance(); |
| 305 | 323 | |
| ... | ... | @@ -338,7 +356,11 @@ |
| 338 | 356 | if (null != nextCheckTime) { |
| 339 | 357 | condition = condition.and("nextCheckTime", nextCheckTime, MongoOper.GTE); |
| 340 | 358 | } |
| 359 | + if (null!=nextCheckTimeLte){ | |
| 360 | + condition = condition.and("nextCheckTime", nextCheckTime, MongoOper.LTE); | |
| 341 | 361 | |
| 362 | + } | |
| 363 | + | |
| 342 | 364 | if (null != hospitalId) { |
| 343 | 365 | condition = condition.and("hospitalId", hospitalId, MongoOper.IS); |
| 344 | 366 | } |
| ... | ... | @@ -354,6 +376,10 @@ |
| 354 | 376 | |
| 355 | 377 | if (isOpinion) { |
| 356 | 378 | condition = condition.and("treatOpinion", true, MongoOper.EXISTS); |
| 379 | + } | |
| 380 | + if (StringUtils.isNotEmpty(isNextCheckTime)){ | |
| 381 | + condition = condition.and("nextCheckTime", true, MongoOper.EXISTS); | |
| 382 | + | |
| 357 | 383 | } |
| 358 | 384 | |
| 359 | 385 | if (CollectionUtils.isNotEmpty(parentIds)) { |
platform-dal/src/main/java/com/lyms/platform/query/AntExQuery.java
View file @
dff86c4
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | import com.lyms.platform.common.dao.operator.MongoCondition; |
| 6 | 6 | import com.lyms.platform.common.dao.operator.MongoOper; |
| 7 | 7 | import com.lyms.platform.common.dao.operator.MongoQuery; |
| 8 | +import com.lyms.platform.common.utils.StringUtils; | |
| 8 | 9 | import org.apache.commons.collections.CollectionUtils; |
| 9 | 10 | import org.springframework.data.mongodb.core.query.Criteria; |
| 10 | 11 | |
| ... | ... | @@ -52,6 +53,7 @@ |
| 52 | 53 | private Date checkStartDate; |
| 53 | 54 | |
| 54 | 55 | private Date checkEndDate; |
| 56 | + private Date nextCheckTime; | |
| 55 | 57 | |
| 56 | 58 | private Date nextCheckTimeStartDate; |
| 57 | 59 | private Date nextCheckTimeEndDate; |
| ... | ... | @@ -226,6 +228,14 @@ |
| 226 | 228 | this.pid = pid; |
| 227 | 229 | } |
| 228 | 230 | |
| 231 | + public Date getNextCheckTime() { | |
| 232 | + return nextCheckTime; | |
| 233 | + } | |
| 234 | + | |
| 235 | + public void setNextCheckTime(Date nextCheckTime) { | |
| 236 | + this.nextCheckTime = nextCheckTime; | |
| 237 | + } | |
| 238 | + | |
| 229 | 239 | @Override |
| 230 | 240 | public MongoQuery convertToQuery() { |
| 231 | 241 | MongoCondition condition = MongoCondition.newInstance(); |
| ... | ... | @@ -263,6 +273,9 @@ |
| 263 | 273 | condition = condition.and("treatOpinion", true, MongoOper.EXISTS); |
| 264 | 274 | } |
| 265 | 275 | |
| 276 | + if (null!=nextCheckTime){ | |
| 277 | + condition = condition.and("nextCheckTime", nextCheckTime, MongoOper.LTE); | |
| 278 | + } | |
| 266 | 279 | boolean isAddStart = Boolean.FALSE; |
| 267 | 280 | Criteria c = null; |
| 268 | 281 | if (null != start) { |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/StatisticsController.java
View file @
dff86c4
| ... | ... | @@ -11,10 +11,13 @@ |
| 11 | 11 | import com.lyms.platform.common.utils.ResultUtils; |
| 12 | 12 | import com.lyms.platform.common.utils.SystemConfig; |
| 13 | 13 | import com.lyms.platform.operate.web.facade.AntExRecordFacade; |
| 14 | +import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; | |
| 14 | 15 | import com.lyms.platform.operate.web.facade.BasicConfigFacade; |
| 15 | 16 | import com.lyms.platform.operate.web.facade.PatientServiceFacade; |
| 16 | 17 | import com.lyms.platform.operate.web.request.CjStatisticsQueryRequest; |
| 17 | 18 | import com.lyms.platform.operate.web.request.JdStatisticsQueryRequest; |
| 19 | +import com.lyms.platform.query.AntExRecordQuery; | |
| 20 | +import com.lyms.platform.query.PatientsQuery; | |
| 18 | 21 | import com.lymsh.platform.reportdata.model.AreaData; |
| 19 | 22 | import com.lymsh.platform.reportdata.model.AreaDataQuery; |
| 20 | 23 | import com.lymsh.platform.reportdata.model.echarts.*; |
| ... | ... | @@ -46,6 +49,8 @@ |
| 46 | 49 | private BasicConfigFacade basicConfigFacade; |
| 47 | 50 | @Autowired |
| 48 | 51 | private PatientServiceFacade patientServiceFacade; |
| 52 | + @Autowired | |
| 53 | + private AntenatalExaminationFacade antenatalExaminationFacade; | |
| 49 | 54 | |
| 50 | 55 | |
| 51 | 56 | |
| ... | ... | @@ -1188,6 +1193,31 @@ |
| 1188 | 1193 | public BaseResponse jdStatistics(HttpServletRequest request, @Valid JdStatisticsQueryRequest jdStatisticsQueryRequest){ |
| 1189 | 1194 | LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); |
| 1190 | 1195 | return patientServiceFacade.queryStatistics(loginState.getId(),jdStatisticsQueryRequest); |
| 1196 | + } | |
| 1197 | + | |
| 1198 | + @RequestMapping(value = "/yjStatistics", method = RequestMethod.GET) | |
| 1199 | + @ResponseBody | |
| 1200 | + @TokenRequired | |
| 1201 | + public BaseResponse yjStatistics(HttpServletRequest request){ | |
| 1202 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 1203 | + return antenatalExaminationFacade.antenatalExaminationStatistics(loginState.getId()); | |
| 1204 | + } | |
| 1205 | + @RequestMapping(value = "/yjStatistics/list", method = RequestMethod.GET) | |
| 1206 | + @ResponseBody | |
| 1207 | + @TokenRequired | |
| 1208 | + public BaseResponse yjStatisticsList(String parentIds, | |
| 1209 | + Integer page, | |
| 1210 | + Integer limit){ | |
| 1211 | + if (StringUtils.isEmpty(parentIds)){ | |
| 1212 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 1213 | + } | |
| 1214 | + AntExRecordQuery antExRecordQuery = new AntExRecordQuery(); | |
| 1215 | + antExRecordQuery.setNeed("1"); | |
| 1216 | + antExRecordQuery.setParentIds(com.lyms.platform.common.utils.StringUtils.covertToList(parentIds, String.class)); | |
| 1217 | + antExRecordQuery.setNeed("true"); | |
| 1218 | + antExRecordQuery.setLimit(limit); | |
| 1219 | + antExRecordQuery.setPage(page); | |
| 1220 | + return antenatalExaminationFacade.antenatalExaminationStatisticsList(antExRecordQuery); | |
| 1191 | 1221 | } |
| 1192 | 1222 | |
| 1193 | 1223 | @RequestMapping(value = "/cjStatistics/enums", method = RequestMethod.GET) |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java
View file @
dff86c4
| ... | ... | @@ -223,6 +223,220 @@ |
| 223 | 223 | return null; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | + public BaseResponse antenatalExaminationStatisticsList(AntExRecordQuery antExRecordQuery){ | |
| 227 | + BaseListResponse baseListResponse = new BaseListResponse(); | |
| 228 | + List data = new ArrayList<>(); | |
| 229 | + | |
| 230 | + List<AntExRecordModel> list2 = recordService.queryAntExRecords(antExRecordQuery); | |
| 231 | + if (CollectionUtils.isNotEmpty(list2)) { | |
| 232 | + for (AntExRecordModel record : list2) { | |
| 233 | + CjStatisticsListResult cjStatisticsListResult = new CjStatisticsListResult(); | |
| 234 | + cjStatisticsListResult.convertToResult(record); | |
| 235 | + Patients patients = patientsService.findOnePatientById(record.getParentId()); | |
| 236 | + String dueWeek = ""; | |
| 237 | + if (null != patients) { | |
| 238 | + //2017-03-15 高帆说的改成这样 | |
| 239 | + if (patients.getType()==1 &&patients.getLastMenses() != null && record.getCheckTime() != null) { | |
| 240 | + int days = DateUtil.daysBetween(patients.getLastMenses(), record.getCheckTime()); | |
| 241 | + String week = (days / 7) + ""; | |
| 242 | + int day = (days % 7); | |
| 243 | + dueWeek = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : ""); | |
| 244 | + cjStatisticsListResult.setDueWeek(dueWeek); | |
| 245 | + }else if(patients.getType()==3 &&patients.getLastMenses() != null && patients.getDueDate() != null){ | |
| 246 | + int days = DateUtil.daysBetween(patients.getLastMenses(), patients.getDueDate()); | |
| 247 | + String week = (days / 7) + ""; | |
| 248 | + int day = (days % 7); | |
| 249 | + dueWeek = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : ""); | |
| 250 | + cjStatisticsListResult.setDueWeek(dueWeek); | |
| 251 | + } | |
| 252 | + } | |
| 253 | + | |
| 254 | + | |
| 255 | + Users users = usersService.getUsers(NumberUtils.toInt(record.getCheckDoctor())); | |
| 256 | + if (null != users) { | |
| 257 | + cjStatisticsListResult.setCheckDoctor(users.getName()); | |
| 258 | + } | |
| 259 | + | |
| 260 | + //处理高危 | |
| 261 | + handleRisk(record, cjStatisticsListResult); | |
| 262 | + | |
| 263 | + data.add(cjStatisticsListResult); | |
| 264 | + } | |
| 265 | + } | |
| 266 | + | |
| 267 | + return baseListResponse.setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(antExRecordQuery.getPageInfo()); | |
| 268 | + | |
| 269 | + } | |
| 270 | + private void handleRisk(AntExRecordModel e, CjStatisticsListResult antExManagerResult) { | |
| 271 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(e.getfId())) { | |
| 272 | + String risk = null; | |
| 273 | + if (e.getType() == 2) { | |
| 274 | + AntExChuModel model = antExService.findOne(e.getfId()); | |
| 275 | + if (null != model) { | |
| 276 | + risk = model.getOtherHighRisk(); | |
| 277 | + } | |
| 278 | + } else if (e.getType() == 1) { | |
| 279 | + AntenatalExaminationModel model = antExService.findOneById(e.getfId()); | |
| 280 | + if (null != model) { | |
| 281 | + risk = model.getOtherRisk(); | |
| 282 | + } | |
| 283 | + } | |
| 284 | + StringBuffer name = new StringBuffer(); | |
| 285 | + Integer score = 0; | |
| 286 | + List<Map<String, Object>> results = commonService.resolveOtherRisk(risk); | |
| 287 | + if (CollectionUtils.isNotEmpty(results)) { | |
| 288 | + for (Map result : results) { | |
| 289 | + //高危因素名字 | |
| 290 | + name.append(result.get("name").toString() + ","); | |
| 291 | + String level = result.get("levelId").toString(); | |
| 292 | + score += NumberUtils.toInt(result.get("score").toString(), 0); | |
| 293 | + if (org.apache.commons.lang.StringUtils.isNotEmpty(level) && !"null".equals(level)) { | |
| 294 | + e.gethLevel().add(level); | |
| 295 | + } | |
| 296 | + } | |
| 297 | + } | |
| 298 | + //高危因素 | |
| 299 | + antExManagerResult.setrLevel(commonService.findRiskLevel(e.gethLevel())); | |
| 300 | + String ri = commonService.resloveFactor(e.gethRisk()); | |
| 301 | + if (ri.isEmpty()) { | |
| 302 | + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(name.toString())) { | |
| 303 | + ri = name.substring(0, name.length() - 1); | |
| 304 | + } | |
| 305 | + } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(name.toString())) { | |
| 306 | + ri += "," + name.substring(0, name.length() - 1); | |
| 307 | + } | |
| 308 | + antExManagerResult.setrRisk(ri); | |
| 309 | + antExManagerResult.setScore((e.gethScore() + score)); | |
| 310 | + } | |
| 311 | + } | |
| 312 | + public BaseResponse antenatalExaminationStatistics(Integer userId){ | |
| 313 | + String hospitalId = autoMatchFacade.getHospitalId(userId); | |
| 314 | + AntExChuQuery antExChuQuery=new AntExChuQuery(); | |
| 315 | + antExChuQuery.setYn(YnEnums.YES.getId()); | |
| 316 | + antExChuQuery.setHospitalId(hospitalId); | |
| 317 | + //把时间格式化成 yyyy_MM_dd 的日期 | |
| 318 | + Date nextCheckTime= DateUtil.formatDate(new Date()); | |
| 319 | + antExChuQuery.setNextCheckTimeLte(nextCheckTime); | |
| 320 | + //初诊数据 | |
| 321 | + List<AntExChuModel> antExChuModelList= antExService.queryAntExChu(antExChuQuery); | |
| 322 | + if (CollectionUtils.isNotEmpty(antExChuModelList)){ | |
| 323 | + List<Map<String,Object>> list=new ArrayList<>(); | |
| 324 | + //正常健康 | |
| 325 | + Map<String,Object> a=new HashMap<>(); | |
| 326 | + a.put("type",1); | |
| 327 | + a.put("num",0); | |
| 328 | + a.put("riskType",1); | |
| 329 | + //异常健康 | |
| 330 | + Map<String,Object> b=new HashMap<>(); | |
| 331 | + b.put("type",2); | |
| 332 | + b.put("num",0); | |
| 333 | + b.put("riskType",1); | |
| 334 | + //正常高危 | |
| 335 | + Map<String,Object> c=new HashMap<>(); | |
| 336 | + c.put("type",1); | |
| 337 | + c.put("num",0); | |
| 338 | + c.put("riskType",0); | |
| 339 | + //异常高危 | |
| 340 | + Map<String,Object> d=new HashMap<>(); | |
| 341 | + d.put("type",2); | |
| 342 | + d.put("num",0); | |
| 343 | + d.put("riskType",0); | |
| 344 | + | |
| 345 | + AntExQuery antExQuery = new AntExQuery(); | |
| 346 | + for (AntExChuModel antExChuModel:antExChuModelList){ | |
| 347 | + //高危信息 | |
| 348 | + List li = null; | |
| 349 | + try { | |
| 350 | + li = JsonUtil.toList(antExChuModel.getHighrisk(), List.class); | |
| 351 | + } catch (Exception e) { | |
| 352 | + } | |
| 353 | + String parentId=antExChuModel.getParentId(); | |
| 354 | + antExQuery.setParentId(parentId); | |
| 355 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 356 | + String time= DateUtil.getyyyy_MM_dd(antExChuModel.getNextCheckTime()); | |
| 357 | + antExQuery.setCreatedTimeStart(DateUtil.parseYMDHMS(time + " 00:00:00")); | |
| 358 | + antExQuery.setCreatedTimeEnd(DateUtil.parseYMDHMS(time + " 23:59:59")); | |
| 359 | + List <AntenatalExaminationModel> antEx = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); | |
| 360 | + | |
| 361 | + if (CollectionUtils.isNotEmpty(antEx)){ | |
| 362 | + if (CollectionUtils.isNotEmpty(li)&&!li.contains("d42eec03-aa86-45b8-a4e0-78a0ff365fb6")){ | |
| 363 | + //高危 | |
| 364 | + c.put("num",c.get("num")!=null?Integer.valueOf(c.get("num").toString())+1:1); | |
| 365 | + c.put("parentIds",c.get("parentIds")!=null?c.get("parentIds")+","+parentId:parentId); | |
| 366 | + }else { | |
| 367 | + //健康 | |
| 368 | + a.put("num",a.get("num")!=null?Integer.valueOf(a.get("num").toString())+1:1); | |
| 369 | + a.put("parentIds",a.get("parentIds")!=null?a.get("parentIds")+","+parentId:parentId); | |
| 370 | + } | |
| 371 | + }else { | |
| 372 | + if (CollectionUtils.isNotEmpty(li)&&!li.contains("d42eec03-aa86-45b8-a4e0-78a0ff365fb6")){ | |
| 373 | + //高危 | |
| 374 | + d.put("num",d.get("num")!=null?Integer.valueOf(d.get("num").toString())+1:1); | |
| 375 | + d.put("parentIds",d.get("parentIds")!=null?d.get("parentIds")+","+parentId:parentId); | |
| 376 | + }else { | |
| 377 | + //健康 | |
| 378 | + b.put("num",b.get("num")!=null?Integer.valueOf(b.get("num").toString())+1:1); | |
| 379 | + b.put("parentIds",b.get("parentIds")!=null?b.get("parentIds")+","+parentId:parentId); | |
| 380 | + } | |
| 381 | + } | |
| 382 | + } | |
| 383 | + antExQuery.setParentId(null); | |
| 384 | + antExQuery.setCreatedTimeStart(null); | |
| 385 | + antExQuery.setCreatedTimeEnd(null); | |
| 386 | + antExQuery.setHospitalId(hospitalId); | |
| 387 | + antExQuery.setNextCheckTime(nextCheckTime); | |
| 388 | + List <AntenatalExaminationModel> antEx = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); | |
| 389 | + if (CollectionUtils.isNotEmpty(antEx)){ | |
| 390 | + antExQuery.setNextCheckTime(null); | |
| 391 | + for (AntenatalExaminationModel antenatalExaminationModel:antEx){ | |
| 392 | + //高危信息 | |
| 393 | + List li = null; | |
| 394 | + try { | |
| 395 | + li = Arrays.asList(antenatalExaminationModel.getRiskFactor().split(",")); | |
| 396 | + } catch (Exception e) { | |
| 397 | + } | |
| 398 | + String parentId=antenatalExaminationModel.getParentId(); | |
| 399 | + antExQuery.setParentId(parentId); | |
| 400 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 401 | + String time= DateUtil.getyyyy_MM_dd(antenatalExaminationModel.getNextCheckTime()); | |
| 402 | + antExQuery.setCreatedTimeStart(DateUtil.parseYMDHMS(time + " 00:00:00")); | |
| 403 | + antExQuery.setCreatedTimeEnd(DateUtil.parseYMDHMS(time + " 23:59:59")); | |
| 404 | + List <AntenatalExaminationModel> antEx1 = antenatalExaminationService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "checkDate")); | |
| 405 | + if (CollectionUtils.isNotEmpty(antEx1)){ | |
| 406 | + if (CollectionUtils.isNotEmpty(li)&&!li.contains("d42eec03-aa86-45b8-a4e0-78a0ff365fb6")){ | |
| 407 | + //高危 | |
| 408 | + c.put("num",c.get("num")!=null?Integer.valueOf(c.get("num").toString())+1:1); | |
| 409 | + c.put("parentIds",c.get("parentIds")!=null?c.get("parentIds")+","+parentId:parentId); | |
| 410 | + }else { | |
| 411 | + //健康 | |
| 412 | + a.put("num",a.get("num")!=null?Integer.valueOf(a.get("num").toString())+1:1); | |
| 413 | + a.put("parentIds",a.get("parentIds")!=null?a.get("parentIds")+","+parentId:parentId); | |
| 414 | + } | |
| 415 | + }else { | |
| 416 | + if (CollectionUtils.isNotEmpty(li)&&!li.contains("d42eec03-aa86-45b8-a4e0-78a0ff365fb6")){ | |
| 417 | + //高危 | |
| 418 | + d.put("num",d.get("num")!=null?Integer.valueOf(d.get("num").toString())+1:1); | |
| 419 | + d.put("parentIds",d.get("parentIds")!=null?d.get("parentIds")+","+parentId:parentId); | |
| 420 | + }else { | |
| 421 | + //健康 | |
| 422 | + b.put("num",b.get("num")!=null?Integer.valueOf(b.get("num").toString())+1:1); | |
| 423 | + b.put("parentIds",b.get("parentIds")!=null?b.get("parentIds")+","+parentId:parentId); | |
| 424 | + } | |
| 425 | + } | |
| 426 | + } | |
| 427 | + } | |
| 428 | + list.add(a); | |
| 429 | + list.add(b); | |
| 430 | + list.add(c); | |
| 431 | + list.add(d); | |
| 432 | + BaseResponse baseResponse= new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 433 | + baseResponse.setObject(list); | |
| 434 | + return baseResponse; | |
| 435 | + } | |
| 436 | + return new BaseResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功"); | |
| 437 | + } | |
| 438 | + | |
| 439 | + | |
| 226 | 440 | /** |
| 227 | 441 | * 修改最后一次产检时间 |
| 228 | 442 | * |