Commit f1f16f690eefbaffba92e03f58a9afd43ff2ef89
1 parent
95ed5b7415
Exists in
master
and in
6 other branches
修改电子病历
Showing 1 changed file with 54 additions and 26 deletions
platform-operate-api/src/main/java/com/lyms/platform/operate/web/worker/QuanPatientWorker.java
View file @
f1f16f6
... | ... | @@ -68,15 +68,18 @@ |
68 | 68 | @Override |
69 | 69 | public List<QuanPatientsResult> call() throws Exception { |
70 | 70 | List data = new ArrayList<>(); |
71 | - AntExChuQuery antExChuQuery = new AntExChuQuery(); | |
72 | 71 | AntExQuery antExQuery = new AntExQuery(); |
72 | + antExQuery.setYn(YnEnums.YES.getId()); | |
73 | + AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
74 | + | |
75 | + antExChuQuery1.setYn(YnEnums.YES.getId()); | |
73 | 76 | for (Patients patients : patientses) { |
74 | 77 | |
75 | 78 | StopWatch stopWatch = new StopWatch("QuanPatientWorker -" + patients.getId()); |
76 | 79 | QuanPatientsResult quanPatientsResult = new QuanPatientsResult(); |
77 | 80 | quanPatientsResult.convertToResult(patients); |
78 | 81 | antExQuery.setPid(patients.getPid()); |
79 | - antExQuery.setYn(YnEnums.YES.getId()); | |
82 | + | |
80 | 83 | if (StringUtils.isNotEmpty(patients.getBookbuildingDoctor())) { |
81 | 84 | if (NumberUtils.isNumber(patients.getBookbuildingDoctor())) { |
82 | 85 | Users users = usersService.getUsers(NumberUtils.toInt(patients.getBookbuildingDoctor())); |
83 | 86 | |
84 | 87 | |
85 | 88 | |
86 | 89 | |
... | ... | @@ -90,17 +93,23 @@ |
90 | 93 | } |
91 | 94 | } |
92 | 95 | quanPatientsResult.setbTime(DateUtil.getyyyy_MM_dd(patients.getBookbuildingDate())); |
93 | - antExQuery.setHospitalId(null); | |
94 | 96 | stopWatch.start("query ant count"); |
97 | + antExChuQuery1.setPid(patients.getPid()); | |
98 | + List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1.convertToQuery()); | |
95 | 99 | //复诊次数 |
96 | - List<AntenatalExaminationModel> ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery().addOrder(Sort.Direction.DESC, "created")); | |
100 | + List<AntenatalExaminationModel> ant = null; | |
101 | + if (CollectionUtils.isNotEmpty(chu)) { | |
102 | + ant = antExService.queryAntenatalExamination(antExQuery.convertToQuery()); | |
103 | + } | |
104 | + //系统初诊次数 | |
105 | + int ichu = CollectionUtils.isEmpty(chu) ? 0 : chu.size(); | |
106 | + | |
97 | 107 | //系统复诊次数 |
98 | 108 | int i = 0; |
99 | - //系统初诊次数 | |
100 | - int ichu=0; | |
101 | 109 | if (CollectionUtils.isNotEmpty(ant)) { |
102 | 110 | //复诊次数 |
103 | 111 | i = ant.size(); |
112 | + sort(ant); | |
104 | 113 | for (AntenatalExaminationModel a : ant) { |
105 | 114 | try { |
106 | 115 | if (StringUtils.isNotEmpty(a.getHospitalId())) { |
... | ... | @@ -115,11 +124,6 @@ |
115 | 124 | } |
116 | 125 | } |
117 | 126 | } else { |
118 | - AntExChuQuery antExChuQuery1 = new AntExChuQuery(); | |
119 | - antExChuQuery1.setPid(patients.getPid()); | |
120 | - antExChuQuery1.setYn(YnEnums.YES.getId()); | |
121 | - List<AntExChuModel> chu = antExService.queryAntExChu(antExChuQuery1); | |
122 | - ichu=chu.size(); | |
123 | 127 | for (AntExChuModel a : chu) { |
124 | 128 | try { |
125 | 129 | if (StringUtils.isNotEmpty(a.getHospitalId())) { |
126 | 130 | |
127 | 131 | |
128 | 132 | |
... | ... | @@ -134,23 +138,16 @@ |
134 | 138 | } |
135 | 139 | } |
136 | 140 | } |
137 | - antExChuQuery.setPid(patients.getPid()); | |
138 | - antExChuQuery.setYn(YnEnums.YES.getId()); | |
139 | - antExChuQuery.setHospitalId(null); | |
140 | - //初诊次数 | |
141 | - if(0==ichu){ | |
142 | - ichu = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
143 | - } | |
141 | + | |
144 | 142 | quanPatientsResult.setcTimes(i + ichu); |
145 | 143 | |
146 | - antExChuQuery.setHospitalId(hospital); | |
147 | 144 | |
148 | 145 | antExQuery.setHospitalId(hospital); |
149 | 146 | //本院初诊 |
150 | - int chi = antExService.queryAntExChuCount(antExChuQuery.convertToQuery()); | |
147 | + int chi = countAntChu(chu, hospital); | |
151 | 148 | |
152 | 149 | //本院复诊 |
153 | - int chb = capLocalHospital(hospital,ant); | |
150 | + int chb = capLocalHospital(hospital, ant); | |
154 | 151 | quanPatientsResult.setcHTimes(chi + chb); |
155 | 152 | stopWatch.stop(); |
156 | 153 | String nextCheckTime = ""; |
157 | 154 | |
158 | 155 | |
... | ... | @@ -222,17 +219,48 @@ |
222 | 219 | return data; |
223 | 220 | } |
224 | 221 | |
225 | - private int capLocalHospital(String hospitalId,List<AntenatalExaminationModel> list){ | |
226 | - if(CollectionUtils.isEmpty(list)){ | |
222 | + private int capLocalHospital(String hospitalId, List<AntenatalExaminationModel> list) { | |
223 | + if (CollectionUtils.isEmpty(list)) { | |
227 | 224 | return 0; |
228 | 225 | } |
229 | - int count= 0; | |
230 | - for(AntenatalExaminationModel model:list){ | |
231 | - if(model.getHospitalId().equals(hospitalId)){ | |
226 | + int count = 0; | |
227 | + for (AntenatalExaminationModel model : list) { | |
228 | + if (model.getHospitalId().equals(hospitalId)) { | |
232 | 229 | count++; |
233 | 230 | } |
234 | 231 | } |
235 | 232 | return count; |
233 | + } | |
234 | + | |
235 | + //统计复查里面的本院检查数 | |
236 | + private int countAntChu(List<AntExChuModel> list, String hospital) { | |
237 | + int count = 0; | |
238 | + if (CollectionUtils.isEmpty(list) || StringUtils.isEmpty(hospital)) { | |
239 | + return count; | |
240 | + } | |
241 | + for (AntExChuModel model : list) { | |
242 | + if (hospital.equals(model.getHospitalId())) { | |
243 | + count++; | |
244 | + } | |
245 | + } | |
246 | + return count; | |
247 | + } | |
248 | + | |
249 | + private void sort(List<AntenatalExaminationModel> list) { | |
250 | + if (CollectionUtils.isEmpty(list)) { | |
251 | + return; | |
252 | + } | |
253 | + Collections.sort(list, new Comparator<AntenatalExaminationModel>() { | |
254 | + @Override | |
255 | + public int compare(AntenatalExaminationModel o1, AntenatalExaminationModel o2) { | |
256 | + if (o1.getCreated().getTime() > o2.getCreated().getTime()) { | |
257 | + return 1; | |
258 | + } else if (o1.getCreated().getTime() < o2.getCreated().getTime()) { | |
259 | + return -1; | |
260 | + } | |
261 | + return 0; | |
262 | + } | |
263 | + }); | |
236 | 264 | } |
237 | 265 | } |