|
@@ -5,7 +5,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.lantone.common.dto.GetOperationLogDTO;
|
|
|
import com.lantone.common.enums.IsDeleteEnum;
|
|
|
+import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.BeanUtil;
|
|
|
import com.lantone.common.util.DateUtil;
|
|
|
import com.lantone.common.util.EntityUtil;
|
|
@@ -13,23 +15,25 @@ import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.StringUtil;
|
|
|
import com.lantone.common.util.SysUserUtils;
|
|
|
import com.lantone.common.vo.BlockLossTypeGatherVO;
|
|
|
+import com.lantone.common.vo.DataCompareVO;
|
|
|
+import com.lantone.common.vo.DataRepariVO;
|
|
|
+import com.lantone.daqe.client.HisDataService;
|
|
|
import com.lantone.daqe.client.OperationLogService;
|
|
|
import com.lantone.daqe.dto.BlockLossTypeGatherDTO;
|
|
|
import com.lantone.daqe.dto.GetBlockLossPageDTO;
|
|
|
-import com.lantone.common.dto.GetOperationLogDTO;
|
|
|
import com.lantone.daqe.dto.HisMedicalRecordDTO;
|
|
|
import com.lantone.daqe.dto.UpBlockLossByIdVO;
|
|
|
import com.lantone.daqe.entity.BehospitalInfo;
|
|
|
import com.lantone.daqe.entity.BlocklossResult;
|
|
|
import com.lantone.daqe.entity.HomePage;
|
|
|
import com.lantone.daqe.entity.MedicalRecord;
|
|
|
-import com.lantone.daqe.entity.MedicalRecordContent;
|
|
|
+import com.lantone.daqe.enums.DataSaveUrlEnum;
|
|
|
+import com.lantone.daqe.enums.LossIsAuditedEnum;
|
|
|
import com.lantone.daqe.enums.LossStatusEnum;
|
|
|
import com.lantone.daqe.enums.LossTypeEnum;
|
|
|
import com.lantone.daqe.enums.LossWayEnum;
|
|
|
import com.lantone.daqe.facade.base.BehospitalInfoFacade;
|
|
|
import com.lantone.daqe.facade.base.BlocklossResultFacade;
|
|
|
-import com.lantone.common.vo.DataCompareVO;
|
|
|
import com.lantone.daqe.facade.base.HomePageFacade;
|
|
|
import com.lantone.daqe.facade.base.MedicalRecordContentFacade;
|
|
|
import com.lantone.daqe.facade.base.MedicalRecordFacade;
|
|
@@ -67,6 +71,12 @@ public class BlockLossManagementFacade {
|
|
|
@Autowired
|
|
|
private OperationLogService operationLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HisDataService hisDataService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HisDataManagementFacade hisDataManagementFacade;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 获取病历数据丢失明细分页列表
|
|
@@ -87,8 +97,9 @@ public class BlockLossManagementFacade {
|
|
|
public Boolean upBlockLossById(UpBlockLossByIdVO upBlockLossByIdVO) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
BeanUtils.copyProperties(upBlockLossByIdVO, blocklossResult);
|
|
|
- blocklossResult.setModifier(SysUserUtils.getCurrentPrinciple());
|
|
|
+ blocklossResult.setModifier(SysUserUtils.getCurrentPrinciple() == null ? "0" : SysUserUtils.getCurrentPrinciple());
|
|
|
blocklossResult.setGmtModified(DateUtil.now());
|
|
|
+ blocklossResult.setAuditTime(DateUtil.now());
|
|
|
return blocklossResultFacade.updateById(blocklossResult);
|
|
|
}
|
|
|
|
|
@@ -100,100 +111,145 @@ public class BlockLossManagementFacade {
|
|
|
*/
|
|
|
public Boolean dataCompare(DataCompareVO dataCompareVO) {
|
|
|
Boolean flag = false;
|
|
|
- //====1.获取已丢失状态记录,去数据库中对比判断是否补录
|
|
|
- List<BlocklossResult> lossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
|
|
|
- .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
|
|
|
- .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
|
|
|
- .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
+ Long hospitalId = null;
|
|
|
+ Long principleId = null;
|
|
|
+ //定时任务SysUserUtils取不到医院,操作人
|
|
|
+ if (dataCompareVO.getHospitalId() == null) {
|
|
|
+ hospitalId = SysUserUtils.getCurrentHospitalId();
|
|
|
+ principleId = SysUserUtils.getCurrentPrincipleId();
|
|
|
+ }
|
|
|
+ //获取his对应的数据
|
|
|
+ List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
|
|
|
+ if (ListUtil.isEmpty(hisMedicalRecords) && StringUtil.isNotBlank(dataCompareVO.getBehospitalCode())) {
|
|
|
+ Asserts.fail("未查询到该患者信息");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //====1.删除当前时间段的对比记录(未核查的)
|
|
|
+ flag = blocklossResultFacade.remove(new UpdateWrapper<BlocklossResult>()
|
|
|
+ .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
|
|
|
+ .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
|
|
|
+ .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
- Map<String, List<BlocklossResult>> lossResultMap = null;
|
|
|
- if (ListUtil.isNotEmpty(lossResults)) {
|
|
|
- lossResultMap = EntityUtil.makeEntityListMap(lossResults, "lossType");
|
|
|
- //更新以缺失数据的状态
|
|
|
- flag = upBlockLossStatus(lossResultMap);
|
|
|
+
|
|
|
+ //已核查的数据(筛选区间)
|
|
|
+ List<BlocklossResult> auditedResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
|
|
|
+ .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
|
|
|
+ .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
|
|
|
+ .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .notIn("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ //再按照内部|外部区分
|
|
|
+ List<String> inAuditedResultCodes = null;
|
|
|
+ List<String> inAuditedResultHomePages = null;
|
|
|
+ List<String> inAuditedResultRecIds = null;
|
|
|
+ List<String> outAuditedResultCodes = null;
|
|
|
+ List<String> outAuditedResultHomePages = null;
|
|
|
+ List<String> outAuditedResultRecIds = null;
|
|
|
+
|
|
|
+ if (ListUtil.isNotEmpty(auditedResults)) {
|
|
|
+ Map<String, List<BlocklossResult>> auditedResultMap = EntityUtil.makeEntityListMap(auditedResults, "lossType");
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.CODE_LOSS.getKey()))) {
|
|
|
+ List<BlocklossResult> auditedResultCodes = auditedResultMap.get(LossTypeEnum.CODE_LOSS.getKey());
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultCodes)) {
|
|
|
+ Map<String, List<BlocklossResult>> tempCodeMap = EntityUtil.makeEntityListMap(auditedResultCodes, "lossWay");
|
|
|
+ if (ListUtil.isNotEmpty(tempCodeMap.get(LossWayEnum.IN_LOSS.getKey()))) {
|
|
|
+ inAuditedResultCodes = tempCodeMap.get(LossWayEnum.IN_LOSS.getKey()).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(tempCodeMap.get(LossWayEnum.OUT_LOSS.getKey()))) {
|
|
|
+ outAuditedResultCodes = tempCodeMap.get(LossWayEnum.OUT_LOSS.getKey()).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()))) {
|
|
|
+ List<BlocklossResult> auditedResultHomePages = auditedResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey());
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultHomePages)) {
|
|
|
+ Map<String, List<BlocklossResult>> tempHomePageMap = EntityUtil.makeEntityListMap(auditedResultHomePages, "lossWay");
|
|
|
+ if (ListUtil.isNotEmpty(tempHomePageMap.get(LossWayEnum.IN_LOSS.getKey()))) {
|
|
|
+ inAuditedResultHomePages = tempHomePageMap.get(LossWayEnum.IN_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(tempHomePageMap.get(LossWayEnum.OUT_LOSS.getKey()))) {
|
|
|
+ outAuditedResultHomePages = tempHomePageMap.get(LossWayEnum.OUT_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.REC_LOSS.getKey()))) {
|
|
|
+ List<BlocklossResult> auditedResultRecIds = auditedResultMap.get(LossTypeEnum.REC_LOSS.getKey());
|
|
|
+ if (ListUtil.isNotEmpty(auditedResultRecIds)) {
|
|
|
+ Map<String, List<BlocklossResult>> tempRecMap = EntityUtil.makeEntityListMap(auditedResultRecIds, "lossWay");
|
|
|
+ if (ListUtil.isNotEmpty(tempRecMap.get(LossWayEnum.IN_LOSS.getKey()))) {
|
|
|
+ inAuditedResultRecIds = tempRecMap.get(LossWayEnum.IN_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (ListUtil.isNotEmpty(tempRecMap.get(LossWayEnum.OUT_LOSS.getKey()))) {
|
|
|
+ outAuditedResultRecIds = tempRecMap.get(LossWayEnum.OUT_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ //定义对应要更新的已核查集合
|
|
|
+ List<GetOperationLogDTO> dataUps = new ArrayList<>();
|
|
|
+
|
|
|
|
|
|
//====2.某时间的数据对比
|
|
|
//=====2.1获取数据
|
|
|
|
|
|
- //获取his对应的数据
|
|
|
- List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
|
|
|
+
|
|
|
+ Map<String, HisMedicalRecordDTO> hisMedicalRecordMap = EntityUtil.makeEntityMap(hisMedicalRecords, "behospitalCode");
|
|
|
|
|
|
//获取操作记录数据
|
|
|
//病历数据
|
|
|
- dataCompareVO.setOperationUrl("save/saveBehospitalCode");
|
|
|
+ dataCompareVO.setOperationUrl(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey());
|
|
|
List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
|
|
|
//病案首页数据
|
|
|
- dataCompareVO.setOperationUrl("save/saveHomePages");
|
|
|
- List<GetOperationLogDTO> homePageLogs = getOperationLogs(dataCompareVO);
|
|
|
+ List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
|
|
|
//文书数据
|
|
|
- dataCompareVO.setOperationUrl("save/saveRecs");
|
|
|
- List<GetOperationLogDTO> recLogs = getOperationLogs(dataCompareVO);
|
|
|
+ List<GetOperationLogDTO> recLogs = new ArrayList<>();
|
|
|
+
|
|
|
+ //没有病历数据就不用去查病案首页和文书
|
|
|
+ if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
|
|
|
+ //日志去重防止多次操作
|
|
|
+ behospitalCodeLogs = removeRepeat(behospitalCodeLogs, "behospitalCode");
|
|
|
+ List<String> logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
|
|
|
+ dataCompareVO.setBehospitalCodes(logCodes);
|
|
|
+ //病案首页数据
|
|
|
+ dataCompareVO.setOperationUrl(DataSaveUrlEnum.HOME_PAGE.getKey());
|
|
|
+ homePageLogs = removeRepeat(getOperationLogs(dataCompareVO), "homePageId");
|
|
|
+ //文书数据
|
|
|
+ dataCompareVO.setOperationUrl(DataSaveUrlEnum.MEDICAL_RECORD.getKey());
|
|
|
+ recLogs = removeRepeat(getOperationLogs(dataCompareVO), "recId");
|
|
|
+ }
|
|
|
|
|
|
//获取库中数据
|
|
|
//病历数据
|
|
|
List<String> dataBaseBehospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
|
|
|
.select("behospital_code")
|
|
|
- .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
|
|
|
- .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
|
|
|
+ .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
|
|
|
+ .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
.stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
|
|
|
//病案首页数据
|
|
|
- List<String> dataBaseHomePageIds = homePageFacade.list(new QueryWrapper<HomePage>()
|
|
|
- .select("home_page_id")
|
|
|
- .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
|
|
|
- .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
- .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<String> dataBaseHomePageIds = new ArrayList<>();
|
|
|
//文书数据
|
|
|
- List<String> dataBaseRecIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
|
|
|
- .select("rec_id")
|
|
|
- .ge(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getStartDate())
|
|
|
- .le(dataCompareVO.getStartDate() != null, "gmt_create", dataCompareVO.getEndDate())
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
- .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
|
|
|
-
|
|
|
- //==已丢失 外部|内部 病历、文书、病案首页 id集合
|
|
|
- //外部
|
|
|
- List<String> outLossCodes = null;
|
|
|
- List<String> outLossHomepages = null;
|
|
|
- List<String> outLossRecs = null;
|
|
|
- //内部
|
|
|
- List<String> inLossCodes = null;
|
|
|
- List<String> inLossHomepages = null;
|
|
|
- List<String> inLossRecs = null;
|
|
|
- if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.REC_LOSS.getKey()))) {
|
|
|
- Map<String, List<BlocklossResult>> lossWayRecMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.REC_LOSS.getKey()), "lossWay");
|
|
|
- if (ListUtil.isNotEmpty(lossWayRecMap.get(LossWayEnum.OUT_LOSS))) {
|
|
|
- outLossRecs = lossWayRecMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (ListUtil.isNotEmpty(lossWayRecMap.get(LossWayEnum.IN_LOSS))) {
|
|
|
- inLossRecs = lossWayRecMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
+ List<String> dataBaseRecIds = new ArrayList<>();
|
|
|
+ if (ListUtil.isNotEmpty(dataBaseBehospitalCodes)) {
|
|
|
+ dataBaseHomePageIds = homePageFacade.list(new QueryWrapper<HomePage>()
|
|
|
+ .select("home_page_id")
|
|
|
+ .in("behospital_code", dataBaseBehospitalCodes)
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
+ .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
|
|
|
+ dataBaseRecIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
|
|
|
+ .select("rec_id")
|
|
|
+ .in("behospital_code", dataBaseBehospitalCodes)
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
+ .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
|
|
|
}
|
|
|
- if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()))) {
|
|
|
- Map<String, List<BlocklossResult>> lossWayHomePageMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()), "lossWay");
|
|
|
- if (ListUtil.isNotEmpty(lossWayHomePageMap.get(LossWayEnum.OUT_LOSS))) {
|
|
|
- outLossHomepages = lossWayHomePageMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (ListUtil.isNotEmpty(lossWayHomePageMap.get(LossWayEnum.IN_LOSS))) {
|
|
|
- inLossHomepages = lossWayHomePageMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
- if (ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()))) {
|
|
|
- Map<String, List<BlocklossResult>> lossWayCodeMap = EntityUtil.makeEntityListMap(lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()), "lossWay");
|
|
|
- if (ListUtil.isNotEmpty(lossWayCodeMap.get(LossWayEnum.OUT_LOSS))) {
|
|
|
- outLossCodes = lossWayCodeMap.get(LossWayEnum.OUT_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- if (ListUtil.isNotEmpty(lossWayCodeMap.get(LossWayEnum.IN_LOSS))) {
|
|
|
- inLossCodes = lossWayCodeMap.get(LossWayEnum.IN_LOSS).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
//=====2.2数据对比
|
|
|
//his与log日志做对比
|
|
@@ -207,7 +263,7 @@ public class BlockLossManagementFacade {
|
|
|
hisMedicalRecordDTO.getHisRecs().stream().forEach(hisRecDTO -> {
|
|
|
GetOperationLogDTO medicalRecord = new GetOperationLogDTO();
|
|
|
medicalRecord.setRecId(hisRecDTO.getRecId());
|
|
|
- medicalRecord.setRecId(hisRecDTO.getRecTitle());
|
|
|
+ medicalRecord.setRecTitle(hisRecDTO.getRecTitle());
|
|
|
medicalRecord.setBehospitalCode(hisMedicalRecordDTO.getBehospitalCode());
|
|
|
recs.add(medicalRecord);
|
|
|
});
|
|
@@ -217,11 +273,11 @@ public class BlockLossManagementFacade {
|
|
|
//外部丢失数据集合
|
|
|
List<BlocklossResult> outInserts = new ArrayList<>();
|
|
|
//文书数据对比
|
|
|
- compareHisWithLog(recs, recLogs, "0", outInserts, outLossRecs);
|
|
|
+ compareHisWithLog(recs, recLogs, LossTypeEnum.REC_LOSS.getKey(), outAuditedResultRecIds, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
//病案首页数据对比
|
|
|
- compareHisWithLog(medicalRecords, homePageLogs, "1", outInserts, outLossHomepages);
|
|
|
+ compareHisWithLog(medicalRecords, homePageLogs, LossTypeEnum.HOMEPAGE_LOSS.getKey(), outAuditedResultHomePages, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
//病历数据对比
|
|
|
- compareHisWithLog(medicalRecords, behospitalCodeLogs, "2", outInserts, outLossCodes);
|
|
|
+ compareHisWithLog(medicalRecords, behospitalCodeLogs, LossTypeEnum.CODE_LOSS.getKey(), outAuditedResultCodes, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
|
|
|
flag = blocklossResultServiceImpl.saveBatch(outInserts);
|
|
|
}
|
|
@@ -230,87 +286,177 @@ public class BlockLossManagementFacade {
|
|
|
//内部丢失数据集合
|
|
|
List<BlocklossResult> inInserts = new ArrayList<>();
|
|
|
if (ListUtil.isNotEmpty(recLogs)) {
|
|
|
- compareLogWithLocal(recLogs, dataBaseRecIds, "0", inInserts, inLossRecs);
|
|
|
+ compareLogWithLocal(recLogs, dataBaseRecIds, LossTypeEnum.REC_LOSS.getKey(), inAuditedResultRecIds, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
}
|
|
|
if (ListUtil.isNotEmpty(homePageLogs)) {
|
|
|
- compareLogWithLocal(homePageLogs, dataBaseHomePageIds, "1", inInserts, inLossHomepages);
|
|
|
+ compareLogWithLocal(homePageLogs, dataBaseHomePageIds, LossTypeEnum.HOMEPAGE_LOSS.getKey(), inAuditedResultHomePages, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
}
|
|
|
if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
|
|
|
- compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, "2", inInserts, inLossCodes);
|
|
|
+ compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, LossTypeEnum.CODE_LOSS.getKey(), inAuditedResultCodes, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
|
|
|
+ }
|
|
|
+ //更新核查数据的时间
|
|
|
+ if (ListUtil.isNotEmpty(dataUps)) {
|
|
|
+ Long finalPrincipleId = principleId;
|
|
|
+ Long finalHospitalId = hospitalId;
|
|
|
+ dataUps.stream().forEach(data -> {
|
|
|
+ UpdateWrapper<BlocklossResult> updateWrapper = new UpdateWrapper<>();
|
|
|
+ updateWrapper.set("gmt_modified", DateUtil.now())
|
|
|
+ .set("modifier", finalPrincipleId != null ? finalPrincipleId + "" : "0")
|
|
|
+ .notIn("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
|
|
|
+ .eq(StringUtil.isNotBlank(data.getRecId()), "rec_id", data.getRecId())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("behospital_code", data.getBehospitalCode())
|
|
|
+ .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
|
|
|
+ .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
|
|
|
+ .eq(finalHospitalId != null, "hospital_id", finalHospitalId);
|
|
|
+ //更新病案首页或文书
|
|
|
+ if (StringUtil.isNotBlank(data.getRecId())) {
|
|
|
+ updateWrapper.notIn("loss_type", LossTypeEnum.CODE_LOSS.getKey());
|
|
|
+ } else {//更新病历
|
|
|
+ updateWrapper.eq("loss_type", LossTypeEnum.CODE_LOSS.getKey());
|
|
|
+ }
|
|
|
+ blocklossResultFacade.update(updateWrapper);
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
if (ListUtil.isNotEmpty(inInserts)) {
|
|
|
flag = blocklossResultServiceImpl.saveBatch(inInserts);
|
|
|
}
|
|
|
+
|
|
|
+ //====3.获取已丢失状态记录,去数据库中对比判断是否补录
|
|
|
+ List<BlocklossResult> lossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
|
|
|
+ .select("id,behospital_code,rec_id,loss_type,loss_way")
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
+ if (ListUtil.isNotEmpty(lossResults)) {
|
|
|
+ Map<String, List<BlocklossResult>> lossResultMap = EntityUtil.makeEntityListMap(lossResults, "lossType");
|
|
|
+ //更新以缺失数据的状态
|
|
|
+ flag = upBlockLossStatus(lossResultMap, hospitalId, principleId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 数据去重
|
|
|
+ *
|
|
|
+ * @param homePageLogs
|
|
|
+ * @param key
|
|
|
+ * @Return java.util.List<com.lantone.common.dto.GetOperationLogDTO>
|
|
|
+ */
|
|
|
+ private List<GetOperationLogDTO> removeRepeat(List<GetOperationLogDTO> homePageLogs, String key) {
|
|
|
+ Map<String, GetOperationLogDTO> tempMap = EntityUtil.makeEntityMap(homePageLogs, key);
|
|
|
+ List<GetOperationLogDTO> out = new ArrayList<>();
|
|
|
+ tempMap.keySet().stream().forEach(id -> {
|
|
|
+ out.add(tempMap.get(id));
|
|
|
+ });
|
|
|
+ return out;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 日志与入库数据对比
|
|
|
*
|
|
|
- * @param logs 日志记录
|
|
|
- * @param dataBases 入库数据
|
|
|
- * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
|
|
|
- * @param inInserts 内部丢失插入集合
|
|
|
- * @param havingLossIds 已经插入的id集合
|
|
|
+ * @param logs 日志记录
|
|
|
+ * @param dataBases 入库数据
|
|
|
+ * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
|
|
|
+ * @param auditedResultDatas 已核查数据
|
|
|
+ * @param inInserts 内部丢失插入集合
|
|
|
+ * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
|
|
|
+ * @param hospitalId 医院id
|
|
|
+ * @param principleId 操作人id
|
|
|
+ * @param dataUps 要更新的已核查的集合
|
|
|
* @Return void
|
|
|
*/
|
|
|
private void compareLogWithLocal(List<GetOperationLogDTO> logs, List<String> dataBases, String type,
|
|
|
- List<BlocklossResult> inInserts, List<String> havingLossIds) {
|
|
|
+ List<String> auditedResultDatas, List<BlocklossResult> inInserts,
|
|
|
+ Map<String, HisMedicalRecordDTO> hisMedicalRecordMap, Long hospitalId, Long principleId, List<GetOperationLogDTO> dataUps) {
|
|
|
switch (type) {
|
|
|
case "0":
|
|
|
//文书丢失
|
|
|
logs.stream().forEach(rec -> {
|
|
|
//存在记录但是没有入库
|
|
|
if (!dataBases.contains(rec.getRecId())) {
|
|
|
- if (havingLossIds.contains(rec.getRecId())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(rec.getRecId())) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(rec.getBehospitalCode());
|
|
|
blocklossResult.setRecId(rec.getRecId());
|
|
|
blocklossResult.setRecTitle(rec.getRecTitle());
|
|
|
blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(rec.getBehospitalCode()) != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(rec.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
inInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(rec.getBehospitalCode());
|
|
|
+ temp.setRecId(rec.getRecId());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
//判断只插入文书id的情况
|
|
|
- List<String> havingRecIds = medicalRecordContentFacade.list(new QueryWrapper<MedicalRecordContent>()
|
|
|
- .select("rec_id")
|
|
|
- .in("rec_id", dataBases)).stream().map(MedicalRecordContent::getRecId).collect(Collectors.toList());
|
|
|
- List<String> tempList = new ArrayList<>(dataBases);
|
|
|
- tempList.removeAll(havingRecIds);
|
|
|
- Map<String, GetOperationLogDTO> recMap = EntityUtil.makeEntityMap(logs, "recId");
|
|
|
- tempList.stream().forEach(recId -> {
|
|
|
- BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
- blocklossResult.setBehospitalCode(recMap.get(recId).getBehospitalCode());
|
|
|
- blocklossResult.setRecId(recId);
|
|
|
- blocklossResult.setRecTitle(recMap.get(recId).getRecTitle());
|
|
|
- blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
|
|
|
- blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
|
|
|
- blocklossResult.setLossCause("文书id插入成功,文书内容没有插入");
|
|
|
- //拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
- inInserts.add(blocklossResult);
|
|
|
- });
|
|
|
+ //获取插入的文书
|
|
|
+ // if (ListUtil.isNotEmpty(dataBases)) {
|
|
|
+ // List<String> havingRecIds = medicalRecordContentFacade.list(new QueryWrapper<MedicalRecordContent>()
|
|
|
+ // .select("rec_id")
|
|
|
+ // .in("rec_id", dataBases)).stream().map(MedicalRecordContent::getRecId).collect(Collectors.toList());
|
|
|
+ // List<String> tempList = new ArrayList<>(dataBases);
|
|
|
+ // //移除查出来有内容的文书
|
|
|
+ // tempList.removeAll(havingRecIds);
|
|
|
+ // Map<String, GetOperationLogDTO> recMap = EntityUtil.makeEntityMap(logs, "recId");
|
|
|
+ // //有文书id无内容文书
|
|
|
+ // tempList.stream().forEach(recId -> {
|
|
|
+ // //没有被记录过
|
|
|
+ // BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
+ // blocklossResult.setBehospitalCode(recMap.get(recId).getBehospitalCode());
|
|
|
+ // blocklossResult.setRecId(recId);
|
|
|
+ // blocklossResult.setRecTitle(recMap.get(recId).getRecTitle());
|
|
|
+ // blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
|
|
|
+ // blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
|
|
|
+ // blocklossResult.setLossCause("文书id插入成功,文书内容没有插入");
|
|
|
+ // if (hisMedicalRecordMap.get(recMap.get(recId)) != null) {
|
|
|
+ // blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(recMap.get(recId).getBehospitalCode()).getBehospitalDate());
|
|
|
+ // }
|
|
|
+ // //拼装病历数据块丢失明细其他信息
|
|
|
+ // assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
+ // inInserts.add(blocklossResult);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
break;
|
|
|
case "1":
|
|
|
//病案首页丢失
|
|
|
logs.stream().forEach(homePages -> {
|
|
|
//存在记录但是没有入库
|
|
|
- if (!dataBases.contains(homePages.getRecId())) {
|
|
|
- if (havingLossIds.contains(homePages.getRecId())) {
|
|
|
+ if (!dataBases.contains(homePages.getHomePageId())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(homePages.getHomePageId())) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(homePages.getBehospitalCode());
|
|
|
blocklossResult.setRecId(homePages.getHomePageId());
|
|
|
blocklossResult.setRecTitle("病案首页丢失");
|
|
|
blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(homePages.getBehospitalCode()) != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(homePages.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
inInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(homePages.getBehospitalCode());
|
|
|
+ temp.setHomePageId(homePages.getHomePageId());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
@@ -319,15 +465,24 @@ public class BlockLossManagementFacade {
|
|
|
logs.stream().forEach(beHehospitalInfo -> {
|
|
|
//存在记录但是没有入库
|
|
|
if (!dataBases.contains(beHehospitalInfo.getBehospitalCode())) {
|
|
|
- if (havingLossIds.contains(beHehospitalInfo.getBehospitalCode())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(beHehospitalInfo.getBehospitalCode())) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
|
|
|
blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(beHehospitalInfo.getBehospitalCode()) != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(beHehospitalInfo.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
inInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
break;
|
|
@@ -343,7 +498,22 @@ public class BlockLossManagementFacade {
|
|
|
* @param lossResultMap
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private Boolean upBlockLossStatus(Map<String, List<BlocklossResult>> lossResultMap) {
|
|
|
+ private Boolean upBlockLossStatus(Map<String, List<BlocklossResult>> lossResultMap, Long hospitalId, Long principleId) {
|
|
|
+ //====获取所有丢失记录code,在入院记录表没有入院登记则不更新它文书和病案首页状态为已恢复
|
|
|
+ List<String> lossCodes = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
|
|
|
+ .select("DISTINCT behospital_code")
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList());
|
|
|
+ //查询已恢复的
|
|
|
+ List<String> medCode = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
|
|
|
+ .select("DISTINCT behospital_code")
|
|
|
+ .in("behospital_code", lossCodes)
|
|
|
+ .eq(hospitalId != null, "hospital_id", hospitalId)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())).stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
|
|
|
+ //去除已恢复得到已丢失的
|
|
|
+ lossCodes.removeAll(medCode);
|
|
|
+
|
|
|
AtomicReference<Boolean> flag = new AtomicReference<>(false);
|
|
|
lossResultMap.keySet().stream().forEach(lossType -> {
|
|
|
//0:文书丢失 1:病案首页丢失 2:患者信息丢失
|
|
@@ -351,9 +521,10 @@ public class BlockLossManagementFacade {
|
|
|
case "0":
|
|
|
//文书丢失
|
|
|
List<String> redIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("rec_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
|
|
|
.in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
|
|
|
+ .notIn(ListUtil.isNotEmpty(lossCodes), "behospital_code", lossCodes)//如果说入院记录丢失了,文书的状态还是已丢失不会更新
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
.stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
|
|
|
//更新状态-已恢复
|
|
@@ -362,31 +533,33 @@ public class BlockLossManagementFacade {
|
|
|
.set("solve_time", DateUtil.now())
|
|
|
.set("gmt_modified", DateUtil.now())
|
|
|
.set("status", LossStatusEnum.NOT_LOSS.getKey())
|
|
|
- .set("modifier", SysUserUtils.getCurrentPrincipleId())
|
|
|
+ .set("modifier", principleId != null ? principleId + "" : "0")
|
|
|
+ .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
.eq("loss_type", lossType)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("rec_id", redIds)));
|
|
|
}
|
|
|
break;
|
|
|
case "1":
|
|
|
//病案首页丢失
|
|
|
List<String> homePages = homePageFacade.list(new QueryWrapper<HomePage>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("home_page_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
|
|
|
.in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
|
|
|
+ .notIn(ListUtil.isNotEmpty(lossCodes), "behospital_code", lossCodes)//如果说入院记录丢失了,病案首页的状态还是已丢失不会更新
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
.stream().map(HomePage::getHomePageId).collect(Collectors.toList());
|
|
|
-
|
|
|
//更新状态-已恢复
|
|
|
if (ListUtil.isNotEmpty(homePages)) {
|
|
|
flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
|
|
|
.set("solve_time", DateUtil.now())
|
|
|
.set("gmt_modified", DateUtil.now())
|
|
|
.set("status", LossStatusEnum.NOT_LOSS.getKey())
|
|
|
- .set("modifier", SysUserUtils.getCurrentPrincipleId())
|
|
|
+ .set("modifier", principleId != null ? principleId + "" : "0")
|
|
|
+ .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
.eq("loss_type", lossType)
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("rec_id", homePages)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())));
|
|
|
}
|
|
@@ -394,7 +567,7 @@ public class BlockLossManagementFacade {
|
|
|
case "2":
|
|
|
//患者信息丢失
|
|
|
List<String> behospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey()))
|
|
|
.stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
|
|
@@ -404,10 +577,11 @@ public class BlockLossManagementFacade {
|
|
|
.set("solve_time", DateUtil.now())
|
|
|
.set("gmt_modified", DateUtil.now())
|
|
|
.set("status", LossStatusEnum.NOT_LOSS.getKey())
|
|
|
- .set("modifier", SysUserUtils.getCurrentPrincipleId())
|
|
|
+ .set("modifier", principleId != null ? principleId + "" : "0")
|
|
|
+ .eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
.eq("loss_type", lossType)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", hospitalId != null ? hospitalId : 0)
|
|
|
.in("behospital_code", behospitalCodes)));
|
|
|
}
|
|
|
break;
|
|
@@ -419,15 +593,25 @@ public class BlockLossManagementFacade {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param medicalRecords his数据
|
|
|
- * @param logs 日志数据
|
|
|
- * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
|
|
|
- * @param outInserts 外部丢失插入集合
|
|
|
- * @param havingLossIds 已经插入的id集合
|
|
|
+ * @param medicalRecords his数据
|
|
|
+ * @param logs 日志数据
|
|
|
+ * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
|
|
|
+ * @param auditedResultDatas 已核查数据
|
|
|
+ * @param outInserts 外部丢失插入集合
|
|
|
+ * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
|
|
|
+ * @param hospitalId 医院id
|
|
|
+ * @param principleId 操作人id
|
|
|
+ * @param dataUps 要更新的已核查的集合
|
|
|
* @Return void
|
|
|
*/
|
|
|
private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs,
|
|
|
- String type, List<BlocklossResult> outInserts, List<String> havingLossIds) {
|
|
|
+ String type, List<String> auditedResultDatas, List<BlocklossResult> outInserts,
|
|
|
+ Map<String, HisMedicalRecordDTO> hisMedicalRecordMap,
|
|
|
+ Long hospitalId, Long principleId, List<GetOperationLogDTO> dataUps) {
|
|
|
+ //his数据为空直接返回
|
|
|
+ if (ListUtil.isEmpty(medicalRecords)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
switch (type) {
|
|
|
case "0":
|
|
|
List<String> recLogs = logs.stream().map(GetOperationLogDTO::getRecId).collect(Collectors.toList());
|
|
@@ -435,18 +619,28 @@ public class BlockLossManagementFacade {
|
|
|
//文书不存在操作记录
|
|
|
if (StringUtil.isNotEmpty(medicalRecord.getRecId())) {
|
|
|
if (!recLogs.contains(medicalRecord.getRecId())) {
|
|
|
- //该记录没有插入
|
|
|
- if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getRecId())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
|
|
|
+ //该记录没有插入
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
blocklossResult.setRecId(medicalRecord.getRecId());
|
|
|
blocklossResult.setRecTitle(medicalRecord.getRecTitle());
|
|
|
blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
outInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
+ temp.setRecId(medicalRecord.getRecId());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -456,16 +650,25 @@ public class BlockLossManagementFacade {
|
|
|
medicalRecords.stream().forEach(medicalRecord -> {
|
|
|
//病案首页不存在操作记录
|
|
|
if (StringUtil.isNotEmpty(medicalRecord.getHomePageId()) && !homepageLogs.contains(medicalRecord.getHomePageId())) {
|
|
|
- if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getHomePageId())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getHomePageId())) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
blocklossResult.setRecId(medicalRecord.getHomePageId());
|
|
|
blocklossResult.setRecTitle("病案首页丢失");
|
|
|
blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
outInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
+ temp.setRecId(medicalRecord.getHomePageId());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -475,14 +678,22 @@ public class BlockLossManagementFacade {
|
|
|
medicalRecords.stream().forEach(medicalRecord -> {
|
|
|
//病历数据不存在操作记录
|
|
|
if (!behospitalCodeLogs.contains(medicalRecord.getBehospitalCode())) {
|
|
|
- if (ListUtil.isNotEmpty(havingLossIds) && !havingLossIds.contains(medicalRecord.getBehospitalCode())) {
|
|
|
+ if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getBehospitalCode())) {
|
|
|
BlocklossResult blocklossResult = new BlocklossResult();
|
|
|
blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
|
|
|
blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
|
|
|
+ if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
|
|
|
+ blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
|
|
|
+ }
|
|
|
//拼装病历数据块丢失明细其他信息
|
|
|
- assembleOtherBlocklossResult(blocklossResult);
|
|
|
+ assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
|
|
|
outInserts.add(blocklossResult);
|
|
|
+ } else {
|
|
|
+ //更新人工操作记录(核查的)的时间
|
|
|
+ GetOperationLogDTO temp = new GetOperationLogDTO();
|
|
|
+ temp.setBehospitalCode(medicalRecord.getBehospitalCode());
|
|
|
+ dataUps.add(temp);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
@@ -496,13 +707,15 @@ public class BlockLossManagementFacade {
|
|
|
* 拼装病历数据块丢失明细其他信息
|
|
|
*
|
|
|
* @param blocklossResult
|
|
|
+ * @param hospitalId
|
|
|
+ * @param principleId
|
|
|
* @Return void
|
|
|
*/
|
|
|
- private void assembleOtherBlocklossResult(BlocklossResult blocklossResult) {
|
|
|
+ private void assembleOtherBlocklossResult(BlocklossResult blocklossResult, Long hospitalId, Long principleId) {
|
|
|
blocklossResult.setStatus(LossStatusEnum.IS_LOSS.getKey());
|
|
|
- blocklossResult.setHospitalId(SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0);
|
|
|
+ blocklossResult.setHospitalId(hospitalId != null ? hospitalId : 0);
|
|
|
blocklossResult.setGmtCreate(DateUtil.now());
|
|
|
- blocklossResult.setCreator(SysUserUtils.getCurrentPrincipleId() != null ? SysUserUtils.getCurrentPrincipleId() + "" : "0");
|
|
|
+ blocklossResult.setCreator(principleId != null ? principleId + "" : "0");
|
|
|
blocklossResult.setGmtModified(DateUtil.now());
|
|
|
}
|
|
|
|
|
@@ -524,9 +737,10 @@ public class BlockLossManagementFacade {
|
|
|
* @Return java.util.List<com.lantone.daqe.dto.HisMedicalRecordDTO>
|
|
|
*/
|
|
|
private List<HisMedicalRecordDTO> getHisMedicalRecords(DataCompareVO dataCompareVO) {
|
|
|
+ //技术服务部接口 /balance/data/getDataCount
|
|
|
+ // return hisDataService.getDataCount(dataCompareVO).getData();
|
|
|
//###模拟
|
|
|
-
|
|
|
- return new ArrayList<>();
|
|
|
+ return hisDataManagementFacade.getHisMedicalRecords(dataCompareVO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -536,37 +750,60 @@ public class BlockLossManagementFacade {
|
|
|
* @Return com.lantone.daqe.dto.BlockLossTypeGatherDTO
|
|
|
*/
|
|
|
public BlockLossTypeGatherDTO blockLossTypeGather(BlockLossTypeGatherVO blockLossTypeGatherVO) {
|
|
|
- blockLossTypeGatherVO.setOperationUrls(Lists.newArrayList("save/saveBehospitalCode",
|
|
|
- "save/saveHomePages",
|
|
|
- "save/saveRecs"));
|
|
|
+ blockLossTypeGatherVO.setOperationUrls(Lists.newArrayList(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey(),
|
|
|
+ DataSaveUrlEnum.HOME_PAGE.getKey(),
|
|
|
+ DataSaveUrlEnum.MEDICAL_RECORD.getKey()));
|
|
|
+
|
|
|
|
|
|
BlockLossTypeGatherDTO blockLossTypeGatherDTO = new BlockLossTypeGatherDTO();
|
|
|
+ //获取his数据
|
|
|
+ // DataCompareVO dataCompareVO = new DataCompareVO();
|
|
|
+ // dataCompareVO.setStartDate(blockLossTypeGatherVO.getStartDate());
|
|
|
+ // dataCompareVO.setEndDate(blockLossTypeGatherVO.getEndDate());
|
|
|
+ // List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
|
|
|
+ // blockLossTypeGatherDTO.setHisNum(getHisMedicalRecordsCount(hisMedicalRecords));
|
|
|
+
|
|
|
+
|
|
|
+ //获取his数据
|
|
|
+ blockLossTypeGatherDTO.setHisNum(getHisDataCount(blockLossTypeGatherVO));
|
|
|
+
|
|
|
//获取该时间段的日志数量
|
|
|
Integer logNum = operationLogService.getOperationLogNum(blockLossTypeGatherVO).getData();
|
|
|
blockLossTypeGatherDTO.setLogNum(logNum);
|
|
|
+
|
|
|
//获取该时间段的实际数量
|
|
|
- Integer codeNum = behospitalInfoFacade.count(new QueryWrapper<BehospitalInfo>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
- .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
|
|
|
- .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
|
|
|
- Integer homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
- .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
|
|
|
- .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
|
|
|
- Integer recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
- .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
|
|
|
- .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
|
|
|
+ List<String> codes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
|
|
|
+ .select("behospital_code")
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
|
|
|
+ .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
|
|
|
+ .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()))
|
|
|
+ .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Integer codeNum = codes.size();
|
|
|
+ Integer homePageNum = 0;
|
|
|
+ Integer recNum = 0;
|
|
|
+ if (ListUtil.isNotEmpty(codes)) {
|
|
|
+ homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
|
|
|
+ .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("behospital_code", codes));
|
|
|
+ recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
|
|
|
+ .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .in("behospital_code", codes));
|
|
|
+ }
|
|
|
+
|
|
|
blockLossTypeGatherDTO.setRealNum(codeNum + homePageNum + recNum);
|
|
|
//获取该时间段的丢失数量
|
|
|
List<BlocklossResult> blocklossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
|
|
|
- .eq("hospital_id", SysUserUtils.getCurrentHospitalId())
|
|
|
+ .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
|
|
|
.eq("status", LossStatusEnum.IS_LOSS.getKey())
|
|
|
- .ge(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getStartDate())
|
|
|
- .le(blockLossTypeGatherVO.getStartDate() != null, "gmt_create", blockLossTypeGatherVO.getEndDate()));
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
|
|
|
+ .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()));
|
|
|
Integer allLossNum = blocklossResults.size();
|
|
|
blockLossTypeGatherDTO.setAllLossNum(allLossNum);
|
|
|
- blockLossTypeGatherDTO.setHisNum(logNum + allLossNum);
|
|
|
|
|
|
Map<String, List<BlocklossResult>> lossWayMap = EntityUtil.makeEntityListMap(blocklossResults, "lossWay");
|
|
|
//外部丢失
|
|
@@ -611,4 +848,30 @@ public class BlockLossManagementFacade {
|
|
|
}
|
|
|
return blockLossTypeGatherDTO;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取his数据数量
|
|
|
+ *
|
|
|
+ * @param blockLossTypeGatherVO
|
|
|
+ * @Return java.lang.Integer
|
|
|
+ */
|
|
|
+ private Integer getHisDataCount(BlockLossTypeGatherVO blockLossTypeGatherVO) {
|
|
|
+ //获取his数量
|
|
|
+ // return hisDataService.getCount(blockLossTypeGatherVO).getData();
|
|
|
+ //模拟his
|
|
|
+ return hisDataManagementFacade.gethisDataCount(blockLossTypeGatherVO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 数据补录
|
|
|
+ *
|
|
|
+ * @param dataRepariVO
|
|
|
+ * @Return boolean
|
|
|
+ */
|
|
|
+ public boolean dataRepari(DataRepariVO dataRepariVO) {
|
|
|
+ //调用数据补录服务
|
|
|
+
|
|
|
+ return hisDataManagementFacade.dataRepari(dataRepariVO);
|
|
|
+ }
|
|
|
}
|