From ca48bd9dd5ef2937af0a58204a463d79fabe962e Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Wed, 10 Jan 2024 09:18:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E6=8E=A8=E9=80=81=E6=89=8B=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=EF=BC=8C=E6=B2=A1=E6=9C=89=E4=BD=8F=E9=99=A2=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=E5=87=BA=E5=85=A5=E9=99=A2=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=8C=83=E5=9B=B4=EF=BC=88=E5=87=BA=E9=99=A2+3?= =?UTF-8?q?=E5=A4=A9=EF=BC=89=E6=88=96=E8=80=85=E7=AC=A6=E5=90=88=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=9C=A8=E9=99=A2=E7=9A=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../collection/mapper/TBasicMapper.java | 66 ++++++++++++------- .../collection/service/ITBasicService.java | 13 ++++ .../service/impl/TBasicServiceImpl.java | 40 ++++++++++- ...IP1008InspectionReportAdditionHandler.java | 51 ++++++++------ ...HIP1009InspectionReportUpdatesHandler.java | 54 ++++++++++++++- src/main/resources/mapper/TBasicMapper.xml | 7 ++ 6 files changed, 183 insertions(+), 48 deletions(-) diff --git a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java index 59e4530..b03dede 100644 --- a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java @@ -16,14 +16,15 @@ import java.util.List; * @author jiashi * @since 2021-04-14 */ -public interface TBasicMapper{ +public interface TBasicMapper { /** * 根据住院号和住院次数查询业务系统中病案主键 + * * @param inpatientNo 住院号 * @param admissTimes 住院次数 * @return 病案主键 */ - String getPatientIdByInpatientNoAndAdminssTimes(@Param("inpatientNo") String inpatientNo,@Param("adminssTimes") Integer admissTimes); + String getPatientIdByInpatientNoAndAdminssTimes(@Param("inpatientNo") String inpatientNo, @Param("adminssTimes") Integer admissTimes); Integer selectOne(@Param("jzh") String jzh); @@ -37,23 +38,25 @@ public interface TBasicMapper{ Integer updateExtend(@Param("tBasicExtend") TBasicExtend tBasicExtend); - List selectBasicListByAdmissDate(@Param("admissStartDate")String admissStartDate,@Param("admissEndDate") String admissEndDate,@Param("offset") int offset,@Param("size") int size); + List selectBasicListByAdmissDate(@Param("admissStartDate") String admissStartDate, @Param("admissEndDate") String admissEndDate, @Param("offset") int offset, @Param("size") int size); /** * 查询归档关联顺德人医报告的交叉索引 - * @param patientId 归档系统病案主键 + * + * @param patientId 归档系统病案主键 * @return 归档关联顺德人医报告的交叉索引 */ - String getSdRyIndexByPatientId(@Param("patientId")String patientId); + String getSdRyIndexByPatientId(@Param("patientId") String patientId); - List selectBasicListByCreateOrUpdateTime(@Param("startDate")String queryBasicStartDate, @Param("endDate")String queryBasicEndDate, @Param("offset") int offset,@Param("size") int size); + List selectBasicListByCreateOrUpdateTime(@Param("startDate") String queryBasicStartDate, @Param("endDate") String queryBasicEndDate, @Param("offset") int offset, @Param("size") int size); List selectBasicListByPatientIds(@Param("patientIds") List patientIds); - Integer getNurseFileCount(@Param("patientId")String patientId); + Integer getNurseFileCount(@Param("patientId") String patientId); /** * 护理采集过滤的文件数量 + * * @param patientId 病案主键 * @return 过滤的文件数量 */ @@ -61,14 +64,16 @@ public interface TBasicMapper{ /** * 保存护理采集删除文件数量 - * @param patientId 病案主键 + * + * @param patientId 病案主键 * @param removeCount 删除数量 * @return db操作影响行 */ - Integer saveNisRemoveFilesCount(@Param("patientId") String patientId,@Param("count") int removeCount); + Integer saveNisRemoveFilesCount(@Param("patientId") String patientId, @Param("count") int removeCount); /** * 查询顺德人医索引 + * * @param patientId 病案主键 * @return 顺德人医索引 */ @@ -76,21 +81,24 @@ public interface TBasicMapper{ /** * 根据宝宝的患者索引 关联数据 + * * @param babyIndex 宝宝患者索引 * @return 关联数据 */ - MaternalInfantRelationship getMaternalInfantRelationship(@Param("babyIndex")String babyIndex); + MaternalInfantRelationship getMaternalInfantRelationship(@Param("babyIndex") String babyIndex); /** * 根据患者索引,查询病案主键 - * @param sdRyIndex 患者索引 + * + * @param sdRyIndex 患者索引 * @param admissTimes 住院次数 * @return 病案主键 */ - String getPatientIdBySdRyIndexAndAdmissTimes(@Param("sdRyIndex")String sdRyIndex, @Param("admissTimes") String admissTimes ); + String getPatientIdBySdRyIndexAndAdmissTimes(@Param("sdRyIndex") String sdRyIndex, @Param("admissTimes") String admissTimes); /** * 根据病案主键查询基础信息 + * * @param patientId * @return 基础数据 */ @@ -100,14 +108,16 @@ public interface TBasicMapper{ /** * 更新患者的护理采集状态 + * * @param patientId 病案 - * @param state 状态 0未采集 1 已采集 + * @param state 状态 0未采集 1 已采集 * @return 数据库操作 */ int updateNursCollectState(@Param("patientId") String patientId, @Param("state") int state); /** * 根据病案主键获取额外信息 + * * @param patientId 病案主键 * @return 额外信息 */ @@ -115,18 +125,30 @@ public interface TBasicMapper{ /** * 根据工号,获取用户姓名 + * * @param userName 工号 * @return 用户姓名 */ - String getNameByUserName(@Param("userName")String userName); + String getNameByUserName(@Param("userName") String userName); -/** - * 根据住院号和报告时间,查询住院次数 - * @date 2024/1/9 14:46 - * @author YongBin Wen - * @param inpatientNo 住院号 - * @param reportTime 报告时间 yyyy-MM-dd HH:mm:ss - * @return 住院次数 - */ + /** + * 根据住院号和报告时间,查询住院次数 + * + * @param inpatientNo 住院号 + * @param reportTime 报告时间 yyyy-MM-dd HH:mm:ss + * @return 住院次数 + * @date 2024/1/9 14:46 + * @author YongBin Wen + */ List getAdmissTimesByInpNoAndReportTime(@Param("inpatientNo") String inpatientNo, @Param("reportTime") String reportTime); + + /** + * 根据病案号获取患者基础数据集合 + * + * @param inpNo 病案号 + * @return java.util.List + * @date 2024/1/10 8:39 + * @author YongBin Wen + */ + List selectBasicListByInpNo(@Param("inpNo") String inpNo); } diff --git a/src/main/java/com/docus/server/collection/service/ITBasicService.java b/src/main/java/com/docus/server/collection/service/ITBasicService.java index d1b2ac0..53447bc 100644 --- a/src/main/java/com/docus/server/collection/service/ITBasicService.java +++ b/src/main/java/com/docus/server/collection/service/ITBasicService.java @@ -3,6 +3,8 @@ package com.docus.server.collection.service; import com.docus.server.collection.dto.TBasicDto; import com.docus.server.collection.entity.TBasic; +import java.util.Date; + public interface ITBasicService { public void setTBasic(TBasicDto dto) throws Exception; @@ -25,4 +27,15 @@ public interface ITBasicService { * @return 是否婴儿患者 */ boolean getIsBabyBasic(String patientId); + + /** + * 按照报告时间和住院号,匹配患者住院次数 + * @date 2024/1/10 8:33 + * @author YongBin Wen + * @param inpatientNo 住院号 + * @param reportDate 报告时间 + * @param timeRangeAddedHour 匹配范围添加(小时) + * @return java.lang.Integer + */ + Integer matchingAdmissTimesByInpNoAndReportTime(String inpatientNo, Date reportDate, long timeRangeAddedHour); } diff --git a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java index d5f17e6..300d3bf 100644 --- a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java +++ b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; +import java.util.List; import java.util.Objects; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; @@ -349,12 +350,12 @@ public class TBasicServiceImpl implements ITBasicService { // 宝宝索引查妈妈索引 和住院次数 MaternalInfantRelationship infantRelationship = tBasicMapper.getMaternalInfantRelationship(babyIndex); - if (Objects.isNull(infantRelationship) || Func.isBlank(infantRelationship.getMomId()) ) { + if (Objects.isNull(infantRelationship) || Func.isBlank(infantRelationship.getMomId())) { return null; } - String parentSdRyIndex=infantRelationship.getMomId(); + String parentSdRyIndex = infantRelationship.getMomId(); // 通过索引和住院次数查病案主键 - String parentPatientId = tBasicMapper.getPatientIdBySdRyIndexAndAdmissTimes(parentSdRyIndex,infantRelationship.getParentTimes()); + String parentPatientId = tBasicMapper.getPatientIdBySdRyIndexAndAdmissTimes(parentSdRyIndex, infantRelationship.getParentTimes()); if (Func.isBlank(parentPatientId)) { return null; } @@ -368,6 +369,39 @@ public class TBasicServiceImpl implements ITBasicService { return Func.isNotEmpty(tBasic) && Func.isNotBlank(tBasic.getInpatientNo()) && tBasic.getInpatientNo().toUpperCase().contains("B"); } + @Override + public Integer matchingAdmissTimesByInpNoAndReportTime(String inpatientNo, Date reportDate, long timeRangeAddedHour) { + List basicList = tBasicMapper.selectBasicListByInpNo(inpatientNo); + if (Func.isEmpty(basicList)) { + log.warn("住院号:{} 未查询到患者基础数据!", inpatientNo); + return null; + } + + // 转换毫秒范围进行比较运算 + long timeRangeAddedMillis = timeRangeAddedHour * 60 * 60 * 1000; + long reportDateTimeMillis = reportDate.getTime(); + for (TBasic basic : basicList) { + Date admissDate = basic.getAdmissDate(); + Date disDate = basic.getDisDate(); + if (Objects.isNull(admissDate)) { + log.warn("住院号:{} 有入院时间为空的基础数据!", inpatientNo); + continue; + } + // 入院时间大于报告时间,不匹配 + if (admissDate.getTime() > reportDateTimeMillis) { + continue; + } + // 报告时间大于等于入院时间,出院时间为空或者 报告时间小于等于出院时间+时间范围差,则匹配该条数据 + if (Objects.isNull(disDate) || reportDateTimeMillis <= (disDate.getTime() + timeRangeAddedMillis)) { + if (Objects.isNull(basic.getAdmissTimes())) { + log.warn("住院号:{} ,报告时间:{},范围添加 {} 小时,匹配患者数据patientId为:{},但是住院次数为空!", inpatientNo, Func.formatDateTime(reportDate), timeRangeAddedHour, basic.getPatientId()); + } + return basic.getAdmissTimes(); + } + } + log.warn("住院号:{},报告时间:{},范围添加 {} 小时,未匹配到患者基础数据具体住院次数!", inpatientNo, Func.formatDateTime(reportDate), timeRangeAddedHour); + return null; + } public void confirmAndUpdIcuRecordState(String inpatientNo, Integer admissTimes) { threadPoolExecutor.execute(() -> { diff --git a/src/main/java/com/docus/server/report/webservice/impl/HIP1008InspectionReportAdditionHandler.java b/src/main/java/com/docus/server/report/webservice/impl/HIP1008InspectionReportAdditionHandler.java index 13db7a6..7cc2f21 100644 --- a/src/main/java/com/docus/server/report/webservice/impl/HIP1008InspectionReportAdditionHandler.java +++ b/src/main/java/com/docus/server/report/webservice/impl/HIP1008InspectionReportAdditionHandler.java @@ -4,7 +4,7 @@ import com.docus.core.util.DateUtil; import com.docus.core.util.Func; import com.docus.infrastructure.core.exception.BaseException; import com.docus.infrastructure.redis.service.RedisOps; -import com.docus.server.collection.mapper.TBasicMapper; +import com.docus.server.collection.service.ITBasicService; import com.docus.server.report.api.ShunDePeopleService; import com.docus.server.report.api.dto.ReportDto; import com.docus.server.report.config.SdRyReportHandledConfig; @@ -22,7 +22,6 @@ import org.w3c.dom.Node; import javax.annotation.Resource; import java.util.Date; -import java.util.List; /** * HIP1008-检查报告新增服务处理 @@ -41,7 +40,7 @@ public class HIP1008InspectionReportAdditionHandler implements WebserviceReceive @Resource private RedisOps redisOps; @Resource - private TBasicMapper tBasicMapper; + private ITBasicService tBasicService; @Override @@ -93,7 +92,14 @@ public class HIP1008InspectionReportAdditionHandler implements WebserviceReceive String inpatientNo = inpatientNoNode.getNodeValue(); Node admissTimesNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/item[@root='1.2.156.112635.1.2.1.7']/@extension"); - Integer admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + Integer admissTimes; + try { + admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + admissTimes = null; + } + // 患者本次就诊唯一键:患者id【12位】+就诊次数 Node visitSnNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.11']/@extension"); @@ -115,6 +121,10 @@ public class HIP1008InspectionReportAdditionHandler implements WebserviceReceive String reportName = fileTitleNode.getTextContent(); + if (admissTimes == null && isManualDocuments(requestSn)) { + admissTimes = getAdmissTimes(inpatientNo, inspectionInsertXmlUtil); + } + ReportDto reportDto = new ReportDto(); reportDto.setAdmisstimes(admissTimes); reportDto.setInpatientNo(inpatientNo); @@ -149,6 +159,21 @@ public class HIP1008InspectionReportAdditionHandler implements WebserviceReceive return reportDto; } + private Integer getAdmissTimes(String inpatientNo, XmlUtil inspectionInsertXmlUtil) { + try { + //检查报告日期 yyyyMMddHHmmss + String pattern = "yyyyMMddHHmmss"; + Node reportTimeNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/author/time/@value"); + String reportTime = reportTimeNode.getNodeValue(); + Date reportDate = Func.parseDate(reportTime, pattern); + // 出院时间+3天匹配 + int timeRangeAddedHour = 3 * 24; + return tBasicService.matchingAdmissTimesByInpNoAndReportTime(inpatientNo, reportDate, timeRangeAddedHour); + } catch (Exception ex) { + throw new BaseException("解析检查报告时间出错了!"); + } + } + public ReportDto getReportDtoByInspectionInsert(XmlUtil inspectionInsertXmlUtil) { Node senderNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/sender/device/id/item/@extension"); @@ -185,23 +210,7 @@ public class HIP1008InspectionReportAdditionHandler implements WebserviceReceive // 如果是手工单,住院次数可能为空,则需要根据检查报告时间与出入院区间获取住院次数 // todo 实施手工单需求确认 if (admissTimes == null && isManualDocuments(eafNo)) { - //检查报告日期 yyyyMMddHHmmss - String pattern = "yyyyMMddHHmmss"; - Node reportTimeNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/author/time/@value"); - String reportTime = reportTimeNode.getNodeValue(); - Date reportDate = Func.parseDate(reportTime, pattern); - String formatDateTime = Func.formatDateTime(reportDate); - List admissTimesList = tBasicMapper.getAdmissTimesByInpNoAndReportTime(inpatientNo, formatDateTime); - if (Func.isEmpty(admissTimesList)) { - log.warn("住院号:{},报告时间:{} 根据住院号与出入院日期匹配患者基础数据失败!", inpatientNo, formatDateTime); - } else if (admissTimesList.size() > 1) { - log.warn("住院号:{},报告时间:{} 根据住院号与出入院日期匹配患者基础数据失败,有多条!", inpatientNo, formatDateTime); - } else { - admissTimes = admissTimesList.get(0); - if (admissTimes == null) { - log.warn("住院号:{},报告时间:{} 根据住院号与出入院日期匹配患者基础数据,住院次数为空!", inpatientNo, formatDateTime); - } - } + getAdmissTimes(inpatientNo, inspectionInsertXmlUtil); } diff --git a/src/main/java/com/docus/server/report/webservice/impl/HIP1009InspectionReportUpdatesHandler.java b/src/main/java/com/docus/server/report/webservice/impl/HIP1009InspectionReportUpdatesHandler.java index cf6e5f7..927ad88 100644 --- a/src/main/java/com/docus/server/report/webservice/impl/HIP1009InspectionReportUpdatesHandler.java +++ b/src/main/java/com/docus/server/report/webservice/impl/HIP1009InspectionReportUpdatesHandler.java @@ -4,6 +4,7 @@ import com.docus.core.util.DateUtil; import com.docus.core.util.Func; import com.docus.infrastructure.core.exception.BaseException; import com.docus.infrastructure.redis.service.RedisOps; +import com.docus.server.collection.service.ITBasicService; import com.docus.server.report.api.ShunDePeopleService; import com.docus.server.report.api.dto.ReportDto; import com.docus.server.report.config.SdRyReportHandledConfig; @@ -38,6 +39,8 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS private ReportJob reportJob; @Resource private RedisOps redisOps; + @Resource + private ITBasicService tBasicService; @Override @@ -90,7 +93,13 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS String inpatientNo = inpatientNoNode.getNodeValue(); Node admissTimesNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/item[@root='1.2.156.112635.1.2.1.7']/@extension"); - Integer admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + Integer admissTimes; + try { + admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + admissTimes = null; + } // 患者本次就诊唯一键:患者id【12位】+就诊次数 Node visitSnNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.11']/@extension"); @@ -111,6 +120,10 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS String reportName = fileTitleNode.getTextContent(); + if (admissTimes == null && isManualDocuments(requestSn)) { + admissTimes = getAdmissTimes(inpatientNo, inspectionInsertXmlUtil); + } + ReportDto reportDto = new ReportDto(); reportDto.setAdmisstimes(admissTimes); reportDto.setInpatientNo(inpatientNo); @@ -157,7 +170,14 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS String inpatientNo = inpatientNoNode.getNodeValue(); Node admissTimesNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/item[@root='1.2.156.112635.1.2.1.7']/@extension"); - Integer admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + Integer admissTimes; + try { + admissTimes = Integer.valueOf(admissTimesNode.getNodeValue()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + admissTimes = null; + } + // 检查报告单号标识 Node reportFlagNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.32']/@extension"); @@ -185,6 +205,10 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS Node downUrlNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告图像']/report/entry[@displayName='检查报告图像URL地址']/observation/value"); String downUrl = downUrlNode.getTextContent(); + if (admissTimes == null && isManualDocuments(eafNo)) { + admissTimes = getAdmissTimes(inpatientNo, inspectionUpdateXmlUtil); + } + ReportDto reportDto = new ReportDto(); reportDto.setReportSn(reportFlag); @@ -201,6 +225,32 @@ public class HIP1009InspectionReportUpdatesHandler implements WebserviceReceiveS return reportDto; } + /** + * 根据电子申请单号判断是否手工单 + * + * @param eafNo 电子申请单号 + * @return boolean + * @date 2024/1/9 14:38 + * @author YongBin Wen + */ + private boolean isManualDocuments(String eafNo) { + return Func.isBlank(eafNo); + } + + private Integer getAdmissTimes(String inpatientNo, XmlUtil inspectionInsertXmlUtil) { + try { + //检查报告日期 yyyyMMddHHmmss + String pattern = "yyyyMMddHHmmss"; + Node reportTimeNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/author/time/@value"); + String reportTime = reportTimeNode.getNodeValue(); + Date reportDate = Func.parseDate(reportTime, pattern); + // 出院时间+3天匹配 + int timeRangeAddedHour = 3 * 24; + return tBasicService.matchingAdmissTimesByInpNoAndReportTime(inpatientNo, reportDate, timeRangeAddedHour); + } catch (Exception ex) { + throw new BaseException("解析检查报告时间出错了!"); + } + } /** * 返回检查报告更新成功响应消息 diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 9babfce..4deb7a7 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -236,5 +236,12 @@ and #{reportTime} BETWEEN admiss_date and dis_date +