Commit 8e9b062524962d77d300ddf35ee42c6bdb2eacf1
Exists in
dev
Merge branch 'dev' of https://git.healthbaby.com.cn/jiangjiazhi/regional-platform into dev
Showing 6 changed files
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CesareanWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/HypothyroidismWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/InfectiousWorker.java
- platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/OldWorker.java
platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/PuerperaManageController.java
View file @
8e9b062
| ... | ... | @@ -12,7 +12,6 @@ |
| 12 | 12 | import com.lyms.platform.common.result.BaseObjectResponse; |
| 13 | 13 | import com.lyms.platform.common.result.BaseResponse; |
| 14 | 14 | import com.lyms.platform.common.utils.*; |
| 15 | -import com.lyms.platform.operate.web.constant.OrganizationConstant; | |
| 16 | 15 | import com.lyms.platform.operate.web.facade.AntenatalExaminationFacade; |
| 17 | 16 | import com.lyms.platform.operate.web.facade.AutoMatchFacade; |
| 18 | 17 | import com.lyms.platform.operate.web.facade.BasicConfigFacade; |
| ... | ... | @@ -270,6 +269,61 @@ |
| 270 | 269 | return patientFacade.queryBloodSugarAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); |
| 271 | 270 | } |
| 272 | 271 | /** |
| 272 | + * 传染性疾病全部孕妇管理 | |
| 273 | + * | |
| 274 | + * @param patientsQueryRequest | |
| 275 | + * @return 返回结果 | |
| 276 | + */ | |
| 277 | + @RequestMapping(value = "/infectious", method = RequestMethod.GET) | |
| 278 | + @ResponseBody | |
| 279 | + @TokenRequired | |
| 280 | + public BaseResponse queryInfectiousAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 281 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 282 | + return patientFacade.queryInfectiousAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 283 | + } | |
| 284 | + | |
| 285 | + /** | |
| 286 | + * 剖宫产再孕全部孕妇管理 | |
| 287 | + * | |
| 288 | + * @param patientsQueryRequest | |
| 289 | + * @return 返回结果 | |
| 290 | + */ | |
| 291 | + @RequestMapping(value = "/cesarean", method = RequestMethod.GET) | |
| 292 | + @ResponseBody | |
| 293 | + @TokenRequired | |
| 294 | + public BaseResponse queryCesareanAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 295 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 296 | + return patientFacade.queryCesareanAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 297 | + } | |
| 298 | + | |
| 299 | + /** | |
| 300 | + * 高龄孕产妇全部孕妇管理 | |
| 301 | + * | |
| 302 | + * @param patientsQueryRequest | |
| 303 | + * @return 返回结果 | |
| 304 | + */ | |
| 305 | + @RequestMapping(value = "/old", method = RequestMethod.GET) | |
| 306 | + @ResponseBody | |
| 307 | + @TokenRequired | |
| 308 | + public BaseResponse queryOldAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 309 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 310 | + return patientFacade.queryOldAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 311 | + } | |
| 312 | + /** | |
| 313 | + * 甲减产妇全部孕妇管理 | |
| 314 | + * | |
| 315 | + * @param patientsQueryRequest | |
| 316 | + * @return 返回结果 | |
| 317 | + */ | |
| 318 | + @RequestMapping(value = "/hypothyroidism", method = RequestMethod.GET) | |
| 319 | + @ResponseBody | |
| 320 | + @TokenRequired | |
| 321 | + public BaseResponse queryHypothyroidismAllPuerpera(@Valid RiskPatientsQueryRequest patientsQueryRequest, HttpServletRequest request) { | |
| 322 | + LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); | |
| 323 | + return patientFacade.queryhypothyroidismAllPuerpera(patientsQueryRequest, null, 1, loginState.getId(), "true", Boolean.FALSE); | |
| 324 | + } | |
| 325 | + | |
| 326 | + /** | |
| 273 | 327 | * 瘢痕子宫全部孕妇管理 |
| 274 | 328 | * |
| 275 | 329 | * @param patientsQueryRequest |
| ... | ... | @@ -454,7 +508,6 @@ |
| 454 | 508 | @ResponseBody |
| 455 | 509 | public BaseResponse getEnums() { |
| 456 | 510 | Map<String, Object> map = new HashMap<>(); |
| 457 | - | |
| 458 | 511 | map.put("gwfz", basicConfigFacade.getBaseicConfigByParentId(SystemConfig.HIGH_RISK_ID)); |
| 459 | 512 | List list = new ArrayList(); |
| 460 | 513 | for (int i = 5; i <= 100; i = i + 5) { |
| ... | ... | @@ -660,8 +713,13 @@ |
| 660 | 713 | /** |
| 661 | 714 | * 唐山零时限制 |
| 662 | 715 | */ |
| 663 | - // Organization organization = organizationService.getOrganization(usersService.getUsers(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()).getOrgId()); | |
| 664 | - | |
| 716 | + Organization organization = organizationService.getOrganization(usersService.getUsers(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()).getOrgId()); | |
| 717 | + //遵化市妇幼保健院单独放开 | |
| 718 | + if (!"1000000094".equals(String.valueOf(organization.getId())) && "4".equals(organization.getCityId())) | |
| 719 | + { | |
| 720 | + String date = DateUtil.getyyyy_MM_dd(DateUtil.addMonth(new Date(),-3))+" - "+DateUtil.getyyyy_MM_dd(new Date()); | |
| 721 | + patientManagerRequest.setBookBuildingDate(date); | |
| 722 | + } | |
| 665 | 723 | |
| 666 | 724 | patientManagerRequest.setOperatorId(((LoginContext) httpServletRequest.getAttribute("loginContext")).getId()); |
| 667 | 725 |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientFacade.java
View file @
8e9b062
| ... | ... | @@ -273,7 +273,7 @@ |
| 273 | 273 | patientsQuery.setType(type); |
| 274 | 274 | |
| 275 | 275 | //add lqy 高危孕产妇统计需求 |
| 276 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getType())) { | |
| 276 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getType())) { | |
| 277 | 277 | if ("2".equals(riskPatientsQueryRequest.getType())) { |
| 278 | 278 | //1孕妇 |
| 279 | 279 | patientsQuery.setType(1); |
| ... | ... | @@ -294,7 +294,7 @@ |
| 294 | 294 | patientsQuery.setNotoRiskFactor(""); |
| 295 | 295 | patientsQuery.setoRiskFactor("true"); |
| 296 | 296 | } else { |
| 297 | - patientsQuery.setrFactorList(com.lyms.platform.common.utils.StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); | |
| 297 | + patientsQuery.setrFactorList(StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); | |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | Date currentDate = DateUtil.formatDate(new Date()); |
| ... | ... | @@ -470,7 +470,7 @@ |
| 470 | 470 | Iterator <String> it = set.iterator(); |
| 471 | 471 | while (it.hasNext()) { |
| 472 | 472 | String id = it.next(); |
| 473 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) { | |
| 473 | + if (StringUtils.isNotEmpty(id) && !hospitalList.contains(id)) { | |
| 474 | 474 | hospitalList.add(id); |
| 475 | 475 | } |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
| ... | ... | @@ -479,13 +479,13 @@ |
| 479 | 479 | List <String> orgId = new ArrayList <>(); |
| 480 | 480 | orgId.add(riskPatientsQueryRequest.gethId()); |
| 481 | 481 | hospitalList.retainAll(orgId); |
| 482 | - } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getCprovinceId())) { | |
| 482 | + } else if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getCprovinceId())) { | |
| 483 | 483 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
| 484 | 484 | organizationQuery.setYn(YnEnums.YES.getId()); |
| 485 | 485 | organizationQuery.setProvinceId(riskPatientsQueryRequest.getCprovinceId()); |
| 486 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getCcityId())) { | |
| 486 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getCcityId())) { | |
| 487 | 487 | organizationQuery.setCityId(riskPatientsQueryRequest.getCcityId()); |
| 488 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getCareaId())) { | |
| 488 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getCareaId())) { | |
| 489 | 489 | organizationQuery.setAreaId(riskPatientsQueryRequest.getCareaId()); |
| 490 | 490 | } |
| 491 | 491 | } |
| ... | ... | @@ -510,7 +510,7 @@ |
| 510 | 510 | hospitalList.remove("2100002324");//衡水六院登陆 |
| 511 | 511 | hospitalList.add("5100002324");//查询一个空的 |
| 512 | 512 | } |
| 513 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFmHospital())) { | |
| 513 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFmHospital())) { | |
| 514 | 514 | patientsQuery.setHospitalList(Arrays.asList(riskPatientsQueryRequest.getFmHospital())); |
| 515 | 515 | } |
| 516 | 516 | else |
| 517 | 517 | |
| 518 | 518 | |
| ... | ... | @@ -522,13 +522,13 @@ |
| 522 | 522 | |
| 523 | 523 | fmHospitalList.addAll(hospitalList); |
| 524 | 524 | |
| 525 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFprovinceId())) { | |
| 525 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFprovinceId())) { | |
| 526 | 526 | OrganizationQuery organizationQuery = new OrganizationQuery(); |
| 527 | 527 | organizationQuery.setYn(YnEnums.YES.getId()); |
| 528 | 528 | organizationQuery.setProvinceId(riskPatientsQueryRequest.getFprovinceId()); |
| 529 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFcityId())) { | |
| 529 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFcityId())) { | |
| 530 | 530 | organizationQuery.setCityId(riskPatientsQueryRequest.getFcityId()); |
| 531 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFareaId())) { | |
| 531 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFareaId())) { | |
| 532 | 532 | organizationQuery.setAreaId(riskPatientsQueryRequest.getFareaId()); |
| 533 | 533 | } |
| 534 | 534 | } |
| 535 | 535 | |
| ... | ... | @@ -554,12 +554,12 @@ |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | |
| 557 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFmHospital())) { | |
| 557 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFmHospital())) { | |
| 558 | 558 | patientsQuery.setFmHospital(riskPatientsQueryRequest.getFmHospital()); |
| 559 | 559 | //区域孕妇管理全部产妇,筛选时选择具体的分娩医院,要清空hospitalList,原逻辑加上list后,因为是and连接会是只查本院建档本院分娩。数据不准确 |
| 560 | 560 | patientsQuery.setHospitalList(null); |
| 561 | 561 | } else { |
| 562 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(riskPatientsQueryRequest.getFprovinceId())) { | |
| 562 | + if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFprovinceId())) { | |
| 563 | 563 | patientsQuery.setFmHospitalList(fmHospitalList); |
| 564 | 564 | //区域孕妇管理全部产妇,筛选时没有选择具体的分娩医院,也要清空hospitalList,原逻辑加上list后,因为是and连接会是只查本院建档本院分娩。数据不准确 |
| 565 | 565 | patientsQuery.setHospitalList(null); |
| ... | ... | @@ -1027,7 +1027,7 @@ |
| 1027 | 1027 | patientsQuery.setLastMensesStart(riskPatientsQueryRequest.capEnd()); |
| 1028 | 1028 | patientsQuery.setLastMensesEnd(riskPatientsQueryRequest.capStart()); |
| 1029 | 1029 | patientsQuery.setrLevel(riskPatientsQueryRequest.getrLevel()); |
| 1030 | - patientsQuery.setrFactorList(com.lyms.platform.common.utils.StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); | |
| 1030 | + patientsQuery.setrFactorList(StringUtils.covertToList(riskPatientsQueryRequest.getrFacotr(), String.class)); | |
| 1031 | 1031 | if (StringUtils.isNotEmpty(riskPatientsQueryRequest.getFmTime())) { |
| 1032 | 1032 | String fmTime = riskPatientsQueryRequest.getFmTime(); |
| 1033 | 1033 | String[] dates = fmTime.split(" - "); |
| ... | ... | @@ -1076,7 +1076,7 @@ |
| 1076 | 1076 | List <PatientWeight> patientWeightList = mongoTemplate.find(query, PatientWeight.class); |
| 1077 | 1077 | if (CollectionUtils.isNotEmpty(patientWeightList)) { |
| 1078 | 1078 | PatientWeight patientWeight = patientWeightList.get(0); |
| 1079 | - if (patientWeight != null && com.lyms.platform.common.utils.StringUtils.isNotEmpty(patientWeight.getBmi())) { | |
| 1079 | + if (patientWeight != null && StringUtils.isNotEmpty(patientWeight.getBmi())) { | |
| 1080 | 1080 | double bmid = Double.parseDouble(patientWeight.getBmi()); |
| 1081 | 1081 | double bmidStart = Double.parseDouble(riskPatientsQueryRequest.getBmiStart()); |
| 1082 | 1082 | double bmidEnd = Double.parseDouble(riskPatientsQueryRequest.getBmiEnd()); |
| ... | ... | @@ -1505,6 +1505,326 @@ |
| 1505 | 1505 | return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); |
| 1506 | 1506 | } |
| 1507 | 1507 | |
| 1508 | + public BaseResponse queryCesareanAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 1509 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 1510 | + //威县数据流转 | |
| 1511 | + /*if(OrganizationConstant.XT_WX.equals(hospital)){ | |
| 1512 | + riskPatientsQueryRequest.setLastCheckDoctorId(String.valueOf(userId)); | |
| 1513 | + }*/ | |
| 1514 | + | |
| 1515 | + //组合请求 | |
| 1516 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + //查询符合条件的孕妇 | |
| 1520 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 1521 | + stopWatch.start(); | |
| 1522 | + | |
| 1523 | + Query yn = null; | |
| 1524 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1525 | + Criteria criteria1 = Criteria.where("name").is("各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次"); | |
| 1526 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 1527 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1528 | + Criteria criteria2 = Criteria.where("name").is("瘢痕子宫(距前次剖宫产不足2年)"); | |
| 1529 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 1530 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1531 | + Criteria criteria3 = Criteria.where("name").is("剖宫产1次"); | |
| 1532 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 1533 | + } else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1534 | + Criteria criteria4 = Criteria.where("name").is("剖宫产≥2次"); | |
| 1535 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1536 | + } else { | |
| 1537 | + Criteria criteria1 = Criteria.where("name").is("各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次"); | |
| 1538 | + Criteria criteria2 = Criteria.where("name").is("瘢痕子宫(距前次剖宫产不足2年)"); | |
| 1539 | + Criteria criteria3 = Criteria.where("name").is("剖宫产1次"); | |
| 1540 | + Criteria criteria4 = Criteria.where("name").is("剖宫产≥2次"); | |
| 1541 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3, criteria4)); | |
| 1542 | + } | |
| 1543 | + List <BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 1544 | + List <String> rFactorList = new ArrayList <>(); | |
| 1545 | + if (models != null && models.size() > 0) { | |
| 1546 | + for (int i = 0; i < models.size(); i++) { | |
| 1547 | + rFactorList.add(models.get(i).getId()); | |
| 1548 | + } | |
| 1549 | + } | |
| 1550 | + patientsQuery.setrFactorList(rFactorList); | |
| 1551 | + List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 1552 | + stopWatch.stop(); | |
| 1553 | + | |
| 1554 | + logger.info(stopWatch.toString()); | |
| 1555 | + List data = new ArrayList <QuanChanResult>(); | |
| 1556 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 1557 | + if (type == 1) { | |
| 1558 | + //处理全部孕妇的情况 | |
| 1559 | + data = convertToCesareanPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 1560 | + } | |
| 1561 | + } | |
| 1562 | +// patientsQuery.mysqlBuild(data.size()); | |
| 1563 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 1564 | + } | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + public BaseResponse queryInfectiousAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 1568 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 1569 | + //威县数据流转 | |
| 1570 | + /*if(OrganizationConstant.XT_WX.equals(hospital)){ | |
| 1571 | + riskPatientsQueryRequest.setLastCheckDoctorId(String.valueOf(userId)); | |
| 1572 | + }*/ | |
| 1573 | + | |
| 1574 | + //组合请求 | |
| 1575 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + //查询符合条件的孕妇 | |
| 1579 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 1580 | + stopWatch.start(); | |
| 1581 | + | |
| 1582 | + Query yn = null; | |
| 1583 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1584 | + Criteria criteria1 = Criteria.where("name").is("梅毒"); | |
| 1585 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 1586 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1587 | + Criteria criteria2 = Criteria.where("name").is("HIV感染及艾滋病"); | |
| 1588 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 1589 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1590 | + Criteria criteria3 = Criteria.where("name").is("特殊病毒感染(H1N7、寨卡等)"); | |
| 1591 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 1592 | + } else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1593 | + Criteria criteria4 = Criteria.where("name").is("结核病"); | |
| 1594 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1595 | + } else if ("5".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1596 | + Criteria criteria4 = Criteria.where("name").is("病毒性肝炎"); | |
| 1597 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1598 | + } else if ("6".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1599 | + Criteria criteria4 = Criteria.where("name").is("重症感染性肺炎"); | |
| 1600 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1601 | + }else if ("7".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1602 | + Criteria criteria4 = Criteria.where("name").is("所有妊娠合并传染性疾病"); | |
| 1603 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1604 | + }else if ("8".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1605 | + Criteria criteria4 = Criteria.where("name").is("尖锐湿疣"); | |
| 1606 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1607 | + }else if ("9".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1608 | + Criteria criteria4 = Criteria.where("name").is("淋病"); | |
| 1609 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1610 | + }else if ("10".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1611 | + Criteria criteria4 = Criteria.where("name").is("丙肝阳性"); | |
| 1612 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1613 | + }else if ("11".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1614 | + Criteria criteria4 = Criteria.where("name").is("乙肝大三阳"); | |
| 1615 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1616 | + }else if ("12".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1617 | + Criteria criteria4 = Criteria.where("name").is("乙肝小三阳"); | |
| 1618 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1619 | + }else { | |
| 1620 | + Criteria criteria1 = Criteria.where("name").is("梅毒"); | |
| 1621 | + Criteria criteria2 = Criteria.where("name").is("HIV感染及艾滋病"); | |
| 1622 | + Criteria criteria3 = Criteria.where("name").is("特殊病毒感染(H1N7、寨卡等)"); | |
| 1623 | + Criteria criteria4 = Criteria.where("name").is("结核病"); | |
| 1624 | + Criteria criteria5 = Criteria.where("name").is("病毒性肝炎"); | |
| 1625 | + Criteria criteria6 = Criteria.where("name").is("重症感染性肺炎"); | |
| 1626 | + Criteria criteria7 = Criteria.where("name").is("所有妊娠合并传染性疾病"); | |
| 1627 | + Criteria criteria8 = Criteria.where("name").is("尖锐湿疣"); | |
| 1628 | + Criteria criteria9 = Criteria.where("name").is("淋病"); | |
| 1629 | + Criteria criteria10 = Criteria.where("name").is("丙肝阳性"); | |
| 1630 | + Criteria criteria11 = Criteria.where("name").is("乙肝大三阳"); | |
| 1631 | + Criteria criteria12 = Criteria.where("name").is("乙肝小三阳"); | |
| 1632 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3, criteria4,criteria5,criteria6,criteria7,criteria8,criteria9,criteria10,criteria11,criteria12)); | |
| 1633 | + } | |
| 1634 | + List <BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 1635 | + List <String> rFactorList = new ArrayList <>(); | |
| 1636 | + if (models != null && models.size() > 0) { | |
| 1637 | + for (int i = 0; i < models.size(); i++) { | |
| 1638 | + rFactorList.add(models.get(i).getId()); | |
| 1639 | + } | |
| 1640 | + } | |
| 1641 | + patientsQuery.setrFactorList(rFactorList); | |
| 1642 | + List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 1643 | + stopWatch.stop(); | |
| 1644 | + | |
| 1645 | + logger.info(stopWatch.toString()); | |
| 1646 | + List data = new ArrayList <QuanChanResult>(); | |
| 1647 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 1648 | + if (type == 1) { | |
| 1649 | + //处理全部孕妇的情况 | |
| 1650 | + data = convertToInfectiousPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 1651 | + } | |
| 1652 | + } | |
| 1653 | +// patientsQuery.mysqlBuild(data.size()); | |
| 1654 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 1655 | + } | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + /** | |
| 1659 | + * 高龄孕产妇全部孕妇管理 | |
| 1660 | + * | |
| 1661 | + * | |
| 1662 | + */ | |
| 1663 | + public BaseResponse queryOldAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 1664 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 1665 | + //威县数据流转 | |
| 1666 | + /*if(OrganizationConstant.XT_WX.equals(hospital)){ | |
| 1667 | + riskPatientsQueryRequest.setLastCheckDoctorId(String.valueOf(userId)); | |
| 1668 | + }*/ | |
| 1669 | + | |
| 1670 | + //组合请求 | |
| 1671 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + //查询符合条件的孕妇 | |
| 1675 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 1676 | + stopWatch.start(); | |
| 1677 | + | |
| 1678 | + Query yn = null; | |
| 1679 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1680 | + Criteria criteria1 = Criteria.where("name").is("40岁>年龄≥35岁"); | |
| 1681 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 1682 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1683 | + Criteria criteria2 = Criteria.where("name").is("年龄≥40岁"); | |
| 1684 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 1685 | + } else { | |
| 1686 | + Criteria criteria1 = Criteria.where("name").is("40岁>年龄≥35岁"); | |
| 1687 | + Criteria criteria2 = Criteria.where("name").is("年龄≥40岁"); | |
| 1688 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2)); | |
| 1689 | + } | |
| 1690 | + List <BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 1691 | + List <String> rFactorList = new ArrayList <>(); | |
| 1692 | + if (models != null && models.size() > 0) { | |
| 1693 | + for (int i = 0; i < models.size(); i++) { | |
| 1694 | + rFactorList.add(models.get(i).getId()); | |
| 1695 | + } | |
| 1696 | + } | |
| 1697 | + patientsQuery.setrFactorList(rFactorList); | |
| 1698 | + List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 1699 | + stopWatch.stop(); | |
| 1700 | + | |
| 1701 | + logger.info(stopWatch.toString()); | |
| 1702 | + List data = new ArrayList <QuanChanResult>(); | |
| 1703 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 1704 | + if (type == 1) { | |
| 1705 | + //处理全部孕妇的情况 | |
| 1706 | + data = convertToOldPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 1707 | + } | |
| 1708 | + } | |
| 1709 | +// patientsQuery.mysqlBuild(data.size()); | |
| 1710 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 1711 | + } | |
| 1712 | + | |
| 1713 | + private List convertToOldPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 1714 | + List data = new ArrayList <>(); | |
| 1715 | + int batchSize = 4; | |
| 1716 | + int end = 0; | |
| 1717 | + List <Future> listFuture = new ArrayList <>(); | |
| 1718 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 1719 | + end = (end + batchSize); | |
| 1720 | + if (end > patientses.size()) { | |
| 1721 | + end = patientses.size(); | |
| 1722 | + } | |
| 1723 | + listFuture.add(commonThreadPool.submit(new OldWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 1724 | + } | |
| 1725 | + for (Future f : listFuture) { | |
| 1726 | + try { | |
| 1727 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 1728 | + } catch (Exception e) { | |
| 1729 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 1730 | + } | |
| 1731 | + } | |
| 1732 | + return data; | |
| 1733 | + } | |
| 1734 | + | |
| 1735 | + /** | |
| 1736 | + * 甲减产妇全部孕妇管理 | |
| 1737 | + * | |
| 1738 | + * | |
| 1739 | + */ | |
| 1740 | + public BaseResponse queryhypothyroidismAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { | |
| 1741 | + String hospital = autoMatchFacade.getHospitalId(userId); | |
| 1742 | + //威县数据流转 | |
| 1743 | + /*if(OrganizationConstant.XT_WX.equals(hospital)){ | |
| 1744 | + riskPatientsQueryRequest.setLastCheckDoctorId(String.valueOf(userId)); | |
| 1745 | + }*/ | |
| 1746 | + | |
| 1747 | + //组合请求 | |
| 1748 | + PatientsQuery patientsQuery = complayRequest(riskPatientsQueryRequest, isHighRisk, type, userId, needPage, isRegion); | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + //查询符合条件的孕妇 | |
| 1752 | + StopWatch stopWatch = new StopWatch("queryPatient1 -" + hospital); | |
| 1753 | + stopWatch.start(); | |
| 1754 | + | |
| 1755 | + Query yn = null; | |
| 1756 | + if ("1".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1757 | + Criteria criteria1 = Criteria.where("name").is("亚临床甲减"); | |
| 1758 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1)); | |
| 1759 | + } else if ("2".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1760 | + Criteria criteria2 = Criteria.where("name").is("甲减(需药物治疗)"); | |
| 1761 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria2)); | |
| 1762 | + } else if ("3".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1763 | + Criteria criteria3 = Criteria.where("name").is("甲状腺功能减退引起相应系统功能障碍,基础代谢率小于-50%"); | |
| 1764 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria3)); | |
| 1765 | + } else if ("4".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1766 | + Criteria criteria4 = Criteria.where("name").is("甲状腺功能亢进症"); | |
| 1767 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria4)); | |
| 1768 | + }else if ("5".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1769 | + Criteria criteria5 = Criteria.where("name").is("甲状腺功能减退症"); | |
| 1770 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria5)); | |
| 1771 | + }else if ("6".equals(riskPatientsQueryRequest.getTwinsType())) { | |
| 1772 | + Criteria criteria6 = Criteria.where("name").is("甲状腺功能亢进并发心脏病、感染、肝功能异常、精神异常等疾病"); | |
| 1773 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria6)); | |
| 1774 | + }else { | |
| 1775 | + Criteria criteria1 = Criteria.where("name").is("亚临床甲减"); | |
| 1776 | + Criteria criteria2 = Criteria.where("name").is("甲减(需药物治疗)"); | |
| 1777 | + Criteria criteria3 = Criteria.where("name").is("甲状腺功能减退引起相应系统功能障碍,基础代谢率小于-50%"); | |
| 1778 | + Criteria criteria4 = Criteria.where("name").is("甲状腺功能亢进症"); | |
| 1779 | + Criteria criteria5 = Criteria.where("name").is("甲状腺功能减退症"); | |
| 1780 | + Criteria criteria6 = Criteria.where("name").is("甲状腺功能亢进并发心脏病、感染、肝功能异常、精神异常等疾病"); | |
| 1781 | + yn = Query.query(Criteria.where("yn").is(1).orOperator(criteria1, criteria2, criteria3, criteria4, criteria5, criteria6)); | |
| 1782 | + } | |
| 1783 | + List <BasicConfig> models = mongoTemplate.find(yn, BasicConfig.class); | |
| 1784 | + List <String> rFactorList = new ArrayList <>(); | |
| 1785 | + if (models != null && models.size() > 0) { | |
| 1786 | + for (int i = 0; i < models.size(); i++) { | |
| 1787 | + rFactorList.add(models.get(i).getId()); | |
| 1788 | + } | |
| 1789 | + } | |
| 1790 | + patientsQuery.setrFactorList(rFactorList); | |
| 1791 | + List <Patients> patientses = patientsService.queryPatientBySort(patientsQuery, riskPatientsQueryRequest.getSort(), riskPatientsQueryRequest.getOrder()); | |
| 1792 | + stopWatch.stop(); | |
| 1793 | + | |
| 1794 | + logger.info(stopWatch.toString()); | |
| 1795 | + List data = new ArrayList <QuanChanResult>(); | |
| 1796 | + if (CollectionUtils.isNotEmpty(patientses)) { | |
| 1797 | + if (type == 1) { | |
| 1798 | + //处理全部孕妇的情况 | |
| 1799 | + data = convertToHypothyroidismPatient(riskPatientsQueryRequest, patientses, userId, hospital); | |
| 1800 | + } | |
| 1801 | + } | |
| 1802 | +// patientsQuery.mysqlBuild(data.size()); | |
| 1803 | + return new BaseListResponse().setErrormsg("成功").setErrorcode(ErrorCodeConstants.SUCCESS).setData(data).setPageInfo(patientsQuery.getPageInfo()); | |
| 1804 | + } | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + private List convertToHypothyroidismPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 1808 | + List data = new ArrayList <>(); | |
| 1809 | + int batchSize = 4; | |
| 1810 | + int end = 0; | |
| 1811 | + List <Future> listFuture = new ArrayList <>(); | |
| 1812 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 1813 | + end = (end + batchSize); | |
| 1814 | + if (end > patientses.size()) { | |
| 1815 | + end = patientses.size(); | |
| 1816 | + } | |
| 1817 | + listFuture.add(commonThreadPool.submit(new HypothyroidismWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 1818 | + } | |
| 1819 | + for (Future f : listFuture) { | |
| 1820 | + try { | |
| 1821 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 1822 | + } catch (Exception e) { | |
| 1823 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 1824 | + } | |
| 1825 | + } | |
| 1826 | + return data; | |
| 1827 | + } | |
| 1508 | 1828 | public BaseResponse queryScarUterusAllPuerpera(RiskPatientsQueryRequest riskPatientsQueryRequest, Boolean isHighRisk, Integer type, Integer userId, String needPage, boolean isRegion) { |
| 1509 | 1829 | String hospital = autoMatchFacade.getHospitalId(userId); |
| 1510 | 1830 | //威县数据流转 |
| 1511 | 1831 | |
| ... | ... | @@ -1842,7 +2162,50 @@ |
| 1842 | 2162 | } |
| 1843 | 2163 | return data; |
| 1844 | 2164 | } |
| 2165 | + private List convertToInfectiousPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 2166 | + List data = new ArrayList <>(); | |
| 2167 | + int batchSize = 4; | |
| 2168 | + int end = 0; | |
| 2169 | + List <Future> listFuture = new ArrayList <>(); | |
| 2170 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 2171 | + end = (end + batchSize); | |
| 2172 | + if (end > patientses.size()) { | |
| 2173 | + end = patientses.size(); | |
| 2174 | + } | |
| 2175 | + listFuture.add(commonThreadPool.submit(new InfectiousWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 2176 | + } | |
| 2177 | + for (Future f : listFuture) { | |
| 2178 | + try { | |
| 2179 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 2180 | + } catch (Exception e) { | |
| 2181 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 2182 | + } | |
| 2183 | + } | |
| 2184 | + return data; | |
| 2185 | + } | |
| 1845 | 2186 | |
| 2187 | + private List convertToCesareanPatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List<Patients> patientses, Integer userId, String hospital) { | |
| 2188 | + List data = new ArrayList <>(); | |
| 2189 | + int batchSize = 4; | |
| 2190 | + int end = 0; | |
| 2191 | + List <Future> listFuture = new ArrayList <>(); | |
| 2192 | + for (int i = 0; i < patientses.size(); i += batchSize) { | |
| 2193 | + end = (end + batchSize); | |
| 2194 | + if (end > patientses.size()) { | |
| 2195 | + end = patientses.size(); | |
| 2196 | + } | |
| 2197 | + listFuture.add(commonThreadPool.submit(new CesareanWorker(riskPatientsQueryRequest, patientses.subList(i, end), usersService, hospital, antExService, basicConfigService, patientsService, organizationService))); | |
| 2198 | + } | |
| 2199 | + for (Future f : listFuture) { | |
| 2200 | + try { | |
| 2201 | + data.addAll((List) f.get(30, TimeUnit.SECONDS)); | |
| 2202 | + } catch (Exception e) { | |
| 2203 | + ExceptionUtils.catchException(e, "convertToQuanPatient get result Future error."); | |
| 2204 | + } | |
| 2205 | + } | |
| 2206 | + return data; | |
| 2207 | + } | |
| 2208 | + | |
| 1846 | 2209 | private List convertToBloodPressurePatient(RiskPatientsQueryRequest riskPatientsQueryRequest, List <Patients> patientses, Integer userId, String hospital) { |
| 1847 | 2210 | List data = new ArrayList <>(); |
| 1848 | 2211 | int batchSize = 4; |
| ... | ... | @@ -2080,7 +2443,7 @@ |
| 2080 | 2443 | data.put("dueDate", rp.getDueDate()); |
| 2081 | 2444 | data.put("checkDoctor", rp.getCheckDoctor()); |
| 2082 | 2445 | data.put("lName", rp.getlName()); |
| 2083 | - data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone())); | |
| 2446 | + data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : StringUtils.encryPhone(rp.getRealPhone())); | |
| 2084 | 2447 | data.put("serviceType", rp.getServiceType()); |
| 2085 | 2448 | data.put("serviceStatus", rp.getServiceStatus()); |
| 2086 | 2449 | datas.add(data); |
| ... | ... | @@ -2127,7 +2490,7 @@ |
| 2127 | 2490 | data.put("dueDate", rp.getDueDate()); |
| 2128 | 2491 | data.put("checkDoctor", rp.getCheckDoctor()); |
| 2129 | 2492 | data.put("lName", rp.getlName()); |
| 2130 | - data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone())); | |
| 2493 | + data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : StringUtils.encryPhone(rp.getRealPhone())); | |
| 2131 | 2494 | data.put("serviceType", rp.getServiceType()); |
| 2132 | 2495 | data.put("serviceStatus", rp.getServiceStatus()); |
| 2133 | 2496 | datas.add(data); |
| ... | ... | @@ -2178,7 +2541,7 @@ |
| 2178 | 2541 | data.put("cHTimes", rp.getcHTimes()); |
| 2179 | 2542 | data.put("checkDoctor", rp.getCheckDoctor()); |
| 2180 | 2543 | data.put("lName", rp.getlName()); |
| 2181 | - data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone())); | |
| 2544 | + data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : StringUtils.encryPhone(rp.getRealPhone())); | |
| 2182 | 2545 | data.put("addr", rp.getAddr()); |
| 2183 | 2546 | data.put("serviceType", "服务类型"); |
| 2184 | 2547 | data.put("serviceStatus", "服务类型"); |
| ... | ... | @@ -2303,7 +2666,7 @@ |
| 2303 | 2666 | data.put("vcCardNo", rp.getVcCardNo()); |
| 2304 | 2667 | } |
| 2305 | 2668 | data.put("cardNo", rp.getCardNo()); |
| 2306 | - data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : com.lyms.platform.common.utils.StringUtils.encryPhone(rp.getRealPhone())); | |
| 2669 | + data.put("phone", patientsQueryRequest.getIsEncry() == 0 ? rp.getRealPhone() : StringUtils.encryPhone(rp.getRealPhone())); | |
| 2307 | 2670 | data.put("dueWeek", rp.getDueWeek()); |
| 2308 | 2671 | data.put("bTime", rp.getbTime()); |
| 2309 | 2672 | data.put("cTimes", rp.getcTimes()); |
| ... | ... | @@ -2546,7 +2909,7 @@ |
| 2546 | 2909 | } |
| 2547 | 2910 | |
| 2548 | 2911 | private String getBasicConfig(String id) { |
| 2549 | - if (com.lyms.platform.common.utils.StringUtils.isEmpty(id)) { | |
| 2912 | + if (StringUtils.isEmpty(id)) { | |
| 2550 | 2913 | return ""; |
| 2551 | 2914 | } |
| 2552 | 2915 | BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(id); |
| ... | ... | @@ -2756,12 +3119,7 @@ |
| 2756 | 3119 | String hospitalId = autoMatchFacade.getHospitalId(patientManagerRequest.getOperatorId()); |
| 2757 | 3120 | |
| 2758 | 3121 | Organization organization = organizationService.getOrganization(Integer.parseInt(hospitalId)); |
| 2759 | - //遵化市妇幼保健院单独放开 | |
| 2760 | - if (!"1000000094".equals(hospitalId) && "4".equals(organization.getCityId())) | |
| 2761 | - { | |
| 2762 | - String date = DateUtil.getyyyy_MM_dd(DateUtil.addMonth(new Date(),-3))+" - "+DateUtil.getyyyy_MM_dd(new Date()); | |
| 2763 | - patientManagerRequest.setBookBuildingDate(date); | |
| 2764 | - } | |
| 3122 | + | |
| 2765 | 3123 | PatientsQuery patientsQuery = new PatientsQuery(); |
| 2766 | 3124 | patientsQuery.setCurrentAreaId(organization.getAreaId()); |
| 2767 | 3125 | patientsQuery.setWqxType(patientManagerRequest.getWqxType()); |
| ... | ... | @@ -2966,7 +3324,7 @@ |
| 2966 | 3324 | patientManagerQueryModel.setBuildWeek(dueWeek); |
| 2967 | 3325 | |
| 2968 | 3326 | String bookbuildingDoctor = ""; |
| 2969 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 3327 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 2970 | 3328 | Users user = usersService.getUsers(Integer.valueOf(patients.getBookbuildingDoctor())); |
| 2971 | 3329 | if (user != null) { |
| 2972 | 3330 | bookbuildingDoctor = user.getName(); |
| ... | ... | @@ -3241,7 +3599,7 @@ |
| 3241 | 3599 | patientManagerQueryModel.setBuildWeek(dueWeek); |
| 3242 | 3600 | |
| 3243 | 3601 | String bookbuildingDoctor = ""; |
| 3244 | - if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 3602 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 3245 | 3603 | Users user = usersService.getUsers(Integer.valueOf(patients.getBookbuildingDoctor())); |
| 3246 | 3604 | if (user != null) { |
| 3247 | 3605 | bookbuildingDoctor = user.getName(); |
| ... | ... | @@ -3704,5 +4062,6 @@ |
| 3704 | 4062 | private PremaritalCheckupFacade premaritalCheckupFacade; |
| 3705 | 4063 | @Autowired |
| 3706 | 4064 | private ResidentsArchiveFacade residentsArchiveFacade; |
| 4065 | + | |
| 3707 | 4066 | } |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/CesareanWorker.java
View file @
8e9b062
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +public class CesareanWorker implements Callable<List<QuanPatientsResult>> { | |
| 39 | + | |
| 40 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 41 | + | |
| 42 | + private List<Patients> patientses; | |
| 43 | + | |
| 44 | + private String hospital; | |
| 45 | + private UsersService usersService; | |
| 46 | + private AntenatalExaminationService antExService; | |
| 47 | + private BasicConfigService basicConfigService; | |
| 48 | + private PatientsService patientsService; | |
| 49 | + private OrganizationService organizationService; | |
| 50 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 51 | + | |
| 52 | + public CesareanWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 53 | + List<Patients> patientses, | |
| 54 | + UsersService usersService, | |
| 55 | + String hospital, | |
| 56 | + AntenatalExaminationService antExService, | |
| 57 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 58 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 59 | + this.patientses = patientses; | |
| 60 | + this.usersService = usersService; | |
| 61 | + this.antExService = antExService; | |
| 62 | + this.hospital = hospital; | |
| 63 | + this.basicConfigService = basicConfigService; | |
| 64 | + this.patientsService = patientsService; | |
| 65 | + this.organizationService = organizationService; | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public List<QuanPatientsResult> call() throws Exception { | |
| 70 | + List data = new ArrayList<>(); | |
| 71 | + AntExQuery antExQuery = new AntExQuery(); | |
| 72 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 73 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 74 | + | |
| 75 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 76 | + String twinsType = ""; | |
| 77 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 78 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + for (Patients patients : patientses) { | |
| 82 | + | |
| 83 | + StopWatch stopWatch = new StopWatch("CesareanWorker -" + patients.getId()); | |
| 84 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 85 | + twinsPatientsResult.setYi("-"); | |
| 86 | + twinsPatientsResult.setEr("-"); | |
| 87 | + twinsPatientsResult.setSan("-"); | |
| 88 | + twinsPatientsResult.setSi("-"); | |
| 89 | + twinsPatientsResult.setWu("-"); | |
| 90 | + twinsPatientsResult.convertToResult(patients); | |
| 91 | + antExQuery.setPid(patients.getPid()); | |
| 92 | + //增加查询本次产程条数 | |
| 93 | + antExQuery.setStart(patients.getLastMenses()); | |
| 94 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 95 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 96 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 97 | + if (null != users) { | |
| 98 | + twinsPatientsResult.setlName(users.getName()); | |
| 99 | + } else { | |
| 100 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 101 | + } | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + //筛查结果 | |
| 107 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 108 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 109 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 110 | + stopWatch.start("query ant count"); | |
| 111 | + antExChuQuery1.setPid(patients.getPid()); | |
| 112 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 113 | + //增加查询本次产程条数 | |
| 114 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 115 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 116 | + //复诊次数 | |
| 117 | + List<AntenatalExaminationModel> ant = null; | |
| 118 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 119 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 120 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 121 | + if (a.getHospitalId().equals(hospital)) { | |
| 122 | + twinsPatientsResult.setYi("本院"); | |
| 123 | + } else { | |
| 124 | + twinsPatientsResult.setYi("外院"); | |
| 125 | + } | |
| 126 | + break; | |
| 127 | + } | |
| 128 | + } | |
| 129 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 130 | + } | |
| 131 | + | |
| 132 | + //唐山滦县判断复诊是否是本院 | |
| 133 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 134 | + for (int k = 0; k < ant.size(); k++) { | |
| 135 | + if (k >= 4) { | |
| 136 | + break; | |
| 137 | + } | |
| 138 | + if (0 == k) { | |
| 139 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 140 | + twinsPatientsResult.setEr("本院"); | |
| 141 | + } else { | |
| 142 | + twinsPatientsResult.setEr("外院"); | |
| 143 | + } | |
| 144 | + } else if (1 == k) { | |
| 145 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 146 | + twinsPatientsResult.setSan("本院"); | |
| 147 | + } else { | |
| 148 | + twinsPatientsResult.setSan("外院"); | |
| 149 | + } | |
| 150 | + } else if (2 == k) { | |
| 151 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 152 | + twinsPatientsResult.setSi("本院"); | |
| 153 | + } else { | |
| 154 | + twinsPatientsResult.setSi("外院"); | |
| 155 | + } | |
| 156 | + } else if (3 == k) { | |
| 157 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 158 | + twinsPatientsResult.setWu("本院"); | |
| 159 | + } else { | |
| 160 | + twinsPatientsResult.setWu("外院"); | |
| 161 | + } | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + //系统初诊次数 | |
| 167 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 168 | + | |
| 169 | + //系统复诊次数 | |
| 170 | + int i = 0; | |
| 171 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 172 | + //复诊次数 | |
| 173 | + i = ant.size(); | |
| 174 | + sort(ant); | |
| 175 | + for (AntenatalExaminationModel a : ant) { | |
| 176 | + try { | |
| 177 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 178 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 179 | + if (null != og) { | |
| 180 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 181 | + break; | |
| 182 | + } | |
| 183 | + } | |
| 184 | + } catch (Exception e) { | |
| 185 | + twinsPatientsResult.setCurrentCh(""); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + } else { | |
| 189 | + for (AntExChuModel a : chu) { | |
| 190 | + try { | |
| 191 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 192 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 193 | + if (null != og) { | |
| 194 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 195 | + break; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + } catch (Exception e) { | |
| 199 | + twinsPatientsResult.setCurrentCh(""); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + } | |
| 203 | + | |
| 204 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 205 | + | |
| 206 | + | |
| 207 | + antExQuery.setHospitalId(hospital); | |
| 208 | + //本院初诊 | |
| 209 | + int chi = countAntChu(chu, hospital); | |
| 210 | + | |
| 211 | + //本院复诊 | |
| 212 | + int chb = capLocalHospital(hospital, ant); | |
| 213 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 214 | + stopWatch.stop(); | |
| 215 | + String nextCheckTime = ""; | |
| 216 | + stopWatch.start("query antex list"); | |
| 217 | + | |
| 218 | + | |
| 219 | + if (null != patients.getNextCheckTime()) { | |
| 220 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 224 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 225 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 226 | + if (null != users) { | |
| 227 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 228 | + } else { | |
| 229 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 230 | + } | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } | |
| 235 | + | |
| 236 | + | |
| 237 | + stopWatch.stop(); | |
| 238 | + stopWatch.start("query basicconfig"); | |
| 239 | + //注册地址 | |
| 240 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 241 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 242 | + try { | |
| 243 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 244 | + } catch (Exception e) { | |
| 245 | + twinsPatientsResult.setFirstBH(""); | |
| 246 | + } | |
| 247 | + | |
| 248 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 249 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 250 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 251 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 252 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 253 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 254 | + | |
| 255 | + | |
| 256 | + //高危因素 | |
| 257 | + List<String> factor = patients.getRiskFactorId(); | |
| 258 | + | |
| 259 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 260 | + StringBuilder sb = new StringBuilder(56); | |
| 261 | + for (String srt : factor) { | |
| 262 | + if (StringUtils.isNotEmpty(srt)) { | |
| 263 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 264 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 265 | + if(basicConfig.getName().contains("各类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥2次") || | |
| 266 | + basicConfig.getName().contains("瘢痕子宫(距前次剖宫产不足2年)") || | |
| 267 | + basicConfig.getName().contains("剖宫产1次")|| | |
| 268 | + basicConfig.getName().contains("剖宫产≥2次")){ | |
| 269 | + sb.append(basicConfig.getName()).append(','); | |
| 270 | + } | |
| 271 | + } | |
| 272 | + } | |
| 273 | + } | |
| 274 | + if (sb.toString().endsWith(",")) { | |
| 275 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 276 | + } else { | |
| 277 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 278 | + } | |
| 279 | + | |
| 280 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 281 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 282 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 283 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 284 | + }*/ | |
| 285 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 286 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 287 | + } | |
| 288 | + List level = new ArrayList(); | |
| 289 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 290 | + try { | |
| 291 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 292 | + for (String str : list) { | |
| 293 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 294 | + if (null != basicConfig) { | |
| 295 | + Map map = new HashMap(); | |
| 296 | + basicConfig.replenRisk(map); | |
| 297 | + // String name = basicConfig.getName(); | |
| 298 | + // if (name.indexOf("预警") > -1) { | |
| 299 | + // name = name.replace("预警", ""); | |
| 300 | + // } | |
| 301 | + // map.put("name", name); | |
| 302 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 303 | + level.add(map); | |
| 304 | + } | |
| 305 | + } | |
| 306 | + } catch (Exception e) { | |
| 307 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 308 | + } | |
| 309 | + | |
| 310 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 311 | + } | |
| 312 | + twinsPatientsResult.setCardNo(patients.getCardNo()); | |
| 313 | + twinsPatientsResult.setPcerteTypeId(patients.getPcerteTypeId()); | |
| 314 | + stopWatch.stop(); | |
| 315 | + if (twinsPatientsResult.getrFactor() != null) { | |
| 316 | + //双绒双羊、单绒单羊、单绒双羊 | |
| 317 | + if ("1".equals(twinsType)) { | |
| 318 | + if (twinsPatientsResult.getrFactor().contains("类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥次")) { | |
| 319 | + data.add(twinsPatientsResult); | |
| 320 | + } | |
| 321 | + | |
| 322 | + } else if ("2".equals(twinsType)) { | |
| 323 | + if (twinsPatientsResult.getrFactor().contains("瘢痕子宫(距前次剖宫产不足2年)")) { | |
| 324 | + data.add(twinsPatientsResult); | |
| 325 | + } | |
| 326 | + } else if ("3".equals(twinsType)) { | |
| 327 | + if (twinsPatientsResult.getrFactor().contains("剖宫产1次")) { | |
| 328 | + data.add(twinsPatientsResult); | |
| 329 | + } | |
| 330 | + } else if ("4".equals(twinsType)) { | |
| 331 | + if (twinsPatientsResult.getrFactor().contains("剖宫产≥2次")) { | |
| 332 | + data.add(twinsPatientsResult); | |
| 333 | + } | |
| 334 | + } else if (twinsPatientsResult.getrFactor().contains("类子宫手术史(如剖宫产、宫角妊娠、子宫肌瘤挖除术等)≥次") || | |
| 335 | + twinsPatientsResult.getrFactor().contains("瘢痕子宫(距前次剖宫产不足2年)") || | |
| 336 | + twinsPatientsResult.getrFactor().contains("剖宫产1次")|| | |
| 337 | + twinsPatientsResult.getrFactor().contains("剖宫产≥2次")) { | |
| 338 | + data.add(twinsPatientsResult); | |
| 339 | + } | |
| 340 | + } | |
| 341 | + logger.debug(stopWatch.toString()); | |
| 342 | + } | |
| 343 | + return data; | |
| 344 | + } | |
| 345 | + | |
| 346 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 347 | + if (CollectionUtils.isEmpty(list)) { | |
| 348 | + return 0; | |
| 349 | + } | |
| 350 | + int count = 0; | |
| 351 | + for (AntenatalExaminationModel model : list) { | |
| 352 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 353 | + count++; | |
| 354 | + } | |
| 355 | + } | |
| 356 | + return count; | |
| 357 | + } | |
| 358 | + | |
| 359 | + //统计复查里面的本院检查数 | |
| 360 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 361 | + int count = 0; | |
| 362 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 363 | + return count; | |
| 364 | + } | |
| 365 | + for (AntExChuModel model : list) { | |
| 366 | + if (hospital.equals(model.getHospitalId())) { | |
| 367 | + count++; | |
| 368 | + } | |
| 369 | + } | |
| 370 | + return count; | |
| 371 | + } | |
| 372 | + | |
| 373 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 374 | + if (CollectionUtils.isEmpty(list)) { | |
| 375 | + return; | |
| 376 | + } | |
| 377 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 378 | + @Override | |
| 379 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 380 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 381 | + return 1; | |
| 382 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 383 | + return -1; | |
| 384 | + } | |
| 385 | + return 0; | |
| 386 | + } | |
| 387 | + }); | |
| 388 | + } | |
| 389 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/HypothyroidismWorker.java
View file @
8e9b062
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +public class HypothyroidismWorker implements Callable<List<QuanPatientsResult>> { | |
| 39 | + | |
| 40 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 41 | + | |
| 42 | + private List<Patients> patientses; | |
| 43 | + | |
| 44 | + private String hospital; | |
| 45 | + private UsersService usersService; | |
| 46 | + private AntenatalExaminationService antExService; | |
| 47 | + private BasicConfigService basicConfigService; | |
| 48 | + private PatientsService patientsService; | |
| 49 | + private OrganizationService organizationService; | |
| 50 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 51 | + | |
| 52 | + public HypothyroidismWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 53 | + List<Patients> patientses, | |
| 54 | + UsersService usersService, | |
| 55 | + String hospital, | |
| 56 | + AntenatalExaminationService antExService, | |
| 57 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 58 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 59 | + this.patientses = patientses; | |
| 60 | + this.usersService = usersService; | |
| 61 | + this.antExService = antExService; | |
| 62 | + this.hospital = hospital; | |
| 63 | + this.basicConfigService = basicConfigService; | |
| 64 | + this.patientsService = patientsService; | |
| 65 | + this.organizationService = organizationService; | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public List<QuanPatientsResult> call() throws Exception { | |
| 70 | + List data = new ArrayList<>(); | |
| 71 | + AntExQuery antExQuery = new AntExQuery(); | |
| 72 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 73 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 74 | + | |
| 75 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 76 | + String twinsType = ""; | |
| 77 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 78 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + for (Patients patients : patientses) { | |
| 82 | + | |
| 83 | + StopWatch stopWatch = new StopWatch("HypothyroidismWorker -" + patients.getId()); | |
| 84 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 85 | + twinsPatientsResult.setYi("-"); | |
| 86 | + twinsPatientsResult.setEr("-"); | |
| 87 | + twinsPatientsResult.setSan("-"); | |
| 88 | + twinsPatientsResult.setSi("-"); | |
| 89 | + twinsPatientsResult.setWu("-"); | |
| 90 | + twinsPatientsResult.convertToResult(patients); | |
| 91 | + antExQuery.setPid(patients.getPid()); | |
| 92 | + //增加查询本次产程条数 | |
| 93 | + antExQuery.setStart(patients.getLastMenses()); | |
| 94 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 95 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 96 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 97 | + if (null != users) { | |
| 98 | + twinsPatientsResult.setlName(users.getName()); | |
| 99 | + } else { | |
| 100 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 101 | + } | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + //筛查结果 | |
| 107 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 108 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 109 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 110 | + stopWatch.start("query ant count"); | |
| 111 | + antExChuQuery1.setPid(patients.getPid()); | |
| 112 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 113 | + //增加查询本次产程条数 | |
| 114 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 115 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 116 | + //复诊次数 | |
| 117 | + List<AntenatalExaminationModel> ant = null; | |
| 118 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 119 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 120 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 121 | + if (a.getHospitalId().equals(hospital)) { | |
| 122 | + twinsPatientsResult.setYi("本院"); | |
| 123 | + } else { | |
| 124 | + twinsPatientsResult.setYi("外院"); | |
| 125 | + } | |
| 126 | + break; | |
| 127 | + } | |
| 128 | + } | |
| 129 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 130 | + } | |
| 131 | + | |
| 132 | + //唐山滦县判断复诊是否是本院 | |
| 133 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 134 | + for (int k = 0; k < ant.size(); k++) { | |
| 135 | + if (k >= 4) { | |
| 136 | + break; | |
| 137 | + } | |
| 138 | + if (0 == k) { | |
| 139 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 140 | + twinsPatientsResult.setEr("本院"); | |
| 141 | + } else { | |
| 142 | + twinsPatientsResult.setEr("外院"); | |
| 143 | + } | |
| 144 | + } else if (1 == k) { | |
| 145 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 146 | + twinsPatientsResult.setSan("本院"); | |
| 147 | + } else { | |
| 148 | + twinsPatientsResult.setSan("外院"); | |
| 149 | + } | |
| 150 | + } else if (2 == k) { | |
| 151 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 152 | + twinsPatientsResult.setSi("本院"); | |
| 153 | + } else { | |
| 154 | + twinsPatientsResult.setSi("外院"); | |
| 155 | + } | |
| 156 | + } else if (3 == k) { | |
| 157 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 158 | + twinsPatientsResult.setWu("本院"); | |
| 159 | + } else { | |
| 160 | + twinsPatientsResult.setWu("外院"); | |
| 161 | + } | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + //系统初诊次数 | |
| 167 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 168 | + | |
| 169 | + //系统复诊次数 | |
| 170 | + int i = 0; | |
| 171 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 172 | + //复诊次数 | |
| 173 | + i = ant.size(); | |
| 174 | + sort(ant); | |
| 175 | + for (AntenatalExaminationModel a : ant) { | |
| 176 | + try { | |
| 177 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 178 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 179 | + if (null != og) { | |
| 180 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 181 | + break; | |
| 182 | + } | |
| 183 | + } | |
| 184 | + } catch (Exception e) { | |
| 185 | + twinsPatientsResult.setCurrentCh(""); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + } else { | |
| 189 | + for (AntExChuModel a : chu) { | |
| 190 | + try { | |
| 191 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 192 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 193 | + if (null != og) { | |
| 194 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 195 | + break; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + } catch (Exception e) { | |
| 199 | + twinsPatientsResult.setCurrentCh(""); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + } | |
| 203 | + | |
| 204 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 205 | + | |
| 206 | + | |
| 207 | + antExQuery.setHospitalId(hospital); | |
| 208 | + //本院初诊 | |
| 209 | + int chi = countAntChu(chu, hospital); | |
| 210 | + | |
| 211 | + //本院复诊 | |
| 212 | + int chb = capLocalHospital(hospital, ant); | |
| 213 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 214 | + stopWatch.stop(); | |
| 215 | + String nextCheckTime = ""; | |
| 216 | + stopWatch.start("query antex list"); | |
| 217 | + | |
| 218 | + | |
| 219 | + if (null != patients.getNextCheckTime()) { | |
| 220 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 224 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 225 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 226 | + if (null != users) { | |
| 227 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 228 | + } else { | |
| 229 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 230 | + } | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } | |
| 235 | + | |
| 236 | + | |
| 237 | + stopWatch.stop(); | |
| 238 | + stopWatch.start("query basicconfig"); | |
| 239 | + //注册地址 | |
| 240 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 241 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 242 | + try { | |
| 243 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 244 | + } catch (Exception e) { | |
| 245 | + twinsPatientsResult.setFirstBH(""); | |
| 246 | + } | |
| 247 | + | |
| 248 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 249 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 250 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 251 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 252 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 253 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 254 | + | |
| 255 | + | |
| 256 | + //高危因素 | |
| 257 | + List<String> factor = patients.getRiskFactorId(); | |
| 258 | + | |
| 259 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 260 | + StringBuilder sb = new StringBuilder(56); | |
| 261 | + for (String srt : factor) { | |
| 262 | + if (StringUtils.isNotEmpty(srt)) { | |
| 263 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 264 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 265 | + if(basicConfig.getName().contains("亚临床甲减") || | |
| 266 | + basicConfig.getName().contains("甲减(需药物治疗)")|| | |
| 267 | + basicConfig.getName().contains("状腺功能减退引起相应系统功能障碍,基础代谢率小于-50%")|| | |
| 268 | + basicConfig.getName().contains("甲状腺功能亢进症")|| | |
| 269 | + basicConfig.getName().contains("甲状腺功能减退症")|| | |
| 270 | + basicConfig.getName().contains("甲状腺功能亢进并发心脏病、感染、肝功能异常、精神异常等疾病")){ | |
| 271 | + sb.append(basicConfig.getName()).append(','); | |
| 272 | + } | |
| 273 | + } | |
| 274 | + } | |
| 275 | + } | |
| 276 | + if (sb.toString().endsWith(",")) { | |
| 277 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 278 | + } else { | |
| 279 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 280 | + } | |
| 281 | + | |
| 282 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 283 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 284 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 285 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 286 | + }*/ | |
| 287 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 288 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 289 | + } | |
| 290 | + List level = new ArrayList(); | |
| 291 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 292 | + try { | |
| 293 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 294 | + for (String str : list) { | |
| 295 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 296 | + if (null != basicConfig) { | |
| 297 | + Map map = new HashMap(); | |
| 298 | + basicConfig.replenRisk(map); | |
| 299 | + // String name = basicConfig.getName(); | |
| 300 | + // if (name.indexOf("预警") > -1) { | |
| 301 | + // name = name.replace("预警", ""); | |
| 302 | + // } | |
| 303 | + // map.put("name", name); | |
| 304 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 305 | + level.add(map); | |
| 306 | + } | |
| 307 | + } | |
| 308 | + } catch (Exception e) { | |
| 309 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 310 | + } | |
| 311 | + | |
| 312 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 313 | + } | |
| 314 | + twinsPatientsResult.setCardNo(patients.getCardNo()); | |
| 315 | + twinsPatientsResult.setPcerteTypeId(patients.getPcerteTypeId()); | |
| 316 | + stopWatch.stop(); | |
| 317 | + if (twinsPatientsResult.getrFactor() != null) { | |
| 318 | + //双绒双羊、单绒单羊、单绒双羊 | |
| 319 | + if ("1".equals(twinsType)) { | |
| 320 | + if (twinsPatientsResult.getrFactor().contains("亚临床甲减")) { | |
| 321 | + data.add(twinsPatientsResult); | |
| 322 | + } | |
| 323 | + | |
| 324 | + } else if ("2".equals(twinsType)) { | |
| 325 | + if (twinsPatientsResult.getrFactor().contains("甲减(需药物治疗)")) { | |
| 326 | + data.add(twinsPatientsResult); | |
| 327 | + } | |
| 328 | + } else if ("3".equals(twinsType)) { | |
| 329 | + if (twinsPatientsResult.getrFactor().contains("状腺功能减退引起相应系统功能障碍,基础代谢率小于-50%")) { | |
| 330 | + data.add(twinsPatientsResult); | |
| 331 | + } | |
| 332 | + } else if ("4".equals(twinsType)) { | |
| 333 | + if (twinsPatientsResult.getrFactor().contains("甲状腺功能亢进症")) { | |
| 334 | + data.add(twinsPatientsResult); | |
| 335 | + } | |
| 336 | + } else if ("5".equals(twinsType)) { | |
| 337 | + if (twinsPatientsResult.getrFactor().contains("甲状腺功能减退症")) { | |
| 338 | + data.add(twinsPatientsResult); | |
| 339 | + } | |
| 340 | + } else if ("6".equals(twinsType)) { | |
| 341 | + if (twinsPatientsResult.getrFactor().contains("甲状腺功能亢进并发心脏病、感染、肝功能异常、精神异常等疾病")) { | |
| 342 | + data.add(twinsPatientsResult); | |
| 343 | + } | |
| 344 | + } else if (twinsPatientsResult.getrFactor().contains("亚临床甲减") || | |
| 345 | + twinsPatientsResult.getrFactor().contains("甲减(需药物治疗)") || | |
| 346 | + twinsPatientsResult.getrFactor().contains("状腺功能减退引起相应系统功能障碍,基础代谢率小于-50%") || | |
| 347 | + twinsPatientsResult.getrFactor().contains("甲状腺功能亢进症") || | |
| 348 | + twinsPatientsResult.getrFactor().contains("甲状腺功能减退症") || | |
| 349 | + twinsPatientsResult.getrFactor().contains("甲状腺功能亢进并发心脏病、感染、肝功能异常、精神异常等疾病")) { | |
| 350 | + data.add(twinsPatientsResult); | |
| 351 | + } | |
| 352 | + } | |
| 353 | + logger.debug(stopWatch.toString()); | |
| 354 | + } | |
| 355 | + return data; | |
| 356 | + } | |
| 357 | + | |
| 358 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 359 | + if (CollectionUtils.isEmpty(list)) { | |
| 360 | + return 0; | |
| 361 | + } | |
| 362 | + int count = 0; | |
| 363 | + for (AntenatalExaminationModel model : list) { | |
| 364 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 365 | + count++; | |
| 366 | + } | |
| 367 | + } | |
| 368 | + return count; | |
| 369 | + } | |
| 370 | + | |
| 371 | + //统计复查里面的本院检查数 | |
| 372 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 373 | + int count = 0; | |
| 374 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 375 | + return count; | |
| 376 | + } | |
| 377 | + for (AntExChuModel model : list) { | |
| 378 | + if (hospital.equals(model.getHospitalId())) { | |
| 379 | + count++; | |
| 380 | + } | |
| 381 | + } | |
| 382 | + return count; | |
| 383 | + } | |
| 384 | + | |
| 385 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 386 | + if (CollectionUtils.isEmpty(list)) { | |
| 387 | + return; | |
| 388 | + } | |
| 389 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 390 | + @Override | |
| 391 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 392 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 393 | + return 1; | |
| 394 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 395 | + return -1; | |
| 396 | + } | |
| 397 | + return 0; | |
| 398 | + } | |
| 399 | + }); | |
| 400 | + } | |
| 401 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/InfectiousWorker.java
View file @
8e9b062
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +public class InfectiousWorker implements Callable<List<QuanPatientsResult>> { | |
| 39 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 40 | + | |
| 41 | + private List<Patients> patientses; | |
| 42 | + | |
| 43 | + private String hospital; | |
| 44 | + private UsersService usersService; | |
| 45 | + private AntenatalExaminationService antExService; | |
| 46 | + private BasicConfigService basicConfigService; | |
| 47 | + private PatientsService patientsService; | |
| 48 | + private OrganizationService organizationService; | |
| 49 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 50 | + | |
| 51 | + public InfectiousWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 52 | + List<Patients> patientses, | |
| 53 | + UsersService usersService, | |
| 54 | + String hospital, | |
| 55 | + AntenatalExaminationService antExService, | |
| 56 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 57 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 58 | + this.patientses = patientses; | |
| 59 | + this.usersService = usersService; | |
| 60 | + this.antExService = antExService; | |
| 61 | + this.hospital = hospital; | |
| 62 | + this.basicConfigService = basicConfigService; | |
| 63 | + this.patientsService = patientsService; | |
| 64 | + this.organizationService = organizationService; | |
| 65 | + } | |
| 66 | + | |
| 67 | + @Override | |
| 68 | + public List<QuanPatientsResult> call() throws Exception { | |
| 69 | + List data = new ArrayList<>(); | |
| 70 | + AntExQuery antExQuery = new AntExQuery(); | |
| 71 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 72 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 73 | + | |
| 74 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 75 | + String twinsType = ""; | |
| 76 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 77 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 78 | + } | |
| 79 | + | |
| 80 | + for (Patients patients : patientses) { | |
| 81 | + | |
| 82 | + StopWatch stopWatch = new StopWatch("InfectiousWorker -" + patients.getId()); | |
| 83 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 84 | + twinsPatientsResult.setYi("-"); | |
| 85 | + twinsPatientsResult.setEr("-"); | |
| 86 | + twinsPatientsResult.setSan("-"); | |
| 87 | + twinsPatientsResult.setSi("-"); | |
| 88 | + twinsPatientsResult.setWu("-"); | |
| 89 | + twinsPatientsResult.convertToResult(patients); | |
| 90 | + antExQuery.setPid(patients.getPid()); | |
| 91 | + //增加查询本次产程条数 | |
| 92 | + antExQuery.setStart(patients.getLastMenses()); | |
| 93 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 94 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 95 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 96 | + if (null != users) { | |
| 97 | + twinsPatientsResult.setlName(users.getName()); | |
| 98 | + } else { | |
| 99 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 100 | + } | |
| 101 | + } else { | |
| 102 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 103 | + } | |
| 104 | + } | |
| 105 | + //筛查结果 | |
| 106 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 107 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 108 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 109 | + stopWatch.start("query ant count"); | |
| 110 | + antExChuQuery1.setPid(patients.getPid()); | |
| 111 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 112 | + //增加查询本次产程条数 | |
| 113 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 114 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 115 | + //复诊次数 | |
| 116 | + List<AntenatalExaminationModel> ant = null; | |
| 117 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 118 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 119 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 120 | + if (a.getHospitalId().equals(hospital)) { | |
| 121 | + twinsPatientsResult.setYi("本院"); | |
| 122 | + } else { | |
| 123 | + twinsPatientsResult.setYi("外院"); | |
| 124 | + } | |
| 125 | + break; | |
| 126 | + } | |
| 127 | + } | |
| 128 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 129 | + } | |
| 130 | + | |
| 131 | + //唐山滦县判断复诊是否是本院 | |
| 132 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 133 | + for (int k = 0; k < ant.size(); k++) { | |
| 134 | + if (k >= 4) { | |
| 135 | + break; | |
| 136 | + } | |
| 137 | + if (0 == k) { | |
| 138 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 139 | + twinsPatientsResult.setEr("本院"); | |
| 140 | + } else { | |
| 141 | + twinsPatientsResult.setEr("外院"); | |
| 142 | + } | |
| 143 | + } else if (1 == k) { | |
| 144 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 145 | + twinsPatientsResult.setSan("本院"); | |
| 146 | + } else { | |
| 147 | + twinsPatientsResult.setSan("外院"); | |
| 148 | + } | |
| 149 | + } else if (2 == k) { | |
| 150 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 151 | + twinsPatientsResult.setSi("本院"); | |
| 152 | + } else { | |
| 153 | + twinsPatientsResult.setSi("外院"); | |
| 154 | + } | |
| 155 | + } else if (3 == k) { | |
| 156 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 157 | + twinsPatientsResult.setWu("本院"); | |
| 158 | + } else { | |
| 159 | + twinsPatientsResult.setWu("外院"); | |
| 160 | + } | |
| 161 | + } | |
| 162 | + } | |
| 163 | + } | |
| 164 | + | |
| 165 | + //系统初诊次数 | |
| 166 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 167 | + | |
| 168 | + //系统复诊次数 | |
| 169 | + int i = 0; | |
| 170 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 171 | + //复诊次数 | |
| 172 | + i = ant.size(); | |
| 173 | + sort(ant); | |
| 174 | + for (AntenatalExaminationModel a : ant) { | |
| 175 | + try { | |
| 176 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 177 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 178 | + if (null != og) { | |
| 179 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 180 | + break; | |
| 181 | + } | |
| 182 | + } | |
| 183 | + } catch (Exception e) { | |
| 184 | + twinsPatientsResult.setCurrentCh(""); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + } else { | |
| 188 | + for (AntExChuModel a : chu) { | |
| 189 | + try { | |
| 190 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 191 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 192 | + if (null != og) { | |
| 193 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 194 | + break; | |
| 195 | + } | |
| 196 | + } | |
| 197 | + } catch (Exception e) { | |
| 198 | + twinsPatientsResult.setCurrentCh(""); | |
| 199 | + } | |
| 200 | + } | |
| 201 | + } | |
| 202 | + | |
| 203 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 204 | + | |
| 205 | + | |
| 206 | + antExQuery.setHospitalId(hospital); | |
| 207 | + //本院初诊 | |
| 208 | + int chi = countAntChu(chu, hospital); | |
| 209 | + | |
| 210 | + //本院复诊 | |
| 211 | + int chb = capLocalHospital(hospital, ant); | |
| 212 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 213 | + stopWatch.stop(); | |
| 214 | + String nextCheckTime = ""; | |
| 215 | + stopWatch.start("query antex list"); | |
| 216 | + | |
| 217 | + | |
| 218 | + if (null != patients.getNextCheckTime()) { | |
| 219 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 220 | + } | |
| 221 | + | |
| 222 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 223 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 224 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 225 | + if (null != users) { | |
| 226 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 227 | + } else { | |
| 228 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 229 | + } | |
| 230 | + } else { | |
| 231 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 232 | + } | |
| 233 | + } | |
| 234 | + | |
| 235 | + | |
| 236 | + stopWatch.stop(); | |
| 237 | + stopWatch.start("query basicconfig"); | |
| 238 | + //注册地址 | |
| 239 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 240 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 241 | + try { | |
| 242 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 243 | + } catch (Exception e) { | |
| 244 | + twinsPatientsResult.setFirstBH(""); | |
| 245 | + } | |
| 246 | + | |
| 247 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 248 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 249 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 250 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 251 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 252 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 253 | + | |
| 254 | + | |
| 255 | + //高危因素 | |
| 256 | + List<String> factor = patients.getRiskFactorId(); | |
| 257 | + | |
| 258 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 259 | + StringBuilder sb = new StringBuilder(56); | |
| 260 | + for (String srt : factor) { | |
| 261 | + if (StringUtils.isNotEmpty(srt)) { | |
| 262 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 263 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 264 | + if(basicConfig.getName().contains("梅毒") || | |
| 265 | + basicConfig.getName().contains("HIV感染及艾滋病") || | |
| 266 | + basicConfig.getName().contains("特殊病毒感染(H1N7、寨卡等)")|| | |
| 267 | + basicConfig.getName().contains("结核病")|| | |
| 268 | + basicConfig.getName().contains("病毒性肝炎")|| | |
| 269 | + basicConfig.getName().contains("重症感染性肺炎")|| | |
| 270 | + basicConfig.getName().contains("所有妊娠合并传染性疾病")|| | |
| 271 | + basicConfig.getName().contains("尖锐湿疣")|| | |
| 272 | + basicConfig.getName().contains("淋病")|| | |
| 273 | + basicConfig.getName().contains("丙肝阳性")|| | |
| 274 | + basicConfig.getName().contains("乙肝大三阳")|| | |
| 275 | + basicConfig.getName().contains("乙肝小三阳")){ | |
| 276 | + sb.append(basicConfig.getName()).append(','); | |
| 277 | + } | |
| 278 | + } | |
| 279 | + } | |
| 280 | + } | |
| 281 | + if (sb.toString().endsWith(",")) { | |
| 282 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 283 | + } else { | |
| 284 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 285 | + } | |
| 286 | + | |
| 287 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 288 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 289 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 290 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 291 | + }*/ | |
| 292 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 293 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 294 | + } | |
| 295 | + List level = new ArrayList(); | |
| 296 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 297 | + try { | |
| 298 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 299 | + for (String str : list) { | |
| 300 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 301 | + if (null != basicConfig) { | |
| 302 | + Map map = new HashMap(); | |
| 303 | + basicConfig.replenRisk(map); | |
| 304 | + // String name = basicConfig.getName(); | |
| 305 | + // if (name.indexOf("预警") > -1) { | |
| 306 | + // name = name.replace("预警", ""); | |
| 307 | + // } | |
| 308 | + // map.put("name", name); | |
| 309 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 310 | + level.add(map); | |
| 311 | + } | |
| 312 | + } | |
| 313 | + } catch (Exception e) { | |
| 314 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 315 | + } | |
| 316 | + | |
| 317 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 318 | + } | |
| 319 | + twinsPatientsResult.setCardNo(patients.getCardNo()); | |
| 320 | + twinsPatientsResult.setPcerteTypeId(patients.getPcerteTypeId()); | |
| 321 | + stopWatch.stop(); | |
| 322 | + if (twinsPatientsResult.getrFactor() != null) { | |
| 323 | + //双绒双羊、单绒单羊、单绒双羊 | |
| 324 | + if ("1".equals(twinsType)) { | |
| 325 | + if (twinsPatientsResult.getrFactor().contains("梅毒")) { | |
| 326 | + data.add(twinsPatientsResult); | |
| 327 | + } | |
| 328 | + | |
| 329 | + } else if ("2".equals(twinsType)) { | |
| 330 | + if (twinsPatientsResult.getrFactor().contains("HIV感染及艾滋病")) { | |
| 331 | + data.add(twinsPatientsResult); | |
| 332 | + } | |
| 333 | + } else if ("3".equals(twinsType)) { | |
| 334 | + if (twinsPatientsResult.getrFactor().contains("特殊病毒感染(H1N7、寨卡等)")) { | |
| 335 | + data.add(twinsPatientsResult); | |
| 336 | + } | |
| 337 | + } else if ("4".equals(twinsType)) { | |
| 338 | + if (twinsPatientsResult.getrFactor().contains("结核病")) { | |
| 339 | + data.add(twinsPatientsResult); | |
| 340 | + } | |
| 341 | + } else if ("5".equals(twinsType)) { | |
| 342 | + if (twinsPatientsResult.getrFactor().contains("病毒性肝炎")) { | |
| 343 | + data.add(twinsPatientsResult); | |
| 344 | + } | |
| 345 | + }else if ("6".equals(twinsType)) { | |
| 346 | + if (twinsPatientsResult.getrFactor().contains("重症感染性肺炎")) { | |
| 347 | + data.add(twinsPatientsResult); | |
| 348 | + } | |
| 349 | + }else if ("7".equals(twinsType)) { | |
| 350 | + if (twinsPatientsResult.getrFactor().contains("所有妊娠合并传染性疾病")) { | |
| 351 | + data.add(twinsPatientsResult); | |
| 352 | + } | |
| 353 | + }else if ("8".equals(twinsType)) { | |
| 354 | + if (twinsPatientsResult.getrFactor().contains("尖锐湿疣")) { | |
| 355 | + data.add(twinsPatientsResult); | |
| 356 | + } | |
| 357 | + }else if ("9".equals(twinsType)) { | |
| 358 | + if (twinsPatientsResult.getrFactor().contains("淋病")) { | |
| 359 | + data.add(twinsPatientsResult); | |
| 360 | + } | |
| 361 | + }else if ("10".equals(twinsType)) { | |
| 362 | + if (twinsPatientsResult.getrFactor().contains("丙肝阳性")) { | |
| 363 | + data.add(twinsPatientsResult); | |
| 364 | + } | |
| 365 | + }else if ("11".equals(twinsType)) { | |
| 366 | + if (twinsPatientsResult.getrFactor().contains("乙肝大三阳")) { | |
| 367 | + data.add(twinsPatientsResult); | |
| 368 | + } | |
| 369 | + }else if ("12".equals(twinsType)) { | |
| 370 | + if (twinsPatientsResult.getrFactor().contains("乙肝小三阳")) { | |
| 371 | + data.add(twinsPatientsResult); | |
| 372 | + } | |
| 373 | + }else if (twinsPatientsResult.getrFactor().contains("梅毒") || | |
| 374 | + twinsPatientsResult.getrFactor().contains("HIV感染及艾滋病") || | |
| 375 | + twinsPatientsResult.getrFactor().contains("特殊病毒感染(H1N7、寨卡等)")|| | |
| 376 | + twinsPatientsResult.getrFactor().contains("结核病")|| | |
| 377 | + twinsPatientsResult.getrFactor().contains("病毒性肝炎")|| | |
| 378 | + twinsPatientsResult.getrFactor().contains("重症感染性肺炎")|| | |
| 379 | + twinsPatientsResult.getrFactor().contains("所有妊娠合并传染性疾病")|| | |
| 380 | + twinsPatientsResult.getrFactor().contains("尖锐湿疣")|| | |
| 381 | + twinsPatientsResult.getrFactor().contains("淋病")|| | |
| 382 | + twinsPatientsResult.getrFactor().contains("丙肝阳性")|| | |
| 383 | + twinsPatientsResult.getrFactor().contains("乙肝大三阳")|| | |
| 384 | + twinsPatientsResult.getrFactor().contains("乙肝小三阳")) { | |
| 385 | + data.add(twinsPatientsResult); | |
| 386 | + } | |
| 387 | + } | |
| 388 | + logger.debug(stopWatch.toString()); | |
| 389 | + } | |
| 390 | + return data; | |
| 391 | + } | |
| 392 | + | |
| 393 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 394 | + if (CollectionUtils.isEmpty(list)) { | |
| 395 | + return 0; | |
| 396 | + } | |
| 397 | + int count = 0; | |
| 398 | + for (AntenatalExaminationModel model : list) { | |
| 399 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 400 | + count++; | |
| 401 | + } | |
| 402 | + } | |
| 403 | + return count; | |
| 404 | + } | |
| 405 | + | |
| 406 | + //统计复查里面的本院检查数 | |
| 407 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 408 | + int count = 0; | |
| 409 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 410 | + return count; | |
| 411 | + } | |
| 412 | + for (AntExChuModel model : list) { | |
| 413 | + if (hospital.equals(model.getHospitalId())) { | |
| 414 | + count++; | |
| 415 | + } | |
| 416 | + } | |
| 417 | + return count; | |
| 418 | + } | |
| 419 | + | |
| 420 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 421 | + if (CollectionUtils.isEmpty(list)) { | |
| 422 | + return; | |
| 423 | + } | |
| 424 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 425 | + @Override | |
| 426 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 427 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 428 | + return 1; | |
| 429 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 430 | + return -1; | |
| 431 | + } | |
| 432 | + return 0; | |
| 433 | + } | |
| 434 | + }); | |
| 435 | + } | |
| 436 | +} |
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/OldWorker.java
View file @
8e9b062
| 1 | +package com.lyms.platform.operate.web.worker; | |
| 2 | + | |
| 3 | +import com.lyms.platform.biz.service.AntenatalExaminationService; | |
| 4 | +import com.lyms.platform.biz.service.BasicConfigService; | |
| 5 | +import com.lyms.platform.biz.service.PatientsService; | |
| 6 | +import com.lyms.platform.common.enums.ServiceStatusEnums; | |
| 7 | +import com.lyms.platform.common.enums.ServiceTypeEnums; | |
| 8 | +import com.lyms.platform.common.enums.YnEnums; | |
| 9 | +import com.lyms.platform.common.utils.DateUtil; | |
| 10 | +import com.lyms.platform.common.utils.ExceptionUtils; | |
| 11 | +import com.lyms.platform.common.utils.JsonUtil; | |
| 12 | +import com.lyms.platform.operate.web.facade.PatientFacade; | |
| 13 | +import com.lyms.platform.operate.web.request.RiskPatientsQueryRequest; | |
| 14 | +import com.lyms.platform.operate.web.result.HighScoreResult; | |
| 15 | +import com.lyms.platform.operate.web.result.QuanPatientsResult; | |
| 16 | +import com.lyms.platform.operate.web.result.TwinsPatientsResult; | |
| 17 | +import com.lyms.platform.operate.web.utils.CommonsHelper; | |
| 18 | +import com.lyms.platform.permission.model.Organization; | |
| 19 | +import com.lyms.platform.permission.model.Users; | |
| 20 | +import com.lyms.platform.permission.service.OrganizationService; | |
| 21 | +import com.lyms.platform.permission.service.UsersService; | |
| 22 | +import com.lyms.platform.pojo.AntExChuModel; | |
| 23 | +import com.lyms.platform.pojo.AntenatalExaminationModel; | |
| 24 | +import com.lyms.platform.pojo.BasicConfig; | |
| 25 | +import com.lyms.platform.pojo.Patients; | |
| 26 | +import com.lyms.platform.query.AntExChuQuery; | |
| 27 | +import com.lyms.platform.query.AntExQuery; | |
| 28 | +import org.apache.commons.collections.CollectionUtils; | |
| 29 | +import org.apache.commons.lang.StringUtils; | |
| 30 | +import org.apache.commons.lang.math.NumberUtils; | |
| 31 | +import org.slf4j.Logger; | |
| 32 | +import org.slf4j.LoggerFactory; | |
| 33 | +import org.springframework.util.StopWatch; | |
| 34 | + | |
| 35 | +import java.util.*; | |
| 36 | +import java.util.concurrent.Callable; | |
| 37 | + | |
| 38 | +public class OldWorker implements Callable<List<QuanPatientsResult>> { | |
| 39 | + | |
| 40 | + private static final Logger logger = LoggerFactory.getLogger(PatientFacade.class); | |
| 41 | + | |
| 42 | + private List<Patients> patientses; | |
| 43 | + | |
| 44 | + private String hospital; | |
| 45 | + private UsersService usersService; | |
| 46 | + private AntenatalExaminationService antExService; | |
| 47 | + private BasicConfigService basicConfigService; | |
| 48 | + private PatientsService patientsService; | |
| 49 | + private OrganizationService organizationService; | |
| 50 | + private RiskPatientsQueryRequest riskPatientsQueryRequest; | |
| 51 | + | |
| 52 | + public OldWorker(RiskPatientsQueryRequest riskPatientsQueryRequest, | |
| 53 | + List<Patients> patientses, | |
| 54 | + UsersService usersService, | |
| 55 | + String hospital, | |
| 56 | + AntenatalExaminationService antExService, | |
| 57 | + BasicConfigService basicConfigService, PatientsService patientsService, OrganizationService organizationService) { | |
| 58 | + this.riskPatientsQueryRequest = riskPatientsQueryRequest; | |
| 59 | + this.patientses = patientses; | |
| 60 | + this.usersService = usersService; | |
| 61 | + this.antExService = antExService; | |
| 62 | + this.hospital = hospital; | |
| 63 | + this.basicConfigService = basicConfigService; | |
| 64 | + this.patientsService = patientsService; | |
| 65 | + this.organizationService = organizationService; | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Override | |
| 69 | + public List<QuanPatientsResult> call() throws Exception { | |
| 70 | + List data = new ArrayList<>(); | |
| 71 | + AntExQuery antExQuery = new AntExQuery(); | |
| 72 | + antExQuery.setYn(YnEnums.YES.getId()); | |
| 73 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
| 74 | + | |
| 75 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
| 76 | + String twinsType = ""; | |
| 77 | + if(StringUtils.isNotEmpty(riskPatientsQueryRequest.getTwinsType())){ | |
| 78 | + twinsType = riskPatientsQueryRequest.getTwinsType(); | |
| 79 | + } | |
| 80 | + | |
| 81 | + for (Patients patients : patientses) { | |
| 82 | + | |
| 83 | + StopWatch stopWatch = new StopWatch("OldWorker -" + patients.getId()); | |
| 84 | + TwinsPatientsResult twinsPatientsResult = new TwinsPatientsResult(); | |
| 85 | + twinsPatientsResult.setYi("-"); | |
| 86 | + twinsPatientsResult.setEr("-"); | |
| 87 | + twinsPatientsResult.setSan("-"); | |
| 88 | + twinsPatientsResult.setSi("-"); | |
| 89 | + twinsPatientsResult.setWu("-"); | |
| 90 | + twinsPatientsResult.convertToResult(patients); | |
| 91 | + antExQuery.setPid(patients.getPid()); | |
| 92 | + //增加查询本次产程条数 | |
| 93 | + antExQuery.setStart(patients.getLastMenses()); | |
| 94 | + if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { | |
| 95 | + if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { | |
| 96 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); | |
| 97 | + if (null != users) { | |
| 98 | + twinsPatientsResult.setlName(users.getName()); | |
| 99 | + } else { | |
| 100 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 101 | + } | |
| 102 | + } else { | |
| 103 | + twinsPatientsResult.setlName(patients.getBookbuildingDoctor()); | |
| 104 | + } | |
| 105 | + } | |
| 106 | + //筛查结果 | |
| 107 | + String screenStr = basicConfigService.getScreenResult(patients.getScreenResult()); | |
| 108 | + twinsPatientsResult.setScreenResult(screenStr); | |
| 109 | + twinsPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); | |
| 110 | + stopWatch.start("query ant count"); | |
| 111 | + antExChuQuery1.setPid(patients.getPid()); | |
| 112 | + //antExChuQuery1.setParentId(patients.getId()); | |
| 113 | + //增加查询本次产程条数 | |
| 114 | + antExChuQuery1.setStart(patients.getLastMenses()); | |
| 115 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
| 116 | + //复诊次数 | |
| 117 | + List<AntenatalExaminationModel> ant = null; | |
| 118 | + if (CollectionUtils.isNotEmpty(chu)) { | |
| 119 | + for (AntExChuModel a : chu) {//唐山滦县导出判断初诊是否是本院 | |
| 120 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 121 | + if (a.getHospitalId().equals(hospital)) { | |
| 122 | + twinsPatientsResult.setYi("本院"); | |
| 123 | + } else { | |
| 124 | + twinsPatientsResult.setYi("外院"); | |
| 125 | + } | |
| 126 | + break; | |
| 127 | + } | |
| 128 | + } | |
| 129 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
| 130 | + } | |
| 131 | + | |
| 132 | + //唐山滦县判断复诊是否是本院 | |
| 133 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 134 | + for (int k = 0; k < ant.size(); k++) { | |
| 135 | + if (k >= 4) { | |
| 136 | + break; | |
| 137 | + } | |
| 138 | + if (0 == k) { | |
| 139 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 140 | + twinsPatientsResult.setEr("本院"); | |
| 141 | + } else { | |
| 142 | + twinsPatientsResult.setEr("外院"); | |
| 143 | + } | |
| 144 | + } else if (1 == k) { | |
| 145 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 146 | + twinsPatientsResult.setSan("本院"); | |
| 147 | + } else { | |
| 148 | + twinsPatientsResult.setSan("外院"); | |
| 149 | + } | |
| 150 | + } else if (2 == k) { | |
| 151 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 152 | + twinsPatientsResult.setSi("本院"); | |
| 153 | + } else { | |
| 154 | + twinsPatientsResult.setSi("外院"); | |
| 155 | + } | |
| 156 | + } else if (3 == k) { | |
| 157 | + if (ant.get(k).getHospitalId().equals(hospital)) { | |
| 158 | + twinsPatientsResult.setWu("本院"); | |
| 159 | + } else { | |
| 160 | + twinsPatientsResult.setWu("外院"); | |
| 161 | + } | |
| 162 | + } | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + //系统初诊次数 | |
| 167 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
| 168 | + | |
| 169 | + //系统复诊次数 | |
| 170 | + int i = 0; | |
| 171 | + if (CollectionUtils.isNotEmpty(ant)) { | |
| 172 | + //复诊次数 | |
| 173 | + i = ant.size(); | |
| 174 | + sort(ant); | |
| 175 | + for (AntenatalExaminationModel a : ant) { | |
| 176 | + try { | |
| 177 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 178 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 179 | + if (null != og) { | |
| 180 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 181 | + break; | |
| 182 | + } | |
| 183 | + } | |
| 184 | + } catch (Exception e) { | |
| 185 | + twinsPatientsResult.setCurrentCh(""); | |
| 186 | + } | |
| 187 | + } | |
| 188 | + } else { | |
| 189 | + for (AntExChuModel a : chu) { | |
| 190 | + try { | |
| 191 | + if (StringUtils.isNotEmpty(a.getHospitalId())) { | |
| 192 | + Organization og = organizationService.getOrganization(Integer.valueOf(a.getHospitalId())); | |
| 193 | + if (null != og) { | |
| 194 | + twinsPatientsResult.setCurrentCh(og.getName()); | |
| 195 | + break; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + } catch (Exception e) { | |
| 199 | + twinsPatientsResult.setCurrentCh(""); | |
| 200 | + } | |
| 201 | + } | |
| 202 | + } | |
| 203 | + | |
| 204 | + twinsPatientsResult.setcTimes(i + ichu); | |
| 205 | + | |
| 206 | + | |
| 207 | + antExQuery.setHospitalId(hospital); | |
| 208 | + //本院初诊 | |
| 209 | + int chi = countAntChu(chu, hospital); | |
| 210 | + | |
| 211 | + //本院复诊 | |
| 212 | + int chb = capLocalHospital(hospital, ant); | |
| 213 | + twinsPatientsResult.setcHTimes(chi + chb); | |
| 214 | + stopWatch.stop(); | |
| 215 | + String nextCheckTime = ""; | |
| 216 | + stopWatch.start("query antex list"); | |
| 217 | + | |
| 218 | + | |
| 219 | + if (null != patients.getNextCheckTime()) { | |
| 220 | + nextCheckTime = DateUtil.getyyyy_MM_dd(patients.getNextCheckTime()); | |
| 221 | + } | |
| 222 | + | |
| 223 | + if (StringUtils.isNotEmpty(patients.getLastCheckEmployeeId())) { | |
| 224 | + if (NumberUtils.isNumber(patients.getLastCheckEmployeeId())) { | |
| 225 | + Users users = usersService.getUsers(NumberUtils.toInt(patients.getLastCheckEmployeeId())); | |
| 226 | + if (null != users) { | |
| 227 | + twinsPatientsResult.setCheckDoctor(users.getName()); | |
| 228 | + } else { | |
| 229 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 230 | + } | |
| 231 | + } else { | |
| 232 | + twinsPatientsResult.setCheckDoctor(patients.getLastCheckEmployeeId()); | |
| 233 | + } | |
| 234 | + } | |
| 235 | + | |
| 236 | + | |
| 237 | + stopWatch.stop(); | |
| 238 | + stopWatch.start("query basicconfig"); | |
| 239 | + //注册地址 | |
| 240 | + twinsPatientsResult.setRegisterAddr(CommonsHelper.getResidence(patients.getProvinceId(), patients.getCityId(), patients.getAreaId(), patients.getStreetId(), patients.getAddress(), basicConfigService)); | |
| 241 | + twinsPatientsResult.setAddr(CommonsHelper.getResidence(patients.getProvinceRegisterId(), patients.getCityRegisterId(), patients.getAreaRegisterId(), patients.getStreetRegisterId(), patients.getAddressRegister(), basicConfigService)); | |
| 242 | + try { | |
| 243 | + twinsPatientsResult.setFirstBH(organizationService.getOrganization(Integer.valueOf(patients.getHospitalId())).getName()); | |
| 244 | + } catch (Exception e) { | |
| 245 | + twinsPatientsResult.setFirstBH(""); | |
| 246 | + } | |
| 247 | + | |
| 248 | + twinsPatientsResult.setServiceType(ServiceTypeEnums.getTitleById(patients.getServiceType())); | |
| 249 | + twinsPatientsResult.setServiceStatus(ServiceStatusEnums.getNameById(patients.getServiceStatus())); | |
| 250 | + //修改获取建档里面的高危等级不用在重新去算 | |
| 251 | +// HighScoreResult highScoreResult = antenatalExaminationFacade.findLastRisk(patients.getPid(), true); | |
| 252 | +// twinsPatientsResult.setrLevel(highScoreResult.filter(highScoreResult.getLevel())); | |
| 253 | + twinsPatientsResult.setcTime(nextCheckTime); | |
| 254 | + | |
| 255 | + | |
| 256 | + //高危因素 | |
| 257 | + List<String> factor = patients.getRiskFactorId(); | |
| 258 | + | |
| 259 | + if (CollectionUtils.isNotEmpty(factor)) { | |
| 260 | + StringBuilder sb = new StringBuilder(56); | |
| 261 | + for (String srt : factor) { | |
| 262 | + if (StringUtils.isNotEmpty(srt)) { | |
| 263 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(srt); | |
| 264 | + if (null != basicConfig && sb.indexOf(basicConfig.getName()) == -1) { | |
| 265 | + if(basicConfig.getName().contains("40岁>年龄≥35岁") || | |
| 266 | + basicConfig.getName().contains("年龄≥40岁")){ | |
| 267 | + sb.append(basicConfig.getName()).append(','); | |
| 268 | + } | |
| 269 | + } | |
| 270 | + } | |
| 271 | + } | |
| 272 | + if (sb.toString().endsWith(",")) { | |
| 273 | + twinsPatientsResult.setrFactor(sb.substring(0, sb.length() - 1)); | |
| 274 | + } else { | |
| 275 | + twinsPatientsResult.setrFactor(sb.toString()); | |
| 276 | + } | |
| 277 | + | |
| 278 | + /* if (!"-".equals(twinsPatientsResult.getrFactor()) && StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 279 | + twinsPatientsResult.setrFactor(twinsPatientsResult.getrFactor() + "," + patients.getoRiskFactor()); | |
| 280 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 281 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 282 | + }*/ | |
| 283 | + } else if (StringUtils.isNotEmpty(patients.getoRiskFactor())) { | |
| 284 | + twinsPatientsResult.setrFactor(patients.getoRiskFactor()); | |
| 285 | + } | |
| 286 | + List level = new ArrayList(); | |
| 287 | + if (StringUtils.isNotEmpty(patients.getRiskLevelId())) { | |
| 288 | + try { | |
| 289 | + List<String> list = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class); | |
| 290 | + for (String str : list) { | |
| 291 | + BasicConfig basicConfig = basicConfigService.getOneBasicConfigById(str); | |
| 292 | + if (null != basicConfig) { | |
| 293 | + Map map = new HashMap(); | |
| 294 | + basicConfig.replenRisk(map); | |
| 295 | + // String name = basicConfig.getName(); | |
| 296 | + // if (name.indexOf("预警") > -1) { | |
| 297 | + // name = name.replace("预警", ""); | |
| 298 | + // } | |
| 299 | + // map.put("name", name); | |
| 300 | + // map.put("color", "risk_" + RiskDefaultTypeEnum.getColor(name)); | |
| 301 | + level.add(map); | |
| 302 | + } | |
| 303 | + } | |
| 304 | + } catch (Exception e) { | |
| 305 | + ExceptionUtils.catchException(e, "patients.getRiskLevelId error."); | |
| 306 | + } | |
| 307 | + | |
| 308 | + twinsPatientsResult.setrLevel(HighScoreResult.filter(level)); | |
| 309 | + } | |
| 310 | + twinsPatientsResult.setCardNo(patients.getCardNo()); | |
| 311 | + twinsPatientsResult.setPcerteTypeId(patients.getPcerteTypeId()); | |
| 312 | + stopWatch.stop(); | |
| 313 | + if (twinsPatientsResult.getrFactor() != null) { | |
| 314 | + //双绒双羊、单绒单羊、单绒双羊 | |
| 315 | + if ("1".equals(twinsType)) { | |
| 316 | + if (twinsPatientsResult.getrFactor().contains("40岁>年龄≥35岁")) { | |
| 317 | + data.add(twinsPatientsResult); | |
| 318 | + } | |
| 319 | + | |
| 320 | + } else if ("2".equals(twinsType)) { | |
| 321 | + if (twinsPatientsResult.getrFactor().contains("年龄≥40岁")) { | |
| 322 | + data.add(twinsPatientsResult); | |
| 323 | + } | |
| 324 | + } else if (twinsPatientsResult.getrFactor().contains("40岁>年龄≥35岁") || | |
| 325 | + twinsPatientsResult.getrFactor().contains("年龄≥40岁")) { | |
| 326 | + data.add(twinsPatientsResult); | |
| 327 | + } | |
| 328 | + } | |
| 329 | + logger.debug(stopWatch.toString()); | |
| 330 | + } | |
| 331 | + return data; | |
| 332 | + } | |
| 333 | + | |
| 334 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
| 335 | + if (CollectionUtils.isEmpty(list)) { | |
| 336 | + return 0; | |
| 337 | + } | |
| 338 | + int count = 0; | |
| 339 | + for (AntenatalExaminationModel model : list) { | |
| 340 | + if (model.getHospitalId().equals(hospitalId)) { | |
| 341 | + count++; | |
| 342 | + } | |
| 343 | + } | |
| 344 | + return count; | |
| 345 | + } | |
| 346 | + | |
| 347 | + //统计复查里面的本院检查数 | |
| 348 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
| 349 | + int count = 0; | |
| 350 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
| 351 | + return count; | |
| 352 | + } | |
| 353 | + for (AntExChuModel model : list) { | |
| 354 | + if (hospital.equals(model.getHospitalId())) { | |
| 355 | + count++; | |
| 356 | + } | |
| 357 | + } | |
| 358 | + return count; | |
| 359 | + } | |
| 360 | + | |
| 361 | + private void sort(List<AntenatalExaminationModel> list) { | |
| 362 | + if (CollectionUtils.isEmpty(list)) { | |
| 363 | + return; | |
| 364 | + } | |
| 365 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
| 366 | + @Override | |
| 367 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
| 368 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
| 369 | + return 1; | |
| 370 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
| 371 | + return -1; | |
| 372 | + } | |
| 373 | + return 0; | |
| 374 | + } | |
| 375 | + }); | |
| 376 | + } | |
| 377 | +} |