Commit 90a47395fe712c796c94531d52ffa74e4cf13dd6

Authored by liquanyu
1 parent ac586f9a6a

update code

Showing 2 changed files with 142 additions and 14 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java View file @ 90a4739
... ... @@ -43,6 +43,7 @@
43 43 import org.springframework.data.mongodb.core.MongoTemplate;
44 44 import org.springframework.data.mongodb.core.query.Criteria;
45 45 import org.springframework.data.mongodb.core.query.Query;
  46 +import org.springframework.data.mongodb.core.query.Update;
46 47 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
47 48 import org.springframework.stereotype.Component;
48 49 import org.springframework.util.StopWatch;
... ... @@ -509,6 +510,18 @@
509 510 e.printStackTrace();
510 511 }
511 512  
  513 + try {
  514 + //处方计划
  515 + if (antExamModel.getNextCheckTime() != null)
  516 + {
  517 + patients = patientsService.findOnePatientById(antExamModel.getParentId());
  518 + updateTrackCount(antExamModel.getCheckDate(), antExamModel.getNextCheckTime(),patients);
  519 + }
  520 + } catch (Exception e) {
  521 + e.printStackTrace();
  522 + }
  523 +
  524 +
512 525 }
513 526 });
514 527  
... ... @@ -1158,8 +1171,11 @@
1158 1171 }
1159 1172  
1160 1173 try {
1161   - //追访统计
1162   - saveTrackCount(DateUtil.parseYMD(excAddRequest.getNextCheckTime()), patients);
  1174 + if (excAddRequest.getNextCheckTime() != null)
  1175 + {
  1176 + //追访统计
  1177 + saveTrackCount(DateUtil.parseYMD(excAddRequest.getNextCheckTime()), patients);
  1178 + }
1163 1179 } catch (Exception e) {
1164 1180 e.printStackTrace();
1165 1181 }
1166 1182  
1167 1183  
1168 1184  
1169 1185  
1170 1186  
1171 1187  
1172 1188  
... ... @@ -1169,29 +1185,116 @@
1169 1185  
1170 1186 public void saveTrackCount(Date nextCheckTime,Patients patients)
1171 1187 {
  1188 + TrackCountRecord record = new TrackCountRecord();
  1189 + record.setPid(patients.getHospitalId());
  1190 + record.setPatientId(patients.getId());
  1191 + record.setNextCheckTime(nextCheckTime);
  1192 + record.setCreated(new Date());
  1193 + record.setModified(new Date());
  1194 + mongoTemplate.save(record);
  1195 + }
  1196 +
  1197 + public void updateTrackCount(Date checkTime,Date nextCheckTime,Patients patients)
  1198 + {
  1199 + TrackDayConfig trackDayConfig = mongoTemplate.findOne(Query.query(Criteria.where("hospitalId").is(patients.getHospitalId())), TrackDayConfig.class);
  1200 + if (trackDayConfig == null || trackDayConfig.getConfis() == null || trackDayConfig.getConfis().size() == 0)
  1201 + {
  1202 + return;
  1203 + }
  1204 +
1172 1205 AntExRecordQuery antExRecordQuery = new AntExRecordQuery();
1173 1206 antExRecordQuery.setPid(patients.getPid());
1174 1207 List<AntExRecordModel> recordModels = recordService.queryAntExRecords(antExRecordQuery, Sort.Direction.DESC, "checkTime");
1175   - if (CollectionUtils.isNotEmpty(recordModels))
  1208 + if (CollectionUtils.isNotEmpty(recordModels) && recordModels.size() > 1)
1176 1209 {
1177   - AntExRecordModel recordModel = recordModels.get(0);
1178   -// if ()
1179   -// {
1180   -//
1181   -// }
  1210 + TrackCountRecord record = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patients.getPid())).with(new Sort(Sort.Direction.DESC, "created")), TrackCountRecord.class);
  1211 + AntExRecordModel recordModel = recordModels.get(1);
  1212 + if (DateUtil.getyyyy_MM_dd(recordModel.getNextCheckTime()).equals(DateUtil.getyyyy_MM_dd(nextCheckTime)))
  1213 + {
  1214 +
  1215 + record.setZsCheckStatus(1);
  1216 + Query query = Query.query(Criteria.where("_id").is(record.getId()));
  1217 + Update update = MongoConvertHelper
  1218 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(record));
  1219 + mongoTemplate.updateFirst(query, update, TrackCountRecord.class);
  1220 + }
  1221 + else if (checkTime.getTime() < DateUtil.addDay(recordModel.getNextCheckTime(),4).getTime() && checkTime.getTime() > recordModel.getNextCheckTime().getTime())
  1222 + {
  1223 + record.setJsCheckStatus(1);
  1224 + Query query = Query.query(Criteria.where("_id").is(record.getId()));
  1225 + Update update = MongoConvertHelper
  1226 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(record));
  1227 + mongoTemplate.updateFirst(query, update, TrackCountRecord.class);
  1228 + }
  1229 + else if (checkTime.getTime() > DateUtil.addDay(recordModel.getNextCheckTime(),3).getTime())
  1230 + {
  1231 + record.setLoseStatus(1);
  1232 + Query query = Query.query(Criteria.where("_id").is(record.getId()));
  1233 + Update update = MongoConvertHelper
  1234 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(record));
  1235 + mongoTemplate.updateFirst(query, update, TrackCountRecord.class);
  1236 + }
  1237 + //有效期召回人次
  1238 + List<Map<String, String>> configs = trackDayConfig.getConfis();
  1239 + String riskLevelId = patients.getRiskLevelId();
  1240 + if (StringUtils.isNotEmpty(riskLevelId) && !"[]".equals(riskLevelId))
  1241 + {
  1242 + List<String> rlevel = JsonUtil.jkstr2Obj(patients.getRiskLevelId(), List.class);
  1243 + Integer day = getTrackDay(rlevel, configs);
  1244 + if (day != null)
  1245 + {
  1246 + if (checkTime.getTime() < DateUtil.addDay(recordModel.getNextCheckTime(),day+1).getTime() && checkTime.getTime() >= recordModel.getNextCheckTime().getTime())
  1247 + {
  1248 + record.setBackStatus(1);
  1249 + Query query = Query.query(Criteria.where("_id").is(record.getId()));
  1250 + Update update = MongoConvertHelper
  1251 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(record));
  1252 + mongoTemplate.updateFirst(query, update, TrackCountRecord.class);
  1253 + }
  1254 + }
  1255 + }
  1256 + saveTrackCount(recordModel.getNextCheckTime(), patients);
