Commit 5a9b3274e1082db1bd5883fe5cb8d3a97ee8050e

Authored by liquanyu
1 parent c927c1e235

高危诊断配置

Showing 7 changed files with 246 additions and 136 deletions

platform-dal/src/main/java/com/lyms/platform/pojo/DiagnoseConfigModel.java View file @ 5a9b327
... ... @@ -21,7 +21,7 @@
21 21 private String hospitalId;
22 22 //是否启用 0停用 1启用
23 23 private String enable;
24   - private List<Map<Integer,String>> status;
  24 + private List<Map<String,String>> configs;
25 25  
26 26 private Date created;
27 27 private Date modified;
28 28  
... ... @@ -67,12 +67,12 @@
67 67 this.enable = enable;
68 68 }
69 69  
70   - public List<Map<Integer, String>> getStatus() {
71   - return status;
  70 + public List<Map<String, String>> getConfigs() {
  71 + return configs;
72 72 }
73 73  
74   - public void setStatus(List<Map<Integer, String>> status) {
75   - this.status = status;
  74 + public void setConfigs(List<Map<String, String>> configs) {
  75 + this.configs = configs;
76 76 }
77 77 }
platform-dal/src/main/java/com/lyms/platform/pojo/DiagnoseItemModel.java View file @ 5a9b327
... ... @@ -28,7 +28,6 @@
28 28 private String valueThree;
29 29 private String valueFour;
30 30 private String valueFive;
31   - private String valueSix;
32 31 private Date created;
33 32 private Date modified;
34 33  
... ... @@ -36,7 +35,7 @@
36 35 private Integer weight;
37 36  
38 37 //高危id
39   - private String riskId;
  38 + private List<String> riskIds;
40 39  
41 40 public String getConfigId() {
42 41 return configId;
43 42  
... ... @@ -70,12 +69,12 @@
70 69 this.modified = modified;
71 70 }
72 71  
73   - public String getRiskId() {
74   - return riskId;
  72 + public List<String> getRiskIds() {
  73 + return riskIds;
75 74 }
76 75  
77   - public void setRiskId(String riskId) {
78   - this.riskId = riskId;
  76 + public void setRiskIds(List<String> riskIds) {
  77 + this.riskIds = riskIds;
79 78 }
80 79  
81 80 public String getId() {
82 81  
... ... @@ -150,12 +149,6 @@
150 149 this.valueFive = valueFive;
151 150 }
152 151  
153   - public String getValueSix() {
154   - return valueSix;
155   - }
156 152  
157   - public void setValueSix(String valueSix) {
158   - this.valueSix = valueSix;
159   - }
160 153 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java View file @ 5a9b327
... ... @@ -119,6 +119,10 @@
119 119 @Autowired
120 120 private SieveFacade sieveFacade;
121 121  
  122 +
  123 + @Autowired
  124 + private DiagnoseConfigService diagnoseConfigService;
  125 +
122 126 /**
123 127 * 处理区域隐藏建档
124 128 *
125 129  
126 130  
127 131  
128 132  
... ... @@ -2645,18 +2649,157 @@
2645 2649  
2646 2650  
2647 2651 public BaseResponse getAntenatalExRisk(AntExAddRequest antExAddRequest, Integer userId) {
  2652 +
  2653 + List<String> list = new ArrayList<>();
  2654 +
2648 2655 Patients patients = patientsService.findOnePatientById(antExAddRequest.getParentId());
2649 2656 String hospitalId = autoMatchFacade.getHospitalId(userId);
2650 2657  
  2658 + DiagnoseConfigQuery diagnoseConfigQuery = new DiagnoseConfigQuery();
  2659 + diagnoseConfigQuery.setHospitalId(hospitalId);
  2660 + List<DiagnoseConfigModel> configModels = diagnoseConfigService.queryDiagnoseConfigs(diagnoseConfigQuery);
2651 2661  
2652   - return null;
  2662 + if (CollectionUtils.isNotEmpty(configModels))
  2663 + {
  2664 +
  2665 + DiagnoseConfigModel configModel = configModels.get(0);
  2666 +
  2667 + DiagnoseItemsQuery diagnoseItemsQuery = new DiagnoseItemsQuery();
  2668 + diagnoseItemsQuery.setConfigId(configModel.getId());
  2669 +
  2670 + List<DiagnoseItemModel> diagnoseItemModels = diagnoseConfigService.queryDiagnoseItems(diagnoseItemsQuery);
  2671 +
  2672 + }
  2673 +
  2674 + return new BaseObjectResponse().setData(list).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
2653 2675 }
2654 2676  
2655 2677  
2656 2678 public BaseResponse getAntexExRisk(AntExcAddRequest antExcAddRequest, Integer userId) {
  2679 +
  2680 + List<String> list = new ArrayList<>();
  2681 +
2657 2682 Patients patients = patientsService.findOnePatientById(antExcAddRequest.getParentId());
2658   - String hospitalId = autoMatchFacade.getHospitalId(userId);
2659   - return null;
  2683 +
  2684 + DiagnoseConfigQuery diagnoseConfigQuery = new DiagnoseConfigQuery();
  2685 + diagnoseConfigQuery.setHospitalId(patients.getHospitalId());
  2686 + List<DiagnoseConfigModel> configModels = diagnoseConfigService.queryDiagnoseConfigs(diagnoseConfigQuery);
  2687 +
  2688 + Map<Integer,List<DiagnoseItemModel>> mapItems = getRiskConfig(configModels);
  2689 + if (mapItems != null && mapItems.size() > 0)
  2690 + {
  2691 +
  2692 + Integer age = DateUtil.getAge(patients.getBirth(), new Date());
  2693 + //年龄高危匹配
  2694 + List<DiagnoseItemModel> detailItems = mapItems.get(DiagnoseEnums.DiagnoseItemEnums.age.getId());
  2695 + if (CollectionUtils.isNotEmpty(detailItems))
  2696 + {
  2697 + for (DiagnoseItemModel item : detailItems)
  2698 + {
  2699 + if (compare(item,age) && CollectionUtils.isNotEmpty(item.getRiskIds()))
  2700 + {
  2701 + list.addAll(item.getRiskIds());
  2702 + }
  2703 + }
  2704 + }
  2705 + }
  2706 +
  2707 + return new BaseObjectResponse().setData(list).setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功");
  2708 + }
  2709 +
  2710 + /**
  2711 + *
  2712 + * @param expId 表达式id
  2713 + * @param value 计算值
  2714 + * @param calValue 被计算值
  2715 + * @return
  2716 + */
  2717 + private boolean compare(String expId,String value,Integer calValue)
  2718 + {
  2719 + Integer id = Integer.parseInt(expId);
  2720 + switch (id)
  2721 + {
  2722 + case 1 :
  2723 + return calValue > Integer.parseInt(value);
  2724 + case 2 :
  2725 + return calValue >= Integer.parseInt(value) ;
  2726 + case 3 :
  2727 + return calValue < Integer.parseInt(value);
  2728 + case 4 :
  2729 + return calValue <= Integer.parseInt(value) ;
  2730 + case 5 :
  2731 + return calValue == Integer.parseInt(value);
  2732 + case 6 :
  2733 + return Integer.parseInt(value) != calValue;
  2734 + default: return false;
  2735 + }
  2736 + }
  2737 +
  2738 + private boolean compare(DiagnoseItemModel item,Integer calValue)
  2739 + {
  2740 + String expId1 = item.getValueOne();
  2741 + String value1 = item.getValueTwo();
  2742 + String logic = item.getValueThree();
  2743 + String expId2 = item.getValueFour();
  2744 + String value2 = item.getValueFive();
  2745 +
  2746 + if (StringUtils.isNotEmpty(expId1) &&
  2747 + StringUtils.isNotEmpty(value1) &&
  2748 + StringUtils.isNotEmpty(expId2) &&
  2749 + StringUtils.isNotEmpty(value2) &&
  2750 + StringUtils.isNotEmpty(logic))
  2751 + {
  2752 + Integer logicId = Integer.parseInt(logic);
  2753 + switch (logicId)
  2754 + {
  2755 + case 1 :
  2756 + return compare(expId1, value1, calValue) && compare(expId2, value2, calValue);
  2757 + case 2 :
  2758 + return compare(expId1, value1, calValue) || compare(expId2, value2, calValue);
  2759 +
  2760 + default: return false;
  2761 + }
  2762 + }
  2763 + else if (StringUtils.isNotEmpty(expId1) &&
  2764 + StringUtils.isNotEmpty(value1))
  2765 + {
  2766 + return compare(expId1, value1, calValue);
  2767 + }
  2768 + return false;
  2769 + }
  2770 +
  2771 +
  2772 + private Map<Integer,List<DiagnoseItemModel>> getRiskConfig(List<DiagnoseConfigModel> configModels)
  2773 + {
  2774 + Map<Integer,List<DiagnoseItemModel>> mapItems = new HashMap<>();
  2775 +
  2776 + if (CollectionUtils.isNotEmpty(configModels))
  2777 + {
  2778 + DiagnoseConfigModel configModel = configModels.get(0);
  2779 +
  2780 + DiagnoseItemsQuery diagnoseItemsQuery = new DiagnoseItemsQuery();
  2781 + diagnoseItemsQuery.setConfigId(configModel.getId());
  2782 +
  2783 + List<DiagnoseItemModel> diagnoseItemModels = diagnoseConfigService.queryDiagnoseItems(diagnoseItemsQuery);
  2784 + if (CollectionUtils.isNotEmpty(diagnoseItemModels))
  2785 + {
  2786 + for (DiagnoseEnums.DiagnoseItemEnums diagnoses : DiagnoseEnums.DiagnoseItemEnums.values())
  2787 + {
  2788 +
  2789 + List<DiagnoseItemModel> diagnoseItemList = new ArrayList<>();
  2790 + for (DiagnoseItemModel item : diagnoseItemModels)
  2791 + {
  2792 + if (diagnoses.getId() == Integer.parseInt(item.getParentId()))
  2793 + {
  2794 + diagnoseItemList.add(item);
  2795 + }
  2796 + }
  2797 + mapItems.put(diagnoses.getId(),diagnoseItemList);
  2798 + }
  2799 + }
  2800 + }
  2801 +
  2802 + return mapItems;
2660 2803 }
2661 2804  
2662 2805  
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/DiagnoseConfigFacde.java View file @ 5a9b327
... ... @@ -5,6 +5,7 @@
5 5 import com.lyms.platform.common.enums.OptActionEnums;
6 6 import com.lyms.platform.common.result.BaseObjectResponse;
7 7 import com.lyms.platform.common.result.BaseResponse;
  8 +import com.lyms.platform.common.utils.JsonUtil;
8 9 import com.lyms.platform.common.utils.StringUtils;
9 10 import com.lyms.platform.operate.web.request.DiagnoseConfigRequest;
10 11 import com.lyms.platform.operate.web.result.DiagnoseConfigResult;
... ... @@ -18,6 +19,7 @@
18 19 import org.springframework.stereotype.Component;
19 20  
20 21 import java.util.ArrayList;
  22 +import java.util.HashMap;
21 23 import java.util.List;
22 24 import java.util.Map;
23 25  
24 26  
... ... @@ -47,11 +49,30 @@
47 49 String hospitalId = autoMatchFacade.getHospitalId(userId);
48 50  
49 51 DiagnoseConfigModel diagnoseConfigModel = request.convertToDataModel();
  52 +
  53 + Map<Integer, List<DiagnoseItemModel>> items = new HashMap<>();
  54 +
  55 + List<Map<String,String>> configs = request.getConfigs();
  56 + if (CollectionUtils.isNotEmpty(configs))
  57 + {
  58 + for (Map<String,String> config : configs)
  59 + {
  60 + String configItems = config.get("items");
  61 + if (StringUtils.isNotEmpty(configItems))
  62 + {
  63 + items.put(Integer.parseInt(config.get("id")), JsonUtil.toList(configItems,DiagnoseItemModel.class));
  64 + }
  65 + config.remove("items");
  66 + }
  67 + diagnoseConfigModel.setConfigs(configs);
  68 + }
  69 +
  70 +
50 71 diagnoseConfigModel = diagnoseConfigService.saveDiagnoseConfig(diagnoseConfigModel);
51 72  
52 73 operateLogFacade.addAddOptLog(userId,Integer.parseInt(hospitalId),diagnoseConfigModel, OptActionEnums.ADD.getId(), "添加高危诊断基础配置");
53 74  
54   - Map<Integer, List<DiagnoseItemModel>> items = request.getItems();
  75 +
55 76 if (items != null && items.size() > 0)
56 77 {
57 78 for(Integer key : items.keySet())
... ... @@ -94,6 +115,24 @@
94 115 String hospitalId = autoMatchFacade.getHospitalId(userId);
95 116  
96 117 DiagnoseConfigModel diagnoseConfigModel = request.convertToDataModel();
  118 +
  119 + Map<Integer, List<DiagnoseItemModel>> items = new HashMap<>();
  120 +
  121 + List<Map<String,String>> configs = request.getConfigs();
  122 + if (CollectionUtils.isNotEmpty(configs))
  123 + {
  124 + for (Map<String,String> config : configs)
  125 + {
  126 + String configItems = config.get("items");
  127 + if (StringUtils.isNotEmpty(configItems))
  128 + {
  129 + items.put(Integer.parseInt(config.get("id")), JsonUtil.toList(configItems,DiagnoseItemModel.class));
  130 + }
  131 + config.remove("items");
  132 + }
  133 + diagnoseConfigModel.setConfigs(configs);
  134 + }
  135 +
97 136 diagnoseConfigService.updateDiagnoseConfig(diagnoseConfigModel);
98 137  
99 138 if (CollectionUtils.isNotEmpty(befores))
... ... @@ -101,7 +140,6 @@
101 140 operateLogFacade.addModifyOptLog(userId, Integer.parseInt(hospitalId), befores.get(0), diagnoseConfigModel,
102 141 OptActionEnums.UPDATE.getId(), "更新高危诊断基础配置");
103 142  
104   - Map<Integer, List<DiagnoseItemModel>> items = request.getItems();
105 143  
106 144 DiagnoseItemsQuery diagnoseItemsQuery = new DiagnoseItemsQuery();
107 145 diagnoseItemsQuery.setConfigId(request.getId());
108 146  
109 147  
110 148  
111 149  
112 150  
113 151  
... ... @@ -155,25 +193,31 @@
155 193 {
156 194  
157 195 DiagnoseConfigResult result = new DiagnoseConfigResult();
158   - result.convertToResult(configModel);
159 196  
  197 +
160 198 DiagnoseItemsQuery diagnoseItemsQuery = new DiagnoseItemsQuery();
161 199 diagnoseItemsQuery.setConfigId(configModel.getId());
162 200  
163 201 List<DiagnoseItemModel> diagnoseItemModels = diagnoseConfigService.queryDiagnoseItems(diagnoseItemsQuery);
164   - if (CollectionUtils.isNotEmpty(diagnoseItemModels))
  202 + if (CollectionUtils.isNotEmpty(diagnoseItemModels) && CollectionUtils.isNotEmpty(configModel.getConfigs()))
165 203 {
166   - List<DiagnoseItemResult> results = new ArrayList<>();
167   - for (DiagnoseItemModel model : diagnoseItemModels)
  204 + for (Map<String,String> config : configModel.getConfigs())
168 205 {
169   - DiagnoseItemResult itemResult = new DiagnoseItemResult();
170   - itemResult.convertToResult(model);
171   -
172   - results.add(itemResult);
  206 + List<DiagnoseItemResult> itemModels = new ArrayList<>();
  207 + for (DiagnoseItemModel diagnose : diagnoseItemModels)
  208 + {
  209 + if (config.get("id").equals(diagnose.getParentId()))
  210 + {
  211 + DiagnoseItemResult dr = new DiagnoseItemResult();
  212 + dr.convertToResult(diagnose);
  213 + itemModels.add(dr);
  214 + }
  215 + }
  216 + config.put("items",JsonUtil.array2JsonString(itemModels));
173 217 }
174   - result.setResults(results);
175 218 }
176   - new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(result);
  219 + result.convertToResult(configModel);
  220 + return new BaseObjectResponse().setErrorcode(ErrorCodeConstants.SUCCESS).setErrormsg("成功").setData(result);
177 221 }
178 222 return new BaseResponse().setErrorcode(ErrorCodeConstants.NO_DATA).setErrormsg("没有数据");
179 223 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/request/DiagnoseConfigRequest.java View file @ 5a9b327
1 1 package com.lyms.platform.operate.web.request;
2 2  
3 3 import com.lyms.platform.common.base.IBasicRequestConvert;
  4 +import com.lyms.platform.common.utils.StringUtils;
4 5 import com.lyms.platform.pojo.DiagnoseConfigModel;
5 6 import com.lyms.platform.pojo.DiagnoseItemModel;
  7 +import org.apache.commons.collections.CollectionUtils;
6 8  
  9 +import java.util.ArrayList;
7 10 import java.util.List;
8 11 import java.util.Map;
9 12  
... ... @@ -16,8 +19,7 @@
16 19 private String hospitalId;
17 20 //是否启用 0停用 1启用
18 21 private String enable;
19   - private List<Map<Integer,String>> status;
20   - private Map<Integer,List<DiagnoseItemModel>> items;
  22 + private List<Map<String,String>> configs;
21 23  
22 24 public String getId() {
23 25 return id;
24 26  
25 27  
26 28  
... ... @@ -43,29 +45,20 @@
43 45 this.enable = enable;
44 46 }
45 47  
46   - public List<Map<Integer, String>> getStatus() {
47   - return status;
  48 + public List<Map<String, String>> getConfigs() {
  49 + return configs;
48 50 }
49 51  
50   - public void setStatus(List<Map<Integer, String>> status) {
51   - this.status = status;
  52 + public void setConfigs(List<Map<String, String>> configs) {
  53 + this.configs = configs;
52 54 }
53 55  
54   - public Map<Integer, List<DiagnoseItemModel>> getItems() {
55   - return items;
56   - }
57   -
58   - public void setItems(Map<Integer, List<DiagnoseItemModel>> items) {
59   - this.items = items;
60   - }
61   -
62 56 @Override
63 57 public DiagnoseConfigModel convertToDataModel() {
64 58 DiagnoseConfigModel model = new DiagnoseConfigModel();
65 59 model.setId(id);
66 60 model.setEnable(enable);
67 61 model.setHospitalId(hospitalId);
68   - model.setStatus(status);
69 62 return model;
70 63 }
71 64 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/DiagnoseConfigResult.java View file @ 5a9b327
... ... @@ -15,9 +15,8 @@
15 15 private String hospitalId;
16 16 //是否启用 0停用 1启用
17 17 private String enable;
18   - private List<Map<Integer,String>> status;
  18 + private List<Map<String,String>> configs;
19 19  
20   - private List<DiagnoseItemResult> results;
21 20  
22 21  
23 22 public String getId() {
24 23  
25 24  
26 25  
... ... @@ -44,28 +43,20 @@
44 43 this.enable = enable;
45 44 }
46 45  
47   - public List<Map<Integer, String>> getStatus() {
48   - return status;
  46 + public List<Map<String, String>> getConfigs() {
  47 + return configs;
49 48 }
50 49  
51   - public void setStatus(List<Map<Integer, String>> status) {
52   - this.status = status;
  50 + public void setConfigs(List<Map<String, String>> configs) {
  51 + this.configs = configs;
53 52 }
54 53  
55   - public List<DiagnoseItemResult> getResults() {
56   - return results;
57   - }
58   -
59   - public void setResults(List<DiagnoseItemResult> results) {
60   - this.results = results;
61   - }
62   -
63 54 @Override
64 55 public DiagnoseConfigResult convertToResult(DiagnoseConfigModel model) {
65 56 setId(model.getId());
66 57 setHospitalId(model.getHospitalId());
67 58 setEnable(model.getEnable());
68   - setStatus(model.getStatus());
  59 + setConfigs(model.getConfigs());
69 60 return this;
70 61 }
71 62 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/result/DiagnoseItemResult.java View file @ 5a9b327
... ... @@ -3,88 +3,49 @@
3 3 import com.lyms.platform.common.base.IBasicResultConvert;
4 4 import com.lyms.platform.pojo.DiagnoseItemModel;
5 5  
  6 +import java.util.List;
6 7  
  8 +
7 9 /**
8 10 * Created by Administrator on 2018-04-02.
9 11 */
10 12 public class DiagnoseItemResult implements IBasicResultConvert<DiagnoseItemResult,DiagnoseItemModel> {
11 13  
12   - private String id;
13   - private String configId;
14   - private String hospitalId;
15   - private String parentId;
  14 +// private String id;
  15 +// private String configId;
  16 +// private String hospitalId;
  17 +// private String parentId;
16 18 //是否启用 0停用 1启用
17   - private Integer enable;
  19 +// private Integer enable;
18 20 private String valueOne;
19 21 private String valueTwo;
20 22 private String valueThree;
21 23 private String valueFour;
22 24 private String valueFive;
23   - private String valueSix;
24   - //权重
25   - private Integer weight;
  25 +// //权重
  26 +// private Integer weight;
26 27  
27 28 //高危id
28   - private String riskId;
  29 + private List<String> riskIds;
29 30  
30 31 @Override
31 32 public DiagnoseItemResult convertToResult(DiagnoseItemModel model) {
32   - setId(model.getId());
33   - setConfigId(model.getConfigId());
34   - setHospitalId(model.getHospitalId());
35   - setParentId(model.getParentId());
36   - setEnable(model.getEnable());
  33 +// setId(model.getId());
  34 +// setConfigId(model.getConfigId());
  35 +// setHospitalId(model.getHospitalId());
  36 +// setParentId(model.getParentId());
  37 +// setEnable(model.getEnable());
37 38 setValueOne(model.getValueOne());
38 39 setValueTwo(model.getValueTwo());
39 40 setValueThree(model.getValueThree());
40 41 setValueFour(model.getValueFour());
41 42 setValueFive(model.getValueFive());
42   - setValueSix(model.getValueSix());
43   - setWeight(model.getWeight());
44   - setRiskId(model.getRiskId());
  43 + setRiskIds(model.getRiskIds());
45 44 return this;
46 45 }
47 46  
48   - public String getId() {
49   - return id;
50   - }
51 47  
52   - public void setId(String id) {
53   - this.id = id;
54   - }
55 48  
56   - public String getConfigId() {
57   - return configId;
58   - }
59   -
60   - public void setConfigId(String configId) {
61   - this.configId = configId;
62   - }
63   -
64   - public String getHospitalId() {
65   - return hospitalId;
66   - }
67   -
68   - public void setHospitalId(String hospitalId) {
69   - this.hospitalId = hospitalId;
70   - }
71   -
72   - public String getParentId() {
73   - return parentId;
74   - }
75   -
76   - public void setParentId(String parentId) {
77   - this.parentId = parentId;
78   - }
79   -
80   - public Integer getEnable() {
81   - return enable;
82   - }
83   -
84   - public void setEnable(Integer enable) {
85   - this.enable = enable;
86   - }
87   -
88 49 public String getValueOne() {
89 50 return valueOne;
90 51 }
91 52  
92 53  
... ... @@ -125,28 +86,13 @@
125 86 this.valueFive = valueFive;
126 87 }
127 88  
128   - public String getValueSix() {
129   - return valueSix;
130   - }
131 89  
132   - public void setValueSix(String valueSix) {
133   - this.valueSix = valueSix;
  90 + public List<String> getRiskIds() {
  91 + return riskIds;
134 92 }
135 93  
136   - public Integer getWeight() {
137   - return weight;
138   - }
139   -
140   - public void setWeight(Integer weight) {
141   - this.weight = weight;
142   - }
143   -
144   - public String getRiskId() {
145   - return riskId;
146   - }
147   -
148   - public void setRiskId(String riskId) {
149   - this.riskId = riskId;
  94 + public void setRiskIds(List<String> riskIds) {
  95 + this.riskIds = riskIds;
150 96 }
151 97 }