Commit efd46798656be6ac5adcbd6f2c3e151712291412

Authored by zhangchao
1 parent add96c3c62
Exists in dev

#fix:大同lis数据 辅助检查更新

Showing 2 changed files with 163 additions and 32 deletions

platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java View file @ efd4679
... ... @@ -2,10 +2,7 @@
2 2  
3 3 import com.lyms.platform.biz.dal.AssayConfigDao;
4 4 import com.lyms.platform.biz.param.ReferConfigQuery;
5   -import com.lyms.platform.biz.service.AntenatalExaminationService;
6   -import com.lyms.platform.biz.service.LisCrisisItemService;
7   -import com.lyms.platform.biz.service.PatientsService;
8   -import com.lyms.platform.biz.service.ReferConfigService;
  5 +import com.lyms.platform.biz.service.*;
9 6 import com.lyms.platform.common.constants.ErrorCodeConstants;
10 7 import com.lyms.platform.common.dao.operator.MongoCondition;
11 8 import com.lyms.platform.common.dao.operator.MongoOper;
... ... @@ -21,10 +18,7 @@
21 18 import com.lyms.platform.permission.service.LisService;
22 19 import com.lyms.platform.permission.service.OrganizationService;
23 20 import com.lyms.platform.pojo.*;
24   -import com.lyms.platform.query.AntExChuQuery;
25   -import com.lyms.platform.query.AntExQuery;
26   -import com.lyms.platform.query.LisCrisisItemQuery;
27   -import com.lyms.platform.query.PatientsQuery;
  21 +import com.lyms.platform.query.*;
28 22 import net.sf.json.JSONArray;
29 23 import net.sf.json.JSONObject;
30 24 import org.apache.commons.collections.CollectionUtils;
... ... @@ -180,6 +174,7 @@
180 174  
181 175 @Autowired
182 176 private LisCrisisItemService lisCrisisItemService;
  177 +
183 178 /**
184 179 * 根据Lis数据同步大同高危急值
185 180 * @param model
186 181  
... ... @@ -212,7 +207,16 @@
212 207 return;
213 208 }
214 209  
  210 + AntExChuQuery antExChuQuery=new AntExChuQuery();
  211 + antExChuQuery.setParentId(patients.getId());
  212 + antExChuQuery.setYn(1);
  213 + List<AntExChuModel> antExChuModels= antExService.queryAntExChu(antExChuQuery);
  214 + AntExChuModel antExChuModel=null;
  215 + if (CollectionUtils.isNotEmpty(antExChuModels)){
  216 + antExChuModel= antExChuModels.get(0);
  217 + }
215 218  
  219 +
216 220 LisCrisisItem crisisItem = new LisCrisisItem();
217 221 crisisItem.setPid(patients.getPid());
218 222 crisisItem.setPatientId(patients.getId());
219 223  
220 224  
... ... @@ -247,13 +251,15 @@
247 251 referValueMap.put(referValue.getCode(), referValue);
248 252 }
249 253  
  254 + Map<String,String> params=new HashMap<>();
  255 +
250 256 List<LisReportItemModel> itemList= JsonUtil.jsonToList(model.getItemJson(),LisReportItemModel.class);
251 257 // crisis init
252 258 for (LisReportItemModel item : itemList) {
253   -
254   - ReferValue referValue = referValueMap.get(item.getCode().trim());
  259 + String code= item.getCode().trim();
  260 + ReferValue referValue = referValueMap.get(code);
255 261 if (referValue != null) {
256   - //TODO 处理危急值逻辑
  262 +
257 263 boolean flag=buildEmergency(item.getResult(),referValue);
258 264 System.out.println("saveLisCrisisItemList flag"+flag);
259 265 if (flag) {
260 266  
261 267  
262 268  
263 269  
264 270  
265 271  
266 272  
267 273  
... ... @@ -268,31 +274,157 @@
268 274 crisisItem.setRef(buildRef(referValue));
269 275 crisisItem.setUnit(item.getUnit());
270 276 lisCrisisItemService.addLisCrisisItem(crisisItem);
  277 + }
  278 + }
  279 + params.put(code,item.getResult().trim());
  280 + }
271 281  
272   - //当前孕妇关联的初诊复诊医生危急通知
273   - /* Set<String> sets = antenatalExaminationFacade.getCrisisUnionDoc(patients);
  282 + if (antExChuModel!=null && (com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getXhdb())
  283 + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getBxbjs()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getPlatelet())
  284 + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getNdb()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getNt())
  285 + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getUrineKetone()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getBld()))){
  286 + System.out.println("addAntenatalExamination");
  287 + addAntenatalExamination(antExChuModel,patients);
  288 + }else {
  289 + if (antExChuModel!=null){
  290 + antExChuModel.setXhdb(params.get("HGB"));
  291 + antExChuModel.setBxbjs(params.get("WBC"));
  292 + antExChuModel.setPlatelet(params.get("PLT"));
  293 + antExChuModel.setNdb(params.get("PRO"));
  294 + antExChuModel.setNt(params.get("GLU1"));
  295 + antExChuModel.setUrineKetone(params.get("KET"));
  296 + antExChuModel.setBld(params.get("BLD"));
  297 + System.out.println("updateAntExChu");
  298 + antExService.updateAntExChu(antExChuModel,antExChuModel.getId());
  299 + }
  300 + }
  301 + System.out.println("saveLisCrisisItemList end");
  302 + }
274 303  
275   - if (CollectionUtils.isNotEmpty(sets)) {
276   - for (String doctorId : sets) {
277   - LisCrisisNotify notify = new LisCrisisNotify();
278   - notify.setHospitalId(patients.getHospitalId());
279   - notify.setPatientId(patients.getId());
280   - notify.setStatus(0);
281   - notify.setYn(1);
282   - notify.setModified(new Date());
283   - notify.setCreated(new Date());
284   - notify.setDoctorId(doctorId);
  304 + }
285 305  
286   - lisCrisisNotifyService.addLisCrisisNotify(notify);
287   - }
288   - }*/
  306 + @Autowired
  307 + private AntenatalExaminationService antenatalExaminationService;
  308 + @Autowired
  309 + private AntExRecordService antExRecordService;
