Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/DatasyncConstant.java (revision 40507) @@ -0,0 +1,33 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.szslgqdsrmyy; + +/** + * 【组织机构】【患者使用记录】【外来器械申请单】集成平台的科室、人员及病人信息接口开发(基于HTTP POST协议)SZLGSY-10 + */ +public class DatasyncConstant { + + /** + * 组织结构、人员信息及患者信息接口地址 + */ + public final static String SYNC_ADDRESS = "http://172.16.100.10:7808/query"; + + /** + * 接口说明 医疗卫生人员信息查询服务 + */ + public final static String SERVICE_NAME_USER = "ProviderInfoQuery"; + + /** + * 医疗卫生机构(科室)信息查询服务 + */ + public final static String SERVICE_NAME_ORGUNIT = "OrganizationInfoQuery"; + + /** + * 医患者就诊列表(诊疗号)查询服务 + */ + public final static String SERVICE_NAME_TREATMENTNUM = "PatientVisitListQuery"; + + /** + * 手麻申请信息(住院号)查询服务 + */ + public final static String SERVICE_NAME_HOSPITALNUM = "OperaAppInfoQuery"; + +} Index: ssts-web/src/main/webapp/disinfectsystem/config/szslgqdsrmyy/spring/HIS.xml =================================================================== diff -u -r40302 -r40507 --- ssts-web/src/main/webapp/disinfectsystem/config/szslgqdsrmyy/spring/HIS.xml (.../HIS.xml) (revision 40302) +++ ssts-web/src/main/webapp/disinfectsystem/config/szslgqdsrmyy/spring/HIS.xml (.../HIS.xml) (revision 40507) @@ -46,41 +46,13 @@ - - - - - - - - - - - + + - - - - - - - - - - + + - - - - - - - - - - + + \ No newline at end of file Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByHospitalNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 40507) @@ -0,0 +1,365 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.szslgqdsrmyy; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +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.date.DateTools; + +/** + * 【组织机构】【患者使用记录】【外来器械申请单】集成平台的科室、人员及病人信息接口开发(基于HTTP POST协议)的帮助类SZLGSY-10 + */ +public class FindPatientInfoByHospitalNumDaoImpl implements FindPatientInfoByHospitalNumDao { + + Logger logger = Logger.getLogger(this.getClass()); + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNum(String hospitalNum) { + if(StringUtils.isBlank(hospitalNum)){ + return null; + } + PatientInfoVO[] patientInfoArray = null; + try { + List patientInfoVOList = new ArrayList(); + logger.info("住院号病人信息接口地址:" + DatasyncConstant.SYNC_ADDRESS); + JSONObject requestJson = buildHospitalNumRequestJson(DatasyncConstant.SERVICE_NAME_HOSPITALNUM, hospitalNum); + logger.info("住院号病人信息接口请求信息:" + requestJson); + JSONObject responceJson = CssdUtils.sendJSONRequestByHttpPost(DatasyncConstant.SYNC_ADDRESS, requestJson); + //String responceJsonStr = "{'messageId': '2025070818590600004940','messageResTime': '2025-07-08 18:59:06','retDesc': '','retValue': '0000','message': {'patientInfo': [{'orgId': 'G34813575','orgCode': 'G34813575','empiId': '1058521768','patientId': '1527049','patientName': '邱恋','genderCode': '2','genderName': '女','patientAge': '51岁','birthDate': '1973-08-16','idTypeCode': '01','idTypeName': '居民身份证','idCard': '44152219730816212X','patientHeight': '','patientWeight': '','citizenshipCode': '','citizenshipName': '','nationCode': '','nationName': '','maritalCode': '','maritalName': '','unitName': '福田区延缴与趸缴窗口','unitAddress': '','unitPhone': '','startWorkDate': '','careerCode': '','careerName': '','edBackgroundCode': '','edBackgroundName': '','bloodCode': '','bloodName': '','rhBloodCode': '','rhBloodName': '','nativePlace': '','householdType': '','contactPhone': '17724709800','mailingAddress': '南湾街道荔枝园原善窝4巷2栋303','zipCode': ''},{'orgId': 'G34813575','orgCode': 'G34813575','empiId': '1058521768','patientId': '1527049','patientName': '邱恋','genderCode': '2','genderName': '女','patientAge': '51岁','birthDate': '1973-08-16','idTypeCode': '01','idTypeName': '居民身份证','idCard': '44152219730816212X','patientHeight': '','patientWeight': '','citizenshipCode': '','citizenshipName': '','nationCode': '','nationName': '','maritalCode': '','maritalName': '','unitName': '福田区延缴与趸缴窗口','unitAddress': '','unitPhone': '','startWorkDate': '','careerCode': '','careerName': '','edBackgroundCode': '','edBackgroundName': '','bloodCode': '','bloodName': '','rhBloodCode': '','rhBloodName': '','nativePlace': '','householdType': '','contactPhone': '17724709800','mailingAddress': '南湾街道荔枝园原善窝4巷2栋303','zipCode': ''}],'relationInfos': [{'relationName': '唐楚香','relationTypeCode': '3','relationTypeName': '女','relationAddress': '南湾街道荔枝园原善窝4巷2栋303','relationZipCode': '','relationPhone': '17724709800'},{'relationName': '唐楚香','relationTypeCode': '3','relationTypeName': '女','relationAddress': '南湾街道荔枝园原善窝4巷2栋303','relationZipCode': '','relationPhone': '17724709800'}],'visitInfo': [{'patientType': '2','visitNo': '082650','visitSerialNo': '34657','visitTimes': '2','chargeType': '202','deptCode': '902','deptName': '骨科','wardCode': '704','wardName': '外一病区','bedNo': '1229','admitDate': '2025-06-30 17:46:00','admWardDate': '2025-06-30 17:46:13','attendingDoctorCode': '0508','attendingDoctorName': '谢获'},{'patientType': '2','visitNo': '082650','visitSerialNo': '34657','visitTimes': '2','chargeType': '202','deptCode': '902','deptName': '骨科','wardCode': '704','wardName': '外一病区','bedNo': '1229','admitDate': '2025-06-30 17:46:00','admWardDate': '2025-06-30 17:46:13','attendingDoctorCode': '0508','attendingDoctorName': '谢获'}],'clinicInfos': [{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'R00.200','diagName': '心悸','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '3','diagTypeName': ''},{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'R00.200','diagName': '心悸','diagTypeCode': '2','diagTypeName': ''},{'diagCode': 'S72.000','diagName': '股骨颈骨折','diagTypeCode': '3','diagTypeName': ''}],'applyInfo': [{'applyNo': '14371','applyDate': '2025-07-01 09:54:20','applyDeptCode': '902','applyDeptName': '骨科','applyOperatorCode': '0508','applyOperatorName': '谢获','operationScheduledDate': '2025-07-02 09:30:20','operationDeptCode': '57','operationDeptName': '手术室','operationStatus': '1','operationInfo': [{'operationCode': '78.0501','operationName': '左股骨颈骨折切开复位内固定术','operationPart': '','operationFlag': '1'}],'operationScaleCode': '3','operationScaleName': '三级','emerFlag': '0','isolationFlag': '','infection': '无','asaGrade': '','incisionGradeCode': '1','incisionGradeName': '1','healingGradeCode': '','healingGradeName': '','surgeonCode': '1285','surgeonName': '谢获','firstAssistantCode': '0508','firstAssistantName': '谢获','secondAssistantCode': '0329','secondAssistantName': '刘晓辉','thirdAssistantCode': '0140','thirdAssistantName': '张雷','anesthesiaMethodCode': '6','anesthesiaMethodName': '腰麻','anesthesiaDoctorCode': '','anesthesiaDoctorName': '','operationPositionCode': '平卧位','operationPositionName': '平卧位','remark': ''},{'applyNo': '14371','applyDate': '2025-07-01 09:54:20','applyDeptCode': '902','applyDeptName': '骨科','applyOperatorCode': '0508','applyOperatorName': '谢获','operationScheduledDate': '2025-07-02 09:30:20','operationDeptCode': '57','operationDeptName': '手术室','operationStatus': '1','operationInfo': [{'operationCode': '78.0501','operationName': '左股骨颈骨折切开复位内固定术','operationPart': '','operationFlag': '1'}],'operationScaleCode': '3','operationScaleName': '三级','emerFlag': '0','isolationFlag': '','infection': '无','asaGrade': '','incisionGradeCode': '1','incisionGradeName': '1','healingGradeCode': '','healingGradeName': '','surgeonCode': '1285','surgeonName': '谢获','firstAssistantCode': '0508','firstAssistantName': '谢获','secondAssistantCode': '0329','secondAssistantName': '刘晓辉','thirdAssistantCode': '0140','thirdAssistantName': '张雷','anesthesiaMethodCode': '6','anesthesiaMethodName': '腰麻','anesthesiaDoctorCode': '','anesthesiaDoctorName': '','operationPositionCode': '平卧位','operationPositionName': '平卧位','remark': ''}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + //String responceJsonStr = "{'messageId':'例子_2023120710230130963','messageResTime':'2023-12-0710:23:03','retDesc':'成功','retValue':'0000','message':{'applyInfoList':[{'patientInfo':{'orgId':'院区ID','orgCode':'机构编码','empiId':'主索引ID','patientId':'363858','patientName':'例子_测试患者','genderCode':'1','genderName':'男','patientAge':'10岁','birthDate':'2013-04-0300:00:00','idTypeCode':'01','idTypeName':'身份认证类型','idCard':'44030620130403XXXX','patientHeight':'身高(cm)','patientWeight':'体重(kg)','citizenshipCode':'国籍编码','citizenshipName':'国籍名称','nationCode':'民族编码','nationName':'民族名称','maritalCode':'婚姻代码','maritalName':'婚姻名称','unitName':'单位名称','unitAddress':'单位地址','unitPhone':'单位电话','startWorkDate':'开始工作日期','careerCode':'职业分类代码','careerName':'职业分类名称','edBackgroundCode':'文化程度代码','edBackgroundName':'文化程度名称','bloodCode':'ABO血型代码','bloodName':'ABO血型名称','rhBloodCode':'RH血型编码','rhBloodName':'RH血型名称','nativePlace':'籍贯','householdType':'户籍类型','contactPhone':'家庭电话','mailingAddress':'通讯地址','zipCode':'邮政编码'},'relationInfos':{'relationTypeCode':'联系人关系代码','relationTypeName':'联系人关系名称','relationName':'联系人名称','relationAddress':'联系人地址','relationZipCode':'联系人邮政编码','relationPhone':'联系人电话'},'visitInfo':{'patientType':'例子_1','visitNo':'例子_10788268','visitSerialNo':'例子_5562804','visitTimes':'2','chargeType':'213','deptCode':'科室编号','deptName':'手术室','wardCode':'病区编号','wardName':'病区名称','bedNo':'床号','admitDate':'入院时间','admWardDate':'入科时间','attendingDoctorCode':'主治医生编号','attendingDoctorName':'主治医生名称'},'clinicInfos':[{'diagCode':'J40.x00','diagName':'支气管炎','diagTypeCode':'诊断类型编码','diagTypeName':'诊断类型名称','diagDate':'2024-01-1615:36:38'}],'applyInfo':{'applyNo':'申请单号','applyDate':'申请时间','applyDeptCode':'申请科室代码','applyDeptName':'申请科室名称','applyOperatorCode':'申请医生工号','applyOperatorName':'申请医生名称','operationScheduledDate':'2025-07-02 09:30:20','operationDeptCode':'手术科室代码','operationDeptName':'手术科室名称','operationInfo':[{'operationCode':'J40.x00','operationName':'支气管炎手术','operationPart':'支气管炎','operationFlag':'0'}],'operationScaleCode':'手术等级编码','operationScaleName':'手术等级名称','emerFlag':'急诊标志','isolationFlag':'隔离标志','infection':'传染病','asaGrade':'ASA分级','incisionGradeCode':'切口等级编码','incisionGradeName':'切口等级','healingGradeCode':'切口愈合等级编码','healingGradeName':'切口愈合等级','surgeonCode':'手术医生编码','surgeonName':'手术医生名称','firstAssistantCode':'第一手术助手工号','firstAssistantName':'第一手术助手姓名','secondAssistantCode':'第二手术助手工号','secondAssistantName':'第二手术助手姓名','thirdAssistantCode':'第三手术助手工号','thirdAssistantName':'第三手术助手姓名','anesthesiaMethodCode':'麻醉方法编码','anesthesiaMethodName':'麻醉方法名称','anesthesiaDoctorCode':'麻醉医师编码','anesthesiaDoctorName':'麻醉医师名称','operationPositionCode':'手术体位代码','operationPositionName':'手术体位名称','remark':'备注'}}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + logger.info("住院号病人信息接口返回信息:" + responceJson); + if(responceJson == null){ + throw new RuntimeException("接口返回信息为空!"); + } + JSONObject message = responceJson.optJSONObject("message"); + if(message == null){ + throw new RuntimeException("接口返回信息message为空!"); + } + //返回的参数是message-patientInfo、visitInfo、applyInfo分开的格式 + Object patientInfoObj = message.opt("patientInfo"); + //返回的参数是手术申请单,message-applyInfoList + Object applyInfoList = message.opt("applyInfoList"); + if(applyInfoList != null){ + //接口返回手术申请单 + patientInfoVOList = buildPatientInfoVOByApplyInfoList(applyInfoList); + }else if(patientInfoObj != null){ + //先查询接口返回手术申请单号 + List applyNoList = getApplyNoByPatientInfo(message); + //根据手术申请单号查询手术申请单 + patientInfoVOList = findPatientInfoByHospitalNumByApplyNo(applyNoList); + }else{ + throw new RuntimeException("接口返回信息patientInfo/applyInfoList为空!"); + } + + 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; + } + + /** + * 根据手术申请单号查询手术申请单 + * @param applyNoList 手术申请单号 + * @return 住院号患者信息 + */ + private List findPatientInfoByHospitalNumByApplyNo(List applyNoList) { + if(CollectionUtils.isEmpty(applyNoList)){ + return null; + } + List allPatientInfoVOList = new ArrayList(); + for (String applyNo : applyNoList) { + List patientInfoVOList = findPatientInfoByHospitalNumByApplyNo(applyNo); + if(CollectionUtils.isNotEmpty(patientInfoVOList)){ + allPatientInfoVOList.addAll(patientInfoVOList); + } + } + return allPatientInfoVOList; + } + + /** + * 根据手术申请单号查询手术申请单 + * @param applyNo 手术申请单号 + * @return 住院号患者信息 + */ + private List findPatientInfoByHospitalNumByApplyNo(String applyNo) { + if(StringUtils.isBlank(applyNo)){ + return null; + } + logger.info("住院号病人信息接口地址(手术申请单):" + DatasyncConstant.SYNC_ADDRESS); + JSONObject requestJson = buildHospitalNumApplyNoRequestJson(DatasyncConstant.SERVICE_NAME_HOSPITALNUM, applyNo); + logger.info("住院号病人信息接口请求信息(手术申请单):" + requestJson); + JSONObject responceJson = CssdUtils.sendJSONRequestByHttpPost(DatasyncConstant.SYNC_ADDRESS, requestJson); + //String responceJsonStr = "{'messageId':'例子_2023120710230130963','messageResTime':'2023-12-0710:23:03','retDesc':'成功','retValue':'0000','message':{'applyInfoList':[{'patientInfo':{'orgId':'院区ID','orgCode':'机构编码','empiId':'主索引ID','patientId':'363858','patientName':'例子_测试患者','genderCode':'1','genderName':'男','patientAge':'10岁','birthDate':'2013-04-0300:00:00','idTypeCode':'01','idTypeName':'身份认证类型','idCard':'44030620130403XXXX','patientHeight':'身高(cm)','patientWeight':'体重(kg)','citizenshipCode':'国籍编码','citizenshipName':'国籍名称','nationCode':'民族编码','nationName':'民族名称','maritalCode':'婚姻代码','maritalName':'婚姻名称','unitName':'单位名称','unitAddress':'单位地址','unitPhone':'单位电话','startWorkDate':'开始工作日期','careerCode':'职业分类代码','careerName':'职业分类名称','edBackgroundCode':'文化程度代码','edBackgroundName':'文化程度名称','bloodCode':'ABO血型代码','bloodName':'ABO血型名称','rhBloodCode':'RH血型编码','rhBloodName':'RH血型名称','nativePlace':'籍贯','householdType':'户籍类型','contactPhone':'家庭电话','mailingAddress':'通讯地址','zipCode':'邮政编码'},'relationInfos':{'relationTypeCode':'联系人关系代码','relationTypeName':'联系人关系名称','relationName':'联系人名称','relationAddress':'联系人地址','relationZipCode':'联系人邮政编码','relationPhone':'联系人电话'},'visitInfo':{'patientType':'例子_1','visitNo':'例子_10788268','visitSerialNo':'例子_5562804','visitTimes':'2','chargeType':'213','deptCode':'科室编号','deptName':'手术室','wardCode':'病区编号','wardName':'病区名称','bedNo':'床号','admitDate':'入院时间','admWardDate':'入科时间','attendingDoctorCode':'主治医生编号','attendingDoctorName':'主治医生名称'},'clinicInfos':[{'diagCode':'J40.x00','diagName':'支气管炎','diagTypeCode':'诊断类型编码','diagTypeName':'诊断类型名称','diagDate':'2024-01-1615:36:38'}],'applyInfo':{'applyNo':'申请单号','applyDate':'申请时间','applyDeptCode':'申请科室代码','applyDeptName':'申请科室名称','applyOperatorCode':'申请医生工号','applyOperatorName':'申请医生名称','operationScheduledDate':'2025-07-02 09:30:20','operationDeptCode':'手术科室代码','operationDeptName':'手术科室名称','operationInfo':[{'operationCode':'J40.x00','operationName':'支气管炎手术','operationPart':'支气管炎','operationFlag':'0'}],'operationScaleCode':'手术等级编码','operationScaleName':'手术等级名称','emerFlag':'急诊标志','isolationFlag':'隔离标志','infection':'传染病','asaGrade':'ASA分级','incisionGradeCode':'切口等级编码','incisionGradeName':'切口等级','healingGradeCode':'切口愈合等级编码','healingGradeName':'切口愈合等级','surgeonCode':'手术医生编码','surgeonName':'手术医生名称','firstAssistantCode':'第一手术助手工号','firstAssistantName':'第一手术助手姓名','secondAssistantCode':'第二手术助手工号','secondAssistantName':'第二手术助手姓名','thirdAssistantCode':'第三手术助手工号','thirdAssistantName':'第三手术助手姓名','anesthesiaMethodCode':'麻醉方法编码','anesthesiaMethodName':'麻醉方法名称','anesthesiaDoctorCode':'麻醉医师编码','anesthesiaDoctorName':'麻醉医师名称','operationPositionCode':'手术体位代码','operationPositionName':'手术体位名称','remark':'备注'}}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + //String responceJsonStr = "{'messageId':'2025071517481400008397','messageResTime':'2025-07-15 17:48:14','retDesc':'','retValue':'0000','message':{'applyList':[{'patientInfo':{'orgId':'G34813575','orgCode':'G34813575','empiId':'1058521768','patientId':'1527049','patientName':'邱恋','genderCode':'2','genderName':'女','patientAge':'51岁','birthDate':'1973-08-16','idTypeCode':'01','idTypeName':'居民身份证','idCard':'44152219730816212X','patientHeight':'','patientWeight':'','citizenshipCode':'','citizenshipName':'','nationCode':'','nationName':'','maritalCode':'','maritalName':'','unitName':'福田区延缴与趸缴窗口','unitAddress':'','unitPhone':'','startWorkDate':'','careerCode':'','careerName':'','edBackgroundCode':'','edBackgroundName':'','bloodCode':'','bloodName':'','rhBloodCode':'','rhBloodName':'','nativePlace':'','householdType':'','contactPhone':'17724709800','mailingAddress':'南湾街道荔枝园原善窝4巷2栋303','zipCode':''},'relationInfos':{'relationName':'唐楚香','relationTypeCode':'3','relationTypeName':'女','relationAddress':'南湾街道荔枝园原善窝4巷2栋303','relationZipCode':'','relationPhone':'17724709800'},'visitInfo':{'patientType':'2','visitNo':'082650','visitSerialNo':'34657','visitTimes':'2','chargeType':'202','deptCode':'902','deptName':'骨科','wardCode':'704','wardName':'外一病区','bedNo':'1229','admitDate':'2025-06-30 17:46:00','admWardDate':'2025-06-30 17:46:13','attendingDoctorCode':'0508','attendingDoctorName':'谢获'},'clinicInfos':[{'diagCode':'S72.000','diagName':'股骨颈骨折','diagTypeCode':'2','diagTypeName':''},{'diagCode':'S72.000','diagName':'股骨颈骨折','diagTypeCode':'2','diagTypeName':''},{'diagCode':'R00.200','diagName':'心悸','diagTypeCode':'2','diagTypeName':''},{'diagCode':'S72.000','diagName':'股骨颈骨折','diagTypeCode':'3','diagTypeName':''},{'diagCode':'S72.000','diagName':'股骨颈骨折','diagTypeCode':'5','diagTypeName':''}],'applyInfo':{'applyNo':'14371','applyDate':'2025-07-01 09:54:20','applyDeptCode':'902','applyDeptName':'骨科','applyOperatorCode':'0508','applyOperatorName':'谢获','operationScheduledDate':'2025-07-02 09:30:20','operationDeptCode':'57','operationDeptName':'手术室','operationStatus':'1','operationInfo':[{'operationCode':'78.0501','operationName':'左股骨颈骨折切开复位内固定术','operationPart':'','operationFlag':'1'}],'operationScaleCode':'3','operationScaleName':'三级','emerFlag':'0','isolationFlag':'','infection':'无','asaGrade':'','incisionGradeCode':'1','incisionGradeName':'1','healingGradeCode':'','healingGradeName':'','surgeonCode':'1285','surgeonName':'谢获','firstAssistantCode':'0508','firstAssistantName':'谢获','secondAssistantCode':'0329','secondAssistantName':'刘晓辉','thirdAssistantCode':'0140','thirdAssistantName':'张雷','anesthesiaMethodCode':'6','anesthesiaMethodName':'腰麻','anesthesiaDoctorCode':'','anesthesiaDoctorName':'','operationPositionCode':'平卧位','operationPositionName':'平卧位','remark':''}}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + logger.info("住院号病人信息接口返回信息(手术申请单):" + responceJson); + if(responceJson == null){ + return null; + } + JSONObject message = responceJson.optJSONObject("message"); + if(message == null){ + return null; + } + //返回的参数是手术申请单,message-applyInfoList + Object applyInfoList = message.opt("applyInfoList"); + if(applyInfoList == null){ + applyInfoList = message.opt("applyList"); + } + if(applyInfoList == null){ + return null; + } + return buildPatientInfoVOByApplyInfoList(applyInfoList); + } + + /** + * 根据手术申请单号查询住院号患者信息 + * @param serviceName 服务名称 + * @param applyNo 手术申请单号 + * @return requestJson + */ + private JSONObject buildHospitalNumApplyNoRequestJson(String serviceName, String applyNo) { + + JSONObject requestJson = new JSONObject(); + JSONObject msgHeader = HttpClientHelper.buildMsgHeader(serviceName); + JSONObject msgBody = new JSONObject(); + msgBody.put("orgId", "G34813575"); + msgBody.put("orgCode", "G34813575"); + msgBody.put("applyNo", applyNo); + msgBody.put("patientType", "2"); + //默认查询最近一个月的记录 + Date currentDateTime = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentDateTime); + calendar.add(Calendar.MONTH, -1); + Date oneMonthBeforeDateTime = calendar.getTime(); + msgBody.put("startDate", DateTools.getFormatDateStr(oneMonthBeforeDateTime, DateTools.COMMON_DATE_ONLY)); + msgBody.put("endDate", DateTools.getFormatDateStr(currentDateTime, DateTools.COMMON_DATE_ONLY)); + + requestJson.put("msgHeader", msgHeader); + requestJson.put("msgBody", msgBody); + return requestJson; + } + + /** + * 解析并返回手术申请单号 + * @param message message节点 + * @return 手术申请单号 + */ + private List getApplyNoByPatientInfo(JSONObject message) { + JSONArray applyInfoArray = new JSONArray(); + Object applyInfoObj = message.opt("applyInfo"); + if(applyInfoObj instanceof JSONObject){ + applyInfoArray.add(applyInfoObj); + }else if(applyInfoObj instanceof JSONArray){ + applyInfoArray = (JSONArray) applyInfoObj; + }else{ + return null; + } + List applyNoList = new ArrayList(); + for (Object applyInfoObject : applyInfoArray) { + JSONObject applyInfoJson = (JSONObject) applyInfoObject; + String applyNo = applyInfoJson.optString("applyNo"); + if(applyNoList.contains(applyNo)){ + continue; + } + applyNoList.add(applyNo); + } + return applyNoList; + } + + /** + * 解析并返回患者信息 + * @param applyInfoList 手术申请单vo + * @return 患者信息vo + */ + private List buildPatientInfoVOByApplyInfoList(Object applyInfoList) { + JSONArray applyInfoListJSONArray = new JSONArray(); + if(applyInfoList instanceof JSONArray){ + applyInfoListJSONArray = (JSONArray) applyInfoList; + }else if(applyInfoList instanceof JSONObject){ + applyInfoListJSONArray.add(applyInfoList); + }else{ + throw new RuntimeException("接口返回信息applyInfoList异常:" + applyInfoList); + } + List patientInfoVOList = new ArrayList(); + for (Object object : applyInfoListJSONArray) { + JSONObject applyInfo = (JSONObject) object; + PatientInfoVO vo = new PatientInfoVO(); + + Object visitInfo = applyInfo.opt("visitInfo"); + JSONObject visitInfoObj = new JSONObject(); + if(visitInfo instanceof JSONObject){ + visitInfoObj = (JSONObject) visitInfo; + }else if(visitInfo instanceof JSONArray){ + JSONArray visitInfoArr = (JSONArray) visitInfo; + visitInfoObj = visitInfoArr.optJSONObject(0); + } + if(visitInfoObj != null){ + vo.setHospitalNumber(visitInfoObj.optString("visitNo")); + vo.setSerialNumber(visitInfoObj.optString("visitSerialNo")); + vo.setDoctorName(visitInfoObj.optString("attendingDoctorName")); + vo.setAscriptionDepartment(visitInfoObj.optString("deptName")); + vo.setPatientArea(visitInfoObj.optString("wardName")); + vo.setVisitId(visitInfoObj.optLong("visitTimes")); + //vo.setRoomNumber(visitInfoObj.optString("attendingDoctorName")); + vo.setBedNumber(visitInfoObj.optString("bedNo")); + } + + JSONObject patientInfoObj = new JSONObject(); + Object patientInfo = applyInfo.opt("patientInfo"); + if(patientInfo instanceof JSONObject){ + patientInfoObj = (JSONObject) patientInfo; + }else if(patientInfo instanceof JSONArray){ + JSONArray patientInfoArr = (JSONArray) patientInfo; + patientInfoObj = patientInfoArr.optJSONObject(0); + } + if(patientInfoObj != null){ + vo.setPatientName(patientInfoObj.optString("patientName")); + vo.setPatientAge(patientInfoObj.optString("patientAge")); + vo.setPatientSex(patientInfoObj.optString("genderName")); + vo.setPatientIDCard(patientInfoObj.optString("idCard")); + } + + JSONObject applyInfoJson = new JSONObject(); + Object applyInfoObj = applyInfo.opt("applyInfo"); + if(applyInfoObj instanceof JSONObject){ + applyInfoJson = (JSONObject) applyInfoObj; + }else if(applyInfoObj instanceof JSONArray){ + JSONArray applyInfoArray = (JSONArray) applyInfoObj; + applyInfoJson = applyInfoArray.optJSONObject(0); + } + if(applyInfoJson != null){ + vo.setOperationTime(applyInfoJson.optString("operationScheduledDate")); + vo.setOperationScheduleId(applyInfoJson.optString("applyNo")); + + JSONArray operationInfoArr = new JSONArray(); + Object operationInfo = applyInfoJson.opt("operationInfo"); + if(operationInfo instanceof JSONObject){ + operationInfoArr.add(operationInfo); + }else if(operationInfo instanceof JSONArray){ + operationInfoArr = (JSONArray) operationInfo; + } + + if(operationInfoArr != null && operationInfoArr.size() > 0){ + for (Object operationInfoObjLoop : operationInfoArr) { + PatientInfoVO voLoop = new PatientInfoVO(); + //visitInfo + voLoop.setHospitalNumber(vo.getHospitalNumber()); + voLoop.setSerialNumber(vo.getSerialNumber()); + voLoop.setDoctorName(vo.getDoctorName()); + voLoop.setAscriptionDepartment(vo.getAscriptionDepartment()); + voLoop.setPatientArea(vo.getPatientArea()); + voLoop.setVisitId(vo.getVisitId()); + voLoop.setBedNumber(vo.getBedNumber()); + + //patientInfo + voLoop.setPatientName(vo.getPatientName()); + voLoop.setPatientAge(vo.getPatientAge()); + voLoop.setPatientSex(vo.getPatientSex()); + voLoop.setPatientIDCard(vo.getPatientIDCard()); + + //applyInfo + voLoop.setOperationTime(vo.getOperationTime()); + voLoop.setOperationScheduleId(vo.getOperationScheduleId()); + + //operationInfo + JSONObject operationInfoJsonLoop = (JSONObject) operationInfoObjLoop; + voLoop.setOperation(operationInfoJsonLoop.optString("operationName")); + patientInfoVOList.add(voLoop); + } + } + + }else{ + patientInfoVOList.add(vo); + } + + } + return patientInfoVOList; + } + + /** + * 构建住院号接口请求信息 + * @param serviceName 服务名称 + * @param hospitalNum 住院号 + * @return requestJson + */ + private JSONObject buildHospitalNumRequestJson(String serviceName, String hospitalNum) { + JSONObject requestJson = new JSONObject(); + JSONObject msgHeader = HttpClientHelper.buildMsgHeader(serviceName); + JSONObject msgBody = new JSONObject(); + msgBody.put("orgId", "G34813575"); + msgBody.put("orgCode", "G34813575"); + msgBody.put("visitNo", hospitalNum); + msgBody.put("patientType", "2"); + //默认查询最近一个月的记录 + Date currentDateTime = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(currentDateTime); + calendar.add(Calendar.MONTH, -1); + Date oneMonthBeforeDateTime = calendar.getTime(); + msgBody.put("startDate", DateTools.getFormatDateStr(oneMonthBeforeDateTime, DateTools.COMMON_DATE_ONLY)); + msgBody.put("endDate", DateTools.getFormatDateStr(currentDateTime, DateTools.COMMON_DATE_ONLY)); + + requestJson.put("msgHeader", msgHeader); + requestJson.put("msgBody", msgBody); + return requestJson; + + } + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNumBeforeOperation(String hospitalNum) { + return this.findPatientInfoByHospitalNum(hospitalNum); + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/HttpClientHelper.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/HttpClientHelper.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/HttpClientHelper.java (revision 40507) @@ -0,0 +1,37 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.szslgqdsrmyy; + +import java.util.UUID; + +import net.sf.json.JSONObject; + +import com.forgon.tools.date.DateTools; + +/** + * 【组织机构】【患者使用记录】【外来器械申请单】集成平台的科室、人员及病人信息接口开发(基于HTTP POST协议)的帮助类SZLGSY-10 + */ +public class HttpClientHelper { + + /** + * 构建请求参数的msgHeader + * @param serviceName 信息查询服务 + * @return msgHeader + */ + public static JSONObject buildMsgHeader(String serviceName) { + JSONObject msgHeader = new JSONObject(); + msgHeader.put("targetOrg", "G34813575"); + msgHeader.put("messageReqTime", DateTools.getCurrentDayByFormat(DateTools.COMMON_DATE_HMS)); + msgHeader.put("sender", "CSSD"); + msgHeader.put("callOrg", "G34813575"); + + msgHeader.put("format", "JSON"); + msgHeader.put("certificate", "96bb82e8da85f0117eed49dd9030f9a4"); + msgHeader.put("messageId", UUID.randomUUID().toString().replace("-", "")); + msgHeader.put("serviceName", serviceName); + + msgHeader.put("operatorCode", "CSSD"); + msgHeader.put("operatorName", "消毒供应室追溯系统"); + msgHeader.put("version", "v1.0"); + return msgHeader; + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/SyncOrgUnitAndUserDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/SyncOrgUnitAndUserDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/SyncOrgUnitAndUserDaoImpl.java (revision 40507) @@ -0,0 +1,190 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.szslgqdsrmyy; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.log4j.Logger; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import com.forgon.disinfectsystem.common.CssdUtils; +import com.forgon.disinfectsystem.datasynchronization.dao.SyncOrgUnitAndUserDao; +import com.forgon.disinfectsystem.datasynchronization.model.OrgUnitVo; +import com.forgon.disinfectsystem.datasynchronization.model.UserVo; + +/** + * 科室人员同步接口SZLGSY-10 + */ +public class SyncOrgUnitAndUserDaoImpl implements SyncOrgUnitAndUserDao { + + Logger logger = Logger.getLogger(this.getClass()); + + @Override + public UserVo[] getAllUser() { + UserVo[] userVoArray = null; + try { + List userVoList = new ArrayList(); + logger.info("人员同步接口地址:" + DatasyncConstant.SYNC_ADDRESS); + JSONObject requestJson = buildUserSyncRequestJson(DatasyncConstant.SERVICE_NAME_USER); + logger.info("人员同步接口请求信息:" + requestJson); + JSONObject responceJson = CssdUtils.sendJSONRequestByHttpPost(DatasyncConstant.SYNC_ADDRESS, requestJson); + //String responceJsonStr = "{'messageId':'96f178819f4b4ea18287d48a76459b41','retValue':'0000','retDesc':'成功!','messageResTime':'2025-07-0117:17:59','message':{'staff':[{'staffCode':'1301','staffName':'李金燕1','deptCode':'1001','deptName':'急诊科(一级)'},{'staffCode':'1302','staffName':'李金燕2','deptCode':'1001','deptName':'急诊科(一级)'}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + logger.info("人员同步接口返回信息:" + responceJson); + if(responceJson == null){ + throw new RuntimeException("接口返回信息为空!"); + } + JSONObject message = responceJson.optJSONObject("message"); + if(message == null){ + throw new RuntimeException("接口返回信息message为空!"); + } + /*JSONArray staffArray = message.optJSONArray("staff"); + if(staffArray == null || staffArray.size() == 0){ + throw new RuntimeException("接口返回信息staff为空!"); + }*/ + JSONArray staffArray = new JSONArray(); + Object staffObj = message.opt("staff"); + if(staffObj == null){ + throw new RuntimeException("接口返回信息staff为空!"); + } + if(staffObj instanceof JSONArray){ + staffArray = (JSONArray) staffObj; + }else if(staffObj instanceof JSONObject){ + staffArray.add(staffObj); + }else{ + throw new RuntimeException("接口返回信息staff异常:" + staffObj); + } + if(staffArray == null || staffArray.size() == 0){ + return userVoArray; + } + for (Object object : staffArray) { + JSONObject staffJson = (JSONObject) object; + String name = staffJson.optString("staffName"); + String coding = staffJson.optString("staffCode"); + String orgUnitCoding = staffJson.optString("deptCode"); + UserVo vo = new UserVo(); + vo.setCoding(coding); + vo.setName(name); + vo.setOrgUnitCoding(orgUnitCoding); + userVoList.add(vo); + } + userVoArray = new UserVo[userVoList.size()]; + userVoList.toArray(userVoArray); + } catch (Exception e) { + e.printStackTrace(); + logger.info("人员信息同步失败:" + e.getMessage()); + } + return userVoArray; + } + + /** + * 构建请求参数 + * @param serviceName 信息查询服务 + * @return requestJson + */ + private JSONObject buildUserSyncRequestJson(String serviceName) { + JSONObject requestJson = new JSONObject(); + JSONObject msgHeader = HttpClientHelper.buildMsgHeader(serviceName); + JSONObject msgBody = new JSONObject(); + msgBody.put("orgId", "G34813575"); + msgBody.put("orgCode", "G34813575"); + requestJson.put("msgHeader", msgHeader); + requestJson.put("msgBody", msgBody); + return requestJson; + } + + + @Override + public OrgUnitVo[] getAllOrgUnit() { + OrgUnitVo[] orgUnitVoArray = null; + try { + List orgUnitVoList = new ArrayList(); + logger.info("组织机构同步接口地址:" + DatasyncConstant.SYNC_ADDRESS); + JSONObject requestJson = buildOrgUnitSyncRequestJson(DatasyncConstant.SERVICE_NAME_ORGUNIT); + logger.info("组织机构同步接口请求信息:" + requestJson); + JSONObject responceJson = CssdUtils.sendJSONRequestByHttpPost(DatasyncConstant.SYNC_ADDRESS, requestJson); + //String responceJsonStr = "{'messageId':'96f178819f4b4ea18287d48a76459b41','retValue':'0000','retDesc':'成功!','messageResTime':'2025-07-0117:20:19','message':{'depart':[{'deptCode':'1001','deptName':'急诊科(一级)'},{'deptCode':'1001','deptName':'急诊科(二级)'}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + logger.info("组织机构同步接口返回信息:" + responceJson); + + if(responceJson == null){ + throw new RuntimeException("接口返回信息为空!"); + } + JSONObject message = responceJson.optJSONObject("message"); + if(message == null){ + throw new RuntimeException("接口返回信息message为空!"); + } + JSONArray departArray = new JSONArray(); + Object departObj = message.opt("depart"); + if(departObj == null){ + throw new RuntimeException("接口返回信息depart为空!"); + } + if(departObj instanceof JSONArray){ + departArray = (JSONArray) departObj; + }else if(departObj instanceof JSONObject){ + departArray.add(departObj); + }else{ + throw new RuntimeException("接口返回信息depart异常:" + departObj); + } + if(departArray == null || departArray.size() == 0){ + return orgUnitVoArray; + } + for (Object object : departArray) { + JSONObject departJson = (JSONObject) object; + String coding = departJson.optString("deptCode"); + String name = departJson.optString("deptName"); + OrgUnitVo orgVo = new OrgUnitVo(); + orgVo.setCoding(coding); + orgVo.setName(name); + //现场科室不存在上级科室编码 + //orgVo.setParentCoding(parentCoding); + orgUnitVoList.add(orgVo); + } + + orgUnitVoArray = new OrgUnitVo[orgUnitVoList.size()]; + orgUnitVoList.toArray(orgUnitVoArray); + + } catch (Exception e) { + e.printStackTrace(); + logger.error("组织机构同步失败" + e); + } + return orgUnitVoArray; + } + + /** + * 构建组织机构同步入参 + * @param serviceName 信息查询服务 + * @return requestJson + */ + private JSONObject buildOrgUnitSyncRequestJson(String serviceName) { + JSONObject requestJson = new JSONObject(); + JSONObject msgHeader = HttpClientHelper.buildMsgHeader(serviceName); + JSONObject msgBody = new JSONObject(); + msgBody.put("orgId", "G34813575"); + msgBody.put("orgCode", "G34813575"); + //科室类型标识 + //0:标准科室,1:业务科室 + //(现场应用标准科室0) + msgBody.put("busFlag", 0); + requestJson.put("msgHeader", msgHeader); + requestJson.put("msgBody", msgBody); + return requestJson; + } + + @Override + public OrgUnitVo[] paramToOrgUnitVos(String param) { + return null; + } + + @Override + public UserVo[] paramToUserVos(String param) { + return null; + } + + @Override + public JSONObject buttjoinResponse(Boolean success, String message, String param) { + return null; + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByTreatmentNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/szslgqdsrmyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 40507) @@ -0,0 +1,139 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.szslgqdsrmyy; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +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.date.DateTools; + +/** + * 【组织机构】【患者使用记录】【外来器械申请单】集成平台的科室、人员及病人信息接口开发(基于HTTP POST协议)的帮助类SZLGSY-10 + */ +public class FindPatientInfoByTreatmentNumDaoImpl implements FindPatientInfoByTreatmentNumDao { + + Logger logger = Logger.getLogger(this.getClass()); + + @Override + public PatientInfoVO[] findPatientInfoByTreatmentNum(String treatmentNum) { + if(StringUtils.isBlank(treatmentNum)){ + return null; + } + PatientInfoVO[] patientInfoArray = null; + try { + logger.info("诊疗号病人信息接口地址:" + DatasyncConstant.SYNC_ADDRESS); + JSONObject requestJson = buildTreatmentNumRequestJson(DatasyncConstant.SERVICE_NAME_TREATMENTNUM, treatmentNum); + logger.info("诊疗号病人信息接口请求信息:" + requestJson); + JSONObject responceJson = CssdUtils.sendJSONRequestByHttpPost(DatasyncConstant.SYNC_ADDRESS, requestJson); + //String responceJsonStr = "{'messageId': '2025070818523200006178','messageResTime': '2025-07-08 18:52:32','retDesc': '','retValue': '0000','message': {'patientInfo': [{'orgId': '1','orgCode': 'G34813575','empiId': '','patientId': '1618584','patientName': '陶鹤天','patientType': '1','genderCode': '2','genderName': '女','patientAge': '29岁','idTypeCode': '01','idTypeName': '居民身份证','idCard': '220502199605140826','patientTel': '13699878697','visitStartDate': '2025-05-23 09:42:04','visitEndDate': '2025-05-23 10:57:38','visitNo': '1322490','visitSerialNo': '2948695','visitTimes': '1','wardCode': '','wardName': '','deptCode': '833','deptName': '妇科门诊','bedLabel': '','bedNo': 'bedNo','doctorCode': '0597','doctorName': '孙凤艳'},{'orgId': '1','orgCode': 'G34813575','empiId': '','patientId': '1618584','patientName': '陶鹤天','patientType': '1','genderCode': '2','genderName': '女','patientAge': '29岁','idTypeCode': '01','idTypeName': '居民身份证','idCard': '220502199605140826','patientTel': '13699878697','visitStartDate': '2025-05-23 10:42:04','visitEndDate': '2025-05-23 10:57:38','visitNo': '1322490','visitSerialNo': '2948695','visitTimes': '1','wardCode': '','wardName': '','deptCode': '833','deptName': '妇科门诊','bedLabel': '','bedNo': 'bedNo','doctorCode': '0597','doctorName': '孙凤艳'}]}}"; + //JSONObject responceJson = JSONObject.fromObject(responceJsonStr); + logger.info("诊疗号病人信息接口返回信息:" + responceJson); + if(responceJson == null){ + throw new RuntimeException("接口返回信息为空!"); + } + JSONObject message = responceJson.optJSONObject("message"); + if(message == null){ + throw new RuntimeException("接口返回信息message为空!"); + } + Object patientInfoObj = message.opt("patientInfo"); + if(patientInfoObj == null){ + throw new RuntimeException("接口返回信息patientInfo为空!"); + } + JSONArray patientInfoJSONArray = new JSONArray(); + if(patientInfoObj instanceof JSONArray){ + patientInfoJSONArray = (JSONArray) patientInfoObj; + }else if(patientInfoObj instanceof JSONObject){ + patientInfoJSONArray.add(patientInfoObj); + }else{ + throw new RuntimeException("接口返回信息patientInfo异常:" + patientInfoObj); + } + List patientInfoVOList = new ArrayList(); + for (Object object : patientInfoJSONArray) { + JSONObject patientInfo = (JSONObject) object; + PatientInfoVO vo = new PatientInfoVO(); + vo.setClinicNumber(patientInfo.optString("visitNo")); + vo.setSerialNumber(patientInfo.optString("visitSerialNo")); + vo.setPatientName(patientInfo.optString("patientName")); + vo.setPatientAge(patientInfo.optString("patientAge")); + vo.setPatientSex(patientInfo.optString("genderName")); + vo.setPatientIDCard(patientInfo.optString("idCard")); + vo.setDoctorName(patientInfo.optString("doctorName")); + //vo.setOperation(patientInfo.optString("")); + vo.setOperationTime(patientInfo.optString("visitStartDate")); + vo.setPatientArea(patientInfo.optString("wardName")); + vo.setAscriptionDepartment(patientInfo.optString("deptName")); + //vo.setRoomNumber(patientInfo.optString("")); + vo.setBedNumber(patientInfo.optString("bedNo")); + //vo.setRemark(patientInfo.optString("")); + patientInfoVOList.add(vo); + } + 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; + } + + /** + * 构建诊疗号病人信息接口请求信息 + * @param serviceName 查询服务 + * @return + */ + private JSONObject buildTreatmentNumRequestJson(String serviceName, String treatmentNum) { + JSONObject requestJson = new JSONObject(); + JSONObject msgHeader = HttpClientHelper.buildMsgHeader(serviceName); + JSONObject msgBody = new JSONObject(); + msgBody.put("orgId", "G34813575"); + msgBody.put("orgCode", "G34813575"); + msgBody.put("patientType", "1"); + msgBody.put("visitNo", treatmentNum); + msgBody.put("queryType", "1"); + //Date currentDateTime = new Date(); + //msgBody.put("startDate", DateTools.getFormatDateStr(DateTools.addDate(currentDateTime, 365L), DateTools.COMMON_DATE_HMS)); + //msgBody.put("endDate", DateTools.getFormatDateStr(currentDateTime, DateTools.COMMON_DATE_HMS)); + + requestJson.put("msgHeader", msgHeader); + requestJson.put("msgBody", msgBody); + return requestJson; + } + +}