Commit 770712124e56931b38e3f53ad04512ed41c4e7e1
1 parent
b2dab2c848
Exists in
master
and in
6 other branches
血糖报告
Showing 1 changed file with 52 additions and 151 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/BloodSugarServiceImpl.java
View file @
7707121
| ... | ... | @@ -267,9 +267,9 @@ |
| 267 | 267 | one.setModified(new Date()); |
| 268 | 268 | one.setCreatYmdDate(DateUtil.getyyyy_MM_dd(new Date())); |
| 269 | 269 | if(!flag) { |
| 270 | - bloodSugarService.add(one); | |
| 270 | + bloodSugarService.add(one); | |
| 271 | 271 | } else { |
| 272 | - mongoTemplate.save(one); | |
| 272 | + mongoTemplate.save(one); | |
| 273 | 273 | } |
| 274 | 274 | return RespBuilder.buildSuccess(one.getId()); |
| 275 | 275 | } |
| ... | ... | @@ -459,7 +459,7 @@ |
| 459 | 459 | hrisks.add("5aab6d3e422b03d4ad2bf83f"); |
| 460 | 460 | hrisks.add("de7468e6-1bb5-4fab-ae84-78857868409a"); |
| 461 | 461 | antExRecordQuery.setrFactorList(hrisks); |
| 462 | - List<AntExRecordModel> antExRecordModelList = recordService.queryAntExRecords(antExRecordQuery, Sort.Direction.ASC, "created"); | |
| 462 | + List<AntExRecordModel> antExRecordModelList = recordService.queryAntExRecords(antExRecordQuery, Sort.Direction.ASC,"created"); | |
| 463 | 463 | if (org.apache.commons.collections.CollectionUtils.isNotEmpty(antExRecordModelList)) |
| 464 | 464 | { |
| 465 | 465 | for (AntExRecordModel model : antExRecordModelList) |
| 466 | 466 | |
| 467 | 467 | |
| 468 | 468 | |
| 469 | 469 | |
| ... | ... | @@ -503,26 +503,24 @@ |
| 503 | 503 | Integer type = Integer.valueOf(String.valueOf(map.get("type"))); // 1 无需药物治疗 2 需药物治疗 |
| 504 | 504 | Date checkDate = (Date)map.get("checkDate"); //第一次出现糖尿病的检查时间 |
| 505 | 505 | |
| 506 | - //Date currentDate = DateUtil.addDay(DateUtil.formatDate(new Date()),-7); | |
| 506 | + Date currentDate = DateUtil.addDay(DateUtil.formatDate(new Date()),-7); | |
| 507 | 507 | |
| 508 | 508 | BloodSugarQuery bloodSugarQuery = new BloodSugarQuery(); |
| 509 | 509 | bloodSugarQuery.setIsExistReportDate(true); |
| 510 | 510 | bloodSugarQuery.setPid(pid); |
| 511 | 511 | List<BloodSugar> bloodSugars = bloodSugarService.queryBloodSugarList(bloodSugarQuery, Sort.Direction.DESC, "reportDate"); |
| 512 | - | |
| 513 | 512 | if (CollectionUtils.isNotEmpty(bloodSugars)) |
| 514 | 513 | { |
| 515 | 514 | BloodSugar blood = bloodSugars.get(0); |
| 516 | 515 | if (blood != null && blood.getReportDate() != null) |
| 517 | 516 | { |
| 518 | - queryDate = blood.getReportDate(); | |
| 517 | + queryDate = currentDate.getTime() > blood.getReportDate().getTime() ? currentDate : blood.getReportDate(); | |
| 519 | 518 | } |
| 520 | 519 | } |
| 521 | 520 | else |
| 522 | 521 | { |
| 523 | - queryDate = checkDate; | |
| 522 | + queryDate = checkDate.getTime() < currentDate.getTime() ? currentDate : checkDate; | |
| 524 | 523 | } |
| 525 | - | |
| 526 | 524 | //达标次数 |
| 527 | 525 | int successCount = 0; |
| 528 | 526 | |
| 529 | 527 | |
| 530 | 528 | |
| 531 | 529 | |
| 532 | 530 | |
| 533 | 531 | |
| 534 | 532 | |
| 535 | 533 | |
| 536 | 534 | |
| 537 | 535 | |
| 538 | 536 | |
| 539 | 537 | |
| 540 | 538 | |
| 541 | 539 | |
| 542 | 540 | |
| ... | ... | @@ -532,162 +530,65 @@ |
| 532 | 530 | //7 药物治疗,监测次数达标,血糖平稳但不理想 |
| 533 | 531 | Integer monitorStatus = null; |
| 534 | 532 | |
| 535 | - if (DateUtil.daysBetween(queryDate,new Date()) >= 7) | |
| 533 | + if (DateUtil.daysBetween(queryDate,new Date()) == 7) | |
| 536 | 534 | { |
| 535 | + BloodSugarQuery buery = new BloodSugarQuery(); | |
| 536 | + buery.setPid(pid); | |
| 537 | + buery.setCreatedStart(queryDate); | |
| 538 | + buery.setCreatedEnd(DateUtil.formatDate(DateUtil.addDay(DateUtil.formatDate(new Date()),7))); | |
| 539 | + List<BloodSugar> list = bloodSugarService.queryBloodSugarList(buery, Sort.Direction.DESC, "created"); | |
| 537 | 540 | |
| 538 | - while (true) | |
| 541 | + int size = list == null ? 0 : list.size(); | |
| 542 | + if (type == 1 && size < 8) | |
| 539 | 543 | { |
| 540 | - | |
| 541 | - Date endDate = DateUtil.addDay(queryDate,7); | |
| 542 | - if (endDate.getTime() > new Date().getTime()) | |
| 544 | + monitorStatus = 1; | |
| 545 | + } | |
| 546 | + else if (type == 1 && size >= 8) | |
| 547 | + { | |
| 548 | + for (BloodSugar blood : list) | |
| 543 | 549 | { |
| 544 | - break; | |
| 545 | - } | |
| 546 | - | |
| 547 | - BloodSugarQuery buery = new BloodSugarQuery(); | |
| 548 | - buery.setPid(pid); | |
| 549 | - buery.setCreatedStart(queryDate); | |
| 550 | - buery.setCreatedEnd(endDate); | |
| 551 | - List<BloodSugar> list = bloodSugarService.queryBloodSugarList(buery, Sort.Direction.DESC, "created"); | |
| 552 | - | |
| 553 | - | |
| 554 | - int size = list == null ? 0 : list.size(); | |
| 555 | - if (type == 1 && size < 8) | |
| 556 | - { | |
| 557 | - monitorStatus = 1; | |
| 558 | - } | |
| 559 | - else if (type == 1 && size >= 8) | |
| 560 | - { | |
| 561 | - for (BloodSugar blood : list) | |
| 550 | + Integer bsType = blood.getBloodSugarType(); | |
| 551 | + if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 562 | 552 | { |
| 563 | - Integer bsType = blood.getBloodSugarType(); | |
| 564 | - if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 565 | - { | |
| 566 | - continue; | |
| 567 | - } | |
| 568 | - successCount += getBloodSugarSuccess(bsType, blood); | |
| 569 | - | |
| 553 | + continue; | |
| 570 | 554 | } |
| 571 | - double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 572 | - monitorStatus = result < 0.8 ? 2 : 3; | |
| 555 | + successCount += getBloodSugarSuccess(bsType, blood); | |
| 556 | + | |
| 573 | 557 | } |
| 574 | - else if (type == 2 && size < 21) | |
| 558 | + double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 559 | + monitorStatus = result < 0.8 ? 2 : 3; | |
| 560 | + } | |
| 561 | + else if (type == 2 && size < 21) | |
| 562 | + { | |
| 563 | + monitorStatus = 4; | |
| 564 | + } | |
| 565 | + else if (type == 2 && size >= 21) | |
| 566 | + { | |
| 567 | + for (BloodSugar blood : list) | |
| 575 | 568 | { |
| 576 | - monitorStatus = 4; | |
| 577 | - } | |
| 578 | - else if (type == 2 && size >= 21) | |
| 579 | - { | |
| 580 | - for (BloodSugar blood : list) | |
| 569 | + Integer bsType = blood.getBloodSugarType(); | |
| 570 | + if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 581 | 571 | { |
| 582 | - Integer bsType = blood.getBloodSugarType(); | |
| 583 | - if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 584 | - { | |
| 585 | - continue; | |
| 586 | - } | |
| 587 | - successCount += getBloodSugarSuccess(bsType, blood); | |
| 572 | + continue; | |
| 588 | 573 | } |
| 589 | - double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 590 | - monitorStatus = result < 0.6 ? 5 : (result < 0.8 ? 6 : 7); | |
| 574 | + successCount += getBloodSugarSuccess(bsType, blood); | |
| 591 | 575 | } |
| 576 | + double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 577 | + monitorStatus = result < 0.6 ? 5 : (result < 0.8 ? 6 : 7); | |
| 578 | + } | |
| 592 | 579 | |
| 593 | - Patients patients = mongoTemplate.findById(one.getParentId(), Patients.class); | |
| 594 | - int week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.formatDate(one.getCreated())); | |
| 595 | - if (week < 6) | |
| 596 | - { | |
| 597 | - return false; | |
| 598 | - } | |
| 599 | - one.setCurrentWeek(week); | |
| 600 | - one.setMonitorStatus(monitorStatus); | |
| 601 | - one.setReportDate(DateUtil.formatDate(DateUtil.addDay(new Date(), -1))); | |
| 602 | - one.setStatus(1); //报告状态 1未查看 2查看 | |
| 603 | - | |
| 604 | - queryDate = endDate; | |
| 605 | - | |
| 606 | - return true; | |
| 580 | + Patients patients = mongoTemplate.findById(one.getParentId(), Patients.class); | |
| 581 | + int week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.formatDate(one.getCreated())); | |
| 582 | + if (week < 6) | |
| 583 | + { | |
| 584 | + return false; | |
| 607 | 585 | } |
| 586 | + one.setCurrentWeek(week); | |
| 587 | + one.setMonitorStatus(monitorStatus); | |
| 588 | + one.setReportDate(DateUtil.formatDate(DateUtil.addDay(new Date(), -1))); | |
| 589 | + one.setStatus(1); //报告状态 1未查看 2查看 | |
| 590 | + return true; | |
| 608 | 591 | } |
| 609 | - | |
| 610 | - | |
| 611 | -// if (CollectionUtils.isNotEmpty(bloodSugars)) | |
| 612 | -// { | |
| 613 | -// BloodSugar blood = bloodSugars.get(0); | |
| 614 | -// if (blood != null && blood.getReportDate() != null) | |
| 615 | -// { | |
| 616 | -// queryDate = currentDate.getTime() > blood.getReportDate().getTime() ? currentDate : blood.getReportDate(); | |
| 617 | -// } | |
| 618 | -// } | |
| 619 | -// else | |
| 620 | -// { | |
| 621 | -// queryDate = checkDate.getTime() < currentDate.getTime() ? currentDate : checkDate; | |
| 622 | -// } | |
| 623 | -// //达标次数 | |
| 624 | -// int successCount = 0; | |
| 625 | -// | |
| 626 | -// //监测状态 1 非药物治疗,监测不足 2 非药物治疗,监测次数达标,血糖控制不理想 | |
| 627 | -// //3 非药物治疗,监测次数达标,血糖控制良好 4 药物治疗,监测不足 | |
| 628 | -// //5 药物治疗,监测次数达标,血糖波动较大 6 药物治疗,监测次数达标,血糖控制良好 | |
| 629 | -// //7 药物治疗,监测次数达标,血糖平稳但不理想 | |
| 630 | -// Integer monitorStatus = null; | |
| 631 | -// | |
| 632 | -// if (DateUtil.daysBetween(queryDate,new Date()) == 7) | |
| 633 | -// { | |
| 634 | -// BloodSugarQuery buery = new BloodSugarQuery(); | |
| 635 | -// buery.setPid(pid); | |
| 636 | -// buery.setCreatedStart(queryDate); | |
| 637 | -// buery.setCreatedEnd(DateUtil.formatDate(DateUtil.addDay(DateUtil.formatDate(new Date()),7))); | |
| 638 | -// List<BloodSugar> list = bloodSugarService.queryBloodSugarList(buery, Sort.Direction.DESC, "created"); | |
| 639 | -// | |
| 640 | -// int size = list == null ? 0 : list.size(); | |
| 641 | -// if (type == 1 && size < 8) | |
| 642 | -// { | |
| 643 | -// monitorStatus = 1; | |
| 644 | -// } | |
| 645 | -// else if (type == 1 && size >= 8) | |
| 646 | -// { | |
| 647 | -// for (BloodSugar blood : list) | |
| 648 | -// { | |
| 649 | -// Integer bsType = blood.getBloodSugarType(); | |
| 650 | -// if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 651 | -// { | |
| 652 | -// continue; | |
| 653 | -// } | |
| 654 | -// successCount += getBloodSugarSuccess(bsType, blood); | |
| 655 | -// | |
| 656 | -// } | |
| 657 | -// double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 658 | -// monitorStatus = result < 0.8 ? 2 : 3; | |
| 659 | -// } | |
| 660 | -// else if (type == 2 && size < 21) | |
| 661 | -// { | |
| 662 | -// monitorStatus = 4; | |
| 663 | -// } | |
| 664 | -// else if (type == 2 && size >= 21) | |
| 665 | -// { | |
| 666 | -// for (BloodSugar blood : list) | |
| 667 | -// { | |
| 668 | -// Integer bsType = blood.getBloodSugarType(); | |
| 669 | -// if (StringUtils.isEmpty(blood.getBloodSugar()) || bsType == null) | |
| 670 | -// { | |
| 671 | -// continue; | |
| 672 | -// } | |
| 673 | -// successCount += getBloodSugarSuccess(bsType, blood); | |
| 674 | -// } | |
| 675 | -// double result = new BigDecimal((float)successCount / size).setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue(); | |
| 676 | -// monitorStatus = result < 0.6 ? 5 : (result < 0.8 ? 6 : 7); | |
| 677 | -// } | |
| 678 | -// | |
| 679 | -// Patients patients = mongoTemplate.findById(one.getParentId(), Patients.class); | |
| 680 | -// int week = DateUtil.getWeek2(patients.getLastMenses(), DateUtil.formatDate(one.getCreated())); | |
| 681 | -// if (week < 6) | |
| 682 | -// { | |
| 683 | -// return false; | |
| 684 | -// } | |
| 685 | -// one.setCurrentWeek(week); | |
| 686 | -// one.setMonitorStatus(monitorStatus); | |
| 687 | -// one.setReportDate(DateUtil.formatDate(DateUtil.addDay(new Date(), -1))); | |
| 688 | -// one.setStatus(1); //报告状态 1未查看 2查看 | |
| 689 | -// return true; | |
| 690 | -// } | |
| 691 | 592 | } |
| 692 | 593 | return false; |
| 693 | 594 | } |