1182 1257 }
1183 1258 }
1184 1259  
1185   - public void updateTrackCount(Date nextCheckTime,Patients patients)
  1260 + private Integer getTrackDay(List<String> rlevel,List<Map<String,String>> configs)
1186 1261 {
1187   - AntExRecordQuery antExRecordQuery = new AntExRecordQuery();
1188   - antExRecordQuery.setPid(patients.getPid());
1189   - List<AntExRecordModel> recordModels = recordService.queryAntExRecords(antExRecordQuery, Sort.Direction.DESC, "checkTime");
1190   - if (CollectionUtils.isNotEmpty(recordModels))
  1262 + Integer day = null;
  1263 + //紫色
  1264 + if (rlevel.contains("224b2329-cb82-4da3-a071-8527f8283aab"))
1191 1265 {
1192   - AntExRecordModel recordModel = recordModels.get(0);
  1266 + day = getDay(configs,"224b2329-cb82-4da3-a071-8527f8283aab");
  1267 + }
  1268 + //
  1269 + else if (rlevel.contains("eb146c03-b19f-4e28-b85f-fda574b2283b"))
  1270 + {
  1271 + day = getDay(configs,"eb146c03-b19f-4e28-b85f-fda574b2283b");
  1272 + }
  1273 + else if (rlevel.contains("49a36aea-c5b6-4162-87d2-9eb3c6ec00c2"))
  1274 + {
  1275 + day = getDay(configs,"49a36aea-c5b6-4162-87d2-9eb3c6ec00c2");
  1276 + }
  1277 + else if (rlevel.contains("315107bd-91fe-42a1-9237-752f3c046a40"))
  1278 + {
  1279 + day = getDay(configs,"315107bd-91fe-42a1-9237-752f3c046a40");
  1280 + }
  1281 + else if (rlevel.contains("e637b361-99cf-41eb-84f2-f0dab596e928"))
  1282 + {
  1283 + day = getDay(configs,"e637b361-99cf-41eb-84f2-f0dab596e928");
  1284 + }
  1285 + return day;
  1286 + }
1193 1287  
  1288 + private Integer getDay(List<Map<String,String>> configs,String rlevel)
  1289 + {
  1290 + for (Map<String, String> config : configs)
  1291 + {
  1292 + if (config.get("riskLevel").equals(rlevel))
  1293 + {
  1294 + return Integer.parseInt(config.get("day"));
  1295 + }
1194 1296 }
  1297 + return null;
1195 1298 }
1196 1299  
1197 1300 public void saveCheckItem(Date nextCheckTime,Patients patients)
platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java View file @ 90a4739
... ... @@ -17,6 +17,7 @@
17 17 import org.springframework.data.mongodb.core.MongoTemplate;
18 18 import org.springframework.data.mongodb.core.query.Criteria;
19 19 import org.springframework.data.mongodb.core.query.Query;
  20 +import org.springframework.data.mongodb.core.query.Update;
20 21 import org.springframework.stereotype.Service;
21 22 import org.springframework.util.StopWatch;
22 23  
23 24  
... ... @@ -930,7 +931,31 @@
930 931 trackDownService.add(trackDown);
931 932 String recordId = trackDown.getTrackDownRecId();
932 933 updateRecordStatus(trackDown, recordId);
  934 + updateTrackCount(trackDown.getParentId());
933 935 return RespBuilder.buildSuccess(trackDown.getId());
  936 + }
  937 +
  938 +
  939 + /**
  940 + * 追访统计
  941 + * @param patientId
  942 + */
  943 + private void updateTrackCount(String patientId)
  944 + {
  945 + Patients patients = patientsService.findOnePatientById(patientId);
  946 + if (patients != null)
  947 + {
  948 + TrackCountRecord record = mongoTemplate.findOne(Query.query(Criteria.where("pid").is(patients.getPid())).with(new Sort(Sort.Direction.DESC,
  949 + "created")), TrackCountRecord.class);
  950 + if (record != null)
  951 + {
  952 + record.setTrackStatus(record.getTrackStatus() == null ? 1 : record.getTrackStatus() + 1);
  953 + Query query = Query.query(Criteria.where("_id").is(record.getId()));
  954 + Update update = MongoConvertHelper
  955 + .convertToNativeUpdate(ReflectionUtils.getUpdateField(record));
  956 + mongoTemplate.updateFirst(query, update, TrackCountRecord.class);
  957 + }
  958 + }
934 959 }
935 960  
936 961 /**