diff --git a/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java b/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java index c5ff35f..b2a3edf 100644 --- a/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java +++ b/platform-biz-service/src/main/java/com/lyms/platform/permission/service/impl/LisServiceImpl.java @@ -2,10 +2,7 @@ package com.lyms.platform.permission.service.impl; import com.lyms.platform.biz.dal.AssayConfigDao; import com.lyms.platform.biz.param.ReferConfigQuery; -import com.lyms.platform.biz.service.AntenatalExaminationService; -import com.lyms.platform.biz.service.LisCrisisItemService; -import com.lyms.platform.biz.service.PatientsService; -import com.lyms.platform.biz.service.ReferConfigService; +import com.lyms.platform.biz.service.*; import com.lyms.platform.common.constants.ErrorCodeConstants; import com.lyms.platform.common.dao.operator.MongoCondition; import com.lyms.platform.common.dao.operator.MongoOper; @@ -21,10 +18,7 @@ import com.lyms.platform.permission.model.LisReportQuery; import com.lyms.platform.permission.service.LisService; import com.lyms.platform.permission.service.OrganizationService; import com.lyms.platform.pojo.*; -import com.lyms.platform.query.AntExChuQuery; -import com.lyms.platform.query.AntExQuery; -import com.lyms.platform.query.LisCrisisItemQuery; -import com.lyms.platform.query.PatientsQuery; +import com.lyms.platform.query.*; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.collections.CollectionUtils; @@ -180,6 +174,7 @@ public class LisServiceImpl implements LisService { @Autowired private LisCrisisItemService lisCrisisItemService; + /** * 根据Lis数据同步大同高危急值 * @param model @@ -212,6 +207,15 @@ public class LisServiceImpl implements LisService { return; } + AntExChuQuery antExChuQuery=new AntExChuQuery(); + antExChuQuery.setParentId(patients.getId()); + antExChuQuery.setYn(1); + List antExChuModels= antExService.queryAntExChu(antExChuQuery); + AntExChuModel antExChuModel=null; + if (CollectionUtils.isNotEmpty(antExChuModels)){ + antExChuModel= antExChuModels.get(0); + } + LisCrisisItem crisisItem = new LisCrisisItem(); crisisItem.setPid(patients.getPid()); @@ -247,13 +251,15 @@ public class LisServiceImpl implements LisService { referValueMap.put(referValue.getCode(), referValue); } + Map params=new HashMap<>(); + List itemList= JsonUtil.jsonToList(model.getItemJson(),LisReportItemModel.class); // crisis init for (LisReportItemModel item : itemList) { - - ReferValue referValue = referValueMap.get(item.getCode().trim()); + String code= item.getCode().trim(); + ReferValue referValue = referValueMap.get(code); if (referValue != null) { - //TODO 处理危急值逻辑 + boolean flag=buildEmergency(item.getResult(),referValue); System.out.println("saveLisCrisisItemList flag"+flag); if (flag) { @@ -268,31 +274,157 @@ public class LisServiceImpl implements LisService { crisisItem.setRef(buildRef(referValue)); crisisItem.setUnit(item.getUnit()); lisCrisisItemService.addLisCrisisItem(crisisItem); + } + } + params.put(code,item.getResult().trim()); + } - //当前孕妇关联的初诊复诊医生危急通知 - /* Set sets = antenatalExaminationFacade.getCrisisUnionDoc(patients); - - if (CollectionUtils.isNotEmpty(sets)) { - for (String doctorId : sets) { - LisCrisisNotify notify = new LisCrisisNotify(); - notify.setHospitalId(patients.getHospitalId()); - notify.setPatientId(patients.getId()); - notify.setStatus(0); - notify.setYn(1); - notify.setModified(new Date()); - notify.setCreated(new Date()); - notify.setDoctorId(doctorId); - - lisCrisisNotifyService.addLisCrisisNotify(notify); - } - }*/ + if (antExChuModel!=null && (com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getXhdb()) + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getBxbjs()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getPlatelet()) + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getNdb()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getNt()) + || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getUrineKetone()) || com.lyms.platform.common.utils.StringUtils.isNotEmpty(antExChuModel.getBld()))){ + System.out.println("addAntenatalExamination"); + addAntenatalExamination(antExChuModel,patients); + }else { + if (antExChuModel!=null){ + antExChuModel.setXhdb(params.get("HGB")); + antExChuModel.setBxbjs(params.get("WBC")); + antExChuModel.setPlatelet(params.get("PLT")); + antExChuModel.setNdb(params.get("PRO")); + antExChuModel.setNt(params.get("GLU1")); + antExChuModel.setUrineKetone(params.get("KET")); + antExChuModel.setBld(params.get("BLD")); + System.out.println("updateAntExChu"); + antExService.updateAntExChu(antExChuModel,antExChuModel.getId()); + } + } + System.out.println("saveLisCrisisItemList end"); + } + + } + @Autowired + private AntenatalExaminationService antenatalExaminationService; + @Autowired + private AntExRecordService antExRecordService; + + public void addAntenatalExamination(AntExChuModel antExChuModel,Patients patients){ + AntExRecordModel antExRecordModel = new AntExRecordModel(); + antExRecordModel.setType(2); + antExRecordModel.setHospitalId(patients.getHospitalId()); + antExRecordModel.setLastMenses(patients.getLastMenses()); + antExRecordModel.setName(patients.getUsername()); + antExRecordModel.setNextCheckTime(patients.getNextCheckTime()); + antExRecordModel.setBrith(patients.getBirth()); + antExRecordModel.setParentId(patients.getId()); + antExRecordModel.setPid(patients.getPid()); + antExRecordModel.setDueDate(patients.getDueDate()); + antExRecordModel.setCardNo(patients.getCardNo()); + antExRecordModel.setCheckDoctor(String.valueOf(patients.getOperator())); + antExRecordModel.setType(1); + antExRecordModel.setCheckTime(patients.getBookbuildingDate()); + antExRecordModel.setBuildTime(patients.getBookbuildingDate()); + if (antExRecordModel.getDueDate() != null) { + antExRecordModel.setStatus(antExRecordModel.getDueDate().compareTo(new Date()) > 0 ? 2 : 1); + antExRecordModel.setDueStatus(antExRecordModel.getStatus()); + } + + AntenatalExaminationModel antenatalExaminationModel = new AntenatalExaminationModel(); + antenatalExaminationModel.setYn(1); + antenatalExaminationModel.setParentId(patients.getId()); + antenatalExaminationModel.setPid(patients.getPid()); + antenatalExaminationModel.setCheckDoctor(String.valueOf(patients.getOperator())); + antenatalExaminationModel.setHospitalId(patients.getHospitalId()); + antenatalExaminationModel.setName(patients.getUsername()); + antenatalExaminationModel.setRiskScore(antExChuModel.getHighriskSocre()); + antenatalExaminationModel.setRiskFactor(antExChuModel.getHighrisk()); + antenatalExaminationModel.setLastMenses(patients.getLastMenses()); + antenatalExaminationModel.setNextCheckTime(patients.getNextCheckTime()); + antenatalExaminationModel.setCurrentDueDate(getBuildingWeek(patients)); + antenatalExaminationModel.setCheckDate(patients.getBookbuildingDate()); + antenatalExaminationModel=antenatalExaminationService.addOneBabyAnt(antenatalExaminationModel); + antExRecordModel.setfId(antenatalExaminationModel.getId()); + antExRecordService.addOneRecord(antExRecordModel); + //添加复诊时添加追访信息 + addTrackDownInfo(patients.getOperator(), patients, patients.getNextCheckTime()); + } - } + + /** + * 查询孕期 + * + * @param patients + * @return + */ + private String getBuildingWeek(Patients patients) { + String weekDay = ""; + try { + // 徐倩说改的 + if (patients.getBookbuildingDate().getTime() - patients.getDueDate().getTime() > 0 && patients.getBuildType() == 2) { +// if (patients.getBookbuildingDate().getTime() - patients.getFmDate().getTime() > 0 && patients.getBuildType() == 2) { + weekDay = ""; + } else { + int days = DateUtil.daysBetween(patients.getLastMenses(), patients.getBookbuildingDate()); + if (days > 7 * 42 - 1) { + weekDay = ""; + } else { + String week = days / 7 + ""; + int day = (days % 7); + weekDay = "孕" + week + "周" + (day > 0 ? "+" + day + "天" : ""); } + } + } catch (Exception e) { + // 什么都不干 + } + return weekDay; + } + @Autowired + private TrackDownRecordService trackDownRecordService; + + /** + * 初诊、复诊添加或更新追访信息 + * + * @param userId + * @param patient + */ + public void addTrackDownInfo(Integer userId, Patients patient, Date nextCheckTime) { + //添加产后追访信息 + TrackDownRecord trackDownRecord = patient.build(); + //根据patient查询是否存在追访信息 + TrackDownRecordQuery downRecordQuery = new TrackDownRecordQuery(); + downRecordQuery.setParentId(patient.getId()); + downRecordQuery.setStatus(3); + if (nextCheckTime!=null) { + trackDownRecord.setAppointmentDate(nextCheckTime); + trackDownRecord.setNextCheckTime(nextCheckTime); + } else { + trackDownRecord.setAppointmentDate(new Date()); + } + List records = trackDownRecordService.queryTrackDown(downRecordQuery); + if (CollectionUtils.isNotEmpty(records)) {//存在则进行修改,只修改基本信息,不修改显示状态和追访类型 + TrackDownRecord trackDownRecord1 = records.get(0); + trackDownRecord.setId(trackDownRecord1.getId()); + //流程只能往下流转,不能往上回退,,因为9,10,11,12,是后面加入的产筛转出流程所以不做判断 + if (trackDownRecord.getTrackType() != null && trackDownRecord1.getTrackType() != 8 && trackDownRecord1.getTrackType() != 9 && trackDownRecord1.getTrackType() != 10 && trackDownRecord1.getTrackType() != 11 && trackDownRecord.getTrackType() < trackDownRecord1.getTrackType().intValue()) { + //用以前追访的类型和来源id + trackDownRecord.setTrackType(trackDownRecord1.getTrackType()); + trackDownRecord.setSource(trackDownRecord1.getSource()); } - System.out.println("saveLisCrisisItemList end"); + //由显示修改成不显示,后期数据更新时,不允许将不显示修改成显示。 + if (trackDownRecord1.getStatus() < trackDownRecord.getStatus()) { + trackDownRecord.setStatus(trackDownRecord1.getStatus()); + } + trackDownRecord.setOverTimes(0); + trackDownRecordService.updateTrackDown(trackDownRecord, trackDownRecord1.getId()); + }else { + trackDownRecord.setOverTimes(0); + trackDownRecordService.addTrackDown(trackDownRecord); + } + + //把下次预约时间更新为空 + if (nextCheckTime == null && StringUtils.isNotEmpty(trackDownRecord.getId())) { + trackDownRecordService.updateTrackDownOneCol(trackDownRecord.getId(), null); } } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java index 3269f48..eea9c62 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/AntenatalExaminationFacade.java @@ -1594,8 +1594,7 @@ public class AntenatalExaminationFacade { //根据patient查询是否存在追访信息 TrackDownRecordQuery downRecordQuery = new TrackDownRecordQuery(); downRecordQuery.setParentId(patient.getId()); - //TODO 不知道这个status是干嘛用的 所以注释了 测试有问题的话再放开 - //downRecordQuery.setStatus(3); + downRecordQuery.setStatus(3); List records = trackDownRecordService.queryTrackDown(downRecordQuery); if (CollectionUtils.isNotEmpty(records)) {//存在则进行修改,只修改基本信息,不修改显示状态和追访类型 TrackDownRecord trackDownRecord1 = records.get(0);