289 310  
  311 + public void addAntenatalExamination(AntExChuModel antExChuModel,Patients patients){
  312 + AntExRecordModel antExRecordModel = new AntExRecordModel();
  313 + antExRecordModel.setType(2);
  314 + antExRecordModel.setHospitalId(patients.getHospitalId());
  315 + antExRecordModel.setLastMenses(patients.getLastMenses());
  316 + antExRecordModel.setName(patients.getUsername());
  317 + antExRecordModel.setNextCheckTime(patients.getNextCheckTime());
  318 + antExRecordModel.setBrith(patients.getBirth());
  319 + antExRecordModel.setParentId(patients.getId());
  320 + antExRecordModel.setPid(patients.getPid());
  321 + antExRecordModel.setDueDate(patients.getDueDate());
  322 + antExRecordModel.setCardNo(patients.getCardNo());
  323 + antExRecordModel.setCheckDoctor(String.valueOf(patients.getOperator()));
  324 + antExRecordModel.setType(1);
  325 + antExRecordModel.setCheckTime(patients.getBookbuildingDate());
  326 + antExRecordModel.setBuildTime(patients.getBookbuildingDate());
  327 + if (antExRecordModel.getDueDate() != null) {
  328 + antExRecordModel.setStatus(antExRecordModel.getDueDate().compareTo(new Date()) > 0 ? 2 : 1);
  329 + antExRecordModel.setDueStatus(antExRecordModel.getStatus());
  330 + }
290 331  
291   - }
  332 + AntenatalExaminationModel antenatalExaminationModel = new AntenatalExaminationModel();
  333 + antenatalExaminationModel.setYn(1);
  334 + antenatalExaminationModel.setParentId(patients.getId());
  335 + antenatalExaminationModel.setPid(patients.getPid());
  336 + antenatalExaminationModel.setCheckDoctor(String.valueOf(patients.getOperator()));
  337 + antenatalExaminationModel.setHospitalId(patients.getHospitalId());
  338 + antenatalExaminationModel.setName(patients.getUsername());
  339 + antenatalExaminationModel.setRiskScore(antExChuModel.getHighriskSocre());
  340 + antenatalExaminationModel.setRiskFactor(antExChuModel.getHighrisk());
  341 + antenatalExaminationModel.setLastMenses(patients.getLastMenses());
  342 + antenatalExaminationModel.setNextCheckTime(patients.getNextCheckTime());
  343 + antenatalExaminationModel.setCurrentDueDate(getBuildingWeek(patients));
  344 + antenatalExaminationModel.setCheckDate(patients.getBookbuildingDate());
  345 + antenatalExaminationModel=antenatalExaminationService.addOneBabyAnt(antenatalExaminationModel);
  346 + antExRecordModel.setfId(antenatalExaminationModel.getId());
  347 + antExRecordService.addOneRecord(antExRecordModel);
  348 + //添加复诊时添加追访信息
  349 + addTrackDownInfo(patients.getOperator(), patients, patients.getNextCheckTime());
  350 + }
  351 +
  352 +
  353 + /**
  354 + * 查询孕期
  355 + *
  356 + * @param patients
  357 + * @return
  358 + */
  359 + private String getBuildingWeek(Patients patients) {
  360 + String weekDay = "";
  361 + try {
  362 + // 徐倩说改的
  363 + if (patients.getBookbuildingDate().getTime() - patients.getDueDate().getTime() > 0 && patients.getBuildType() == 2) {
  364 +// if (patients.getBookbuildingDate().getTime() - patients.getFmDate().getTime() > 0 && patients.getBuildType() == 2) {
  365 + weekDay = "";
  366 + } else {
  367 + int days = DateUtil.daysBetween(patients.getLastMenses(), patients.getBookbuildingDate());
  368 + if (days > 7 * 42 - 1) {
  369 + weekDay = "";
  370 + } else {
  371 + String week = days / 7 + "";
  372 + int day = (days % 7);
  373 + weekDay = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : "");
292 374 }
  375 + }
  376 + } catch (Exception e) {
  377 + // 什么都不干
  378 + }
  379 + return weekDay;
  380 + }
