Index: ssts-web/src/main/webapp/disinfectsystem/config/bj309yy/spring/HIS.xml =================================================================== diff -u -r36287 -r36473 --- ssts-web/src/main/webapp/disinfectsystem/config/bj309yy/spring/HIS.xml (.../HIS.xml) (revision 36287) +++ ssts-web/src/main/webapp/disinfectsystem/config/bj309yy/spring/HIS.xml (.../HIS.xml) (revision 36473) @@ -1,4 +1,4 @@ - + - - - - - - - - - - - + + + + - - - - - - - - - - - Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/SyncOrgUnitAndUserDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/SyncOrgUnitAndUserDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/SyncOrgUnitAndUserDaoImpl.java (revision 36473) @@ -0,0 +1,195 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.bj309yy; + + +import java.util.ArrayList; +import java.util.List; + +import net.sf.json.JSONObject; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; + +import com.forgon.disinfectsystem.datasynchronization.dao.SyncOrgUnitAndUserDao; +import com.forgon.disinfectsystem.datasynchronization.model.OrgUnitVo; +import com.forgon.disinfectsystem.datasynchronization.model.UserVo; + +/** + * 查询科室与人员信息(北京309医院) + * + */ +public class SyncOrgUnitAndUserDaoImpl implements SyncOrgUnitAndUserDao { + + Logger logger = Logger.getLogger(SyncOrgUnitAndUserDaoImpl.class); + + @Override + public UserVo[] getAllUser() { + UserVo[] userVoArray = null; + List userVoList = new ArrayList(); + try { + String inputXml = WebServiceClientHelper.buildInputStr(DatasyncConstant.ACTION_USER_INFO_QUERY, null, null); + logger.info("人员同步接口请求信息:" + inputXml); + String result = WebServiceClientHelper.axisInvokeWebservice(DatasyncConstant.WebserviceAddress, DatasyncConstant.targetNamespace, DatasyncConstant.soapAction, DatasyncConstant.method, DatasyncConstant.paramName, inputXml, "utf-8"); + logger.info("人员同步接口返回信息:" + result); + //String result = "0C7202023072020230720;" + int startIndex = result.indexOf(""); + if(startIndex == -1){ + return null; + } + int endIndex = result.indexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + return null; + } + String xmlString = result.substring(startIndex + "".length(), endIndex); + xmlString = "" + xmlString + ""; + Document document = DocumentHelper.parseText(xmlString); + // 查询结果 + String resultCodeXpath = "/RESPONSE/RET_INFO/RET_CODE"; + String resultCotentXpath = "/RESPONSE/RET_INFO/RET_DESCRIPTION"; + String resultCode = WebServiceClientHelper.processDataByXpath(document, resultCodeXpath); + String resultCotent = WebServiceClientHelper.processDataByXpath(document, resultCotentXpath); + if(!StringUtils.equals(resultCode, DatasyncConstant.RET_CODE_SUCCESS)){ + logger.info("用户信息查询失败:" + resultCotent); + return null; + } + String itemXpath = "/RESPONSE/MSG_INFO/MSG/USER_LIST/USER"; // 返回结果可能存在多条用户信息 + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + for (int i = 1; i <= nodeList.size(); i++) { + + String msgXpath = "/RESPONSE/MSG_INFO/MSG/USER_LIST/USER[" + i + "]"; + // 工号 + String codeXpath = msgXpath + "/USER_CODE"; + // 姓名 + String nameXpath = msgXpath + "/USER_NAME"; + // 上级科室编码 + String orgUnitCodeXpath = msgXpath + "/ORGUNIT_CODE"; + + String code = WebServiceClientHelper.processDataByXpath(document, codeXpath); + String name = WebServiceClientHelper.processDataByXpath(document, nameXpath); + String orgUnitCoding = WebServiceClientHelper.processDataByXpath(document, orgUnitCodeXpath); + UserVo userVo = new UserVo(); + userVo.setCoding(code); + userVo.setName(name); + userVo.setOrgUnitCoding(orgUnitCoding); + + //如果人员工号或名称为空,则忽略该条数据 + if(StringUtils.isBlank(userVo.getName()) || StringUtils.isBlank(userVo.getCoding())){ + continue; + } + userVoList.add(userVo); + } + userVoArray = new UserVo[userVoList.size()]; + userVoList.toArray(userVoArray); + } else { + logger.info("未找到人员数据"); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("查询人员信息失败:" + e); + } + return userVoArray; + } + + @Override + public OrgUnitVo[] getAllOrgUnit() { + OrgUnitVo[] orgUnitVoArray = null; + List orgUnitVoList = new ArrayList(); + try { + String inputXml = WebServiceClientHelper.buildInputStr(DatasyncConstant.ACTION_ORGUNIT_INFO_QUERY, null, null); + logger.info("科室同步接口请求信息:" + inputXml); + String result = WebServiceClientHelper.axisInvokeWebservice(DatasyncConstant.WebserviceAddress, DatasyncConstant.targetNamespace, DatasyncConstant.soapAction, DatasyncConstant.method, DatasyncConstant.paramName, inputXml, "utf-8"); + logger.info("科室同步接口返回信息:" + result); + //String result = " 0202307204009H20230720测试科室]]>;" + int startIndex = result.indexOf(""); + if(startIndex == -1){ + return null; + } + int endIndex = result.indexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + return null; + } + String xmlString = result.substring(startIndex + "".length(), endIndex); + xmlString = "" + xmlString + ""; + Document document = DocumentHelper.parseText(xmlString); + // 查询结果 + String resultCodeXpath = "/RESPONSE/RET_INFO/RET_CODE"; + String resultCotentXpath = "/RESPONSE/RET_INFO/RET_DESCRIPTION"; + String resultCode = WebServiceClientHelper.processDataByXpath(document, resultCodeXpath); + String resultCotent = WebServiceClientHelper.processDataByXpath(document, resultCotentXpath); + if(!StringUtils.equals(resultCode, DatasyncConstant.RET_CODE_SUCCESS)){ + logger.info("科室信息查询失败:" + resultCotent); + return null; + } + String itemXpath = "/RESPONSE/MSG_INFO/MSG/ORGUNIT_LIST/ORGUNIT"; // 返回结果可能存在多条科室信息 + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + for (int i = 1; i <= nodeList.size(); i++) { + + String msgXpath = itemXpath + "[" + i + "]"; + // 科室编码 + String codeXpath = msgXpath + "/ORGUNIT_CODE"; + // 科室名称 + String nameXpath = msgXpath + "/ORGUNIT_NAME"; + // 上级科室编码 + String parentCodingXpath = msgXpath + "/PARENT_ORGUNIT_CODE"; + + String code = WebServiceClientHelper.processDataByXpath(document, codeXpath); + String name = WebServiceClientHelper.processDataByXpath(document, nameXpath); + String parentCoding = WebServiceClientHelper.processDataByXpath(document, parentCodingXpath); + OrgUnitVo orgUnitVo = new OrgUnitVo(); + orgUnitVo.setCoding(code); + orgUnitVo.setName(name); + orgUnitVo.setParentCoding(parentCoding); + + //科室编码与上级科室编码相同时,默认其上级科室编码为空 + if(StringUtils.equals(orgUnitVo.getCoding(), orgUnitVo.getParentCoding())){ + orgUnitVo.setParentCoding(null); + } + //如果科室编码或名称为空,则忽略该条数据 + if(StringUtils.isBlank(orgUnitVo.getCoding()) || StringUtils.isBlank(orgUnitVo.getName())){ + continue; + } + orgUnitVoList.add(orgUnitVo); + } + orgUnitVoArray = new OrgUnitVo[orgUnitVoList.size()]; + orgUnitVoList.toArray(orgUnitVoArray); + } else { + logger.info("未找到科室数据"); + } + } catch (Exception e) { + e.printStackTrace(); + logger.error("科室信息失败" + e); + } + return orgUnitVoArray; + } + + @Override + public OrgUnitVo[] paramToOrgUnitVos(String param) { + // TODO Auto-generated method stub + return null; + } + + @Override + public UserVo[] paramToUserVos(String param) { + // TODO Auto-generated method stub + return null; + } + + @Override + public JSONObject buttjoinResponse(Boolean success, String message, + String param) { + // TODO Auto-generated method stub + return null; + } + + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/DatasyncConstant.java (revision 36473) @@ -0,0 +1,62 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.bj309yy; + +/** + * 北京309医院接口相关常量 + * + */ +public class DatasyncConstant { + + /** + * 科室信息、人员信息、患者信息Web Service接口地址:http://172.25.0.82:9090/services/HisMessageServiceV1 + */ + public final static String WebserviceAddress = "http://172.25.0.82:9090/services/HisMessageServiceV1"; + + public final static String targetNamespace = "http://service.forgon.com/"; + + public final static String soapAction = "HisMessageServiceV1"; + + public final static String method = "HisMessageServiceV1"; + + public final static String paramName = "message"; + + /** + * 科室查询的action + */ + public static String ACTION_ORGUNIT_INFO_QUERY = "ORGUNIT_INFO_QUERY"; + + /** + * 人员查询的action + */ + public static String ACTION_USER_INFO_QUERY = "USER_INFO_QUERY"; + + /** + * 患者信息查询的action + */ + public static String ACTION_PATIENT_INFO_QUERY = "PATIENT_INFO_QUERY"; + + /** + * 根据住院号查询 + */ + public static String CODE_TYPE_HOSPITAL_NUMBER = "INHOSP_INDEX_NO"; + + /** + * 根据诊疗号查询 + */ + public static String CODE_TYPE_TREATMENT_NUMBER = "OUTHOSP_INDEX_NO"; + + /** + * 根据手术单号查询 + */ + public static String CODE_TYPE_OPRATION_SCHEDULEID = "SURGERY_APPLI_FORM_NO"; + + /** + * 调用成功的返回码 + */ + public static String RET_CODE_SUCCESS = "0"; + + /** + * 调用失败的返回码 + */ + public static String RET_CODE_FAIL = "1"; + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/FindPatientInfoByHospitalNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/FindPatientInfoByHospitalNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/bj309yy/FindPatientInfoByHospitalNumDaoImpl.java (revision 36473) @@ -0,0 +1,253 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.bj309yy; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; + +import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.tools.date.DateTools; + +/** + * 根据住院号查询病人信息(北京309医院) + * + */ +public class FindPatientInfoByHospitalNumDaoImpl implements + FindPatientInfoByHospitalNumDao { + + Logger logger = Logger.getLogger(FindPatientInfoByHospitalNumDaoImpl.class); + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNum(String hospitalNum) { + try { + String inputXml = WebServiceClientHelper.buildInputStr(DatasyncConstant.ACTION_PATIENT_INFO_QUERY, DatasyncConstant.CODE_TYPE_HOSPITAL_NUMBER, hospitalNum); + logger.info("住院病人信息同步接口请求信息:" + inputXml); + String result = WebServiceClientHelper.axisInvokeWebservice(DatasyncConstant.WebserviceAddress, DatasyncConstant.targetNamespace, DatasyncConstant.soapAction, DatasyncConstant.method, DatasyncConstant.paramName, inputXml, "utf-8"); + logger.info("病人信息同步接口返回信息:" + result); + /*String result = "" + + "" + + "0" + + "" + + "" + + "" + + "" + + "" + + "" + + "0000000001" + + "" + + "1" + + "1" + + "患者1" + + "" + + "1990-07-20 10:00:00" + + "手术名称" + + "2023-07-25 17:48:00" + + "001" + + "医生" + + "" + + "GY护士1" + + "" + + "洗手护士" + + "4009H" + + "" + + "" + + "" + + "0000000001" + + "" + + "1" + + "1" + + "患者1" + + "" + + "1990-07-20 10:00:00" + + "手术名称" + + "2023-07-25 17:48:00" + + "001" + + "医生" + + "" + + "GY护士1" + + "" + + "洗手护士" + + "4009H" + + "" + + "" + + "" + + "" + + "" + + ""; + logger.info("病人信息同步接口返回信息:" + result);*/ + int startIndex = result.indexOf(""); + if(startIndex == -1){ + logger.info("住院病人接口返回信息没有标签!"); + return null; + } + int endIndex = result.indexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + logger.info("住院病人接口返回信息没有标签"); + return null; + } + String xmlString = result.substring(startIndex + "".length(), endIndex); + if(StringUtils.isBlank(xmlString)){ + logger.info("住院病人接口返回信息为空!" + xmlString); + return null; + } + xmlString = "" + xmlString + ""; + Document document = DocumentHelper.parseText(xmlString); + // 查询结果 + String resultCodeXpath = "/RESPONSE/RET_INFO/RET_CODE"; + String resultCotentXpath = "/RESPONSE/RET_INFO/RET_DESCRIPTION"; + String resultCode = WebServiceClientHelper.processDataByXpath(document, resultCodeXpath); + String resultCotent = WebServiceClientHelper.processDataByXpath(document, resultCotentXpath); + if(!StringUtils.equals(resultCode, DatasyncConstant.RET_CODE_SUCCESS)){ + logger.info("住院病人接口查询失败:" + resultCotent); + return null; + } + String itemXpath = "/RESPONSE/MSG_INFO/MSG/SURGERY_LIST/SURGERY"; // 返回结果可能存在多条住院病人信息 + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + List patientInfoVOList = new ArrayList(); + for (int i = 1; i <= nodeList.size(); i++) { + String msgXpath = itemXpath + "[" + i + "]"; + // 住院号 + String hospitalNumberXpath = msgXpath + "/INHOSP_INDEX_NO"; + // 流水号 + String serialNumberXpath = msgXpath + "/VISIT_ID"; + // 所属科室 + String ascriptionDepartmentXpath = msgXpath + "/DEPT_STAYED"; + // 手术时间 + String operationTimeXpath = msgXpath + "/SCHEDULED_DATETIME"; + // 手术间 + String opRoomIdXpath = msgXpath + "/OPERATING_ROOM_NO"; + // 医生姓名 + String doctorNameXpath = msgXpath + "/SURGEON"; + //巡回护士 + String circuitNurseXpath = msgXpath + "/FIRST_OPERATION_NURSE"; + //洗手护士 + String washHandNurseXpath = msgXpath + "/FIRST_SUPPLY_NURSE"; + // 手术单号 + String operationScheduleIdXpath = msgXpath + "/SURGERY_APPLI_FORM_NO"; + // 手术名称 + String operationXpath = msgXpath + "/OPERATION"; + // 病人姓名 + String patientNameXpath = msgXpath + "/NAME"; + // 病人年龄 + String patientBirthDayXpath = msgXpath + "/DATE_OF_BIRTH"; + // 病人性别 + String patientSexXpath = msgXpath + "/SEX"; + + String hospitalNumber = WebServiceClientHelper.processDataByXpath(document, hospitalNumberXpath); + String serialNumber = WebServiceClientHelper.processDataByXpath(document, serialNumberXpath); + String ascriptionDepartment = WebServiceClientHelper.processDataByXpath(document, ascriptionDepartmentXpath); + String operationTime = WebServiceClientHelper.processDataByXpath(document, operationTimeXpath); + String opRoomId = WebServiceClientHelper.processDataByXpath(document, opRoomIdXpath); + String doctorName = WebServiceClientHelper.processDataByXpath(document, doctorNameXpath); + String circuitNurse = WebServiceClientHelper.processDataByXpath(document, circuitNurseXpath); + String washHandNurse = WebServiceClientHelper.processDataByXpath(document, washHandNurseXpath); + String operationScheduleId = WebServiceClientHelper.processDataByXpath(document, operationScheduleIdXpath); + String operation = WebServiceClientHelper.processDataByXpath(document, operationXpath); + String patientName = WebServiceClientHelper.processDataByXpath(document, patientNameXpath); + String patientSex = WebServiceClientHelper.processDataByXpath(document, patientSexXpath); + String patientAge = null; + String patientBirthDate = WebServiceClientHelper.processDataByXpath(document, patientBirthDayXpath); + Integer age = getAgeByDateTime(patientBirthDate); + if(age != null){ + patientAge = age.intValue() + ""; + } + + PatientInfoVO patientInfoVO = new PatientInfoVO(); + patientInfoVO.setHospitalNumber(hospitalNumber); + patientInfoVO.setSerialNumber(serialNumber); + patientInfoVO.setAscriptionDepartment(ascriptionDepartment); + patientInfoVO.setOperationTime(operationTime); + patientInfoVO.setOpRoomId(opRoomId); + patientInfoVO.setDoctorName(doctorName); + patientInfoVO.setCircuitNurse(circuitNurse); + patientInfoVO.setWashHandNurse(washHandNurse); + patientInfoVO.setOperationScheduleId(operationScheduleId); + patientInfoVO.setOperation(operation); + patientInfoVO.setPatientName(patientName); + patientInfoVO.setPatientAge(patientAge); + patientInfoVO.setPatientSex(patientSex); + + patientInfoVOList.add(patientInfoVO); + } + if (CollectionUtils.isNotEmpty(patientInfoVOList)) { + // 只取最新录入的一条记录 + PatientInfoVO patientInfoVO = patientInfoVOList.get(0); + logger.debug("完成住院病人信息解析,病人住院号为:" + patientInfoVO.getHospitalNumber()); + PatientInfoVO[] patientInfoArray = new PatientInfoVO[patientInfoVOList.size()]; + for(int i=0;i"); + inputSb.append("" + DatasyncConstant.ACTION_ORGUNIT_INFO_QUERY + ""); + inputSb.append(""); + inputSb.append("" + StringUtils.defaultString(code) + ""); + inputSb.append(""); + inputSb.append(""); + } else if(StringUtils.equals(action, DatasyncConstant.ACTION_USER_INFO_QUERY)){ + inputSb.append(""); + inputSb.append("" + DatasyncConstant.ACTION_USER_INFO_QUERY + ""); + inputSb.append(""); + inputSb.append("" + StringUtils.defaultString(code) + ""); + inputSb.append(""); + inputSb.append(""); + } else if(StringUtils.equals(action, DatasyncConstant.ACTION_PATIENT_INFO_QUERY)){ + if(StringUtils.equals(codeType, DatasyncConstant.CODE_TYPE_HOSPITAL_NUMBER)){ + inputSb.append(""); + inputSb.append("" + DatasyncConstant.ACTION_PATIENT_INFO_QUERY + ""); + inputSb.append(""); + inputSb.append("" + DatasyncConstant.CODE_TYPE_HOSPITAL_NUMBER + ""); + inputSb.append("" + StringUtils.defaultString(code) + ""); + inputSb.append(""); + inputSb.append(""); + } else if(StringUtils.equals(codeType, DatasyncConstant.CODE_TYPE_TREATMENT_NUMBER)){ + inputSb.append(""); + inputSb.append("" + DatasyncConstant.ACTION_PATIENT_INFO_QUERY + ""); + inputSb.append(""); + inputSb.append("" + DatasyncConstant.CODE_TYPE_TREATMENT_NUMBER + ""); + inputSb.append("" + StringUtils.defaultString(code) + ""); + inputSb.append(""); + inputSb.append(""); + } else if(StringUtils.equals(codeType, DatasyncConstant.CODE_TYPE_OPRATION_SCHEDULEID)){ + inputSb.append(""); + inputSb.append("" + DatasyncConstant.ACTION_PATIENT_INFO_QUERY + ""); + inputSb.append(""); + inputSb.append("" + DatasyncConstant.CODE_TYPE_OPRATION_SCHEDULEID + ""); + inputSb.append("" + StringUtils.defaultString(code) + ""); + inputSb.append(""); + inputSb.append(""); + } else{ + throw new RuntimeException("无效的codeType值"); + } + } else { + throw new RuntimeException("无效的action值"); + } + return inputSb.toString(); + } + + /** + * axis调用webservice + * @param endpoint + * @param targetNamespace 命名空间,在WSDL中对应的标签是:targetNamespace  + * @param soapActionURI 具体方法的调用URI,在WSDL中对应的标签是: + * @param method 具体调用的方法名,在WSDL中对应的标签是: + * @param paramName 调用接口的参数的名字 + * @param input 参数值 + * @param encodingStyle 字符集"utf-8" + * @return + * @throws Exception + */ + public static String axisInvokeWebservice(String endpoint, String targetNamespace, String soapActionURI, String method, + String paramName, String input, String encodingStyle) throws Exception { + //logger.info("input : " + input); + Service service = new Service(); + Call call = (Call) service.createCall(); + //call.setTimeout(new Integer(20000)); //设置超时时间 + call.setSOAPActionURI(soapActionURI); + call.setTargetEndpointAddress(new java.net.URL(endpoint)); //设置目标接口的地址 + call.setEncodingStyle(encodingStyle);//设置传入服务端的字符集格式如utf-8等 + call.setOperationName(new QName(targetNamespace, method));// 具体调用的方法名,可以由接口提供方告诉你,也可以自己从WSDL中找 + call.setUseSOAPAction(true); + call.addParameter(paramName, + org.apache.axis.encoding.XMLType.XSD_STRING, + javax.xml.rpc.ParameterMode.IN);// 接口的参数 + call.setReturnClass(java.lang.String.class); //返回字符串类型 + // 给方法传递参数,并且调用方法 ,如果无参,则new Obe + String result = (String)call.invoke(new String[] {input}); + // 打印返回值 + //logger.info("result is " + result); + return result; + } + +}