BlockLossManagementFacade.java 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. package com.lantone.daqe.facade;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  4. import com.baomidou.mybatisplus.core.metadata.IPage;
  5. import com.google.common.collect.Lists;
  6. import com.lantone.common.dto.GetOperationLogDTO;
  7. import com.lantone.common.enums.IsDeleteEnum;
  8. import com.lantone.common.util.BeanUtil;
  9. import com.lantone.common.util.DateUtil;
  10. import com.lantone.common.util.EntityUtil;
  11. import com.lantone.common.util.ListUtil;
  12. import com.lantone.common.util.StringUtil;
  13. import com.lantone.common.util.SysUserUtils;
  14. import com.lantone.common.vo.BlockLossTypeGatherVO;
  15. import com.lantone.common.vo.DataCompareVO;
  16. import com.lantone.common.vo.DataRepariVO;
  17. import com.lantone.daqe.client.OperationLogService;
  18. import com.lantone.daqe.dto.BlockLossTypeGatherDTO;
  19. import com.lantone.daqe.dto.GetBlockLossPageDTO;
  20. import com.lantone.daqe.dto.HisMedicalRecordDTO;
  21. import com.lantone.daqe.dto.UpBlockLossByIdVO;
  22. import com.lantone.daqe.entity.BehospitalInfo;
  23. import com.lantone.daqe.entity.BlocklossResult;
  24. import com.lantone.daqe.entity.HomePage;
  25. import com.lantone.daqe.entity.MedicalRecord;
  26. import com.lantone.daqe.enums.DataSaveUrlEnum;
  27. import com.lantone.daqe.enums.LossIsAuditedEnum;
  28. import com.lantone.daqe.enums.LossStatusEnum;
  29. import com.lantone.daqe.enums.LossTypeEnum;
  30. import com.lantone.daqe.enums.LossWayEnum;
  31. import com.lantone.daqe.facade.base.BehospitalInfoFacade;
  32. import com.lantone.daqe.facade.base.BlocklossResultFacade;
  33. import com.lantone.daqe.facade.base.HomePageFacade;
  34. import com.lantone.daqe.facade.base.MedicalRecordContentFacade;
  35. import com.lantone.daqe.facade.base.MedicalRecordFacade;
  36. import com.lantone.daqe.service.impl.BlocklossResultServiceImpl;
  37. import com.lantone.daqe.vo.GetBlockLossPageVO;
  38. import org.springframework.beans.BeanUtils;
  39. import org.springframework.beans.factory.annotation.Autowired;
  40. import org.springframework.stereotype.Component;
  41. import java.util.ArrayList;
  42. import java.util.List;
  43. import java.util.Map;
  44. import java.util.concurrent.atomic.AtomicReference;
  45. import java.util.stream.Collectors;
  46. /**
  47. * @Description: 病历数据丢失明细-业务处理类
  48. * @author: songxl
  49. * @time: 2022/3/4 10:39
  50. */
  51. @Component
  52. public class BlockLossManagementFacade {
  53. @Autowired
  54. private BlocklossResultFacade blocklossResultFacade;
  55. @Autowired
  56. private BlocklossResultServiceImpl blocklossResultServiceImpl;
  57. @Autowired
  58. private BehospitalInfoFacade behospitalInfoFacade;
  59. @Autowired
  60. private HomePageFacade homePageFacade;
  61. @Autowired
  62. private MedicalRecordFacade medicalRecordFacade;
  63. @Autowired
  64. private MedicalRecordContentFacade medicalRecordContentFacade;
  65. @Autowired
  66. private OperationLogService operationLogService;
  67. @Autowired
  68. private HisDataManagementFacade hisDataManagementFacade;
  69. /**
  70. * 获取病历数据丢失明细分页列表
  71. *
  72. * @param getBlockLossPageVO
  73. * @Return com.baomidou.mybatisplus.core.metadata.IPage<com.lantone.daqe.dto.GetBlockLossPageDTO>
  74. */
  75. public IPage<GetBlockLossPageDTO> getBlockLossPage(GetBlockLossPageVO getBlockLossPageVO) {
  76. return blocklossResultFacade.getBaseMapper().getBlockLossPage(getBlockLossPageVO);
  77. }
  78. /**
  79. * 通过id修改病历数据块丢失明细
  80. *
  81. * @param upBlockLossByIdVO
  82. * @Return java.lang.Boolean
  83. */
  84. public Boolean upBlockLossById(UpBlockLossByIdVO upBlockLossByIdVO) {
  85. BlocklossResult blocklossResult = new BlocklossResult();
  86. BeanUtils.copyProperties(upBlockLossByIdVO, blocklossResult);
  87. blocklossResult.setModifier(SysUserUtils.getCurrentPrinciple() == null ? "0" : SysUserUtils.getCurrentPrinciple());
  88. blocklossResult.setGmtModified(DateUtil.now());
  89. blocklossResult.setAuditTime(DateUtil.now());
  90. return blocklossResultFacade.updateById(blocklossResult);
  91. }
  92. /**
  93. * 数据对比
  94. *
  95. * @param dataCompareVO
  96. * @Return java.lang.Boolean
  97. */
  98. public Boolean dataCompare(DataCompareVO dataCompareVO) {
  99. Boolean flag = false;
  100. Long hospitalId = null;
  101. Long principleId = null;
  102. //定时任务SysUserUtils取不到医院,操作人
  103. if (dataCompareVO.getHospitalId() == null) {
  104. hospitalId = SysUserUtils.getCurrentHospitalId();
  105. principleId = SysUserUtils.getCurrentPrincipleId();
  106. }
  107. //====1.获取已丢失状态记录,去数据库中对比判断是否补录
  108. List<BlocklossResult> lossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
  109. .select("id,behospital_code,rec_id,loss_type,loss_way")
  110. .eq(hospitalId != null, "hospital_id", hospitalId)
  111. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  112. .eq("is_deleted", IsDeleteEnum.N.getKey()));
  113. if (ListUtil.isNotEmpty(lossResults)) {
  114. Map<String, List<BlocklossResult>> lossResultMap = EntityUtil.makeEntityListMap(lossResults, "lossType");
  115. //更新以缺失数据的状态
  116. flag = upBlockLossStatus(lossResultMap, hospitalId, principleId);
  117. //删除当前时间段的对比记录
  118. flag = blocklossResultFacade.remove(new UpdateWrapper<BlocklossResult>()
  119. .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
  120. .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
  121. .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
  122. .eq(hospitalId != null, "hospital_id", hospitalId)
  123. .eq("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
  124. .eq("is_deleted", IsDeleteEnum.N.getKey()));
  125. }
  126. //已核查的数据(筛选区间)
  127. List<BlocklossResult> auditedResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
  128. .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
  129. .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
  130. .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
  131. .eq(hospitalId != null, "hospital_id", hospitalId)
  132. .notIn("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
  133. .eq("is_deleted", IsDeleteEnum.N.getKey()));
  134. List<String> auditedResultCodes = null;
  135. List<String> auditedResultHomePages = null;
  136. List<String> auditedResultRecIds = null;
  137. if (ListUtil.isNotEmpty(auditedResults)) {
  138. Map<String, List<BlocklossResult>> auditedResultMap = EntityUtil.makeEntityListMap(auditedResults, "lossType");
  139. if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.CODE_LOSS.getKey()))) {
  140. auditedResultCodes = auditedResultMap.get(LossTypeEnum.CODE_LOSS.getKey()).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList());
  141. }
  142. if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()))) {
  143. auditedResultHomePages = auditedResultMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
  144. }
  145. if (ListUtil.isNotEmpty(auditedResultMap.get(LossTypeEnum.REC_LOSS.getKey()))) {
  146. auditedResultRecIds = auditedResultMap.get(LossTypeEnum.REC_LOSS.getKey()).stream().map(BlocklossResult::getRecId).collect(Collectors.toList());
  147. }
  148. }
  149. //定义对应要更新的已核查集合
  150. List<GetOperationLogDTO> dataUps = new ArrayList<>();
  151. //====2.某时间的数据对比
  152. //=====2.1获取数据
  153. //获取his对应的数据
  154. List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
  155. Map<String, HisMedicalRecordDTO> hisMedicalRecordMap = EntityUtil.makeEntityMap(hisMedicalRecords, "behospitalCode");
  156. //获取操作记录数据
  157. //病历数据
  158. dataCompareVO.setOperationUrl(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey());
  159. List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
  160. //病案首页数据
  161. List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
  162. //文书数据
  163. List<GetOperationLogDTO> recLogs = new ArrayList<>();
  164. List<String> logCodes = null;
  165. //没有病历数据就不用去查病案首页和文书
  166. if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
  167. //日志去重防止多次操作
  168. behospitalCodeLogs = removeRepeat(behospitalCodeLogs, "behospitalCode");
  169. logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
  170. dataCompareVO.setBehospitalCodes(logCodes);
  171. //病案首页数据
  172. dataCompareVO.setOperationUrl(DataSaveUrlEnum.HOME_PAGE.getKey());
  173. homePageLogs = removeRepeat(getOperationLogs(dataCompareVO), "homePageId");
  174. //文书数据
  175. dataCompareVO.setOperationUrl(DataSaveUrlEnum.MEDICAL_RECORD.getKey());
  176. recLogs = removeRepeat(getOperationLogs(dataCompareVO), "recId");
  177. }
  178. //获取库中数据
  179. //病历数据
  180. List<String> dataBaseBehospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  181. .select("behospital_code")
  182. .ge(dataCompareVO.getStartDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getStartDate())
  183. .le(dataCompareVO.getEndDate() != null && StringUtil.isBlank(dataCompareVO.getBehospitalCode()), "behospital_date", dataCompareVO.getEndDate())
  184. .eq(StringUtil.isNotBlank(dataCompareVO.getBehospitalCode()), "behospital_code", dataCompareVO.getBehospitalCode())
  185. .eq(hospitalId != null, "hospital_id", hospitalId)
  186. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  187. .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
  188. //病案首页数据
  189. List<String> dataBaseHomePageIds = new ArrayList<>();
  190. //文书数据
  191. List<String> dataBaseRecIds = new ArrayList<>();
  192. if (ListUtil.isNotEmpty(dataBaseBehospitalCodes)) {
  193. dataBaseHomePageIds = homePageFacade.list(new QueryWrapper<HomePage>()
  194. .select("home_page_id")
  195. .in("behospital_code", dataBaseBehospitalCodes)
  196. .eq(hospitalId != null, "hospital_id", hospitalId)
  197. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  198. .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
  199. dataBaseRecIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
  200. .select("rec_id")
  201. .in("behospital_code", dataBaseBehospitalCodes)
  202. .eq(hospitalId != null, "hospital_id", hospitalId)
  203. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  204. .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
  205. }
  206. //=====2.2数据对比
  207. //his与log日志做对比
  208. if (ListUtil.isNotEmpty(hisMedicalRecords)) {
  209. //获取His病历数据 - His病案首页数据
  210. List<GetOperationLogDTO> medicalRecords = BeanUtil.listCopyTo(hisMedicalRecords, GetOperationLogDTO.class);
  211. //获取His文书数据
  212. List<GetOperationLogDTO> recs = new ArrayList<>();
  213. hisMedicalRecords.stream().forEach(hisMedicalRecordDTO -> {
  214. if (ListUtil.isNotEmpty(hisMedicalRecordDTO.getHisRecs())) {
  215. hisMedicalRecordDTO.getHisRecs().stream().forEach(hisRecDTO -> {
  216. GetOperationLogDTO medicalRecord = new GetOperationLogDTO();
  217. medicalRecord.setRecId(hisRecDTO.getRecId());
  218. medicalRecord.setRecTitle(hisRecDTO.getRecTitle());
  219. medicalRecord.setBehospitalCode(hisMedicalRecordDTO.getBehospitalCode());
  220. recs.add(medicalRecord);
  221. });
  222. }
  223. });
  224. //外部丢失数据集合
  225. List<BlocklossResult> outInserts = new ArrayList<>();
  226. //文书数据对比
  227. compareHisWithLog(recs, recLogs, LossTypeEnum.REC_LOSS.getKey(), auditedResultRecIds, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  228. //病案首页数据对比
  229. compareHisWithLog(medicalRecords, homePageLogs, LossTypeEnum.HOMEPAGE_LOSS.getKey(), auditedResultHomePages, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  230. //病历数据对比
  231. compareHisWithLog(medicalRecords, behospitalCodeLogs, LossTypeEnum.CODE_LOSS.getKey(), auditedResultCodes, outInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  232. flag = blocklossResultServiceImpl.saveBatch(outInserts);
  233. }
  234. //日志与入库数据对比
  235. //内部丢失数据集合
  236. List<BlocklossResult> inInserts = new ArrayList<>();
  237. if (ListUtil.isNotEmpty(recLogs)) {
  238. compareLogWithLocal(recLogs, dataBaseRecIds, LossTypeEnum.REC_LOSS.getKey(), auditedResultRecIds, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  239. }
  240. if (ListUtil.isNotEmpty(homePageLogs)) {
  241. compareLogWithLocal(homePageLogs, dataBaseHomePageIds, LossTypeEnum.HOMEPAGE_LOSS.getKey(), auditedResultHomePages, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  242. }
  243. if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
  244. compareLogWithLocal(behospitalCodeLogs, dataBaseBehospitalCodes, LossTypeEnum.CODE_LOSS.getKey(), auditedResultCodes, inInserts, hisMedicalRecordMap, hospitalId, principleId, dataUps);
  245. }
  246. //更新核查数据的时间
  247. if (ListUtil.isNotEmpty(dataUps)) {
  248. Long finalPrincipleId = principleId;
  249. Long finalHospitalId = hospitalId;
  250. dataUps.stream().forEach(data->{
  251. blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  252. .set("gmt_modified", DateUtil.now())
  253. .set("modifier", finalPrincipleId != null ? finalPrincipleId + "" : "0")
  254. .eq(StringUtil.isNotBlank(data.getRecId()),"rec_id", data.getRecId())
  255. .notIn("is_audited", LossIsAuditedEnum.NOT_AUDITED.getKey())
  256. .eq("behospital_code",data.getBehospitalCode())
  257. .eq("is_deleted", IsDeleteEnum.N.getKey())
  258. .ge(dataCompareVO.getStartDate() != null , "behospital_date", dataCompareVO.getStartDate())
  259. .le(dataCompareVO.getEndDate() != null , "behospital_date", dataCompareVO.getEndDate())
  260. .eq(finalHospitalId != null, "hospital_id", finalHospitalId)
  261. .eq("hospital_id", finalHospitalId != null ? finalHospitalId : 0));
  262. });
  263. }
  264. if (ListUtil.isNotEmpty(inInserts)) {
  265. flag = blocklossResultServiceImpl.saveBatch(inInserts);
  266. }
  267. return flag;
  268. }
  269. /**
  270. * 数据去重
  271. *
  272. * @param homePageLogs
  273. * @param key
  274. * @Return java.util.List<com.lantone.common.dto.GetOperationLogDTO>
  275. */
  276. private List<GetOperationLogDTO> removeRepeat(List<GetOperationLogDTO> homePageLogs, String key) {
  277. Map<String, GetOperationLogDTO> tempMap = EntityUtil.makeEntityMap(homePageLogs, key);
  278. List<GetOperationLogDTO> out = new ArrayList<>();
  279. tempMap.keySet().stream().forEach(id -> {
  280. out.add(tempMap.get(id));
  281. });
  282. return out;
  283. }
  284. /**
  285. * 日志与入库数据对比
  286. *
  287. * @param logs 日志记录
  288. * @param dataBases 入库数据
  289. * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
  290. * @param auditedResultDatas 已核查数据
  291. * @param inInserts 内部丢失插入集合
  292. * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
  293. * @param hospitalId 医院id
  294. * @param principleId 操作人id
  295. * @param dataUps 要更新的已核查的集合
  296. * @Return void
  297. */
  298. private void compareLogWithLocal(List<GetOperationLogDTO> logs, List<String> dataBases, String type,
  299. List<String> auditedResultDatas, List<BlocklossResult> inInserts,
  300. Map<String, HisMedicalRecordDTO> hisMedicalRecordMap, Long hospitalId, Long principleId, List<GetOperationLogDTO> dataUps) {
  301. switch (type) {
  302. case "0":
  303. //文书丢失
  304. logs.stream().forEach(rec -> {
  305. //存在记录但是没有入库
  306. if (!dataBases.contains(rec.getRecId())) {
  307. if (auditedResultDatas == null || !auditedResultDatas.contains(rec.getRecId())) {
  308. BlocklossResult blocklossResult = new BlocklossResult();
  309. blocklossResult.setBehospitalCode(rec.getBehospitalCode());
  310. blocklossResult.setRecId(rec.getRecId());
  311. blocklossResult.setRecTitle(rec.getRecTitle());
  312. blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
  313. blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
  314. if (hisMedicalRecordMap.get(rec.getBehospitalCode()) != null) {
  315. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(rec.getBehospitalCode()).getBehospitalDate());
  316. }
  317. //拼装病历数据块丢失明细其他信息
  318. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  319. inInserts.add(blocklossResult);
  320. } else {
  321. //更新人工操作记录(核查的)的时间
  322. GetOperationLogDTO temp = new GetOperationLogDTO();
  323. temp.setBehospitalCode(rec.getBehospitalCode());
  324. temp.setRecId(rec.getRecId());
  325. dataUps.add(temp);
  326. }
  327. }
  328. });
  329. //判断只插入文书id的情况
  330. //获取插入的文书
  331. // if (ListUtil.isNotEmpty(dataBases)) {
  332. // List<String> havingRecIds = medicalRecordContentFacade.list(new QueryWrapper<MedicalRecordContent>()
  333. // .select("rec_id")
  334. // .in("rec_id", dataBases)).stream().map(MedicalRecordContent::getRecId).collect(Collectors.toList());
  335. // List<String> tempList = new ArrayList<>(dataBases);
  336. // //移除查出来有内容的文书
  337. // tempList.removeAll(havingRecIds);
  338. // Map<String, GetOperationLogDTO> recMap = EntityUtil.makeEntityMap(logs, "recId");
  339. // //有文书id无内容文书
  340. // tempList.stream().forEach(recId -> {
  341. // //没有被记录过
  342. // BlocklossResult blocklossResult = new BlocklossResult();
  343. // blocklossResult.setBehospitalCode(recMap.get(recId).getBehospitalCode());
  344. // blocklossResult.setRecId(recId);
  345. // blocklossResult.setRecTitle(recMap.get(recId).getRecTitle());
  346. // blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
  347. // blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
  348. // blocklossResult.setLossCause("文书id插入成功,文书内容没有插入");
  349. // if (hisMedicalRecordMap.get(recMap.get(recId)) != null) {
  350. // blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(recMap.get(recId).getBehospitalCode()).getBehospitalDate());
  351. // }
  352. // //拼装病历数据块丢失明细其他信息
  353. // assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  354. // inInserts.add(blocklossResult);
  355. // });
  356. // }
  357. break;
  358. case "1":
  359. //病案首页丢失
  360. logs.stream().forEach(homePages -> {
  361. //存在记录但是没有入库
  362. if (!dataBases.contains(homePages.getHomePageId())) {
  363. if (auditedResultDatas == null || !auditedResultDatas.contains(homePages.getHomePageId())) {
  364. BlocklossResult blocklossResult = new BlocklossResult();
  365. blocklossResult.setBehospitalCode(homePages.getBehospitalCode());
  366. blocklossResult.setRecId(homePages.getHomePageId());
  367. blocklossResult.setRecTitle("病案首页丢失");
  368. blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
  369. blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
  370. if (hisMedicalRecordMap.get(homePages.getBehospitalCode()) != null) {
  371. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(homePages.getBehospitalCode()).getBehospitalDate());
  372. }
  373. //拼装病历数据块丢失明细其他信息
  374. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  375. inInserts.add(blocklossResult);
  376. } else {
  377. //更新人工操作记录(核查的)的时间
  378. GetOperationLogDTO temp = new GetOperationLogDTO();
  379. temp.setBehospitalCode(homePages.getBehospitalCode());
  380. temp.setHomePageId(homePages.getHomePageId());
  381. dataUps.add(temp);
  382. }
  383. }
  384. });
  385. break;
  386. case "2":
  387. //患者信息丢失
  388. logs.stream().forEach(beHehospitalInfo -> {
  389. //存在记录但是没有入库
  390. if (!dataBases.contains(beHehospitalInfo.getBehospitalCode())) {
  391. if (auditedResultDatas == null || !auditedResultDatas.contains(beHehospitalInfo.getBehospitalCode())) {
  392. BlocklossResult blocklossResult = new BlocklossResult();
  393. blocklossResult.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
  394. blocklossResult.setLossWay(LossWayEnum.IN_LOSS.getKey());
  395. blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
  396. if (hisMedicalRecordMap.get(beHehospitalInfo.getBehospitalCode()) != null) {
  397. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(beHehospitalInfo.getBehospitalCode()).getBehospitalDate());
  398. }
  399. //拼装病历数据块丢失明细其他信息
  400. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  401. inInserts.add(blocklossResult);
  402. } else {
  403. //更新人工操作记录(核查的)的时间
  404. GetOperationLogDTO temp = new GetOperationLogDTO();
  405. temp.setBehospitalCode(beHehospitalInfo.getBehospitalCode());
  406. dataUps.add(temp);
  407. }
  408. }
  409. });
  410. break;
  411. default:
  412. break;
  413. }
  414. }
  415. /**
  416. * 更新以缺失数据的状态
  417. *
  418. * @param lossResultMap
  419. * @Return void
  420. */
  421. private Boolean upBlockLossStatus(Map<String, List<BlocklossResult>> lossResultMap, Long hospitalId, Long principleId) {
  422. AtomicReference<Boolean> flag = new AtomicReference<>(true);
  423. //获取已丢失的病历(按照人来更新)
  424. if(ListUtil.isNotEmpty(lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()))){
  425. List<String> lossCodes = lossResultMap.get(LossTypeEnum.CODE_LOSS.getKey()).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList());
  426. //已经补录的患者信息
  427. List<String> behospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  428. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  429. .in("behospital_code", lossCodes)
  430. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  431. .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
  432. //有补录的病历时
  433. if(ListUtil.isNotEmpty(behospitalCodes)){
  434. lossResultMap.keySet().stream().forEach(lossType -> {
  435. //0:文书丢失 1:病案首页丢失 2:患者信息丢失
  436. switch (lossType) {
  437. case "0":
  438. //文书丢失
  439. List<String> redIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
  440. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  441. .in("rec_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
  442. .in("behospital_code", behospitalCodes)
  443. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  444. .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
  445. //更新状态-已恢复
  446. if (ListUtil.isNotEmpty(redIds)) {
  447. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  448. .set("solve_time", DateUtil.now())
  449. .set("gmt_modified", DateUtil.now())
  450. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  451. .set("modifier", principleId != null ? principleId + "" : "0")
  452. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  453. .eq("loss_type", lossType)
  454. .eq("is_deleted", IsDeleteEnum.N.getKey())
  455. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  456. .in("rec_id", redIds)));
  457. }
  458. break;
  459. case "1":
  460. //病案首页丢失
  461. List<String> homePages = homePageFacade.list(new QueryWrapper<HomePage>()
  462. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  463. .in("home_page_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
  464. .in("behospital_code", behospitalCodes)
  465. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  466. .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
  467. //更新状态-已恢复
  468. if (ListUtil.isNotEmpty(homePages)) {
  469. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  470. .set("solve_time", DateUtil.now())
  471. .set("gmt_modified", DateUtil.now())
  472. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  473. .set("modifier", principleId != null ? principleId + "" : "0")
  474. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  475. .eq("loss_type", lossType)
  476. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  477. .in("rec_id", homePages)
  478. .eq("is_deleted", IsDeleteEnum.N.getKey())));
  479. }
  480. break;
  481. case "2":
  482. //更新状态-已恢复
  483. if (ListUtil.isNotEmpty(behospitalCodes)) {
  484. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  485. .set("solve_time", DateUtil.now())
  486. .set("gmt_modified", DateUtil.now())
  487. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  488. .set("modifier", principleId != null ? principleId + "" : "0")
  489. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  490. .eq("loss_type", lossType)
  491. .eq("is_deleted", IsDeleteEnum.N.getKey())
  492. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  493. .in("behospital_code", behospitalCodes)));
  494. }
  495. break;
  496. default:
  497. break;
  498. }
  499. });
  500. }
  501. }
  502. return flag.get();
  503. }
  504. /**
  505. * @param medicalRecords his数据
  506. * @param logs 日志数据
  507. * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
  508. * @param auditedResultDatas 已核查数据
  509. * @param outInserts 外部丢失插入集合
  510. * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
  511. * @param hospitalId 医院id
  512. * @param principleId 操作人id
  513. * @param dataUps 要更新的已核查的集合
  514. * @Return void
  515. */
  516. private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs,
  517. String type, List<String> auditedResultDatas, List<BlocklossResult> outInserts,
  518. Map<String, HisMedicalRecordDTO> hisMedicalRecordMap,
  519. Long hospitalId, Long principleId, List<GetOperationLogDTO> dataUps) {
  520. //his数据为空直接返回
  521. if (ListUtil.isEmpty(medicalRecords)) {
  522. return;
  523. }
  524. switch (type) {
  525. case "0":
  526. List<String> recLogs = logs.stream().map(GetOperationLogDTO::getRecId).collect(Collectors.toList());
  527. medicalRecords.stream().forEach(medicalRecord -> {
  528. //文书不存在操作记录
  529. if (StringUtil.isNotEmpty(medicalRecord.getRecId())) {
  530. if (!recLogs.contains(medicalRecord.getRecId())) {
  531. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
  532. //该记录没有插入
  533. BlocklossResult blocklossResult = new BlocklossResult();
  534. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  535. blocklossResult.setRecId(medicalRecord.getRecId());
  536. blocklossResult.setRecTitle(medicalRecord.getRecTitle());
  537. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  538. blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
  539. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  540. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  541. }
  542. //拼装病历数据块丢失明细其他信息
  543. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  544. outInserts.add(blocklossResult);
  545. } else {
  546. //更新人工操作记录(核查的)的时间
  547. GetOperationLogDTO temp = new GetOperationLogDTO();
  548. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  549. temp.setRecId(medicalRecord.getRecId());
  550. dataUps.add(temp);
  551. }
  552. }
  553. }
  554. });
  555. break;
  556. case "1":
  557. List<String> homepageLogs = logs.stream().map(GetOperationLogDTO::getHomePageId).collect(Collectors.toList());
  558. medicalRecords.stream().forEach(medicalRecord -> {
  559. //病案首页不存在操作记录
  560. if (StringUtil.isNotEmpty(medicalRecord.getHomePageId()) && !homepageLogs.contains(medicalRecord.getHomePageId())) {
  561. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getHomePageId())) {
  562. BlocklossResult blocklossResult = new BlocklossResult();
  563. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  564. blocklossResult.setRecId(medicalRecord.getHomePageId());
  565. blocklossResult.setRecTitle("病案首页丢失");
  566. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  567. blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
  568. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  569. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  570. }
  571. //拼装病历数据块丢失明细其他信息
  572. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  573. outInserts.add(blocklossResult);
  574. } else {
  575. //更新人工操作记录(核查的)的时间
  576. GetOperationLogDTO temp = new GetOperationLogDTO();
  577. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  578. temp.setHomePageId(medicalRecord.getHomePageId());
  579. dataUps.add(temp);
  580. }
  581. }
  582. });
  583. break;
  584. case "2":
  585. List<String> behospitalCodeLogs = logs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
  586. medicalRecords.stream().forEach(medicalRecord -> {
  587. //病历数据不存在操作记录
  588. if (!behospitalCodeLogs.contains(medicalRecord.getBehospitalCode())) {
  589. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
  590. BlocklossResult blocklossResult = new BlocklossResult();
  591. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  592. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  593. blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
  594. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  595. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  596. }
  597. //拼装病历数据块丢失明细其他信息
  598. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  599. outInserts.add(blocklossResult);
  600. } else {
  601. //更新人工操作记录(核查的)的时间
  602. GetOperationLogDTO temp = new GetOperationLogDTO();
  603. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  604. dataUps.add(temp);
  605. }
  606. }
  607. });
  608. break;
  609. default:
  610. break;
  611. }
  612. }
  613. /**
  614. * 拼装病历数据块丢失明细其他信息
  615. *
  616. * @param blocklossResult
  617. * @param hospitalId
  618. * @param principleId
  619. * @Return void
  620. */
  621. private void assembleOtherBlocklossResult(BlocklossResult blocklossResult, Long hospitalId, Long principleId) {
  622. blocklossResult.setStatus(LossStatusEnum.IS_LOSS.getKey());
  623. blocklossResult.setHospitalId(hospitalId != null ? hospitalId : 0);
  624. blocklossResult.setGmtCreate(DateUtil.now());
  625. blocklossResult.setCreator(principleId != null ? principleId + "" : "0");
  626. blocklossResult.setGmtModified(DateUtil.now());
  627. }
  628. /**
  629. * 获取操作记录数据
  630. *
  631. * @param dataCompareVO
  632. * @Return java.util.List<com.lantone.common.dto.GetOperationLogDTO>
  633. */
  634. private List<GetOperationLogDTO> getOperationLogs(DataCompareVO dataCompareVO) {
  635. return operationLogService.getOperationLogs(dataCompareVO).getData();
  636. }
  637. /**
  638. * 获取his对应的数据
  639. *
  640. * @param dataCompareVO
  641. * @Return java.util.List<com.lantone.daqe.dto.HisMedicalRecordDTO>
  642. */
  643. private List<HisMedicalRecordDTO> getHisMedicalRecords(DataCompareVO dataCompareVO) {
  644. //技术服务部接口 /balance/data/getDataCount
  645. //###模拟
  646. return hisDataManagementFacade.getHisMedicalRecords(dataCompareVO);
  647. }
  648. /**
  649. * 丢失量分类汇总
  650. *
  651. * @param blockLossTypeGatherVO
  652. * @Return com.lantone.daqe.dto.BlockLossTypeGatherDTO
  653. */
  654. public BlockLossTypeGatherDTO blockLossTypeGather(BlockLossTypeGatherVO blockLossTypeGatherVO) {
  655. blockLossTypeGatherVO.setOperationUrls(Lists.newArrayList(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey(),
  656. DataSaveUrlEnum.HOME_PAGE.getKey(),
  657. DataSaveUrlEnum.MEDICAL_RECORD.getKey()));
  658. DataCompareVO dataCompareVO = new DataCompareVO();
  659. dataCompareVO.setStartDate(blockLossTypeGatherVO.getStartDate());
  660. dataCompareVO.setEndDate(blockLossTypeGatherVO.getEndDate());
  661. //获取his数据
  662. List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
  663. BlockLossTypeGatherDTO blockLossTypeGatherDTO = new BlockLossTypeGatherDTO();
  664. //his数据量
  665. blockLossTypeGatherDTO.setHisNum(getHisMedicalRecordsCount(hisMedicalRecords));
  666. //获取该时间段的日志数量
  667. //病历数据
  668. dataCompareVO.setOperationUrl(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey());
  669. List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
  670. //病案首页数据
  671. List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
  672. //文书数据
  673. List<GetOperationLogDTO> recLogs = new ArrayList<>();
  674. if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
  675. List<String> logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
  676. dataCompareVO.setBehospitalCodes(logCodes);
  677. //病案首页数据
  678. dataCompareVO.setOperationUrl(DataSaveUrlEnum.HOME_PAGE.getKey());
  679. homePageLogs = getOperationLogs(dataCompareVO);
  680. //文书数据
  681. dataCompareVO.setOperationUrl(DataSaveUrlEnum.MEDICAL_RECORD.getKey());
  682. recLogs = getOperationLogs(dataCompareVO);
  683. Integer logNum = logCodes.size() + homePageLogs.size() + recLogs.size();
  684. blockLossTypeGatherDTO.setLogNum(logNum);
  685. }
  686. //获取该时间段的实际数量
  687. List<String> codes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  688. .eq("is_deleted", IsDeleteEnum.N.getKey())
  689. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  690. .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
  691. .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()))
  692. .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
  693. Integer codeNum = codes.size();
  694. Integer homePageNum = 0;
  695. Integer recNum = 0;
  696. if (ListUtil.isNotEmpty(codes)) {
  697. homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
  698. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  699. .in("behospital_code", codes));
  700. recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
  701. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  702. .in("behospital_code", codes));
  703. }
  704. blockLossTypeGatherDTO.setRealNum(codeNum + homePageNum + recNum);
  705. //获取该时间段的丢失数量
  706. List<BlocklossResult> blocklossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
  707. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  708. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  709. .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
  710. .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()));
  711. Integer allLossNum = blocklossResults.size();
  712. blockLossTypeGatherDTO.setAllLossNum(allLossNum);
  713. // blockLossTypeGatherDTO.setHisNum(codeNum + homePageNum + recNum + allLossNum);
  714. Map<String, List<BlocklossResult>> lossWayMap = EntityUtil.makeEntityListMap(blocklossResults, "lossWay");
  715. //外部丢失
  716. if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
  717. Integer outLossNum = lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()).size();
  718. blockLossTypeGatherDTO.setOutLossNum(outLossNum);
  719. if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
  720. Map<String, List<BlocklossResult>> outLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()), "lossType");
  721. if (outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
  722. Integer outRecNum = outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
  723. blockLossTypeGatherDTO.setOutRecNum(outRecNum);
  724. }
  725. if (outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
  726. Integer outCodeNum = outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
  727. blockLossTypeGatherDTO.setOutCodeNum(outCodeNum);
  728. }
  729. if (outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
  730. Integer outHomePageNum = outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
  731. blockLossTypeGatherDTO.setOutHomePageNum(outHomePageNum);
  732. }
  733. }
  734. }
  735. //内部丢失
  736. if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
  737. Integer inLossNum = lossWayMap.get(LossWayEnum.IN_LOSS.getKey()).size();
  738. blockLossTypeGatherDTO.setInLossNum(inLossNum);
  739. if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
  740. Map<String, List<BlocklossResult>> inLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.IN_LOSS.getKey()), "lossType");
  741. if (inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
  742. Integer inRecNum = inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
  743. blockLossTypeGatherDTO.setInRecNum(inRecNum);
  744. }
  745. if (inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
  746. Integer inCodeNum = inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
  747. blockLossTypeGatherDTO.setInCodeNum(inCodeNum);
  748. }
  749. if (inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
  750. Integer inHomePageNum = inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
  751. blockLossTypeGatherDTO.setInHomePageNum(inHomePageNum);
  752. }
  753. }
  754. }
  755. return blockLossTypeGatherDTO;
  756. }
  757. /**
  758. * 获取这段时间内his的数据量
  759. *
  760. * @param hisMedicalRecords
  761. * @Return java.lang.Integer
  762. */
  763. private Integer getHisMedicalRecordsCount(List<HisMedicalRecordDTO> hisMedicalRecords) {
  764. AtomicReference<Integer> num = new AtomicReference<>(0);
  765. if (ListUtil.isNotEmpty(hisMedicalRecords)) {
  766. hisMedicalRecords.stream().forEach(hisMedicalRecordDTO -> {
  767. //病历+1
  768. num.getAndSet(num.get() + 1);
  769. //病案首页+1
  770. if (StringUtil.isNotEmpty(hisMedicalRecordDTO.getHomePageId())) {
  771. num.getAndSet(num.get() + 1);
  772. }
  773. //文书
  774. if (ListUtil.isNotEmpty(hisMedicalRecordDTO.getHisRecs())) {
  775. num.getAndSet(num.get() + hisMedicalRecordDTO.getHisRecs().size());
  776. }
  777. });
  778. }
  779. return num.get();
  780. }
  781. /**
  782. * 数据补录
  783. *
  784. * @param dataRepariVO
  785. * @Return boolean
  786. */
  787. public boolean dataRepari(DataRepariVO dataRepariVO) {
  788. //调用数据补录服务
  789. return hisDataManagementFacade.dataRepari(dataRepariVO);
  790. }
  791. }