diff --git a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearDiagnManageController.java b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearDiagnManageController.java index 3a250b4..d2cd443 100644 --- a/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearDiagnManageController.java +++ b/platform-operate-api/src/main/java/com/lyms/platform/operate/web/controller/HearDiagnManageController.java @@ -162,7 +162,7 @@ public class HearDiagnManageController extends BaseController { //获取当前登录用户ID LoginContext loginState = (LoginContext) request.getAttribute("loginContext"); if (loginState == null) { - return; + return ; } //当前登录人医院Id String hospitalId = autoMatchFacade.getHospitalId(loginState.getId()); @@ -176,6 +176,7 @@ public class HearDiagnManageController extends BaseController { //加入院组 hospitalIds.addAll(hospiIds); query.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()])); + if (hdReq.getDiagnDoctorId() != null) {//诊断医生 query.setDiagnDoctorId(hdReq.getDiagnDoctorId()); } @@ -187,26 +188,48 @@ public class HearDiagnManageController extends BaseController { if (hdReq.getConfirmEndTime() != null) {//确诊结束时间 query.setConfirmEndTime(hdReq.getConfirmEndTime()); } + + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery(); + babyQuery.setQueryNo(hdReq.getKeyWord()); + babyQuery.setBirthStart(hdReq.getBirthStartTime()); + babyQuery.setBirthEnd(hdReq.getBirthEndTime()); + babyQuery.setHospitalId(hospitalId); + List models = earBabyService.queryBabyPatientExtendEarBaby(babyQuery); + + List babyIds = new ArrayList<>(); + if (CollectionUtils.isEmpty(models) && (StringUtils.isNotEmpty(hdReq.getKeyWord()) || hdReq.getBirthStartTime() != null || hdReq.getBirthEndTime() != null)) { + return ; + } + + if (CollectionUtils.isNotEmpty(models)) { + for (BabyPatientExtendEarBaby pa : models) { + babyIds.add(pa.getBabyPatientId()); + } + query.setBabyIds(babyIds.toArray(new String[babyIds.size()])); + } + + //设置确诊 query.setIsconfirm(1); - if (hdReq.getConfirmDegree() != null) {//模糊查询确诊结果 + query.setIfdel(0); + if (hdReq.getConfirmResult() != null) {//模糊查询确诊结果 List cfList = new ArrayList<>(); - if (hdReq.getConfirmDegree() == 1) {//轻度 + if (hdReq.getConfirmResult() == 1) {//轻度 cfList.add(",1,"); cfList.add(",2,"); cfList.add(",3,"); - } else if (hdReq.getConfirmDegree() == 2) {//中度 + } else if (hdReq.getConfirmResult() == 2) {//中度 cfList.add(",4,"); cfList.add(",5,"); cfList.add(",6,"); - } else if (hdReq.getConfirmDegree() == 3) {//重度 + } else if (hdReq.getConfirmResult() == 3) {//重度 cfList.add(",7,"); cfList.add(",8,"); cfList.add(",9,"); cfList.add(",10,"); cfList.add(",11,"); cfList.add(",12,"); - } else if (hdReq.getConfirmDegree() == 4) {//极重度 + } else if (hdReq.getConfirmResult() == 4) {//极重度 cfList.add(",13,"); cfList.add(",14,"); cfList.add(",15,"); @@ -250,11 +273,16 @@ public class HearDiagnManageController extends BaseController { String title = HighRiskEnum.getTitle(Integer.parseInt(hf[b])); map.put(Integer.parseInt(hf[b]), title); // highRiskEnums.add(map); - hrSb.append(title + ","); + hrSb.append(title + "、"); } } - // hea.setHighRiskEnums(highRiskEnums); - hea.setHighRiskEnums(hrSb.toString()); + String hfString = null; + if (hrSb.toString().endsWith("、")) { + hfString = hrSb.substring(0, hrSb.length() - 1); + } else { + hfString = hrSb.toString(); + } + hea.setHighRiskEnums(hfString); } //确诊结果 if (hd.getConfirmResult() != null) { @@ -266,11 +294,16 @@ public class HearDiagnManageController extends BaseController { String title = ConfirmedEnums.getTitle(Integer.parseInt(cr[b])); map.put(Integer.parseInt(cr[b]), title); // hdEnums.add(map); - hdSb.append(title + ","); + hdSb.append(title + "、"); } } - // hea.setDiagnResult(hdEnums); - hea.setDiagnResult(hdSb.toString()); + String hfString = null; + if (hdSb.toString().endsWith("、")) { + hfString = hdSb.substring(0, hdSb.length() - 1); + } else { + hfString = hdSb.toString(); + } + hea.setDiagnResult(hfString); } hdList.add(hea); } @@ -396,7 +429,6 @@ public class HearDiagnManageController extends BaseController { } query.setSort("diagnose_time"); query.setNeed("1"); - List hearingDiagnoseList = hearingDiagnoseService.getHdAndScreen(query); List hdList = new ArrayList<>(); @@ -643,13 +675,31 @@ public class HearDiagnManageController extends BaseController { if (loginState == null) { return; } -//当前登录人医院Id + //当前登录人医院Id String hospitalId = autoMatchFacade.getHospitalId(loginState.getId()); List babyIds = new ArrayList<>(); + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery(); + babyQuery.setQueryNo(model.getKeyWord()); + babyQuery.setBirthStart(model.getBirthStartTime()); + babyQuery.setBirthEnd(model.getBirthEndTime()); + babyQuery.setHospitalId(hospitalId); + List models = earBabyService.queryBabyPatientExtendEarBaby(babyQuery); + + if (CollectionUtils.isEmpty(models) && (StringUtils.isNotEmpty(model.getKeyWord()) || model.getBirthStartTime() != null || model.getBirthEndTime() != null)) { + return; + } + BabyPatientExtendEarScreenQuery screenQuery = new BabyPatientExtendEarScreenQuery(); + if (CollectionUtils.isNotEmpty(models)) { + for (BabyPatientExtendEarBaby pa : models) { + babyIds.add(pa.getBabyPatientId()); + } + screenQuery.setBabyIds(babyIds.toArray(new String[babyIds.size()])); + } + //听筛开始时间 if (model.getSecrStartTime() != null) { screenQuery.setScreenStartDate(model.getSecrStartTime()); @@ -667,7 +717,9 @@ public class HearDiagnManageController extends BaseController { List hospiIds = earFacade.getOrgHospitalIds(hospitalId); List hospitalIds = new ArrayList(); hospitalIds.addAll(hospiIds); + //加入院组 screenQuery.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()])); + //查询全部数据 List earScreens = screenService.dubiousScreen(screenQuery); @@ -772,7 +824,7 @@ public class HearDiagnManageController extends BaseController { /** - * 导出听力可疑儿童列表(听力筛查表,当前医院的复诊未通过的数据) + * 导出全部童列表(听力筛查表,当前医院的复诊未通过的数据) * * @param request * @return @@ -786,54 +838,146 @@ public class HearDiagnManageController extends BaseController { if (loginState == null) { return; } -//当前登录人医院Id + //当前登录人医院Id String hospitalId = autoMatchFacade.getHospitalId(loginState.getId()); + + BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery(); + + Date currentDate = DateUtil.formatDate(new Date()); + if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth()) && model.getMonthAgeStart() != null && model.getMonthAgeEnd() != null) { + + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart()); + String birthStr = model.getBirth(); + String[] dates = birthStr.split(" - "); + + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime()) { + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1])); + } else { + babyQuery.setBirthEnd(start); + } + + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1); + + if (DateUtil.parseYMD(dates[0]).getTime() < end.getTime()) { + babyQuery.setBirthStart(end); + } else { + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + } + } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth()) && model.getMonthAgeStart() != null) { + + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart()); + String birthStr = model.getBirth(); + String[] dates = birthStr.split(" - "); + + if (DateUtil.parseYMD(dates[1]).getTime() < start.getTime()) { + babyQuery.setBirthEnd(DateUtil.parseYMD(dates[1])); + } else { + babyQuery.setBirthEnd(start); + } + + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + + } else if (com.lyms.platform.common.utils.StringUtils.isNotEmpty(model.getBirth())) { + String birthStr = model.getBirth(); + String[] dates = birthStr.split(" - "); + babyQuery.setBirthStart(DateUtil.parseYMD(dates[0])); + babyQuery.setBirthEnd(new Date(DateUtil.parseYMD(dates[1]).getTime() + 24 * 60 * 60 * 1000 - 1)); + } else if (model.getMonthAgeStart() != null && model.getMonthAgeEnd() != null) { + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart()); + babyQuery.setBirthEnd(start); + + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1); + babyQuery.setBirthStart(end); + } else if (model.getMonthAgeStart() != null) { + Date start = DateUtil.addMonth(currentDate, -model.getMonthAgeStart()); + babyQuery.setBirthEnd(start); + } else if (model.getMonthAgeEnd() != null) { + Date end = DateUtil.addDay(DateUtil.addMonth(currentDate, -model.getMonthAgeEnd() - 1), 1); + babyQuery.setBirthStart(end); + } + + + babyQuery.setHospitalId(hospitalId); + babyQuery.setNoEnable("0"); + + List babyIds = new ArrayList<>(); + + //如果查询号不为空,根据查询号查询儿童档案表,获取儿童档案Id + if (StringUtils.isNotEmpty(model.getKeyWord())) {//关键字:姓名、联系方式、就诊卡 查询babyId + babyQuery.setQueryNo(model.getKeyWord()); + // babyQuery.setHospitalId(hospitalId); + } + + List babyModels = earBabyService.queryBabyPatientExtendEarBaby(babyQuery); + + for (BabyPatientExtendEarBaby babyModel : babyModels) { + babyIds.add(babyModel.getBabyPatientId()); + } + + //查询儿童听筛记录 BabyPatientExtendEarScreenQuery screenQuery = new BabyPatientExtendEarScreenQuery(); //检测医生ID if (model.getDiagnDoctorId() != null) { screenQuery.setCheckDoctorId(model.getDiagnDoctorId()); } // screenQuery.setCheckHospitalId(hospitalId); + List hospitalIds = new ArrayList(); //当前登录人医院Id List hospiIds = earFacade.getOrgHospitalIds(hospitalId); - List hospitalIds = new ArrayList(); hospitalIds.addAll(hospiIds); screenQuery.setCheckHospitalIds((String[]) hospitalIds.toArray(new String[hospitalIds.size()])); - List earScreens = screenService.notAuscultationBabyPatientExtendEarScreen(screenQuery); + screenQuery.setStatus(0); + + //根据儿童条件查询如果为空 + if (CollectionUtils.isEmpty(babyIds) && (model.getMonthAgeStart() != null || model.getMonthAgeEnd() != null || StringUtils.isNotEmpty(model.getKeyWord()) || model.getBirthStartTime() != null || model.getBirthEndTime() != null)) { + return ; + } + //查询全部数据 - List hdmResult = new ArrayList<>(); + List earScreens = screenService.queryBabyPatientExtendEarScreen(screenQuery); + Map screenMap = new HashMap<>(); if (CollectionUtils.isNotEmpty(earScreens)) { for (BabyPatientExtendEarScreen es : earScreens) { + screenMap.put(es.getBabyId(), es); + } + } + + //听筛医生不为空 + if (CollectionUtils.isEmpty(earScreens)&&model.getDiagnDoctorId() != null) { + return; + } + + + + //要返回的数据 + List hdmResult = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(babyModels)) { + for (BabyPatientExtendEarBaby ear : babyModels) { HearDiagnManageListResult hdm = new HearDiagnManageListResult(); - hdm.setId(es.getId()); - String docotorId = es.getCheckDoctorId(); - Users users = usersService.getUsers(Integer.parseInt(docotorId == null ? "0" : docotorId)); - if (users != null) { - hdm.setDoctorName(users.getName() == null ? "-" : users.getName()); - } - hdm.setSecrTime(DateUtil.getyyyy_MM_dd(es.getScreenDate())); - BabyModel babyModel = babyService.getOneBabyById(es.getBabyId()); - if (babyModel != null) { - hdm.setBabyName(babyModel.getName()); - hdm.setBabyId(es.getBabyId()); - hdm.setMommyName(com.lyms.platform.common.utils.StringUtils.emptyDeal(babyModel.getMname())); - hdm.setMommnyPhone(com.lyms.platform.common.utils.StringUtils.emptyDeal(babyModel.getMphone())); - hdm.setMommnyEncryptPhone(com.lyms.platform.common.utils.StringUtils.encryPhone(babyModel.getMphone())); - hdm.setMonthAge(DateUtil.getBabyMonthAge(babyModel.getBirth(), new Date())); - hdm.setBirthday(com.lyms.platform.common.utils.StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(babyModel.getBirth()))); - hdm.setSex(com.lyms.platform.common.utils.StringUtils.emptyDeal(SexEnum.getTextById(babyModel.getSex()))); + hdm.setBabyName(ear.getName()); + hdm.setBabyId(ear.getBabyPatientId()); + hdm.setMommyName(com.lyms.platform.common.utils.StringUtils.emptyDeal(ear.getMname())); + hdm.setMommnyPhone(com.lyms.platform.common.utils.StringUtils.emptyDeal(ear.getMphone())); + hdm.setMommnyEncryptPhone(com.lyms.platform.common.utils.StringUtils.encryPhone(ear.getMphone())); + hdm.setMonthAge(DateUtil.getBabyMonthAge(ear.getBirth(), new Date())); + hdm.setBirthday(com.lyms.platform.common.utils.StringUtils.emptyDeal(DateUtil.getyyyy_MM_dd(ear.getBirth()))); + hdm.setSex(com.lyms.platform.common.utils.StringUtils.emptyDeal(SexEnum.getTextById(ear.getSex()))); + BabyPatientExtendEarScreen es = screenMap.get(ear.getBabyPatientId()); + + if(es==null){ + if (model.getDiagnDoctorId() != null) {//筛查医生查询条件不为空,没找到则跳过 + continue; + } } - String babyId = es.getBabyId(); - BabyPatientExtendEarHearingDiagnoseQuery hdQuery = new BabyPatientExtendEarHearingDiagnoseQuery(); - hdQuery.setBabyId(babyId); - //根据babyId查询听力诊断,如果有数据则已诊断 - int count = hearingDiagnoseService.queryBabyPatientExtendEarHearingDiagnoseCount(hdQuery); - hdm.setSecrType("复诊"); - hdm.setSecrResult("未通过"); - if (count > 0) {//儿童在医院里做过听力诊断记录,标记为已诊断 - hdm.setStatus("已诊断"); - } else { - hdm.setStatus("未诊断"); + + if (es != null) { + hdm.setId(es.getId()); + String docotorId = es.getCheckDoctorId(); + Users users = usersService.getUsers(Integer.parseInt(docotorId == null ? "0" : docotorId)); + if (users != null) { + hdm.setDoctorName(users.getName() == null ? "-" : users.getName()); + } + hdm.setSecrTime(DateUtil.getyyyy_MM_dd(es.getScreenDate())); } hdmResult.add(hdm); } @@ -885,7 +1029,7 @@ public class HearDiagnManageController extends BaseController { if (loginState == null) { return new BaseResponse().setErrorcode(ErrorCodeConstants.TOKEN_EXPIRE).setErrormsg("请重新登录"); } -//当前登录人医院Id + //当前登录人医院Id String hospitalId = autoMatchFacade.getHospitalId(loginState.getId()); BabyPatientExtendEarBabyQuery babyQuery = new BabyPatientExtendEarBabyQuery();