diff --git a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java index 5794d25..83f7c62 100644 --- a/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/collection/mapper/TBasicMapper.java @@ -37,4 +37,11 @@ public interface TBasicMapper{ Integer updateExtend(@Param("tBasicExtend") TBasicExtend tBasicExtend); List selectBasicListByAdmissDate(@Param("admissStartDate")String admissStartDate,@Param("admissEndDate") String admissEndDate,@Param("offset") int offset,@Param("size") int size); + + /** + * 查询归档关联顺德人医报告的交叉索引 + * @param patientId 归档系统病案主键 + * @return 归档关联顺德人医报告的交叉索引 + */ + String getSdRyIndexByPatientId(@Param("patientId")String patientId); } diff --git a/src/main/java/com/docus/server/collection/webservice/ReceiveServer.java b/src/main/java/com/docus/server/collection/webservice/ReceiveServer.java index 95952dc..2d8f1e7 100644 --- a/src/main/java/com/docus/server/collection/webservice/ReceiveServer.java +++ b/src/main/java/com/docus/server/collection/webservice/ReceiveServer.java @@ -7,7 +7,7 @@ import javax.jws.WebService; * @date 2022-11-14 19:03 */ -@WebService +@WebService(targetNamespace = "http://impl.webservice.collection.server.docus.com/") public interface ReceiveServer { /** * 科室信息接收,进行操作 diff --git a/src/main/java/com/docus/server/report/client/JaxWsDynamicClient.java b/src/main/java/com/docus/server/report/client/JaxWsDynamicClient.java new file mode 100644 index 0000000..b094d7d --- /dev/null +++ b/src/main/java/com/docus/server/report/client/JaxWsDynamicClient.java @@ -0,0 +1,73 @@ +package com.docus.server.report.client; + +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; +import org.apache.cxf.transport.http.HTTPConduit; +import org.apache.cxf.transports.http.configuration.HTTPClientPolicy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.namespace.QName; +import java.util.Arrays; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * 使用JaxWsDynamicClientFactory 调用 webservice + * @author wyb + */ +public class JaxWsDynamicClient { + + private static final JaxWsDynamicClientFactory CLIENT_FACTORY = JaxWsDynamicClientFactory.newInstance(); + private static final Map CLIENT_MAP=new ConcurrentHashMap<>(); + private static final Logger logger= LoggerFactory.getLogger(JaxWsDynamicClient.class); + + public static String send(String wsdlUrl,String namespaceUri,String operationName,Object[] params){ + try { + Client client = getClient(wsdlUrl); + Object[] result; + if (namespaceUri == null || namespaceUri.isEmpty()) { + result = client.invoke(operationName, params); + } else { + QName qName = new QName(namespaceUri, operationName); + result = client.invoke(qName, params); + } + if (result == null || result[0] == null) { + return null; + } + return String.valueOf(result[0]); + } catch (Exception ex) { + logger.error("wsdlUrl:" + wsdlUrl + " ,operationName:" + operationName + ",params:" + Arrays.toString(params) + " 调用失败了!", ex); + return null; + } + } + + public static Client getClient(String wsdlUrl){ + if(CLIENT_MAP.get(wsdlUrl)==null){ + synchronized (JaxWsDynamicClient.class){ + if(CLIENT_MAP.get(wsdlUrl)==null){ + Client client = CLIENT_FACTORY.createClient(wsdlUrl); + setClientParam(client); + CLIENT_MAP.put(wsdlUrl,client); + } + } + } + return CLIENT_MAP.get(wsdlUrl); + } + + private static void setClientParam(Client client) { + HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); + httpClientPolicy.setConnectionTimeout(30000); + httpClientPolicy.setAllowChunking(false); + httpClientPolicy.setReceiveTimeout(30000); + + HTTPConduit clientConduit = (HTTPConduit) client.getConduit(); + clientConduit.setClient(httpClientPolicy); + } + + + public static void main(String[] args) { + String[] param={"111"}; + System.out.println(send("http://127.0.0.1:9311/webservice/api?wsdl","http://impl.webservice.collection.server.docus.com/", "pushUpdateInspectionReport", param)); + } +} diff --git a/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java b/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java new file mode 100644 index 0000000..0c69b6a --- /dev/null +++ b/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java @@ -0,0 +1,40 @@ +package com.docus.server.report.config; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +/** + * 应用业务配置 + * @author wyb + */ +@Component +@Getter +@Setter +public class SdRyReportQueryConfig { + @Value("${sdry.report-index-query.wsdl-addr:}") + private String queryReportIndexWsdlAddr; + @Value("${sdry.report-index-query.namespace-uri:}") + private String queryReportIndexWsdlNamespaceUri; + @Value("${sdry.report-index-query.operationName:}") + private String queryReportIndexWsdlOperationName; + + @Value("${sdry.report-query-url.lis.url:}") + private String reportQueryLisUrl; + @Value("${sdry.report-query-url.lis.assortId:}") + private String reportQueryLisAssortId; + @Value("${sdry.report-query-url.lis.action:}") + private String reportQueryLisAction; + @Value("${sdry.report-query-url.lis.accessKey:}") + private String reportQueryLisAccessKey; + + @Value("${sdry.report-query-url.inspect.url:}") + private String reportQueryInspectUrl; + @Value("${sdry.report-query-url.inspect.assortId:}") + private String reportQueryInspectAssortId; + @Value("${sdry.report-query-url.inspect.action:}") + private String reportQueryInspectAction; + @Value("${sdry.report-query-url.inspect.accessKey:}") + private String reportQueryInspectAccessKey; +} diff --git a/src/main/java/com/docus/server/report/dto/SdRyLisReportRequest.java b/src/main/java/com/docus/server/report/dto/SdRyLisReportRequest.java new file mode 100644 index 0000000..40c70b2 --- /dev/null +++ b/src/main/java/com/docus/server/report/dto/SdRyLisReportRequest.java @@ -0,0 +1,4 @@ +package com.docus.server.report.dto; + +public class SdRyLisReportRequest { +} diff --git a/src/main/java/com/docus/server/report/dto/SdRyLisReportResponse.java b/src/main/java/com/docus/server/report/dto/SdRyLisReportResponse.java new file mode 100644 index 0000000..5c33e11 --- /dev/null +++ b/src/main/java/com/docus/server/report/dto/SdRyLisReportResponse.java @@ -0,0 +1,4 @@ +package com.docus.server.report.dto; + +public class SdRyLisReportResponse { +} diff --git a/src/main/java/com/docus/server/report/entity/AfJobTime.java b/src/main/java/com/docus/server/report/entity/AfJobTime.java index 9ea10eb..14b804c 100644 --- a/src/main/java/com/docus/server/report/entity/AfJobTime.java +++ b/src/main/java/com/docus/server/report/entity/AfJobTime.java @@ -6,7 +6,6 @@ import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; -import java.time.LocalDateTime; /** *

@@ -26,8 +25,8 @@ public class AfJobTime implements Serializable { @ApiModelProperty(value = "主键id") private Long id; - @ApiModelProperty(value = "最新刷新时间") - private LocalDateTime updateTime; + @ApiModelProperty(value = "最新刷新时间 格式 yyyy-MM-dd HH:mm:ss") + private String updateTime; @ApiModelProperty(value = "调度类型。") private String jobType; @@ -35,7 +34,7 @@ public class AfJobTime implements Serializable { public AfJobTime() { } - public AfJobTime(Long id, LocalDateTime updateTime, String jobType) { + public AfJobTime(Long id, String updateTime, String jobType) { this.id = id; this.updateTime = updateTime; this.jobType = jobType; diff --git a/src/main/java/com/docus/server/report/job/ReportJob.java b/src/main/java/com/docus/server/report/job/ReportJob.java index a43a374..3ad225c 100644 --- a/src/main/java/com/docus/server/report/job/ReportJob.java +++ b/src/main/java/com/docus/server/report/job/ReportJob.java @@ -1,22 +1,37 @@ package com.docus.server.report.job; +import cn.hutool.http.HttpRequest; +import cn.hutool.http.HttpResponse; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.DateUtil; import com.docus.core.util.Func; +import com.docus.infrastructure.core.exception.BaseException; import com.docus.infrastructure.redis.service.IdService; import com.docus.server.collection.entity.TBasic; import com.docus.server.collection.mapper.TBasicMapper; +import com.docus.server.report.client.JaxWsDynamicClient; +import com.docus.server.report.config.SdRyReportQueryConfig; import com.docus.server.report.dto.ReportDto; import com.docus.server.report.entity.AfJobTime; import com.docus.server.report.entity.AfReportRecord; import com.docus.server.report.mapper.AfJobTimeMapper; import com.docus.server.report.mapper.AfReportRecordMapper; import com.docus.server.report.service.ReportService; +import com.docus.server.report.util.IdUtil; +import com.docus.server.report.util.XmlUtil; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import javax.annotation.Resource; +import java.time.Instant; +import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.List; +import java.time.ZoneId; +import java.util.*; import java.util.stream.Collectors; /** @@ -37,66 +52,502 @@ public class ReportJob { private AfJobTimeMapper afJobTimeMapper; @Resource private IdService idService; + @Resource + private SdRyReportQueryConfig sdRyReportQueryConfig; /** - * 检验报告查询,查询入院时间前 3天的检验报告 + * Lis 检验报告查询,查询入院时间前 3天的检验报告 */ - @XxlJob("LisReportQueryJob") - public void lisReportQueryJob() { + @XxlJob("SdRyLisReportQueryJob") + public void sdRyLisReportQueryJob() { // 顺德人医 Lis 检验报告查询 - final String jobType="SDryLisReport"; + final String jobType = "SdRyLisReport"; LocalDateTime now = LocalDateTime.now(); - log.info("检验报告报告查询 任务开始了"); - AfJobTime afJobTime=afJobTimeMapper.getAfJobTimeByJobType(jobType); - + log.info("LIS检验报告报告查询 任务开始了"); // 定义查基础数据 入院时间 开始结束 - String queryBasicAdmissStartDate="1801-01-01 00:00:00"; - if (afJobTime != null && afJobTime.getUpdateTime() != null) { - LocalDateTime updateTime = afJobTime.getUpdateTime(); - queryBasicAdmissStartDate = updateTime.toString(); + AfJobTime afJobTime= getJobTimeByJobType(jobType); + String queryBasicAdmissStartDate =afJobTime.getUpdateTime(); + String queryBasicAdmissEndDate = now.toString(); + // 查询基础数据定义 分页 + int offset = 0; + int pageSize = 50; + boolean loopCondition = true; + try { + do { + List basicList = tBasicMapper.selectBasicListByAdmissDate(queryBasicAdmissStartDate, queryBasicAdmissEndDate, offset, pageSize); + if (Func.isEmpty(basicList)) { + break; + } + if (basicList.size() < pageSize) { + loopCondition = false; + } + for (TBasic tBasic : basicList) { + List reportDtoList = getLisReportList(tBasic); + if (reportDtoList.isEmpty()) { + log.warn("病案主键 patientId {} 未查询 LIS 检验报告!", tBasic.getPatientId()); + continue; + } + reportDtoList.forEach(reportDto -> { + reportService.report(reportDto); + }); + } + offset += pageSize; + } while (loopCondition); + } catch (Exception ex) { + log.error("LIS检验报告报告查询 出错啦!", ex); } - String queryBasicAdmissEndDate=now.toString(); + + afJobTime.setUpdateTime(now.toString()); + refreshTime(afJobTime); + log.info("LIS检验报告报告查询 任务结束了,本次查询出院时间段 {} - {}", "", ""); + } + + + /** + * 检查报告查询,查询入院时间前 3天的检验报告 + */ + @XxlJob("SdRyInspectReportQueryJob") + public void sdRyInspectReportQueryJob() { + // 顺德人医 检查报告查询 + final String jobType = "SdRyInspectReport"; + LocalDateTime now = LocalDateTime.now(); + log.info("检查报告报告查询 任务开始了"); + // 定义查基础数据 入院时间 开始结束 + AfJobTime afJobTime= getJobTimeByJobType(jobType); + String queryBasicAdmissStartDate =afJobTime.getUpdateTime(); + String queryBasicAdmissEndDate = now.toString(); // 查询基础数据定义 分页 - int offset=0; - int size=50; + int offset = 0; + int pageSize = 50; + boolean loopCondition = true; try { do { - List basicList = tBasicMapper.selectBasicListByAdmissDate(queryBasicAdmissStartDate,queryBasicAdmissEndDate,offset,size); - if(Func.isEmpty(basicList)){ - log.warn("未查询到 入院时间 {} - {} 基础数据",queryBasicAdmissStartDate,queryBasicAdmissEndDate); + List basicList = tBasicMapper.selectBasicListByAdmissDate(queryBasicAdmissStartDate, queryBasicAdmissEndDate, offset, pageSize); + if (Func.isEmpty(basicList)) { break; } + if (basicList.size() < pageSize) { + loopCondition = false; + } for (TBasic tBasic : basicList) { - List reportDtoList= getLisReportList(tBasic); - if(reportDtoList==null || reportDtoList.isEmpty()){ - log.warn("病案主键 patientId {} 未查询 LIS 检验报告!",tBasic.getPatientId()); + List reportDtoList = getInspectReportList(tBasic); + if (reportDtoList.isEmpty()) { + log.warn("病案主键 patientId {} 未查询 检查报告!", tBasic.getPatientId()); continue; } reportDtoList.forEach(reportDto -> { reportService.report(reportDto); }); } - offset+=size; - }while (true); + offset += pageSize; + } while (loopCondition); + } catch (Exception ex) { + log.error("检查报告报告查询 出错啦!", ex); + } + + afJobTime.setUpdateTime(now.toString()); + refreshTime(afJobTime); + log.info("检查报告报告查询 任务结束了,本次查询出院时间段 {} - {}", "", ""); + } + + private List getInspectReportList(TBasic tBasic) { + // 根据基础信息查顺德报告业务系统索引,查 交叉索引 + List sdRyReportPatientIds = getSdRyReportPatientIds(tBasic.getPatientId()); + if (sdRyReportPatientIds.isEmpty()) { + log.warn("patientId:{} 未查询到检查报告患者交叉索引", tBasic.getPatientId()); + return new ArrayList<>(); + } + List reportDtoList = new ArrayList<>(); + // 根据交叉索引查询报告 + for (String sdRyReportPatientId : sdRyReportPatientIds) { + List reportDtoList2 = getInspectReportDtoListBySdRyReportPatientId(sdRyReportPatientId, tBasic); + reportDtoList.addAll(reportDtoList2); + } + return reportDtoList; + } + + private List getInspectReportDtoListBySdRyReportPatientId(String sdRyReportPatientId, TBasic tBasic) { + try { + List reportDtos = new ArrayList<>(); + int pageNum=1; + final int pageSize=10; + boolean loopCondition=true; + do { + String requestParam = organizationQuerySdRyInspectReportParam(sdRyReportPatientId, tBasic,pageNum,pageSize); + String url = organizationQuerySdRyInspectReportUrl(sdRyReportQueryConfig.getReportQueryInspectUrl()); + log.info("查询检查报告请求地址:{} ,请求body参数:{}", url, requestParam); + String respBody= this.sendPost(url,requestParam); + log.info("查询检查报告请求成功,响应参数:{}", respBody); + List reportDtoList=parseQuerySdRyInspectReport(respBody,tBasic); + if(reportDtoList.isEmpty()){ + break; + } + if(reportDtoList.size()(); + } + } + + private String organizationQuerySdRyInspectReportUrl(String reportQueryLisUrl) { + return reportQueryLisUrl + "/query?uuid=" + IdUtil.standardUUID() + + "&action=" + sdRyReportQueryConfig.getReportQueryInspectAction() + + "&accessKey=" + sdRyReportQueryConfig.getReportQueryInspectAccessKey() + + "&creationTime=" + Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI); + + } + + private String organizationQuerySdRyInspectReportParam(String sdRyReportPatientId, TBasic tBasic, int pageNum, int pageSize) { + boolean isPage = true; + String orgCode="4560886379"; + Date admissDate = tBasic.getAdmissDate(); + if(admissDate==null){ + throw new BaseException("patientId:"+tBasic.getPatientId()+"的入院时间为空"); } + Instant instant = admissDate.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDate admissLocalDate = instant.atZone(zoneId).toLocalDate(); + LocalDate endTimeLocalDate = admissLocalDate.plusDays(1); + LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3); + String startTime=startTimeLocalDate+" 00:00:00"; + String endTime=endTimeLocalDate+" 00:00:00"; - if (afJobTime == null) { + HashMap map = new HashMap<>(7); + map.put("isPage",isPage); + map.put("pageNo",pageNum); + map.put("pageSize",pageSize); + map.put("OrgCode",orgCode); + map.put("StartTime",startTime); + map.put("EndTime",endTime); + map.put("PatientId",sdRyReportPatientId); + return Func.toJson(map); + } + + private List parseQuerySdRyInspectReport(String respBody, TBasic tBasic) { + JSONObject jsonObject = Func.readJson(respBody, JSONObject.class); + Object resultCode = jsonObject.get("ResultCode"); + String successCode="0"; + if(!successCode.equals(String.valueOf(resultCode))){ + return new ArrayList<>(); + } + try { + Object data = jsonObject.get("data"); + String dataJsonStr = Func.toJson(data); + // 是否是json object ,因为返回的如果是 [] ,则不会识别为jsonObject + List reportDtoList = new ArrayList<>(); + if( Func.isJsonObject(dataJsonStr)){ + JSONObject dataJsonObject = Func.readJson(dataJsonStr, JSONObject.class); + Object result = dataJsonObject.get("result"); + String resultJsonStr = Func.toJson(result); + List reportObjectList = Func.parseJsonArray(resultJsonStr, JSONObject.class); + if(Func.isNotEmpty(reportObjectList)){ + for (JSONObject reportObject : reportObjectList) { + // 检查报告号 + String examReportSn =String.valueOf( reportObject.get("EXAM_REPORT_SN")); + // 申请单号 + String requestSn = String.valueOf(reportObject.get("REQUEST_SN")); + // pdf地址 + String pdfUrl = String.valueOf(reportObject.get("FILE_PATH")); + // 报告名称 + String reportName = String.valueOf(reportObject.get("REPORT_NAME")); + // 系统修改 + String updateBy = String.valueOf(reportObject.get("UPDATEBY")); + + ReportDto reportDto = new ReportDto(); + reportDto.setAdmisstimes(tBasic.getAdmissTimes()); + reportDto.setInpatientNo(tBasic.getInpatientNo()); + // 确定报告唯一 报告单号+申请单号 + reportDto.setSerialnum(examReportSn+requestSn); + reportDto.setFileTitle(reportName); + reportDto.setDownUrl(pdfUrl); + reportDto.setAssortId(sdRyReportQueryConfig.getReportQueryInspectAssortId()); + reportDto.setSysFlag(updateBy); + reportDto.setFileSource("1"); + reportDto.setFilestoragetype("1"); + reportDtoList.add(reportDto); + } + } + } + return reportDtoList; + }catch (Exception ex){ + log.error(ex.getMessage(),ex); + return new ArrayList<>(); + } + } + + private String sendPost(String url,String body){ + HttpRequest post = HttpUtil.createPost(url); + post.timeout(60 * 1000); + post.header("Content-Type", "application/json; charset=utf-8"); + post.body(body); + HttpResponse response = post.execute(); + return response.body(); + } + + /** + * 查询job需要的开始时间 + * @param jobType job类型 + * @return job需要的开始时间,未查到 默认 1801-01-01 00:00:00 + */ + private AfJobTime getJobTimeByJobType(String jobType){ + AfJobTime afJobTime = afJobTimeMapper.getAfJobTimeByJobType(jobType); + // 定义查基础数据 入院时间 开始结束 + String startTime = "1801-01-01 00:00:00"; + if (afJobTime ==null) { afJobTime = new AfJobTime(); afJobTime.setJobType(jobType); + afJobTime.setUpdateTime(startTime); } - afJobTime.setUpdateTime(now); - - refreshTime(afJobTime); - log.info("检验报告报告查询 任务结束了,本次查询出院时间段 {} - {}","",""); + if(Func.isBlank(afJobTime.getUpdateTime())){ + afJobTime.setUpdateTime(startTime); + } + return afJobTime; } + private List getLisReportList(TBasic tBasic) { - // TODO wyb 未完成! 2023-4-4 18:06:26 - return null; + // 根据基础信息查顺德报告业务系统索引,查 交叉索引 + List sdRyReportPatientIds = getSdRyReportPatientIds(tBasic.getPatientId()); + if (sdRyReportPatientIds.isEmpty()) { + log.warn("patientId:{} 未查询到Lis检验报告患者交叉索引", tBasic.getPatientId()); + return new ArrayList<>(); + } + List reportDtoList = new ArrayList<>(); + // 根据交叉索引查询报告 + for (String sdRyReportPatientId : sdRyReportPatientIds) { + List reportDtoList2 = getLisReportDtoListBySdRyReportPatientId(sdRyReportPatientId, tBasic); + reportDtoList.addAll(reportDtoList2); + } + return reportDtoList; + } + + private List getLisReportDtoListBySdRyReportPatientId(String sdRyReportPatientId, TBasic tBasic) { + try { + List reportDtos = new ArrayList<>(); + int pageNum=1; + final int pageSize=10; + boolean loopCondition=true; + do { + String requestParam = organizationQuerySdRyLisReportParam(sdRyReportPatientId, tBasic,pageNum,pageSize); + String url = organizationQuerySdRyLisReportUrl(sdRyReportQueryConfig.getReportQueryLisUrl()); + log.info("查询Lis报告请求地址:{} ,请求body参数:{}", url, requestParam); + HttpRequest post = HttpUtil.createPost(url); + post.timeout(60 * 1000); + post.header("Content-Type", "application/json; charset=utf-8"); + post.body(requestParam); + HttpResponse response = post.execute(); + String respBody = response.body(); + log.info("查询Lis报告请求成功,响应参数:{}", respBody); + List reportDtoList=parseQuerySdRyLisReport(respBody,tBasic); + if(reportDtoList.isEmpty()){ + break; + } + if(reportDtoList.size()(); + } + } + + private List parseQuerySdRyLisReport(String respBody, TBasic tBasic) { + JSONObject jsonObject = Func.readJson(respBody, JSONObject.class); + Object resultCode = jsonObject.get("ResultCode"); + String successCode="0"; + if(!successCode.equals(String.valueOf(resultCode))){ + return new ArrayList<>(); + } + try { + Object data = jsonObject.get("data"); + String dataJsonStr = Func.toJson(data); + // 是否是json object ,因为返回的如果是 [] ,则不会识别为jsonObject + List reportDtoList = new ArrayList<>(); + if( Func.isJsonObject(dataJsonStr)){ + JSONObject dataJsonObject = Func.readJson(dataJsonStr, JSONObject.class); + Object result = dataJsonObject.get("result"); + String resultJsonStr = Func.toJson(result); + List reportObjectList = Func.parseJsonArray(resultJsonStr, JSONObject.class); + if(Func.isNotEmpty(reportObjectList)){ + for (JSONObject reportObject : reportObjectList) { + // 检验报告号 + String labReportSn =String.valueOf( reportObject.get("LAB_REPORT_SN")); + // 申请单号 + String requestSn = String.valueOf(reportObject.get("REQUEST_SN")); + // pdf地址 + String pdfUrl = String.valueOf(reportObject.get("PDF_URL")); + // 报告名称 + String reportTypeName = String.valueOf(reportObject.get("REPORT_TYPE_NAME")); + // 系统修改 + String updateBy = String.valueOf(reportObject.get("UPDATEBY")); + + ReportDto reportDto = new ReportDto(); + reportDto.setAdmisstimes(tBasic.getAdmissTimes()); + reportDto.setInpatientNo(tBasic.getInpatientNo()); + // 确定报告唯一 报告单号+申请单号 + reportDto.setSerialnum(labReportSn+requestSn); + reportDto.setFileTitle(reportTypeName); + reportDto.setDownUrl(pdfUrl); + reportDto.setAssortId(sdRyReportQueryConfig.getReportQueryLisAssortId()); + reportDto.setSysFlag(updateBy); + reportDto.setFileSource("1"); + reportDto.setFilestoragetype("1"); + reportDtoList.add(reportDto); + } + } + } + return reportDtoList; + }catch (Exception ex){ + log.error(ex.getMessage(),ex); + return new ArrayList<>(); + } + } + + private String organizationQuerySdRyLisReportUrl(String reportQueryLisUrl) { + return reportQueryLisUrl + "/query?uuid=" + IdUtil.standardUUID() + + "&action=" + sdRyReportQueryConfig.getReportQueryLisAction() + + "&accessKey=" + sdRyReportQueryConfig.getReportQueryLisAccessKey() + + "&creationTime=" + Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI); + + } + + private String organizationQuerySdRyLisReportParam(String sdRyReportPatientId, TBasic tBasic, int pageNum, int pageSize) { + boolean isPage = true; + String orgCode="4560886379"; + Date admissDate = tBasic.getAdmissDate(); + if(admissDate==null){ + throw new BaseException("patientId:"+tBasic.getPatientId()+"的入院时间为空"); + } + Instant instant = admissDate.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDate admissLocalDate = instant.atZone(zoneId).toLocalDate(); + LocalDate endTimeLocalDate = admissLocalDate.plusDays(1); + LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3); + String startTime=startTimeLocalDate+" 00:00:00"; + String endTime=endTimeLocalDate+" 00:00:00"; + + HashMap map = new HashMap<>(7); + map.put("isPage",isPage); + map.put("pageNo",pageNum); + map.put("pageSize",pageSize); + map.put("OrgCode",orgCode); + map.put("StartTime",startTime); + map.put("EndTime",endTime); + map.put("PatientId",sdRyReportPatientId); + return Func.toJson(map); + } + + /** + * 根据归档病案主键查询报告交叉索引 + * + * @param patientId 归档病案主键 + * @return 报告交叉索引 + */ + private List getSdRyReportPatientIds(String patientId) { + String sDryIndex = tBasicMapper.getSdRyIndexByPatientId(patientId); + if (Func.isBlank(sDryIndex)) { + log.warn("patientId:{} 未关联到第三方索引", patientId); + return new ArrayList<>(); + } + String param = organizationQuerySdRyReportIndexParam(sDryIndex); + String[] params = {param}; + String namespaceUri = sdRyReportQueryConfig.getQueryReportIndexWsdlNamespaceUri(); + String wsdlAddr = sdRyReportQueryConfig.getQueryReportIndexWsdlAddr(); + String operationName = sdRyReportQueryConfig.getQueryReportIndexWsdlOperationName(); + String result = JaxWsDynamicClient.send(wsdlAddr, namespaceUri, operationName, params); + log.info("查询顺德人医患者交叉索引数据,返回值:{}", result); + if (result == null) { + return new ArrayList<>(); + } + return parseQuerySdRyReportIndex(result); } + /** + * 组织顺德人医查询交叉索引的请求参数 + * + * @param sDryIndex 顺德人医关联索引 + * @return 顺德人医查询交叉索引的请求参数 + */ + private String organizationQuerySdRyReportIndexParam(String sDryIndex) { + sDryIndex = sDryIndex.toLowerCase() + .replace("m", "") + .replace("z", ""); + String receiver = "Orion-001"; + String sender = "PaperlessManagementMRIS-001"; + String now = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI); + + return "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + "\n"; + } + + + private static List parseQuerySdRyReportIndex(String result) { + try { + XmlUtil xmlUtil = XmlUtil.of(result); + NodeList nodeList = xmlUtil.getNodeList("/PRPA_HIP1179/controlActProcess/subject/empiIndex/patientIds/patientId"); + int nodeListLength = nodeList.getLength(); + ArrayList patientIds = new ArrayList<>(); + if (nodeListLength > 0) { + for (int i = 0; i < nodeListLength; i++) { + Node node = nodeList.item(i); + String patientId = node.getTextContent(); + if (Func.isNotBlank(patientId)) { + patientIds.add(patientId); + } + } + } + return patientIds; + } catch (Exception ex) { + log.error("顺德人医解析患者交叉索引失败。", ex); + return new ArrayList<>(); + } + } + + private void refreshTime(AfJobTime afJobTime) { if (afJobTime.getId() == null) { afJobTime.setId(idService.getDateSeq()); diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 1a74554..2e663e5 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -41,6 +41,29 @@ spring: shared-configs: - comm.${spring.cloud.nacos.config.file-extension} +sdry: + # 顺德人医查询检查、检验报告之前查患者交叉索引的wsdl配置 + report-index-query: + wsdl-addr: http://127.0.0.1:9311/webservice/api?wsdl + namespace-uri: http://impl.webservice.collection.server.docus.com/ + operationName: pushUpdateInspectionReport + # 顺德人医查询检查、检验报告的地址配置 + report-query-url: + # lis检验报告地址 和文件分段 + lis: + url: http://127.0.0.1:9311/report/makeup/lisReport + assortId: lis + action: 1 + accessKey: 1 + # 检查报告地址 + inspect: + url: http://127.0.0.1:9311/report/makeup/lisReport + assortId: inspect + action: 1 + accessKey: 1 + + + docus: dbtype: mysql diff --git a/src/main/resources/mapper/AfJobTimeMapper.xml b/src/main/resources/mapper/AfJobTimeMapper.xml index fa917d9..f46eacc 100644 --- a/src/main/resources/mapper/AfJobTimeMapper.xml +++ b/src/main/resources/mapper/AfJobTimeMapper.xml @@ -15,8 +15,8 @@ diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 6044f87..2773e6e 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -110,4 +110,9 @@ limit #{offset} , #{size} +