293 381  
  382 + @Autowired
  383 + private TrackDownRecordService trackDownRecordService;
  384 +
  385 + /**
  386 + * 初诊、复诊添加或更新追访信息
  387 + *
  388 + * @param userId
  389 + * @param patient
  390 + */
  391 + public void addTrackDownInfo(Integer userId, Patients patient, Date nextCheckTime) {
  392 + //添加产后追访信息
  393 + TrackDownRecord trackDownRecord = patient.build();
  394 + //根据patient查询是否存在追访信息
  395 + TrackDownRecordQuery downRecordQuery = new TrackDownRecordQuery();
  396 + downRecordQuery.setParentId(patient.getId());
  397 + downRecordQuery.setStatus(3);
  398 + if (nextCheckTime!=null) {
  399 + trackDownRecord.setAppointmentDate(nextCheckTime);
  400 + trackDownRecord.setNextCheckTime(nextCheckTime);
  401 + } else {
  402 + trackDownRecord.setAppointmentDate(new Date());
  403 + }
  404 + List <TrackDownRecord> records = trackDownRecordService.queryTrackDown(downRecordQuery);
  405 + if (CollectionUtils.isNotEmpty(records)) {//存在则进行修改,只修改基本信息,不修改显示状态和追访类型
  406 + TrackDownRecord trackDownRecord1 = records.get(0);
  407 + trackDownRecord.setId(trackDownRecord1.getId());
  408 + //流程只能往下流转,不能往上回退,,因为9,10,11,12,是后面加入的产筛转出流程所以不做判断
  409 + if (trackDownRecord.getTrackType() != null && trackDownRecord1.getTrackType() != 8 && trackDownRecord1.getTrackType() != 9 && trackDownRecord1.getTrackType() != 10 && trackDownRecord1.getTrackType() != 11 && trackDownRecord.getTrackType() < trackDownRecord1.getTrackType().intValue()) {
  410 + //用以前追访的类型和来源id
  411 + trackDownRecord.setTrackType(trackDownRecord1.getTrackType());
  412 + trackDownRecord.setSource(trackDownRecord1.getSource());
294 413 }
295   - System.out.println("saveLisCrisisItemList end");
  414 + //由显示修改成不显示,后期数据更新时,不允许将不显示修改成显示。
  415 + if (trackDownRecord1.getStatus() < trackDownRecord.getStatus()) {
  416 + trackDownRecord.setStatus(trackDownRecord1.getStatus());
  417 + }
  418 + trackDownRecord.setOverTimes(0);
  419 + trackDownRecordService.updateTrackDown(trackDownRecord, trackDownRecord1.getId());
  420 + }else {
  421 + trackDownRecord.setOverTimes(0);
  422 + trackDownRecordService.addTrackDown(trackDownRecord);
  423 + }
  424 +
  425 + //把下次预约时间更新为空
  426 + if (nextCheckTime == null && StringUtils.isNotEmpty(trackDownRecord.getId())) {
  427 + trackDownRecordService.updateTrackDownOneCol(trackDownRecord.getId(), null);
296 428 }
297 429  
298 430 }
platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java View file @ efd4679
... ... @@ -1594,8 +1594,7 @@
1594 1594 //根据patient查询是否存在追访信息
1595 1595 TrackDownRecordQuery downRecordQuery = new TrackDownRecordQuery();
1596 1596 downRecordQuery.setParentId(patient.getId());
1597   - //TODO 不知道这个status是干嘛用的 所以注释了 测试有问题的话再放开
1598   - //downRecordQuery.setStatus(3);
  1597 + downRecordQuery.setStatus(3);
1599 1598 List <TrackDownRecord> records = trackDownRecordService.queryTrackDown(downRecordQuery);
1600 1599 if (CollectionUtils.isNotEmpty(records)) {//存在则进行修改,只修改基本信息,不修改显示状态和追访类型
1601 1600 TrackDownRecord trackDownRecord1 = records.get(0);