Commit 5e7b3dd666025caa546d66e53a2fcd867a445c86
1 parent
b2d6800dcb
Exists in
master
and in
6 other branches
儿童报告
Showing 1 changed file with 133 additions and 71 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/BabyNutritionFacade.java
View file @
5e7b3dd
... | ... | @@ -91,7 +91,7 @@ |
91 | 91 | Map<String, String> map = new HashMap<>(); |
92 | 92 | map.put("id",model.getId()); |
93 | 93 | map.put("babyId",model.getBabyId()); |
94 | - map.put("created",DateUtil.getyyyy_MM_dd(model.getCreated())); | |
94 | + map.put("recordTime",DateUtil.getyyyy_MM_dd(model.getNutritiTime())); | |
95 | 95 | map.put("hospitalId",model.getHospitalId()); |
96 | 96 | list.add(map); |
97 | 97 | } |
98 | 98 | |
... | ... | @@ -327,9 +327,9 @@ |
327 | 327 | return new BaseObjectResponse().setData(data).setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("月龄范围没有报告"); |
328 | 328 | } |
329 | 329 | String bmi = patientWeightService.getBmi(String.valueOf(model.getWeight()),String.valueOf(model.getHeight())); |
330 | - String kaupEvaluate = getBabyStatus(month,baby.getSex(),model.getHeight(),model.getWeight(),bmi); | |
330 | + String kaupEvaluate = getBabyStatus(month, baby.getSex(), model.getHeight(), model.getWeight(), bmi); | |
331 | 331 | |
332 | - double kaul = getKal(month,model.getHeight(),model.getWeight(), baby.getSex(), kaupEvaluate); | |
332 | + double kaul = getKal(month, model.getHeight(), model.getWeight(), baby.getSex(), kaupEvaluate); | |
333 | 333 | |
334 | 334 | map.put("kaupEvaluate", kaupEvaluate); |
335 | 335 | map.put("month", month); |
... | ... | @@ -399,7 +399,7 @@ |
399 | 399 | } |
400 | 400 | |
401 | 401 | |
402 | - List<String> yys = getYys(month); | |
402 | + List<String> yys = getYys(month,kaul,model.getWeight()); | |
403 | 403 | //每日所需营养素 |
404 | 404 | data.put("yys",yys); |
405 | 405 | |
... | ... | @@ -410,45 +410,6 @@ |
410 | 410 | |
411 | 411 | List<Map> wlysMapList = new ArrayList<>(); |
412 | 412 | |
413 | - //能量计算 | |
414 | - double nl = getBasicKaul( month, model.getWeight(),model.getHeight(),baby.getSex()); | |
415 | - double nlCurrent = 0; | |
416 | - yysMapList.add(getNl(nl,nlCurrent)); | |
417 | - | |
418 | - double tsCurrent = 0;//碳素化合物 TODO | |
419 | - double dbzCurrent = 0;//蛋白质 TODO | |
420 | - double zfCurrent = 0;//脂肪 TODO | |
421 | - if (month < 5) | |
422 | - { | |
423 | - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); | |
424 | - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.09)); | |
425 | - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); | |
426 | - | |
427 | - } | |
428 | - else if (month < 12) | |
429 | - { | |
430 | - | |
431 | - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.65)); | |
432 | - | |
433 | - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.05,0.07)); | |
434 | - | |
435 | - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.4,0.5)); | |
436 | - } | |
437 | - else if (month < 36) | |
438 | - { | |
439 | - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.5,0.7)); | |
440 | - | |
441 | - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); | |
442 | - | |
443 | - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.2,0.35)); | |
444 | - } | |
445 | - else | |
446 | - { | |
447 | - yysMapList.add(getYysItems( nl, tsCurrent, "碳水化合物",0.55,0.7)); | |
448 | - yysMapList.add(getYysItems( nl, dbzCurrent, "蛋白质",0.07,0.2)); | |
449 | - yysMapList.add(getYysItems( nl, zfCurrent, "脂肪",0.15,0.3)); | |
450 | - } | |
451 | - | |
452 | 413 | Map<String,Double> elements = new HashMap(); |
453 | 414 | |
454 | 415 | List<Map> mainFoods = model.getMainFood(); |
... | ... | @@ -511,6 +472,48 @@ |
511 | 472 | List<Map> vegXd = model.getVegXd(); |
512 | 473 | getFoodElements(elements,vegXd); |
513 | 474 | |
475 | + | |
476 | + | |
477 | + //能量计算 | |
478 | + double nl = getBasicKaul( month, model.getWeight(),model.getHeight(),baby.getSex()); | |
479 | + Double nlCurrent = elements.get("能量") == null ? 0 : elements.get("能量"); | |
480 | + getNl(yysMapList, nl, nlCurrent); | |
481 | + | |
482 | + Double tsCurrent = elements.get("碳素化合物") == null ? 0 : elements.get("碳素化合物");//碳素化合物 | |
483 | + Double dbzCurrent = elements.get("蛋白质") == null ? 0 : elements.get("蛋白质");//蛋白质 | |
484 | + Double zfCurrent = elements.get("脂肪") == null ? 0 : elements.get("脂肪");//脂肪 | |
485 | + if (month < 5) | |
486 | + { | |
487 | + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.65); | |
488 | + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.09); | |
489 | + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.4, 0.5); | |
490 | + | |
491 | + } | |
492 | + else if (month < 12) | |
493 | + { | |
494 | + | |
495 | + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.65); | |
496 | + | |
497 | + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.05, 0.07); | |
498 | + | |
499 | + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.4, 0.5); | |
500 | + } | |
501 | + else if (month < 36) | |
502 | + { | |
503 | + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.5, 0.7); | |
504 | + | |
505 | + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.2); | |
506 | + | |
507 | + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.2, 0.35); | |
508 | + } | |
509 | + else | |
510 | + { | |
511 | + getYysItems(yysMapList, nl, tsCurrent, "碳水化合物", 0.55, 0.7); | |
512 | + getYysItems(yysMapList, nl, dbzCurrent, "蛋白质", 0.07, 0.2); | |
513 | + getYysItems(yysMapList, nl, zfCurrent, "脂肪", 0.15, 0.3); | |
514 | + } | |
515 | + | |
516 | + | |
514 | 517 | if (elements.size() > 0) |
515 | 518 | { |
516 | 519 | for (String key : elements.keySet()) |
517 | 520 | |
... | ... | @@ -526,11 +529,25 @@ |
526 | 529 | String normalValue = babyNutritionConfig1.getNormalValue(); |
527 | 530 | String downValue = babyNutritionConfig1.getDownValue(); |
528 | 531 | |
532 | + int status = 0; | |
533 | + if (StringUtils.isNotEmpty(upValue) && StringUtils.isNotEmpty(normalValue)) | |
534 | + { | |
535 | + status = Double.parseDouble(upValue) < value ? 1 : (Double.parseDouble(normalValue) > value ? -1 : 0); | |
536 | + }else if (StringUtils.isNotEmpty(downValue) && StringUtils.isNotEmpty(normalValue)) | |
537 | + { | |
538 | + status = Double.parseDouble(normalValue) < value ? 1 : (Double.parseDouble(downValue) > value ? -1 : 0); | |
539 | + } | |
540 | + else if (StringUtils.isNotEmpty(normalValue)) | |
541 | + { | |
542 | + status = Double.parseDouble(normalValue) > value ? -1 : 0; | |
543 | + } | |
544 | + | |
545 | + | |
529 | 546 | Map wly = new HashMap(); |
530 | 547 | wly.put("name",key); |
531 | 548 | wly.put("normalValue", normalValue); |
532 | - wly.put("currentValue", value); | |
533 | - wly.put("status", -1); | |
549 | + wly.put("currentValue", String.format("%.2f",value)); | |
550 | + wly.put("status", status); | |
534 | 551 | wlysMapList.add(wly); |
535 | 552 | } |
536 | 553 | } |
537 | 554 | |
538 | 555 | |
... | ... | @@ -544,14 +561,23 @@ |
544 | 561 | { |
545 | 562 | for (Map map1 : yysMapList) |
546 | 563 | { |
564 | + if (map1 == null) | |
565 | + { | |
566 | + continue; | |
567 | + } | |
568 | + | |
547 | 569 | Integer status = Integer.valueOf(String.valueOf(map1.get("status"))); |
548 | 570 | if (status != 0) |
549 | 571 | { |
550 | 572 | String str = status == -1 ? "摄入不足" : "摄入过量"; |
551 | 573 | BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( |
552 | 574 | Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); |
575 | + if (babyNutritionConfig1 == null) | |
576 | + { | |
577 | + continue; | |
578 | + } | |
553 | 579 | Map item = new HashMap(); |
554 | - item.put("title",babyNutritionConfig1.getTitle()); | |
580 | + item.put("title",babyNutritionConfig1.getTitle()+str); | |
555 | 581 | item.put("content",babyNutritionConfig1.getContentOne()); |
556 | 582 | items.add(item); |
557 | 583 | } |
558 | 584 | |
... | ... | @@ -570,8 +596,12 @@ |
570 | 596 | String str = status == -1 ? "摄入不足" : "摄入过量"; |
571 | 597 | BabyNutritionConfigModel babyNutritionConfig1 = mongoTemplate.findOne( |
572 | 598 | Query.query(Criteria.where("type").is(7).and("status").is(str).and("title").is(String.valueOf(map1.get("name")))), BabyNutritionConfigModel.class); |
599 | + if (babyNutritionConfig1 == null) | |
600 | + { | |
601 | + continue; | |
602 | + } | |
573 | 603 | Map item = new HashMap(); |
574 | - item.put("title",babyNutritionConfig1.getTitle()); | |
604 | + item.put("title",babyNutritionConfig1.getTitle()+str); | |
575 | 605 | item.put("content",babyNutritionConfig1.getContentOne()); |
576 | 606 | wlysitems.add(item); |
577 | 607 | } |
... | ... | @@ -614,8 +644,12 @@ |
614 | 644 | { |
615 | 645 | for (FoodResult food : foodResults) |
616 | 646 | { |
617 | - Double protein = (elements.get(food.getNutritionName()) == null ? 0 : elements.get(food.getNutritionName())) * Double.valueOf(val); | |
618 | - elements.put(food.getNutritionName(),protein == null ? 0+food.getProtein() : protein+food.getProtein()); | |
647 | + Double protein = (elements.get(food.getNutritionName()) == null ? 0 : elements.get(food.getNutritionName())); | |
648 | + if (food.getProtein() != null) | |
649 | + { | |
650 | + elements.put(food.getNutritionName(),protein == null ? food.getProtein() : protein+food.getProtein()); | |
651 | + } | |
652 | + | |
619 | 653 | } |
620 | 654 | } |
621 | 655 | } |
622 | 656 | |
623 | 657 | |
624 | 658 | |
625 | 659 | |
626 | 660 | |
627 | 661 | |
628 | 662 | |
629 | 663 | |
630 | 664 | |
631 | 665 | |
632 | 666 | |
633 | 667 | |
634 | 668 | |
... | ... | @@ -623,55 +657,83 @@ |
623 | 657 | } |
624 | 658 | } |
625 | 659 | |
626 | - private Map getYysItems(double nl,double current,String title,double down,double up) | |
660 | + private void getYysItems(List<Map> yysMapList,double nl,Double current,String title,double down,double up) | |
627 | 661 | { |
662 | + if (current == null || current == 0) | |
663 | + { | |
664 | + return; | |
665 | + } | |
628 | 666 | Map map = new HashMap(); |
629 | 667 | map.put("name",title); |
630 | - map.put("normalValue", (nl * down) + "-" + (nl * up)); | |
631 | - map.put("currentValue", current); | |
668 | + map.put("normalValue", String.format("%.2f",(nl * down)) + "-" + String.format("%.2f",(nl * up))); | |
669 | + map.put("currentValue", String.format("%.2f", current)); | |
632 | 670 | map.put("status", (nl * up) < current ? 1 : (nl * down > current ? -1 : 0)); |
633 | - return map; | |
671 | + yysMapList.add(map); | |
634 | 672 | } |
635 | 673 | |
636 | - private Map getNl(double nl,double current) | |
674 | + private void getNl(List<Map> yysMapList,double nl,Double current) | |
637 | 675 | { |
638 | - | |
676 | + if (current == null || current == 0) | |
677 | + { | |
678 | + return; | |
679 | + } | |
639 | 680 | Map nlMap = new HashMap(); |
640 | 681 | nlMap.put("name","能量"); |
641 | - nlMap.put("normalValue",(nl-50)+"-" +(nl+50)); | |
642 | - nlMap.put("currentValue",current); | |
682 | + nlMap.put("normalValue",String.format("%.2f",(nl-50))+"-" +String.format("%.2f",(nl+50))); | |
683 | + nlMap.put("currentValue",String.format("%.2f",current)); | |
643 | 684 | nlMap.put("status", nl + 50 < current ? 1 : (nl - 50 > current ? -1 : 0)); |
644 | - return nlMap; | |
685 | + yysMapList.add(nlMap); | |
645 | 686 | } |
646 | 687 | |
647 | 688 | |
648 | - private List<String> getYys(int month){ | |
689 | + private List<String> getYys(int month,Double nl,Double weight){ | |
649 | 690 | List<String> list = new ArrayList<>(); |
650 | 691 | |
651 | 692 | if (month < 36) |
652 | 693 | { |
653 | - list.add("碳水化合物:总能量的50-70%"); | |
654 | - list.add("蛋白质:总能量的7-20%,平均每日约0.96g/kg"); | |
655 | - list.add("脂肪:总能量的20-35%"); | |
656 | - list.add("n-6:总能量的4-8%"); | |
657 | - list.add("N-3:总能量的1%"); | |
694 | + //总能量的50-70% | |
695 | + list.add("碳水化合物:"+handleData( nl,0.5,0.7)); | |
696 | + //总能量的7-20% | |
697 | + list.add("蛋白质:"+handleData( nl,0.07,0.2)+",平均每日约0.96g/kg"); | |
698 | + //总能量的20-35% | |
699 | + list.add("脂肪:"+handleData( nl,0.2,0.35)); | |
700 | + //总能量的4-8% | |
701 | + list.add("n-6:"+handleData( nl,0.04,0.08)); | |
702 | + //总能量的1% | |
703 | + list.add("N-3:"+handleData( nl,0.01)); | |
658 | 704 | list.add("无机物:钙的推荐摄入量为500mg,磷的推荐摄入量为500mg,钠的充分摄入为0.7g,氯的充分摄入量为1.1g,钾的充分摄入量为1.7g,镁的推荐摄入量为75mg,铁的推荐摄入量为6mg,锌的推荐摄入量为3mg,铜的推荐摄入量为290 μg,氟的充分摄入量为0.6mg,猛的充分摄入量为1.4mg,碘的推荐摄入量为80 μg,硒的推荐摄入量为20 μg"); |
659 | 705 | list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为5mg α-TE,维生素K的充分摄入量为25μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.6mg,维生素B3烟酸的推荐摄入量为6mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为180mg,维生素B6的推荐摄入量0.6mg,叶酸的推荐摄入量为150μg DFE,维生素B12的推荐摄入量为0.9μg,泛酸的充分摄入量为2mg,维生素H的充分摄入量9μg"); |
660 | - list.add("水分:1岁120-135ml/kg/day;2岁115-125ml/kg/day"); | |
706 | + //1岁120-135ml/kg/day;2岁115-125ml/kg/day | |
707 | + list.add("水分:1岁"+handleData(weight,120,135)+"ml/day;2岁"+handleData(weight,115,125)+"ml/kg/day"); | |
661 | 708 | } |
662 | 709 | else |
663 | 710 | { |
664 | - list.add("碳水化合物:总能量的55-70%"); | |
665 | - list.add("蛋白质:总能量的7-20%,平均每日约0.88g/kg"); | |
666 | - list.add("脂肪:总能量的15-30%"); | |
667 | - list.add("n-6:总能量的4-8%"); | |
668 | - list.add("n-3:总能量的1%"); | |
711 | + //总能量的55-70% | |
712 | + list.add("碳水化合物:"+handleData( nl,0.55,0.7)); | |
713 | + //总能量的7-20% | |
714 | + list.add("蛋白质:"+handleData( nl,0.07,0.2)+",平均每日约0.88g/kg"); | |
715 | + //总能量的15-30% | |
716 | + list.add("脂肪:"+handleData( nl,0.15,0.3)); | |
717 | + //总能量的4-8% | |
718 | + list.add("n-6:"+handleData( nl,0.04,0.08)); | |
719 | + //总能量的1% | |
720 | + list.add("n-3:"+handleData( nl,0.01)); | |
669 | 721 | list.add("无机物:钙的推荐摄入量为600mg,磷的推荐摄入量为500mg,钠的充分摄入量为0.9g,氯的充分摄入量为1.4g,钾的充分摄入量为2.3g,镁的推荐摄入量为100mg,铁的推荐摄入量7mg,锌的推荐摄入量为4mg,铜的推荐摄入量为330 μg,氟的充分摄入量为0.8mg,猛的充分摄入量为2.0mg,碘的推荐摄入量为90 μg,硒的推荐摄入量为25 μg"); |
670 | 722 | list.add("维生素:维生素A的推荐摄入量为300 μgRE,维生素D的充分摄入量为5 μg,维生素E的充分摄入量为6mg α-TE,维生素K的充分摄入量为30μg,维生素C的推荐摄入量为40mg,维生素B1的推荐摄入量为0.5mg,维生素B2(核黄素)的0.7mg,维生素B3烟酸的推荐摄入量为7mgNE,尼克酸的上限摄入量为10mg,尼克酰胺的上限摄入量为250mg,维生素B6的推荐摄入量0.7mg,叶酸的推荐摄入量为180μg DFE,维生素B12的推荐摄入量为1.1μg,泛酸的充分摄入量为3mg,维生素H的充分摄入量11μg"); |
671 | - list.add("水分:90-100ml/kg/day"); | |
723 | + //90-100ml/kg/day | |
724 | + list.add("水分:"+handleData(weight,90,100)+"ml/day"); | |
672 | 725 | } |
673 | 726 | |
674 | 727 | return list; |
728 | + } | |
729 | + | |
730 | + private String handleData(Double nl,double up,double down) | |
731 | + { | |
732 | + return String.format("%.2f",(nl * down))+"-"+String.format("%.2f",(nl * up)); | |
733 | + } | |
734 | + private String handleData(Double nl,double value) | |
735 | + { | |
736 | + return String.format("%.2f",(nl * value)); | |
675 | 737 | } |
676 | 738 | |
677 | 739 | /** |