diff --git a/src/main/java/com/docus/server/report/webservice/impl/HIP1112RecallInspectionReportHandler.java b/src/main/java/com/docus/server/report/webservice/impl/HIP1112RecallInspectionReportHandler.java index 910b711..c1b3002 100644 --- a/src/main/java/com/docus/server/report/webservice/impl/HIP1112RecallInspectionReportHandler.java +++ b/src/main/java/com/docus/server/report/webservice/impl/HIP1112RecallInspectionReportHandler.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.server.collection.mapper.TBasicMapper; +import com.docus.server.report.config.SdRyReportQueryConfig; import com.docus.server.report.service.ReportService; import com.docus.server.report.util.IdUtil; import com.docus.server.report.util.XmlUtil; @@ -34,14 +35,18 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe @Resource private TBasicMapper tBasicMapper; + @Resource + private SdRyReportQueryConfig sdRyReportQueryConfig; + + public static void main(String[] args) { String xml = "\n" + "\n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -56,7 +61,7 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -65,7 +70,7 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -84,35 +89,35 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + - " \n" + + " \n" + " \n" + - " \n" + + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -123,38 +128,39 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + + " \n" + " \n" + " \n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + " \n" + - " \n" + - " \n" + + " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -169,12 +175,12 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -195,9 +201,9 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe " \n" + " \n" + " \n" + - " \n" + + " \n" + " \n" + - " \n" + + " \n" + " \n" + " \n" + " \n" + @@ -230,81 +236,178 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe msgId = xmlUtil.getNode("/POOR_HIP1112/id/@extension").getNodeValue(); sender = xmlUtil.getNode("/POOR_HIP1112/sender/device/id/item/@extension").getNodeValue(); receiver = xmlUtil.getNode("/POOR_HIP1112/receiver/device/id/item/@extension").getNodeValue(); - String inpatientNo; - int admissTimes; - String patientId; - String sysFlag = sender; - - Node inpatientNoNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/subject/patient/id/item[@root='2.16.156.10011.1.12']/@extension"); - if (Objects.isNull(inpatientNoNode)) { - throw new BaseException("未找到住院号节点!"); - } - inpatientNo = inpatientNoNode.getNodeValue(); - if (Func.isBlank(inpatientNo)) { - throw new BaseException("住院号解析为空!"); - } - Node admissTimesNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/componentOf1/encounter/id/item[@root='1.2.156.10011.1.2.1.7']/@extension"); - if (Objects.isNull(admissTimesNode)) { - throw new BaseException("未找到住院次数节点!"); - } - try { - admissTimes = Integer.parseInt(admissTimesNode.getNodeValue()); - } catch (Exception ex) { - throw new BaseException("无法解析住院次数!"); - } - if (admissTimes <= 0) { - throw new BaseException("住院次数解析不正常,应该为大于0的数字!"); - } - try { - patientId = tBasicMapper.getPatientIdByInpatientNoAndAdminssTimes(inpatientNo, admissTimes); - } catch (Exception ex) { - log.error("检查/检验召回,根据住院号:" + inpatientNo + ",和住院次数:" + admissTimes + ",无法匹配正确的患者!" + ex.getMessage(), ex); - throw new BaseException("匹配患者失败!"); - } - if (Func.isBlank(patientId)) { - throw new BaseException("无法匹配患者!"); + String mzFlag = "1"; + String zyFlag = "3"; + String flag = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/componentOf1/encounter/code/@code").getNodeValue(); + if (zyFlag.equals(flag)) { + handleZy(xmlUtil, sender); + } else if (mzFlag.equals(flag)) { + handleMz(xmlUtil, sender); } + return success(msgId, sender, receiver); + } catch (BaseException baseException) { + log.error(baseException.getMessage(), baseException); + return failed(msgId, sender, receiver, baseException.getMessage()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + return failed(msgId, sender, receiver, "系统错误!"); + } + } + private void handleMz(XmlUtil xmlUtil, String sender) { + String reportQueryMzInspectCollectorId = sdRyReportQueryConfig.getReportQueryMzInspectCollectorId(); + String reportQueryLisCollectorId = sdRyReportQueryConfig.getReportQueryLisCollectorId(); + // 处理门诊的 + String sdryIndex; + int admissTimes; + String patientId; - String jy = "1"; - String jc = "2"; - String reportAttribute = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/reportAttribute/@extension").getNodeValue(); - Node reportFlagNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/id[@root='2.16.156.10011.1.32']/@extension"); - String reportFlag = reportFlagNode.getNodeValue(); - if (Func.isBlank(reportFlag)) { - throw new BaseException("报告单号为空!"); - } + Node sdryIndexNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/subject/patient/id/item[@root='1.2.156.10011.1.2.1.2']/@extension"); - NodeList requestNoNodes = xmlUtil.getNodeList("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/inFulfillmentOf/order/id/@extension"); - int length = requestNoNodes.getLength(); - if (length > 0) { - for (int i = 0; i < length; i++) { - Node item = requestNoNodes.item(i); - String requestNo = item.getNodeValue(); - if (jc.equals(reportAttribute)) { - String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, requestNo, sender); - reportService.cancel(patientId, sysFlag, jianChaFileSerialnum); - } - if (jy.equals(reportAttribute)) { - String jianYanFileSerialnum = getJyFileSerialnum(reportFlag, requestNo); - reportService.cancel(patientId, sysFlag, jianYanFileSerialnum); - } - } - } else { + if (Objects.isNull(sdryIndexNode)) { + throw new BaseException("未找到域id节点!"); + } + sdryIndex = sdryIndexNode.getNodeValue(); + if (Func.isBlank(sdryIndex)) { + throw new BaseException("域ID解析为空!"); + } + Node admissTimesNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/componentOf1/encounter/id/item[@root='1.2.156.10011.1.2.1.7']/@extension"); + if (Objects.isNull(admissTimesNode)) { + throw new BaseException("未找到就诊次数节点!"); + } + try { + admissTimes = Integer.parseInt(admissTimesNode.getNodeValue()); + } catch (Exception ex) { + throw new BaseException("无法解析就诊次数!"); + } + if (admissTimes <= 0) { + throw new BaseException("就诊次数解析不正常,应该为大于0的数字!"); + } + + try { +// patientId = tBasicMapper.getPatientIdByInpatientNoAndAdminssTimes(inpatientNo, admissTimes); + patientId = tBasicMapper.getPatientIdBySdRyIndexAndAdmissTimes(sdryIndex, admissTimes + ""); + } catch (Exception ex) { +// log.error("门诊检查/检验召回,根据门急诊号:" + mzjNo + ",和就诊次数:" + admissTimes + ",无法匹配正确的患者!" + ex.getMessage(), ex); + log.error("门诊检查/检验召回,根据域id:" + sdryIndex + "无法匹配正确的患者!" + ex.getMessage(), ex); + return; + } + if (Func.isBlank(patientId)) { + log.error("门诊检查/检验召回,根据域id:" + sdryIndex + "无法匹配正确的患者!"); + return; + } + + + String jy = "1"; + String jc = "2"; + String reportAttribute = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/reportAttribute/@extension").getNodeValue(); + Node reportFlagNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/id[@root='2.16.156.10011.1.32']/@extension"); + String reportFlag = reportFlagNode.getNodeValue(); + if (Func.isBlank(reportFlag)) { + throw new BaseException("报告单号为空!"); + } + + NodeList requestNoNodes = xmlUtil.getNodeList("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/inFulfillmentOf/order/id/@extension"); + int length = requestNoNodes.getLength(); + if (length > 0) { + for (int i = 0; i < length; i++) { + Node item = requestNoNodes.item(i); + String requestNo = item.getNodeValue(); if (jc.equals(reportAttribute)) { - String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, null, sender); - if (Func.isNotBlank(jianChaFileSerialnum)) { - reportService.cancel(patientId, sysFlag, jianChaFileSerialnum); + String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, requestNo, sender); + reportService.cancel(patientId, reportQueryMzInspectCollectorId, jianChaFileSerialnum); + } + if (jy.equals(reportAttribute)) { + String jianYanFileSerialnum = getMzJyFileSerialnum(reportFlag, requestNo); + if (Func.isNotBlank(jianYanFileSerialnum)) { + reportService.cancel(patientId, reportQueryLisCollectorId, jianYanFileSerialnum); } } } - return success(msgId, sender, receiver); - } catch (BaseException baseException) { - log.error(baseException.getMessage(), baseException); - return failed(msgId, sender, receiver, baseException.getMessage()); + } else { + if (jc.equals(reportAttribute)) { + String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, null, sender); + if (Func.isNotBlank(jianChaFileSerialnum)) { + reportService.cancel(patientId, reportQueryMzInspectCollectorId, jianChaFileSerialnum); + } + } + } + + } + + private void handleZy(XmlUtil xmlUtil, String sender) { + // 处理住院 + String sdryIndex; + int admissTimes; + String patientId; + String sysFlag = sender; + + + Node sdryIndexNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/subject/patient/id/item[@root='1.2.156.10011.1.2.1.2']/@extension"); + + if (Objects.isNull(sdryIndexNode)) { + throw new BaseException("未找到域id节点!"); + } + sdryIndex = sdryIndexNode.getNodeValue(); + if (Func.isBlank(sdryIndex)) { + throw new BaseException("域ID解析为空!"); + } + + Node admissTimesNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/componentOf1/encounter/id/item[@root='1.2.156.10011.1.2.1.7']/@extension"); + if (Objects.isNull(admissTimesNode)) { + throw new BaseException("未找到住院次数节点!"); + } + try { + admissTimes = Integer.parseInt(admissTimesNode.getNodeValue()); } catch (Exception ex) { - log.error(ex.getMessage(), ex); - return failed(msgId, sender, receiver, "系统错误!"); + throw new BaseException("无法解析住院次数!"); + } + if (admissTimes <= 0) { + throw new BaseException("住院次数解析不正常,应该为大于0的数字!"); + } + try { + patientId = tBasicMapper.getPatientIdBySdRyIndexAndAdmissTimes(sdryIndex, admissTimes + ""); + } catch (Exception ex) { + log.error("住院检查/检验召回,根据域ID:" + sdryIndex + ",和住院次数:" + admissTimes + ",无法匹配正确的患者!" + ex.getMessage(), ex); + return; + } + if (Func.isBlank(patientId)) { + log.error("住院检查/检验召回,根据域ID:" + sdryIndex + ",和住院次数:" + admissTimes + ",无法匹配正确的患者!"); + return; + } + + + String jy = "1"; + String jc = "2"; + String reportAttribute = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/reportAttribute/@extension").getNodeValue(); + Node reportFlagNode = xmlUtil.getNode("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/id[@root='2.16.156.10011.1.32']/@extension"); + String reportFlag = reportFlagNode.getNodeValue(); + if (Func.isBlank(reportFlag)) { + throw new BaseException("报告单号为空!"); + } + + NodeList requestNoNodes = xmlUtil.getNodeList("/POOR_HIP1112/controlActProcess/subject/placerGroup/component/inFulfillmentOf/order/id/@extension"); + int length = requestNoNodes.getLength(); + if (length > 0) { + for (int i = 0; i < length; i++) { + Node item = requestNoNodes.item(i); + String requestNo = item.getNodeValue(); + if (jc.equals(reportAttribute)) { + String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, requestNo, sender); + reportService.cancel(patientId, sysFlag, jianChaFileSerialnum); + } + if (jy.equals(reportAttribute)) { + String jianYanFileSerialnum = getZyJyFileSerialnum(reportFlag, requestNo); + reportService.cancel(patientId, sysFlag, jianYanFileSerialnum); + } + } + } else { + if (jc.equals(reportAttribute)) { + String jianChaFileSerialnum = getJcFileSerialnum(reportFlag, null, sender); + if (Func.isNotBlank(jianChaFileSerialnum)) { + reportService.cancel(patientId, sysFlag, jianChaFileSerialnum); + } + } } } @@ -333,13 +436,26 @@ public class HIP1112RecallInspectionReportHandler implements WebserviceReceiveSe /** * @param reportFlag 报告单号 * @param requestNo 电子申请单号 - * @return 检验报告的归档唯一id + * @return 住院检验报告的归档唯一id */ - private String getJyFileSerialnum(String reportFlag, String requestNo) { + private String getZyJyFileSerialnum(String reportFlag, String requestNo) { return reportFlag + "@" + requestNo; } + /** + * @param reportFlag 报告单号 + * @param requestNo 电子申请单号 + * @return 门诊检验报告的归档唯一id + */ + private String getMzJyFileSerialnum(String reportFlag, String requestNo) { + if (Objects.isNull(requestNo)) { + return null; + } + return reportFlag + requestNo; + } + + /** * 返回检查报告新增成功消息 *