BlockLossManagementFacade.java 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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<>(false);
  423. lossResultMap.keySet().stream().forEach(lossType -> {
  424. //0:文书丢失 1:病案首页丢失 2:患者信息丢失
  425. switch (lossType) {
  426. case "0":
  427. //文书丢失
  428. List<String> redIds = medicalRecordFacade.list(new QueryWrapper<MedicalRecord>()
  429. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  430. .in("rec_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
  431. .in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
  432. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  433. .stream().map(MedicalRecord::getRecId).collect(Collectors.toList());
  434. //更新状态-已恢复
  435. if (ListUtil.isNotEmpty(redIds)) {
  436. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  437. .set("solve_time", DateUtil.now())
  438. .set("gmt_modified", DateUtil.now())
  439. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  440. .set("modifier", principleId != null ? principleId + "" : "0")
  441. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  442. .eq("loss_type", lossType)
  443. .eq("is_deleted", IsDeleteEnum.N.getKey())
  444. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  445. .in("rec_id", redIds)));
  446. }
  447. break;
  448. case "1":
  449. //病案首页丢失
  450. List<String> homePages = homePageFacade.list(new QueryWrapper<HomePage>()
  451. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  452. .in("home_page_id", lossResultMap.get(lossType).stream().map(BlocklossResult::getRecId).collect(Collectors.toList()))
  453. .in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
  454. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  455. .stream().map(HomePage::getHomePageId).collect(Collectors.toList());
  456. //更新状态-已恢复
  457. if (ListUtil.isNotEmpty(homePages)) {
  458. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  459. .set("solve_time", DateUtil.now())
  460. .set("gmt_modified", DateUtil.now())
  461. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  462. .set("modifier", principleId != null ? principleId + "" : "0")
  463. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  464. .eq("loss_type", lossType)
  465. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  466. .in("rec_id", homePages)
  467. .eq("is_deleted", IsDeleteEnum.N.getKey())));
  468. }
  469. break;
  470. case "2":
  471. //患者信息丢失
  472. List<String> behospitalCodes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  473. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  474. .in("behospital_code", lossResultMap.get(lossType).stream().map(BlocklossResult::getBehospitalCode).collect(Collectors.toList()))
  475. .eq("is_deleted", IsDeleteEnum.N.getKey()))
  476. .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
  477. //更新状态-已恢复
  478. if (ListUtil.isNotEmpty(behospitalCodes)) {
  479. flag.set(blocklossResultFacade.update(new UpdateWrapper<BlocklossResult>()
  480. .set("solve_time", DateUtil.now())
  481. .set("gmt_modified", DateUtil.now())
  482. .set("status", LossStatusEnum.NOT_LOSS.getKey())
  483. .set("modifier", principleId != null ? principleId + "" : "0")
  484. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  485. .eq("loss_type", lossType)
  486. .eq("is_deleted", IsDeleteEnum.N.getKey())
  487. .eq("hospital_id", hospitalId != null ? hospitalId : 0)
  488. .in("behospital_code", behospitalCodes)));
  489. }
  490. break;
  491. default:
  492. break;
  493. }
  494. });
  495. return flag.get();
  496. }
  497. /**
  498. * @param medicalRecords his数据
  499. * @param logs 日志数据
  500. * @param type 对比类型:0:文书丢失 1:病案首页丢失 2:患者信息丢失
  501. * @param auditedResultDatas 已核查数据
  502. * @param outInserts 外部丢失插入集合
  503. * @param hisMedicalRecordMap his病历数据map(key-住院序号:value-人的his数据)
  504. * @param hospitalId 医院id
  505. * @param principleId 操作人id
  506. * @param dataUps 要更新的已核查的集合
  507. * @Return void
  508. */
  509. private void compareHisWithLog(List<GetOperationLogDTO> medicalRecords, List<GetOperationLogDTO> logs,
  510. String type, List<String> auditedResultDatas, List<BlocklossResult> outInserts,
  511. Map<String, HisMedicalRecordDTO> hisMedicalRecordMap,
  512. Long hospitalId, Long principleId, List<GetOperationLogDTO> dataUps) {
  513. //his数据为空直接返回
  514. if (ListUtil.isEmpty(medicalRecords)) {
  515. return;
  516. }
  517. switch (type) {
  518. case "0":
  519. List<String> recLogs = logs.stream().map(GetOperationLogDTO::getRecId).collect(Collectors.toList());
  520. medicalRecords.stream().forEach(medicalRecord -> {
  521. //文书不存在操作记录
  522. if (StringUtil.isNotEmpty(medicalRecord.getRecId())) {
  523. if (!recLogs.contains(medicalRecord.getRecId())) {
  524. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
  525. //该记录没有插入
  526. BlocklossResult blocklossResult = new BlocklossResult();
  527. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  528. blocklossResult.setRecId(medicalRecord.getRecId());
  529. blocklossResult.setRecTitle(medicalRecord.getRecTitle());
  530. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  531. blocklossResult.setLossType(LossTypeEnum.REC_LOSS.getKey());
  532. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  533. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  534. }
  535. //拼装病历数据块丢失明细其他信息
  536. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  537. outInserts.add(blocklossResult);
  538. } else {
  539. //更新人工操作记录(核查的)的时间
  540. GetOperationLogDTO temp = new GetOperationLogDTO();
  541. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  542. temp.setRecId(medicalRecord.getRecId());
  543. dataUps.add(temp);
  544. }
  545. }
  546. }
  547. });
  548. break;
  549. case "1":
  550. List<String> homepageLogs = logs.stream().map(GetOperationLogDTO::getHomePageId).collect(Collectors.toList());
  551. medicalRecords.stream().forEach(medicalRecord -> {
  552. //病案首页不存在操作记录
  553. if (StringUtil.isNotEmpty(medicalRecord.getHomePageId()) && !homepageLogs.contains(medicalRecord.getHomePageId())) {
  554. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
  555. BlocklossResult blocklossResult = new BlocklossResult();
  556. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  557. blocklossResult.setRecId(medicalRecord.getHomePageId());
  558. blocklossResult.setRecTitle("病案首页丢失");
  559. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  560. blocklossResult.setLossType(LossTypeEnum.HOMEPAGE_LOSS.getKey());
  561. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  562. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  563. }
  564. //拼装病历数据块丢失明细其他信息
  565. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  566. outInserts.add(blocklossResult);
  567. } else {
  568. //更新人工操作记录(核查的)的时间
  569. GetOperationLogDTO temp = new GetOperationLogDTO();
  570. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  571. temp.setHomePageId(medicalRecord.getHomePageId());
  572. dataUps.add(temp);
  573. }
  574. }
  575. });
  576. break;
  577. case "2":
  578. List<String> behospitalCodeLogs = logs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
  579. medicalRecords.stream().forEach(medicalRecord -> {
  580. //病历数据不存在操作记录
  581. if (!behospitalCodeLogs.contains(medicalRecord.getBehospitalCode())) {
  582. if (auditedResultDatas == null || !auditedResultDatas.contains(medicalRecord.getRecId())) {
  583. BlocklossResult blocklossResult = new BlocklossResult();
  584. blocklossResult.setBehospitalCode(medicalRecord.getBehospitalCode());
  585. blocklossResult.setLossWay(LossWayEnum.OUT_LOSS.getKey());
  586. blocklossResult.setLossType(LossTypeEnum.CODE_LOSS.getKey());
  587. if (hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate() != null) {
  588. blocklossResult.setBehospitalDate(hisMedicalRecordMap.get(medicalRecord.getBehospitalCode()).getBehospitalDate());
  589. }
  590. //拼装病历数据块丢失明细其他信息
  591. assembleOtherBlocklossResult(blocklossResult, hospitalId, principleId);
  592. outInserts.add(blocklossResult);
  593. } else {
  594. //更新人工操作记录(核查的)的时间
  595. GetOperationLogDTO temp = new GetOperationLogDTO();
  596. temp.setBehospitalCode(medicalRecord.getBehospitalCode());
  597. dataUps.add(temp);
  598. }
  599. }
  600. });
  601. break;
  602. default:
  603. break;
  604. }
  605. }
  606. /**
  607. * 拼装病历数据块丢失明细其他信息
  608. *
  609. * @param blocklossResult
  610. * @param hospitalId
  611. * @param principleId
  612. * @Return void
  613. */
  614. private void assembleOtherBlocklossResult(BlocklossResult blocklossResult, Long hospitalId, Long principleId) {
  615. blocklossResult.setStatus(LossStatusEnum.IS_LOSS.getKey());
  616. blocklossResult.setHospitalId(hospitalId != null ? hospitalId : 0);
  617. blocklossResult.setGmtCreate(DateUtil.now());
  618. blocklossResult.setCreator(principleId != null ? principleId + "" : "0");
  619. blocklossResult.setGmtModified(DateUtil.now());
  620. }
  621. /**
  622. * 获取操作记录数据
  623. *
  624. * @param dataCompareVO
  625. * @Return java.util.List<com.lantone.common.dto.GetOperationLogDTO>
  626. */
  627. private List<GetOperationLogDTO> getOperationLogs(DataCompareVO dataCompareVO) {
  628. return operationLogService.getOperationLogs(dataCompareVO).getData();
  629. }
  630. /**
  631. * 获取his对应的数据
  632. *
  633. * @param dataCompareVO
  634. * @Return java.util.List<com.lantone.daqe.dto.HisMedicalRecordDTO>
  635. */
  636. private List<HisMedicalRecordDTO> getHisMedicalRecords(DataCompareVO dataCompareVO) {
  637. //技术服务部接口 /balance/data/getDataCount
  638. //###模拟
  639. return hisDataManagementFacade.getHisMedicalRecords(dataCompareVO);
  640. }
  641. /**
  642. * 丢失量分类汇总
  643. *
  644. * @param blockLossTypeGatherVO
  645. * @Return com.lantone.daqe.dto.BlockLossTypeGatherDTO
  646. */
  647. public BlockLossTypeGatherDTO blockLossTypeGather(BlockLossTypeGatherVO blockLossTypeGatherVO) {
  648. blockLossTypeGatherVO.setOperationUrls(Lists.newArrayList(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey(),
  649. DataSaveUrlEnum.HOME_PAGE.getKey(),
  650. DataSaveUrlEnum.MEDICAL_RECORD.getKey()));
  651. DataCompareVO dataCompareVO = new DataCompareVO();
  652. dataCompareVO.setStartDate(blockLossTypeGatherVO.getStartDate());
  653. dataCompareVO.setEndDate(blockLossTypeGatherVO.getEndDate());
  654. //获取his数据
  655. List<HisMedicalRecordDTO> hisMedicalRecords = getHisMedicalRecords(dataCompareVO);
  656. BlockLossTypeGatherDTO blockLossTypeGatherDTO = new BlockLossTypeGatherDTO();
  657. //his数据量
  658. blockLossTypeGatherDTO.setHisNum(getHisMedicalRecordsCount(hisMedicalRecords));
  659. //获取该时间段的日志数量
  660. //病历数据
  661. dataCompareVO.setOperationUrl(DataSaveUrlEnum.BEHOSPITAL_INFO.getKey());
  662. List<GetOperationLogDTO> behospitalCodeLogs = getOperationLogs(dataCompareVO);
  663. //病案首页数据
  664. List<GetOperationLogDTO> homePageLogs = new ArrayList<>();
  665. //文书数据
  666. List<GetOperationLogDTO> recLogs = new ArrayList<>();
  667. if (ListUtil.isNotEmpty(behospitalCodeLogs)) {
  668. List<String> logCodes = behospitalCodeLogs.stream().map(GetOperationLogDTO::getBehospitalCode).collect(Collectors.toList());
  669. dataCompareVO.setBehospitalCodes(logCodes);
  670. //病案首页数据
  671. dataCompareVO.setOperationUrl(DataSaveUrlEnum.HOME_PAGE.getKey());
  672. homePageLogs = getOperationLogs(dataCompareVO);
  673. //文书数据
  674. dataCompareVO.setOperationUrl(DataSaveUrlEnum.MEDICAL_RECORD.getKey());
  675. recLogs = getOperationLogs(dataCompareVO);
  676. Integer logNum = logCodes.size() + homePageLogs.size() + recLogs.size();
  677. blockLossTypeGatherDTO.setLogNum(logNum);
  678. }
  679. //获取该时间段的实际数量
  680. List<String> codes = behospitalInfoFacade.list(new QueryWrapper<BehospitalInfo>()
  681. .eq("is_deleted", IsDeleteEnum.N.getKey())
  682. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  683. .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
  684. .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()))
  685. .stream().map(BehospitalInfo::getBehospitalCode).collect(Collectors.toList());
  686. Integer codeNum = codes.size();
  687. Integer homePageNum = 0;
  688. Integer recNum = 0;
  689. if (ListUtil.isNotEmpty(codes)) {
  690. homePageNum = homePageFacade.count(new QueryWrapper<HomePage>()
  691. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  692. .in("behospital_code", codes));
  693. recNum = medicalRecordFacade.count(new QueryWrapper<MedicalRecord>()
  694. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  695. .in("behospital_code", codes));
  696. }
  697. blockLossTypeGatherDTO.setRealNum(codeNum + homePageNum + recNum);
  698. //获取该时间段的丢失数量
  699. List<BlocklossResult> blocklossResults = blocklossResultFacade.list(new QueryWrapper<BlocklossResult>()
  700. .eq("hospital_id", SysUserUtils.getCurrentHospitalId() != null ? SysUserUtils.getCurrentHospitalId() : 0)
  701. .eq("status", LossStatusEnum.IS_LOSS.getKey())
  702. .ge(blockLossTypeGatherVO.getStartDate() != null, "behospital_date", blockLossTypeGatherVO.getStartDate())
  703. .le(blockLossTypeGatherVO.getEndDate() != null, "behospital_date", blockLossTypeGatherVO.getEndDate()));
  704. Integer allLossNum = blocklossResults.size();
  705. blockLossTypeGatherDTO.setAllLossNum(allLossNum);
  706. // blockLossTypeGatherDTO.setHisNum(codeNum + homePageNum + recNum + allLossNum);
  707. Map<String, List<BlocklossResult>> lossWayMap = EntityUtil.makeEntityListMap(blocklossResults, "lossWay");
  708. //外部丢失
  709. if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
  710. Integer outLossNum = lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()).size();
  711. blockLossTypeGatherDTO.setOutLossNum(outLossNum);
  712. if (lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()) != null) {
  713. Map<String, List<BlocklossResult>> outLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.OUT_LOSS.getKey()), "lossType");
  714. if (outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
  715. Integer outRecNum = outLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
  716. blockLossTypeGatherDTO.setOutRecNum(outRecNum);
  717. }
  718. if (outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
  719. Integer outCodeNum = outLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
  720. blockLossTypeGatherDTO.setOutCodeNum(outCodeNum);
  721. }
  722. if (outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
  723. Integer outHomePageNum = outLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
  724. blockLossTypeGatherDTO.setOutHomePageNum(outHomePageNum);
  725. }
  726. }
  727. }
  728. //内部丢失
  729. if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
  730. Integer inLossNum = lossWayMap.get(LossWayEnum.IN_LOSS.getKey()).size();
  731. blockLossTypeGatherDTO.setInLossNum(inLossNum);
  732. if (lossWayMap.get(LossWayEnum.IN_LOSS.getKey()) != null) {
  733. Map<String, List<BlocklossResult>> inLossTypeMap = EntityUtil.makeEntityListMap(lossWayMap.get(LossWayEnum.IN_LOSS.getKey()), "lossType");
  734. if (inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()) != null) {
  735. Integer inRecNum = inLossTypeMap.get(LossTypeEnum.REC_LOSS.getKey()).size();
  736. blockLossTypeGatherDTO.setInRecNum(inRecNum);
  737. }
  738. if (inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()) != null) {
  739. Integer inCodeNum = inLossTypeMap.get(LossTypeEnum.CODE_LOSS.getKey()).size();
  740. blockLossTypeGatherDTO.setInCodeNum(inCodeNum);
  741. }
  742. if (inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()) != null) {
  743. Integer inHomePageNum = inLossTypeMap.get(LossTypeEnum.HOMEPAGE_LOSS.getKey()).size();
  744. blockLossTypeGatherDTO.setInHomePageNum(inHomePageNum);
  745. }
  746. }
  747. }
  748. return blockLossTypeGatherDTO;
  749. }
  750. /**
  751. * 获取这段时间内his的数据量
  752. *
  753. * @param hisMedicalRecords
  754. * @Return java.lang.Integer
  755. */
  756. private Integer getHisMedicalRecordsCount(List<HisMedicalRecordDTO> hisMedicalRecords) {
  757. AtomicReference<Integer> num = new AtomicReference<>(0);
  758. if (ListUtil.isNotEmpty(hisMedicalRecords)) {
  759. hisMedicalRecords.stream().forEach(hisMedicalRecordDTO -> {
  760. //病历+1
  761. num.getAndSet(num.get() + 1);
  762. //病案首页+1
  763. if (StringUtil.isNotEmpty(hisMedicalRecordDTO.getHomePageId())) {
  764. num.getAndSet(num.get() + 1);
  765. }
  766. //文书
  767. if (ListUtil.isNotEmpty(hisMedicalRecordDTO.getHisRecs())) {
  768. num.getAndSet(num.get() + hisMedicalRecordDTO.getHisRecs().size());
  769. }
  770. });
  771. }
  772. return num.get();
  773. }
  774. /**
  775. * 数据补录
  776. *
  777. * @param dataRepariVO
  778. * @Return boolean
  779. */
  780. public boolean dataRepari(DataRepariVO dataRepariVO) {
  781. //调用数据补录服务
  782. return hisDataManagementFacade.dataRepari(dataRepariVO);
  783. }
  784. }