|
|
|
@ -0,0 +1,125 @@
|
|
|
|
|
package com.docus.server.report.listener;
|
|
|
|
|
|
|
|
|
|
import com.docus.infrastructure.redis.service.RedisOps;
|
|
|
|
|
import com.docus.server.collection.entity.TBasic;
|
|
|
|
|
import com.docus.server.collection.mapper.TBasicMapper;
|
|
|
|
|
import com.docus.server.common.util.RedisKeyExpirationHandler;
|
|
|
|
|
import com.docus.server.common.util.RedisKeyExpirationListener;
|
|
|
|
|
import com.docus.server.report.config.SdRyReportQueryConfig;
|
|
|
|
|
import com.docus.server.report.consts.ReportDownloadWait;
|
|
|
|
|
import com.docus.server.report.mapper.AfScanAssortMapper;
|
|
|
|
|
import com.docus.server.report.service.ShunDePeopleBusinessService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author WYBDEV
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class NisReportDownloadWaitHandler extends RedisKeyExpirationHandler {
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisKeyExpirationListener redisKeyExpirationListener;
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisOps redisOps;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SdRyReportQueryConfig sdRyReportQueryConfig;
|
|
|
|
|
@Autowired
|
|
|
|
|
private TBasicMapper tBasicMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private AfScanAssortMapper scanAssortMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ShunDePeopleBusinessService shunDePeopleBusinessService;
|
|
|
|
|
|
|
|
|
|
@PostConstruct
|
|
|
|
|
public void registerRedisKeyExpireListener() {
|
|
|
|
|
redisKeyExpirationListener.register(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String collectId = "3";
|
|
|
|
|
String redisKey = String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY, collectId, "20230501");
|
|
|
|
|
System.out.println(redisKey);
|
|
|
|
|
String redisKeyPrefix1 = String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY, collectId, "");
|
|
|
|
|
System.out.println(redisKey.startsWith(redisKeyPrefix1));
|
|
|
|
|
// 得到病案主键
|
|
|
|
|
System.out.println(redisKey.replace(redisKeyPrefix1, ""));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void businessHandle(String expireRedisKey) throws Exception {
|
|
|
|
|
// 是否是护理采集要校验的redisKey,校验护理采集下载的文件数量是否和推送过滤后的匹配,匹配则调用 质控,不匹配发送异常信息
|
|
|
|
|
if (!isNisReportWaitKey(expireRedisKey)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String patientId = getPatientId(expireRedisKey);
|
|
|
|
|
log.info("病案主键:{} 护理采集数量校对开始!", patientId);
|
|
|
|
|
boolean verifyNisFileCountResult = verifyNisFileCountAndPushErr(patientId);
|
|
|
|
|
if (verifyNisFileCountResult) {
|
|
|
|
|
nisQualityControl(patientId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean verifyNisFileCountAndPushErr(String patientId) {
|
|
|
|
|
TBasic tBasic = tBasicMapper.getByPatientId(patientId);
|
|
|
|
|
String inpatientNo = tBasic.getInpatientNo();
|
|
|
|
|
Integer admissTimes = tBasic.getAdmissTimes();
|
|
|
|
|
Integer submitNurseFileCount = tBasicMapper.getNurseFileCount(patientId);
|
|
|
|
|
// 判断提交的文件数量
|
|
|
|
|
if (submitNurseFileCount == null || submitNurseFileCount == 0) {
|
|
|
|
|
log.warn("{} , {},未获取到护理提交的文件数量!", inpatientNo, admissTimes);
|
|
|
|
|
shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes, "未获取到护理提交的文件数量!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// 有些报告在采集的时候会过滤掉,有记录过滤的条数,计算实际应该要采集到的文件数量,和文件表数量做对比,文件表数量的小于应该采集到的,推送错误信息
|
|
|
|
|
Integer nurseRemoveFileCount = tBasicMapper.getNurseRemoveFileCount(patientId);
|
|
|
|
|
int realFileCount = submitNurseFileCount - nurseRemoveFileCount;
|
|
|
|
|
String collectorId = sdRyReportQueryConfig.getReportQueryNurseInsertSugarCollectorId();
|
|
|
|
|
Integer downloadSuccessFileCount = scanAssortMapper.countByPatientAndCollectorId(patientId, collectorId);
|
|
|
|
|
if (downloadSuccessFileCount < realFileCount) {
|
|
|
|
|
shunDePeopleBusinessService.nurseFileCountError(inpatientNo, admissTimes, "未完整采集该病案的文件!");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void nisQualityControl(String patientId) {
|
|
|
|
|
// todo 调用护理质控接口等待 质控那边开发
|
|
|
|
|
log.info("调用护理质控:{}", patientId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void handleException(String expireRedisKey) {
|
|
|
|
|
// 异常主键重新推送
|
|
|
|
|
redisOps.setEx(expireRedisKey, "0", ReportDownloadWait.REPORT_DOWNLOAD_WAIT_TIME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是否是护理报告等待的redisKey
|
|
|
|
|
*
|
|
|
|
|
* @param expireRedisKey 过期的redisKey
|
|
|
|
|
* @return 是否是护理报告等待的redisKey
|
|
|
|
|
*/
|
|
|
|
|
private boolean isNisReportWaitKey(String expireRedisKey) {
|
|
|
|
|
String collectorId = sdRyReportQueryConfig.getReportQueryNurseInsertSugarCollectorId();
|
|
|
|
|
// 护理报告的key的前缀
|
|
|
|
|
String nisKeyPrefix = String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY, collectorId, "");
|
|
|
|
|
return expireRedisKey.startsWith(nisKeyPrefix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取病案主键id
|
|
|
|
|
*/
|
|
|
|
|
private String getPatientId(String expireRedisKey) {
|
|
|
|
|
String collectorId = sdRyReportQueryConfig.getReportQueryNurseInsertSugarCollectorId();
|
|
|
|
|
// 护理报告的key的前缀
|
|
|
|
|
String nisKeyPrefix = String.format(ReportDownloadWait.REPORT_DOWNLOAD_WAIT_KEY, collectorId, "");
|
|
|
|
|
return expireRedisKey.replace(nisKeyPrefix, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|