Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByTreatmentNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 40587) @@ -0,0 +1,92 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qhrsgzzyy; + +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByTreatmentNumDao; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.tools.Constants; +import com.forgon.tools.date.DateTools; + +/** + * 【接口管理】开发获取患者信息的webservice接口,用于【外来器械申请】以及【病人使用记录】填写 + * QHRSGZZYY-17 + */ +public class FindPatientInfoByTreatmentNumDaoImpl implements FindPatientInfoByTreatmentNumDao { + + Logger logger = Logger.getLogger(this.getClass()); + + /** + * 接口地址 + */ + private String webServiceAddress; + + public String getWebServiceAddress() { + return webServiceAddress; + } + + public void setWebServiceAddress(String webServiceAddress) { + this.webServiceAddress = webServiceAddress; + } + + @Override + public PatientInfoVO[] findPatientInfoByTreatmentNum(String treatmentNum) { + if(StringUtils.isBlank(treatmentNum)){ + return null; + } + PatientInfoVO[] patientInfoArray = null; + try { + logger.debug("诊疗号(患者登记号)病人信息接口地址:" + webServiceAddress); + String request = WebServiceClientHelper.buildHospitalNumRequest(DatasyncConstant.TYPE_TREATMENTNUM, treatmentNum); + logger.debug("诊疗号(患者登记号)病人信息接口请求信息:" + request); + String responce = CssdUtils.callWebService(webServiceAddress, request, Constants.CHARSET_utf8, DatasyncConstant.SOAP_ACTION); + //String responce = " 111232 40331 522702 3612193 0000522541 167042 3612193 3612193||1 31 恢复室 恢复室 7 07 张凌翔 12岁 张凌翔(男 12岁) 跨省异地 66 结直肠肛门外科 47 结直肠肛门外科放疗科护理单元 47||20 1118床 结直肠肛门外科放疗科护理单元 1118床 66 结直肠肛门外科 JZCGMWK 129 中心手术部 K61.001,N47.x01 肛周脓肿,包皮过长 40156,41844 肛门瘘管切除术,包皮环切术 肛门,会阴 肛门瘘管切除术(二级,肛门),包皮环切术(一级,会阴) 30,1042 惠庆申,蔡亮 HQS,CL 838,838 蔡榛彬 惠庆申,蔡亮,蔡榛彬 1521 许腾飞 2025-07-08 2025-07-08 08:00:00 2025-07-07 08:54:59 血型:A型,RH血型:阳性(+) 5 RoomOut 术毕 #F2FFFF B 择期 N N N N A型 阳性(+) 化验中 化验中 化验中 化验中 08:00:00 1 21 喉罩全麻 449 陈郡兴 2835 沈浩欢 陈郡兴,沈浩欢 54.6 159 2025-07-08 12:25:00 2025-07-08 13:15:00 2025-07-08 12:00:00 2025-07-08 13:35:00 阴性(-) A型 阳性(+) N Y / Ward 2025-07-08 13:36:00 2025-07-08 14:05:00 肛门瘘管切除术(二级,肛门),包皮环切术(一级,会阴) 2 II级 / 5 截石位 喉罩全麻 2025-07-07 08:10:31 陈郡兴 姚蒙蒙 结直肠肛门外科 1118床 1524 周佳敏 2025-07-08 12:10:00 2025-07-08 14:05:00 喉罩全麻 21 喉罩全麻 肛门瘘管切除术(二级,肛门),包皮环切术(一级,会阴) 11间 838 500 2 498 21.60 258574 258574 111232 40156 肛门瘘管切除术 6 二级 4 Ⅲ类切口 28 肛门 17 30 惠庆申 HQS 838 蔡榛彬 肛门瘘管切除术 258575 258575 111232 41844 包皮环切术 2 一级 2 Ⅰ类切口 29 会阴 17 1042 蔡亮 CL 838 蔡榛彬 包皮环切术 ]]> "; + logger.debug("诊疗号(患者登记号)病人信息接口返回信息:" + responce); + List patientInfoVOList = WebServiceClientHelper.buildPatientInfoVO(responce); + if(CollectionUtils.isEmpty(patientInfoVOList)){ + return null; + } + patientInfoVOList = patientInfoVOList.stream().sorted(new Comparator() { + @Override + public int compare(PatientInfoVO o1, PatientInfoVO o2) { + Date operationTime1 = null; + try { + operationTime1 = DateTools.coverStrToDate(o1.getOperationTime(), DateTools.COMMON_DATE_HMS); + } catch (Exception e) { + e.printStackTrace(); + } + Date operationTime2 = null; + try { + operationTime2 = DateTools.coverStrToDate(o2.getOperationTime(), DateTools.COMMON_DATE_HMS); + } catch (Exception e) { + e.printStackTrace(); + } + if(operationTime1 == null && operationTime2 == null){ + return 0; + } + if(operationTime1 != null && operationTime2 == null){ + return -1; + } + if(operationTime1 == null && operationTime2 != null){ + return 1; + } + return operationTime2.compareTo(operationTime1); + } + }).collect(Collectors.toList()); + patientInfoArray = new PatientInfoVO[patientInfoVOList.size()]; + patientInfoVOList.toArray(patientInfoArray); + } catch (Exception e) { + e.printStackTrace(); + logger.debug("诊疗号(患者登记号)病人信息接口查询失败:" + e.getMessage()); + } + return patientInfoArray; + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByHospitalNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 40587) @@ -0,0 +1,97 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qhrsgzzyy; + +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.tools.Constants; +import com.forgon.tools.date.DateTools; + +/** + * 【接口管理】开发获取患者信息的webservice接口,用于【外来器械申请】以及【病人使用记录】填写 + * QHRSGZZYY-17 + */ +public class FindPatientInfoByHospitalNumDaoImpl implements FindPatientInfoByHospitalNumDao { + + Logger logger = Logger.getLogger(this.getClass()); + + /** + * 接口地址 + */ + private String webServiceAddress; + + public String getWebServiceAddress() { + return webServiceAddress; + } + + public void setWebServiceAddress(String webServiceAddress) { + this.webServiceAddress = webServiceAddress; + } + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNum(String hospitalNum) { + if(StringUtils.isBlank(hospitalNum)){ + return null; + } + PatientInfoVO[] patientInfoArray = null; + try { + logger.debug("住院号(患者病案号)病人信息接口地址:" + webServiceAddress); + String request = WebServiceClientHelper.buildHospitalNumRequest(DatasyncConstant.TYPE_HOSPITALNUMBER, hospitalNum); + logger.debug("住院号(患者病案号)病人信息接口请求信息:" + request); + String responce = CssdUtils.callWebService(webServiceAddress, request, Constants.CHARSET_utf8, DatasyncConstant.SOAP_ACTION); + //String responce = " 53324 19072 431560 1848129 0000431423 131898 1848129 1848129||4 2 2间 2间 5 05 卢杰萍 41岁 卢杰萍(女 41岁) 职工医保 153 手术室 41 肝胆甲乳护理单元 41||21 1019床 肝胆甲乳护理单元 1019床 153 肝胆外科 GDWK 129 中心手术部 R93.203 肝占位性病变 45494 静脉输液港植入术 其他部位 仰卧位 静脉输液港植入术(二级,其他部位) 1217 黄雨 HY 919 木塔力甫·斯来曼 黄雨,木塔力甫·斯来曼 1043 李世杰 2023-03-31 2023-03-31 14:00:00 2023-03-31 10:32:19 血型:AB型,RH血型:阳性(+) 7 Finish 完成 #F2FFFF E 急诊 N N N N AB型 阳性(+) 阴性(-) 阴性(-) 阴性(-) 阴性(-) 14:00:00 10 局部浸润麻醉 N 54.4 161 2023-03-31 14:00:00 2023-03-31 19:50:00 阴性(-) AB型 阳性(+) N 20.99 120611 120611 53324 45494 静脉输液港植入术 6 二级 2 Ⅰ类切口 其他部位 仰卧位 1217 黄雨 919 木塔力甫·斯来曼 静脉输液港植入术 ]]> "; + logger.debug("住院号(患者病案号)病人信息接口返回信息:" + responce); + List patientInfoVOList = WebServiceClientHelper.buildPatientInfoVO(responce); + if(CollectionUtils.isEmpty(patientInfoVOList)){ + return null; + } + patientInfoVOList = patientInfoVOList.stream().sorted(new Comparator() { + @Override + public int compare(PatientInfoVO o1, PatientInfoVO o2) { + Date operationTime1 = null; + try { + operationTime1 = DateTools.coverStrToDate(o1.getOperationTime(), DateTools.COMMON_DATE_HMS); + } catch (Exception e) { + e.printStackTrace(); + } + Date operationTime2 = null; + try { + operationTime2 = DateTools.coverStrToDate(o2.getOperationTime(), DateTools.COMMON_DATE_HMS); + } catch (Exception e) { + e.printStackTrace(); + } + if(operationTime1 == null && operationTime2 == null){ + return 0; + } + if(operationTime1 != null && operationTime2 == null){ + return -1; + } + if(operationTime1 == null && operationTime2 != null){ + return 1; + } + return operationTime2.compareTo(operationTime1); + } + }).collect(Collectors.toList()); + patientInfoArray = new PatientInfoVO[patientInfoVOList.size()]; + patientInfoVOList.toArray(patientInfoArray); + } catch (Exception e) { + e.printStackTrace(); + logger.info("住院号(患者病案号)病人信息接口查询失败:" + e.getMessage()); + } + return patientInfoArray; + } + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNumBeforeOperation(String hospitalNum) { + return this.findPatientInfoByHospitalNum(hospitalNum); + } + +} Index: ssts-basedata/src/main/java/com/forgon/disinfectsystem/common/CssdUtils.java =================================================================== diff -u -r40302 -r40587 --- ssts-basedata/src/main/java/com/forgon/disinfectsystem/common/CssdUtils.java (.../CssdUtils.java) (revision 40302) +++ ssts-basedata/src/main/java/com/forgon/disinfectsystem/common/CssdUtils.java (.../CssdUtils.java) (revision 40587) @@ -1151,6 +1151,20 @@ */ public static String callWebService(String wsdl, String soap , String charset) throws Exception{ + return callWebService(wsdl, soap, charset, null); + } + + /** + * 调用webservice方法 + * @param wsdl webservice接口地址 + * @param soap 输入参数 + * @param charset 字符编码集 + * @param SOAPAction SOAPAction + * @return 接口返回的xml + * @throws Exception + */ + public static String callWebService(String wsdl, String soap , String charset, String SOAPAction) + throws Exception{ StringBuilder sb = new StringBuilder(); HttpURLConnection conn = null; try { @@ -1164,6 +1178,9 @@ conn.setRequestProperty("Content-Type", "text/xml; charset=" + charset); conn.setRequestProperty("Charset", charset); conn.setRequestProperty("contentType", charset); + if(StringUtils.isNotBlank(SOAPAction)){ + conn.setRequestProperty("SOAPAction", SOAPAction); + } conn.setDoOutput(true); conn.setDoInput(true); conn.setConnectTimeout(20000); @@ -1201,6 +1218,7 @@ } } catch (Exception e) { e.printStackTrace(); + logger.debug("接口调用异常:"+ e.getMessage()); }finally{ if(conn!=null){ conn.disconnect(); Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/WebServiceClientHelper.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/WebServiceClientHelper.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/WebServiceClientHelper.java (revision 40587) @@ -0,0 +1,177 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qhrsgzzyy; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; + +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.exception.SystemException; + +/** + * 【接口管理】开发获取患者信息的webservice接口,用于【外来器械申请】以及【病人使用记录】填写 + * QHRSGZZYY-17 + */ +public class WebServiceClientHelper { + + /** + * 构建根据住院号查询患者信息的请求信息 + * @param type 类型 + * @param number 住院号/诊疗号 + * @return + */ + public static String buildHospitalNumRequest(String type, String number) { + StringBuffer requestBuffer = new StringBuffer() + .append("") + .append("") + .append("") + .append("") + .append("" + DatasyncConstant.ACTION_CODE + "") + .append("") + .append("") + .append("") + .append(number) + .append("") + .append("") + .append(DatasyncConstant.TYPE_HOSPITALNUMBER) + .append("") + .append(""); + }else if(StringUtils.equals(type, DatasyncConstant.TYPE_TREATMENTNUM)){ + requestBuffer.append("") + .append("") + .append(number) + .append("") + .append("") + .append(DatasyncConstant.TYPE_TREATMENTNUM) + .append("") + .append(""); + }else{ + throw new RuntimeException("住院号和诊疗号不能都为空!"); + } + requestBuffer.append("]]>") + .append("") + .append("") + .append("") + .append(""); + return requestBuffer.toString(); + } + + /** + * 解析xml并返回患者信息 + * @param result 接口返回的xml + * @return 患者信息 + */ + @SuppressWarnings("unchecked") + public static List buildPatientInfoVO(String result) throws Exception { + if(StringUtils.isBlank(result)){ + throw new SystemException("接口返回的参数为空!"); + } + int startIndex = result.indexOf(""); + if(startIndex == -1){ + throw new SystemException("接口返回的参数为空!"); + } + int endIndex = result.lastIndexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + throw new SystemException("接口返回的参数为空!"); + } + String xmlString = result.substring(startIndex + "".length(), endIndex); + //去除 + xmlString = replaceCDATA(xmlString); + if(StringUtils.isBlank(xmlString)){ + throw new SystemException("接口返回的参数为空!"); + } + + Document document = DocumentHelper.parseText(xmlString); + String itemXpath = "/Result/OperInfo"; // 返回结果可能存在多条住院病人信息 + XPath xpath = document.createXPath(itemXpath); + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + List patientInfoVOList = new ArrayList(); + for (int i = 1; i <= nodeList.size(); i++) { + String operInfoXpath = itemXpath + "[" + i + "]"; + String clinicNumber = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/RegNo"); + String hospitalNumber = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/MedcareNo"); + String patientName = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatName"); + String patientIDCard = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatCardID"); + String patientSex = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatGender"); + String patientAge = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatAge"); + String operationTime = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/OperDateTime"); + String ascriptionDepartCode = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatDeptID"); + String ascriptionDepartment = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatDeptDesc"); + String patientArea = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatWardDesc"); + String bedNumber = WebServiceClientHelper.processDataByXpath(document, operInfoXpath + "/PatBedCode"); + + String operationListRowXpathStr = operInfoXpath + "/OperationList/Row"; + XPath operationListRowXpath = document.createXPath(operationListRowXpathStr); + List operationListRowNodeList = operationListRowXpath.selectNodes(document, operationListRowXpath); + if(CollectionUtils.isNotEmpty(operationListRowNodeList)){ + for (int j = 1; j <= operationListRowNodeList.size(); j++) { + String operationXpath = operationListRowXpathStr+ "[" + j + "]"; + String operation = WebServiceClientHelper.processDataByXpath(document, operationXpath + "/OperationDesc"); + String doctorName = WebServiceClientHelper.processDataByXpath(document, operationXpath + "/SurgeonDesc"); + PatientInfoVO patientInfoVO = new PatientInfoVO(); + patientInfoVO.setClinicNumber(clinicNumber); + patientInfoVO.setHospitalNumber(hospitalNumber); + patientInfoVO.setPatientName(patientName); + patientInfoVO.setPatientIDCard(patientIDCard); + patientInfoVO.setPatientSex(patientSex); + patientInfoVO.setPatientAge(patientAge); + patientInfoVO.setOperationTime(operationTime); + patientInfoVO.setAscriptionDepartCode(ascriptionDepartCode); + patientInfoVO.setAscriptionDepartment(ascriptionDepartment); + patientInfoVO.setPatientArea(patientArea); + patientInfoVO.setBedNumber(bedNumber); + patientInfoVO.setOperation(operation); + patientInfoVO.setDoctorName(doctorName); + patientInfoVOList.add(patientInfoVO); + } + } + } + return patientInfoVOList; + } + + return null; + } + + /** + * 去除 + * @param xmlString 接口返回的xml + * @return 患者信息xml + */ + private static String replaceCDATA(String xmlString) { + if(StringUtils.isBlank(xmlString)){ + return xmlString; + } + int startIndex = xmlString.indexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + return xmlString; + } + return xmlString.substring(startIndex + " - - - - - - - - - + + + - - - - - - - - - + + + Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qhrsgzzyy/DatasyncConstant.java (revision 40587) @@ -0,0 +1,35 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qhrsgzzyy; + +/** + * 【接口管理】开发获取患者信息的webservice接口,用于【外来器械申请】以及【病人使用记录】填写 + * QHRSGZZYY-17 + */ +public class DatasyncConstant { + + /** + * 住院号、治疗号(腕带)都调用这个接口获取患者信息 + */ + //public static final String WEB_SERVICE_ADDRESS = "http://10.254.241.9/csp/hsb/DHC.Published.PUB0036.BS.PUB0036.cls"; + + /** + * soapAction + */ + public static final String SOAP_ACTION = "http://www.dhcc.com.cn/DHC.Published.PUB0036.BS.PUB0036.HIPManagerServer"; + + /** + * 入参的action + */ + public static final String ACTION_CODE = "MES0808"; + + /** + * MedcareNo 患者病案号 住院号 + */ + public static final String TYPE_HOSPITALNUMBER = "MedcareNo"; + + /** + * RegNo 患者登记号 诊疗号 + */ + public static final String TYPE_TREATMENTNUM = "RegNo"; + + +}