Commit 8731e7e0685c8b7e6b90f50161cfa548c823c9ab

Authored by liquanyu
1 parent 025991f869

公共卫生统计

Showing 2 changed files with 186 additions and 24 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/AreaCountController.java View file @ 8731e7e
... ... @@ -600,6 +600,54 @@
600 600 }
601 601  
602 602 /**
  603 + * 早孕13周以前建档人数
  604 + * @param request
  605 + * @param page
  606 + * @param limit
  607 + * @param areaId
  608 + * @param streetId
  609 + * @param type
  610 + * @param dateTime
  611 + * @return
  612 + */
  613 + @RequestMapping(method = RequestMethod.GET, value = "/getPregnantBuildCountList")
  614 + @ResponseBody
  615 + @TokenRequired
  616 + public BaseResponse getPregnantBuildCountList(HttpServletRequest request,
  617 + Integer page, Integer limit,
  618 + @RequestParam String areaId,
  619 + @RequestParam( required = false) String streetId,
  620 + @RequestParam Integer type, // 1 13周以前建档人数 2 孕产妇健康管理人数
  621 + @RequestParam Date dateTime) {
  622 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  623 + return patientSyncMysqlFacade.getPregnantBuildCountList(page,limit,areaId,streetId,dateTime,type);
  624 + }
  625 +
  626 +
  627 + /**
  628 + * 产后访视人数
  629 + * @param request
  630 + * @param page
  631 + * @param limit
  632 + * @param areaId
  633 + * @param streetId
  634 + * @param type
  635 + * @param dateTime
  636 + * @return
  637 + */
  638 + @RequestMapping(method = RequestMethod.GET, value = "/getChFsCountList")
  639 + @ResponseBody
  640 + @TokenRequired
  641 + public BaseResponse getChFsCountList(HttpServletRequest request,
  642 + Integer page, Integer limit,
  643 + @RequestParam String areaId,
  644 + @RequestParam( required = false) String streetId,
  645 + @RequestParam Date dateTime) {
  646 + LoginContext loginState = (LoginContext) request.getAttribute("loginContext");
  647 + return patientSyncMysqlFacade.getChFsCountList(page,limit,areaId,streetId,dateTime);
  648 + }
  649 +
  650 + /**
603 651 * 公共卫生项目统计 中医指导明细
604 652 * @param request
605 653 * @param provinceId
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientSyncMysqlFacade.java View file @ 8731e7e
... ... @@ -9,6 +9,7 @@
9 9 import com.lyms.platform.operate.web.result.BabyCheckPageResult;
10 10 import com.lyms.platform.operate.web.result.BabyPageResult;
11 11 import com.lyms.platform.operate.web.service.impl.BaseServiceImpl;
  12 +import com.lyms.platform.operate.web.utils.CommonsHelper;
12 13 import com.lyms.platform.operate.web.utils.ResponseUtil;
13 14 import com.lyms.platform.operate.web.utils.UnitConstants;
14 15 import com.lyms.platform.operate.web.utils.UnitUtils;
... ... @@ -3398,7 +3399,7 @@
3398 3399 patientsQuery.setBuildDaysEnd(13*7);
3399 3400 patientsQuery.setExtEnable(false);
3400 3401 patientsQuery.setBuildTypeNot(1);
3401   - patientsQuery.setBookbuildingDateStart(startDateFirst);
  3402 + patientsQuery.setBookbuildingDateStart(DateUtil.addYear(new Date(),-20));
3402 3403 patientsQuery.setBookbuildingDateEnd(endDate);
3403 3404 int data15 = patientsService.queryPatientCount(patientsQuery);
3404 3405 int lastDate15= null==hospitalDate.get("data15")?0:Integer.parseInt(hospitalDate.get("data15").toString());
3405 3406  
3406 3407  
... ... @@ -3407,13 +3408,15 @@
3407 3408  
3408 3409 patientsQuery.setBuildDaysStart(null);
3409 3410 patientsQuery.setBuildDaysEnd(null);
3410   - patientsQuery.setBookbuildingDateStart(startDateFirst);
  3411 +
3411 3412 patientsQuery.setBookbuildingDateEnd(endDate);
3412 3413 int buildCount = patientsService.queryPatientCount(patientsQuery);
  3414 + int allBuildCount = null==hospitalDate.get("allBuildCount")?0:Integer.parseInt(hospitalDate.get("allBuildCount").toString());
  3415 + hospitalDate.put("allBuildCount",buildCount+allBuildCount);
3413 3416 String data15_data2="0.00";
3414 3417 if(Integer.parseInt(hospitalDate.get("data2").toString())!=0){
3415 3418 float v = (float) Integer.parseInt(hospitalDate.get("data15").toString()) /
3416   - buildCount;
  3419 + allBuildCount;
3417 3420 if(v>=1){
3418 3421 data15_data2="100.00";
3419 3422 }else {
... ... @@ -3444,14 +3447,9 @@
3444 3447 }
3445 3448 hospitalDate.put("data18",data17_data2+"%");
3446 3449 //产后访视人数
3447   - int data19=0;
3448   - AggregationOperation match2 = Aggregation.match(Criteria
3449   - .where("hospitalId").is(hospitalId)
3450   - .and("createDate").gte(startDateFirst).lte(endDate));
3451   - AggregationOperation group2 = Aggregation.group("pid");
3452   - Aggregation aggregation2= Aggregation.newAggregation(match2, group2);
3453   - AggregationResults<HashMap> result2 = mongoTemplate.aggregate(aggregation2,"lyms_matdeliver_follow", HashMap.class);
3454   - data19=result2.getMappedResults().size();
  3450 + int data19= (int)mongoTemplate.count(new Query(Criteria.
  3451 + where("hospitalId").is(hospitalId).and("visitDate").lte(endDate)),MatdeliverFollowModel.class);
  3452 +
3455 3453 int lastDate19= null==hospitalDate.get("data19")?0:Integer.parseInt(hospitalDate.get("data19").toString());
3456 3454 hospitalDate.put("data19",data19+lastDate19);
3457 3455 //产后访视率%
3458 3456  
... ... @@ -3486,19 +3484,9 @@
3486 3484 hospitalDate.put("data23",data23+lastDate23);
3487 3485  
3488 3486  
3489   - //年度内儿童接收儿童中医指导的人数
3490   - int data24=0;
3491   - AggregationOperation match24 = Aggregation.match(Criteria.where("hospitalId").is(hospitalId)
3492   - .and("yn")
3493   - .is(YnEnums.YES.getId()).and("birth").gte(end).lte(start));
3494   - AggregationOperation group24 = Aggregation.group("buildId");
3495   - Aggregation aggregation24= Aggregation.newAggregation(match24, group24);
3496   - AggregationResults<HashMap> result24 = mongoTemplate.aggregate(aggregation24,"lyms_babycheck", HashMap.class);
3497   - data24=result24.getMappedResults().size();
  3487 + //0-3岁儿童人数
  3488 + int data24=data5;
3498 3489  
3499   -// data24 = (int) mongoTemplate.count(new Query(Criteria.where("hospitalId").is(hospitalId)
3500   -// .and("yn")
3501   -// .is(YnEnums.YES.getId()).and("birth").gte(end).lte(start)),BabyCheckModel.class);
3502 3490 int lastDate24= null==hospitalDate.get("data24")?0:Integer.parseInt(hospitalDate.get("data24").toString());
3503 3491 hospitalDate.put("data24",data24+lastDate24);
3504 3492  
... ... @@ -3739,6 +3727,7 @@
3739 3727 results.add(result);
3740 3728 }
3741 3729 }
  3730 + pageResult.setGrid(results);
3742 3731 return RespBuilder.buildSuccess(pageResult);
3743 3732 }
3744 3733 return new BaseListResponse();
... ... @@ -3810,6 +3799,131 @@
3810 3799 }
3811 3800 return new BaseListResponse().setErrorcode(0).setErrormsg("成功")
3812 3801 .setData(results).setPageInfo(babyQuery.getPageInfo());
  3802 +
  3803 + }
  3804 +
  3805 + public BaseResponse getPregnantBuildCountList(Integer page, Integer limit, String areaId, String streetId, Date dateTime, Integer type) {
  3806 + List<Map> results = new ArrayList<>();
  3807 + //获得区县下的街道
  3808 + List<BasicConfig> regions = getRegions(areaId,streetId);
  3809 + List<String> hospitalIds = new ArrayList<>();
  3810 + for (BasicConfig region : regions) {
  3811 + //获得街道下的医院
  3812 + List<Organization> organizations = getOrganization(region.getId());
  3813 + for (Organization organization : organizations) {
  3814 + String hospitalId= StringUtils.getIntToVal(organization.getId());
  3815 + hospitalIds.add(hospitalId);
  3816 + }
  3817 + }
  3818 +
  3819 + Date endDate=DateUtil.getDayLastSecond(DateUtil.getDateMonthLast(dateTime));
  3820 + PatientsQuery patientsQuery=new PatientsQuery();
  3821 + if (CollectionUtils.isNotEmpty(hospitalIds))
  3822 + {
  3823 + //孕13周之前建册的人数
  3824 +
  3825 + patientsQuery.setYn(YnEnums.YES.getId());
  3826 + patientsQuery.setHospitalList(hospitalIds);
  3827 + patientsQuery.setBuildDaysStart(0);
  3828 + patientsQuery.setBuildDaysEnd(13*7);
  3829 + patientsQuery.setExtEnable(false);
  3830 + patientsQuery.setBuildTypeNot(1);
  3831 + patientsQuery.setBookbuildingDateStart(DateUtil.addYear(new Date(),-20));
  3832 + patientsQuery.setBookbuildingDateEnd(endDate);
  3833 + patientsQuery.setPage(page);
  3834 + patientsQuery.setLimit(limit);
  3835 + patientsQuery.setNeed("Need");
  3836 + if (type == 1)
  3837 + {
  3838 +
  3839 + }
  3840 + else
  3841 + {
  3842 +
  3843 + }
  3844 + List<Patients> datas = patientsService.queryPatient(patientsQuery);
  3845 + System.out.println(patientsQuery.convertToQuery().convertToMongoQuery().toString());
  3846 + if (CollectionUtils.isNotEmpty(datas))
  3847 + {
  3848 + for (Patients model : datas)
  3849 + {
  3850 + Map result = new HashMap();
  3851 + result.put("username",model.getUsername());
  3852 + result.put("age",DateUtil.getAge2(model.getBirth(),model.getBookbuildingDate()));
  3853 + result.put("buildWeek",DateUtil.getWeekDesc(model.getLastMenses(),model.getBookbuildingDate()));
  3854 + result.put("buildDate",DateUtil.getyyyy_MM_dd(model.getBookbuildingDate()));
  3855 + result.put("phone",model.getPhone());
  3856 + result.put("cardNo",model.getCardNo());
  3857 + result.put("address", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(),
  3858 + model.getAreaId(), model.getStreetId(), model.getAddress(),
  3859 + basicConfigService));
  3860 + String buildHospital = organizationService.getOrganization(Integer.parseInt(model.getHospitalId())).getName();
  3861 + result.put("buildHospital",buildHospital);
  3862 + result.put("patientId",model.getId());
  3863 + results.add(result);
  3864 + }
  3865 + }
  3866 + }
  3867 + return new BaseListResponse().setErrorcode(0).setErrormsg("成功")
  3868 + .setData(results).setPageInfo(patientsQuery.getPageInfo());
  3869 + }
  3870 +
  3871 + public BaseResponse getChFsCountList(Integer page, Integer limit, String areaId, String streetId, Date dateTime) {
  3872 + List<Map> results = new ArrayList<>();
  3873 + //获得区县下的街道
  3874 + List<BasicConfig> regions = getRegions(areaId,streetId);
  3875 + List<String> hospitalIds = new ArrayList<>();
  3876 + for (BasicConfig region : regions) {
  3877 + //获得街道下的医院
  3878 + List<Organization> organizations = getOrganization(region.getId());
  3879 + for (Organization organization : organizations) {
  3880 + String hospitalId= StringUtils.getIntToVal(organization.getId());
  3881 + hospitalIds.add(hospitalId);
  3882 + }
  3883 + }
  3884 + Date endDate=DateUtil.getDayLastSecond(DateUtil.getDateMonthLast(dateTime));
  3885 + if (CollectionUtils.isNotEmpty(hospitalIds))
  3886 + {
  3887 + Criteria criteria = Criteria.
  3888 + where("hospitalId").in(hospitalIds).and("visitDate").lte(endDate);
  3889 +
  3890 + PageResult pageResult = findMongoPage(MatdeliverFollowModel.class, new Query(criteria).with(new Sort(Sort.Direction.DESC, "visitDate")), page, limit);
  3891 + List <MatdeliverFollowModel> followModels = (List <MatdeliverFollowModel>) pageResult.getGrid();
  3892 + if (CollectionUtils.isNotEmpty(followModels))
  3893 + {
  3894 + for (MatdeliverFollowModel followModel : followModels)
  3895 + {
  3896 + Map result = new HashMap();
  3897 + MaternalDeliverModel maternalDeliverModel = mongoTemplate.findOne(Query.query(Criteria.where("id").is(followModel.getDeliverId())), MaternalDeliverModel.class);
  3898 +
  3899 + if (maternalDeliverModel == null)
  3900 + {
  3901 + continue;
  3902 + }
  3903 + Patients model = patientsService.findOnePatientById(maternalDeliverModel.getParentId());
  3904 + if (model == null)
  3905 + {
  3906 + continue;
  3907 + }
  3908 + result.put("username",model.getUsername());
  3909 + result.put("age",DateUtil.getAge2(model.getBirth(),followModel.getVisitDate()));
  3910 + result.put("fsDay",DateUtil.getDays(maternalDeliverModel.getDueDate1(),followModel.getVisitDate()));
  3911 + result.put("fsDate",DateUtil.getyyyy_MM_dd(followModel.getVisitDate()));
  3912 + result.put("phone",model.getPhone());
  3913 + result.put("cardNo",model.getCardNo());
  3914 + result.put("address", CommonsHelper.getResidence(model.getProvinceId(), model.getCityId(),
  3915 + model.getAreaId(), model.getStreetId(), model.getAddress(),
  3916 + basicConfigService));
  3917 + String fsHospital = organizationService.getOrganization(Integer.parseInt(followModel.getHospitalId())).getName();
  3918 + result.put("fsHospital",fsHospital);
  3919 + result.put("fsId",followModel.getId());
  3920 + results.add(result);
  3921 + }
  3922 + }
  3923 + pageResult.setGrid(results);
  3924 + return RespBuilder.buildSuccess(pageResult);
  3925 + }
  3926 + return new BaseListResponse();
3813 3927  
3814 3928 }
3815 3929 }