diff --git a/src/main/java/com/docus/server/report/api/dto/ReportDto.java b/src/main/java/com/docus/server/report/api/dto/ReportDto.java index c10af6e..708f3e4 100644 --- a/src/main/java/com/docus/server/report/api/dto/ReportDto.java +++ b/src/main/java/com/docus/server/report/api/dto/ReportDto.java @@ -67,6 +67,17 @@ public class ReportDto { */ private Integer downtype = 1; + /** + * 患者本次就诊唯一键:患者id【12位】+就诊次 + * 数 + */ + private String visitSn; + + /** + * 患者id + */ + private String patientSn; + /** * 检查报告单号,用于顺德人医推送 报告信息和报告地址的关联 diff --git a/src/main/java/com/docus/server/report/job/ReportJob.java b/src/main/java/com/docus/server/report/job/ReportJob.java index 40e7a8e..9b44830 100644 --- a/src/main/java/com/docus/server/report/job/ReportJob.java +++ b/src/main/java/com/docus/server/report/job/ReportJob.java @@ -135,7 +135,7 @@ public class ReportJob { } List reportDtoList = collectZyInspectReport(basicList.get(0)); // 是否是宝宝的病案,如果是,报告需要给母亲的信息 - if(isBabyTask(reportDownTwoDto)){ + if (isBabyTask(reportDownTwoDto)) { PatientInfoDTO parent = reportDownTwoDto.getParent(); for (ReportDto reportDto : reportDtoList) { reportDto.setPatientId(parent.getPatientId()); @@ -184,17 +184,17 @@ public class ReportJob { Integer filesNumber = nurseInsertSugarReportList.get(0).getFILES_NUMBER(); Integer nurseFileCount = tBasicMapper.getNurseFileCount(patientId); if (filesNumber == null) { - log.warn("{} ,{},接口未返回文件数量!",inpatientNo,admissTimes); + log.warn("{} ,{},接口未返回文件数量!", inpatientNo, admissTimes); return; } if (nurseFileCount == null) { log.warn("{} , {},未获取到护理提交的文件数量!", inpatientNo, admissTimes); - shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes,"未获取到护理提交的文件数量!"); + shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes, "未获取到护理提交的文件数量!"); return; } if (!filesNumber.equals(nurseFileCount)) { log.warn("{} , {},护理提交的文件数量与接口返回的文件数量不匹配!", inpatientNo, admissTimes); - shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes,"护理提交的文件数量与接口返回的文件数量不匹配"); + shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes, "护理提交的文件数量与接口返回的文件数量不匹配"); return; } // 从配置获取需要过滤的文件名称 @@ -231,8 +231,8 @@ public class ReportJob { } log.info("住院号:{},住院次数{},护理采集文件: {} 条", inpatientNo, admissTimes, collectFileCount); // 设置一个redisKey,过期被监听处理 - String redisKey=String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY,reportQueryNurseInsertSugarCollectorId,patientId); - redisOps.setEx(redisKey,"0",ReportDownloadWait.REPORT_DOWNLOAD_WAIT_TIME); + String redisKey = String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY, reportQueryNurseInsertSugarCollectorId, patientId); + redisOps.setEx(redisKey, "0", ReportDownloadWait.REPORT_DOWNLOAD_WAIT_TIME); } } @@ -249,7 +249,6 @@ public class ReportJob { } - /** * 判断是否是需要作废的病案 * @@ -468,22 +467,22 @@ public class ReportJob { AtomicInteger reportTotalCount = new AtomicInteger(0); // 已经查询的条数 int alreadyQrCount = 0; + Integer admissTimes = tBasic.getAdmissTimes(); + Date admissDate = tBasic.getAdmissDate(); + Date disDate = tBasic.getDisDate(); + if (admissDate == null || disDate == null) { + throw new BaseException("patientId:" + tBasic.getPatientId() + "的入院时间为空"); + } + ZoneId zoneId = ZoneId.systemDefault(); + Instant adminssDateInstant = admissDate.toInstant(); + Instant disDateInstant = disDate.toInstant(); + // 开始时间去入院前三天 + LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate(); + LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3); + LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate(); + String startTime = startTimeLocalDate.toString() + " 00:00:00"; + String endTime = disLocalDate.toString() + " 23:59:59"; do { - Date admissDate = tBasic.getAdmissDate(); - Date disDate = tBasic.getDisDate(); - if (admissDate == null || disDate == null) { - throw new BaseException("patientId:" + tBasic.getPatientId() + "的入院时间为空"); - } - ZoneId zoneId = ZoneId.systemDefault(); - Instant adminssDateInstant = admissDate.toInstant(); - Instant disDateInstant = disDate.toInstant(); - // 开始时间去入院前三天 - LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate(); - LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3); - LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate(); - String startTime = startTimeLocalDate.toString() + " 00:00:00"; - String endTime = disLocalDate.toString() + " 23:59:59"; - SdJxReportDto sdJxReportDto = new SdJxReportDto(); sdJxReportDto.setPage(true); sdJxReportDto.setPageNo(pageNum); @@ -496,6 +495,8 @@ public class ReportJob { String respBody = shunDePeopleService.getInspectReportByJxId(sdJxReportDto); alreadyQrCount += pageSize; List reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic, reportTotalCount); + // 住院次数不是本次的,不需要 + reportDtoList = reportDtoList.stream().filter(t -> admissTimes.equals(getAdmissTimes(t.getVisitSn(), t.getPatientSn()))).collect(Collectors.toList()); reportDtos.addAll(reportDtoList); // 解析之后,总数已经赋值了,判断已经查询的数量是否已经满足总数 if (reportTotalCount.get() == 0 || alreadyQrCount >= reportTotalCount.get()) { @@ -510,6 +511,18 @@ public class ReportJob { } } + /** + * 从就诊唯一键中,获取就诊次数 + * + * @param visitSn 患者本次就诊唯一键:患者id【12位】+就诊次数 + * @param patientSn 患者id + * @return 就诊次数 + */ + private static Integer getAdmissTimes(String visitSn, String patientSn) { + patientSn = patientSn.replace("m", "").replace("z", ""); + String admissTimesStr = visitSn.replace(patientSn, ""); + return Integer.valueOf(admissTimesStr); + } private List parseQuerySdRyInspectReport(String respBody, TBasic tBasic, AtomicInteger reportTotalCount) { JSONObject jsonObject = Func.readJson(respBody, JSONObject.class); @@ -541,6 +554,18 @@ public class ReportJob { List reportObjectList = Func.parseJsonArray(resultJsonStr, JSONObject.class); if (Func.isNotEmpty(reportObjectList)) { for (JSONObject reportObject : reportObjectList) { + // 系统修改 + String updateBy = String.valueOf(reportObject.get("UPDATEBY")); + if (config != null && Func.isNotBlank(config.getHandlerSystem())) { + String handlerSystem = config.getHandlerSystem().toLowerCase(); + List handlerSystems = Arrays.asList(handlerSystem.split(",")); + if (!handlerSystems.contains(updateBy.toLowerCase())) { + continue; + } + } else { + continue; + } + // 检查报告号 String examReportSn = String.valueOf(reportObject.get("EXAM_REPORT_SN")); // 申请单号 @@ -549,8 +574,11 @@ public class ReportJob { String pdfUrl = String.valueOf(reportObject.get("FILE_PATH")); // 报告名称 String reportName = String.valueOf(reportObject.get("REPORT_NAME")); - // 系统修改 - String updateBy = String.valueOf(reportObject.get("UPDATEBY")); + + // 患者本次就诊唯一键:患者id【12位】+就诊次数 + String visitSn = String.valueOf(reportObject.get("VISIT_SN")); + // 患者id + String patientSn = String.valueOf(reportObject.get("PATIENT_SN")); ReportDto reportDto = new ReportDto(); reportDto.setAdmisstimes(tBasic.getAdmissTimes()); @@ -558,15 +586,8 @@ public class ReportJob { // 确定报告唯一 报告单号+申请单号 reportDto.setSerialnum(examReportSn + requestSn); reportDto.setFileTitle(reportName); - if (config != null && Func.isNotBlank(config.getHandlerSystem())) { - String handlerSystem = config.getHandlerSystem().toLowerCase(); - List handlerSystems = Arrays.asList(handlerSystem.split(",")); - if (!handlerSystems.contains(updateBy.toLowerCase())) { - continue; - } - } else { - continue; - } + reportDto.setVisitSn(visitSn); + reportDto.setPatientSn(patientSn); // 检查报告需要从Pacs接口获取base64 String[] split = examReportSn.split("_");