diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java index 3f654c2..ae3cc3e 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/TrackDownFacade.java @@ -73,6 +73,7 @@ public class TrackDownFacade { @PostConstruct private void init() { trackDownTypeHandlerMap = new HashMap<>(); + //婚前检查 trackDownTypeHandlerMap.put(TrackDownDateEnums.A.getId(), new FQTrackDownTypeHandler()); //怀孕建档 trackDownTypeHandlerMap.put(TrackDownDateEnums.B.getId(), new FQTrackDownTypeHandler()); @@ -144,6 +145,7 @@ public class TrackDownFacade { public BaseObjectResponse mother(String parentId, Integer trackType, Integer userId) { String hospitalId = autoMatchFacade.getHospitalId(userId); Map map = new HashMap<>(); + //如果是婚前检查、怀孕建档 if (TrackDownDateEnums.C.getId() > trackType) { ResidentsArchiveModel resid = residentsArchiveService.getResident(parentId); map.put("username", resid.getUsername()); @@ -152,37 +154,49 @@ public class TrackDownFacade { map.put("age", DateUtil.getAge(resid.getBirthday())); } else { Patients patients = patientsService.findOnePatientById(parentId); - map.put("username", patients.getUsername()); - map.put("phone", patients.getPhone()); - map.put("cardNo", patients.getCardNo()); - map.put("age", DateUtil.getAge(patients.getBirth())); - map.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); - map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); /** 预产期 */ - map.put("trackCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(TrackDownDateEnums.F.getId()).and("yn").is(1)), TrackDown.class)); /** 访视次数 */ - map.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate())); - TrackDown tc = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(TrackDownDateEnums.E.getId()).and("yn").is(1)).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); - if (tc != null) { - map.put("reservatDate", DateUtil.getyyyy_MM_dd(tc.getReservatDate())); /** 预约住院日期 */ + if (patients != null) { + map.put("username", patients.getUsername()); + map.put("phone", patients.getPhone()); + map.put("cardNo", patients.getCardNo()); + map.put("age", DateUtil.getAge(patients.getBirth())); + map.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); + map.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); /** 预产期 */ + map.put("trackCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(trackType).and("yn").is(1)), TrackDown.class)); /** 访视次数 */ + map.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate())); } - map.put("fcCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(TrackDownDateEnums.G.getId()).and("yn").is(1)), TrackDown.class)); /** 复查次数 */ - map.put("checkCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("hospitalId").is(hospitalId)), AntenatalExaminationModel.class) + - mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId)), AntExChuModel.class)); /** 本院产检次数 */ - AntenatalExaminationModel examinationModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)).with(new Sort(Sort.Direction.DESC, "created")), AntenatalExaminationModel.class); - if (examinationModel != null) { - map.put("checkTime", DateUtil.getyyyy_MM_dd(examinationModel.getCheckDate())); /** 产检日期 */ - map.put("nextCheckTime", DateUtil.getyyyy_MM_dd(examinationModel.getNextCheckTime())); /** 预约产检日期 */ - } else { - AntExChuModel antExChuModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)).with(new Sort(Sort.Direction.DESC, "created")), AntExChuModel.class); - if (antExChuModel != null) { - map.put("checkTime", DateUtil.getyyyy_MM_dd(antExChuModel.getCheckTime())); /** 产检日期 */ - map.put("nextCheckTime", DateUtil.getyyyy_MM_dd(antExChuModel.getNextCheckTime())); /** 预约产检日期 */ - } else { - map.put("checkTime", "--"); /** 产检日期 */ - map.put("nextCheckTime", "--"); /** 预约产检日期 */ + } + map.put("checkTime", "--"); /** 产检日期 */ + //查询分娩追访记录 + TrackDown tc = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(trackType).and("yn").is(1)).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); + if (tc != null) { + map.put("nextCheckTime", tc.getReservatDate()==null?"--": DateUtil.getyyyy_MM_dd(tc.getReservatDate())); // 预约预约时间 + map.put("yyfsDate", DateUtil.getyyyy_MM_dd(tc.getReservatDate())); /** 预约访视日期 */ + } + // map.put("fcCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("trackDownDateType").is(TrackDownDateEnums.G.getId()).and("yn").is(1)), TrackDown.class)); /** 复查次数 */ + + //产后复查次数 + map.put("fcCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("yn").is(1)), PostReviewModel.class)); + //产前检查次数(初诊+复诊) + map.put("checkCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("hospitalId").is(hospitalId)), AntenatalExaminationModel.class) + mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId)), AntExChuModel.class)); + + + //复诊 + AntenatalExaminationModel examinationModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)).with(new Sort(Sort.Direction.DESC, "created")), AntenatalExaminationModel.class); + if (examinationModel != null) { + map.put("checkTime", DateUtil.getyyyy_MM_dd(examinationModel.getCheckDate())); //产检日期 + if (examinationModel.getNextCheckTime() != null) { + map.put("nextCheckTime", DateUtil.getyyyy_MM_dd(examinationModel.getNextCheckTime())); //预约产检日期 + } + }else{ + //初诊 + AntExChuModel antExChuModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(parentId)).with(new Sort(Sort.Direction.DESC, "created")), AntExChuModel.class); + if (antExChuModel != null) { + map.put("checkTime", DateUtil.getyyyy_MM_dd(antExChuModel.getCheckTime())); // 产检日期 + if (antExChuModel.getNextCheckTime() != null) { + map.put("nextCheckTime", DateUtil.getyyyy_MM_dd(antExChuModel.getNextCheckTime())); // 预约产检日期 } } } - return RespBuilder.buildSuccess(map); } @@ -246,22 +260,28 @@ public class TrackDownFacade { temp.put("phone", StringUtils.encryPhone(downRecord.getPhone())); TrackDown trackDown = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(downRecord.getParentId()).and("yn").is(1).and("trackDownDateType").is(downRecord.getTrackType())).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); temp.put("age", DateUtil.getAge(downRecord.getBirth())); - // 婚检追访结果 + // 追访结果 temp.put("result", trackDown == null ? "--" : trackDown.getResult()); - // 婚检追访时间 + // 追访时间 temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); // 预约时间 temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); + //预约复查时间默认用追访时间 + temp.put("yyfcDate", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); PostReviewQuery postReviewQuery = new PostReviewQuery(); postReviewQuery.setYn(YnEnums.YES.getId()); postReviewQuery.setParentId(downRecord.getParentId()); - List list = postReviewService.findWithList(postReviewQuery); + Patients patients = patientsService.findOnePatientById(downRecord.getParentId()); - /** 复查次数 */ - temp.put("fcNum", list.size()); + temp.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate())); temp.put("ccfcDate", "--"); temp.put("yyfcDate ", "--"); + + + List list = postReviewService.findWithList(postReviewQuery); + /** 复查次数 */ + temp.put("fcNum", list.size()); if (CollectionUtils.isNotEmpty(list)) { /** 初次复查日期 */ temp.put("ccfcDate", list.get(list.size() - 1).getCheckTime() == null ? "--" : DateUtil.getyyyy_MM_dd(list.get(list.size() - 1).getCheckTime())); @@ -289,14 +309,26 @@ public class TrackDownFacade { temp.put("trackDownDateType", downRecord.getTrackType()); temp.put("residenceAddress", CommonsHelper.getFullAddress(downRecord.getProvinceRegisterId(), downRecord.getCityRegisterId(), downRecord.getAreaRegisterId(), downRecord.getAddressRegister(), basicConfigService)); /** 居住地 */ temp.put("phone", StringUtils.encryPhone(downRecord.getPhone())); - TrackDown trackDown = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(downRecord.getParentId()).and("yn").is(1).and("trackDownDateType").is(downRecord.getTrackType())).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); + List trackDowns = mongoTemplate.find(Query.query(Criteria.where("parentId").is(downRecord.getParentId()).and("yn").is(1).and("trackDownDateType").is(downRecord.getTrackType())).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); temp.put("age", DateUtil.getAge(downRecord.getBirth())); - // 婚检追访结果 - temp.put("result", trackDown == null ? "--" : trackDown.getResult()); - // 婚检追访时间 - temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); - // 预约时间 - temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); + if (CollectionUtils.isNotEmpty(trackDowns)) { + TrackDown trackDown = trackDowns.get(0); + // 追访结果 + temp.put("result", trackDown == null ? "--" : trackDown.getResult()); + // 追访时间 + temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); + // 预约时间 + temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); + //访视次数 + temp.put("trackCount", trackDowns.size()); + } + Patients patients = patientsService.findOnePatientById(downRecord.getParentId()); + if (patients != null) { + //分娩日期 + temp.put("fmDate", DateUtil.getyyyy_MM_dd(patients.getFmDate())); + } + + return temp; } } @@ -354,7 +386,7 @@ public class TrackDownFacade { // 婚检追访时间 temp.put("trackDownTime", CollectionUtils.isEmpty(trackDown) ? "--" : DateUtil.getyyyy_MM_dd(trackDown.get(0).getTrackDownDate())); // 预约时间 - temp.put("yyTime", CollectionUtils.isEmpty(trackDown)? "--" : DateUtil.getyyyy_MM_dd(trackDown.get(0).getReservatDate())); + temp.put("yyTime", CollectionUtils.isEmpty(trackDown) ? "--" : DateUtil.getyyyy_MM_dd(trackDown.get(0).getReservatDate())); return temp; } } @@ -367,31 +399,60 @@ public class TrackDownFacade { @Override public Map build(TrackDownRecord downRecord, MongoTemplate mongoTemplate) { + + String parentId = downRecord.getParentId(); + String hospitalId = downRecord.getHospitalId(); + Patients patients = patientsService.findOnePatientById(downRecord.getParentId()); Map temp = new HashMap<>(); temp.put("username", downRecord.getUsername()); temp.put("age", DateUtil.getAge(downRecord.getBirth())); temp.put("cardNo", StringUtils.encryCardNo(downRecord.getCardNo())); temp.put("trackDownDateType", downRecord.getTrackType()); + temp.put("dueDate", DateUtil.getyyyy_MM_dd(patients.getDueDate())); /** 预产期 */ + temp.put("residenceAddress", CommonsHelper.getFullAddress(downRecord.getProvinceRegisterId(), downRecord.getCityRegisterId(), downRecord.getAreaRegisterId(), downRecord.getAddressRegister(), basicConfigService)); /** 居住地 */ temp.put("phone", StringUtils.encryPhone(downRecord.getPhone())); temp.put("id", downRecord.getId()); temp.put("parentId", downRecord.getParentId()); -// temp.put("dueDate", DateUtil.getyyyy_MM_dd(patient.getDueDate())); - if (null != downRecord.getLastMenses()) { - temp.put("week", DateUtil.getWeekDesc(downRecord.getLastMenses(), new Date())); /** 孕周 */ + if (patients != null) { + if (null != patients.getLastMenses()) { + temp.put("week", DateUtil.getWeekDesc(patients.getLastMenses(), new Date())); /** 孕周 */ + } } - temp.put("cjDate", ""); /** 产检日期 */ - temp.put("yycjDate", ""); /** 预约产检日期 */ - temp.put("cjzfDate", ""); /** 产检追访时间 */ + temp.put("checkCount", mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId).and("hospitalId").is(hospitalId)), AntenatalExaminationModel.class) + mongoTemplate.count(Query.query(Criteria.where("parentId").is(parentId)), AntExChuModel.class)); + TrackDown trackDown = mongoTemplate.findOne(Query.query(Criteria.where("yn").is(1).and("parentId").is(downRecord.getParentId()).and("trackDownDateType").is(downRecord.getTrackType())).with(new Sort(Sort.Direction.DESC, "created")), TrackDown.class); if (trackDown != null) { - temp.put("result", StringUtils.isEmpty(trackDown.getResult()) ? "--" : trackDown.getResult()); // 婚检追访结果 + temp.put("result", StringUtils.isEmpty(trackDown.getResult()) ? "--" : trackDown.getResult()); // 追访结果 temp.put("trackDownTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); // 追访时间 - temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); // 预约时间 + temp.put("yyTime", trackDown == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getReservatDate())); // 预约预约时间 } else { temp.put("result", "--"); // 婚检追访结果 temp.put("trackDownTime", "--"); // 追访时间 - temp.put("yyTime", "--"); // 预约时间 + temp.put("yyTime", "--"); // 预约预约时间 + } + + //如果是产前筛查去预约结果 + if (downRecord.getTrackType() == TrackDownDateEnums.C.getId()||downRecord.getTrackType() == TrackDownDateEnums.I.getId()) { + + + //复诊 + AntenatalExaminationModel examinationModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(downRecord.getParentId())).with(new Sort(Sort.Direction.DESC, "created")), AntenatalExaminationModel.class); + if (examinationModel != null) { + temp.put("cjDate", DateUtil.getyyyy_MM_dd(examinationModel.getCheckDate())); /** 产检日期 */ + if (examinationModel.getNextCheckTime() != null) { + temp.put("yyTime", DateUtil.getyyyy_MM_dd(examinationModel.getNextCheckTime())); /** 预约产检日期 */ + } + }else{ + //初诊 + AntExChuModel antExChuModel = mongoTemplate.findOne(Query.query(Criteria.where("parentId").is(downRecord.getParentId())).with(new Sort(Sort.Direction.DESC, "created")), AntExChuModel.class); + if (antExChuModel != null) { + temp.put("cjDate", DateUtil.getyyyy_MM_dd(antExChuModel.getCheckTime())); /** 产检日期 */ + if (antExChuModel.getNextCheckTime() != null) { + temp.put("yyTime", DateUtil.getyyyy_MM_dd(antExChuModel.getNextCheckTime())); /** 预约产检日期 */ + } + } + } } return temp; } diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java index 626e342..4ed0026 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/service/impl/TrackDownServiceImpl.java @@ -456,7 +456,7 @@ public class TrackDownServiceImpl extends BaseServiceImpl implements ITrackDownS List> chfcList = new ArrayList<>(); // 产后复查 for (TrackDown trackDown : trackDowns) { Map temp = new HashMap<>(); - temp.put("trackDownDate", DateUtil.getyyyy_MM_dd_hms(trackDown.getTrackDownDate())); + temp.put("trackDownDate", DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); temp.put("trackDownUser", trackDown.getTrackDownUserId()); temp.put("trackDownType", TrackDownTypeEnums.getName(trackDown.getTrackDownDateType())); temp.put("result", StringUtils.isEmpty(trackDown.getResult()) ? "--" : trackDown.getResult()); @@ -506,7 +506,7 @@ public class TrackDownServiceImpl extends BaseServiceImpl implements ITrackDownS for (TrackDown trackDown : trackDowns) { Map temp = new HashMap<>(); - temp.put("trackDownDate", trackDown.getTrackDownDate() == null ? "--" : DateUtil.getyyyy_MM_dd_hms(trackDown.getTrackDownDate())); + temp.put("trackDownDate", trackDown.getTrackDownDate() == null ? "--" : DateUtil.getyyyy_MM_dd(trackDown.getTrackDownDate())); temp.put("trackDownUser", StringUtils.isEmpty(trackDown.getTrackDownUserId()) ? "--" : trackDown.getTrackDownUserId()); if(trackDown.getTrackDownType() == TrackDownDateEnums.H.getId()){ trackDown.setTrackDownType(4);