检查、检验报告住院门诊查询,检查通过pacs进行base64下载方式

3.2.4.44
wyb 2 years ago
parent 62482ca042
commit 703b8f8063

@ -1,5 +1,7 @@
package com.docus.server.report.api;
import com.docus.server.report.api.dto.SdJxReportDto;
import java.util.List;
/**
@ -14,7 +16,20 @@ public interface ShunDePeopleService {
* @param sdRyIndex
* @return
*/
List<String> getSdRyReportPatientIds(String sdRyIndex);
List<String> getSdRyReportJxIds(String sdRyIndex);
/**
*
* @param sdJxReportDto
* @return
*/
String getInspectReportByJxId(SdJxReportDto sdJxReportDto);
/**
* Lis
* @param sdJxReportDto
* @return
*/
String getLisReportByJxId(SdJxReportDto sdJxReportDto);
/**
* PACSPDFPDFBASE64

@ -0,0 +1,28 @@
package com.docus.server.report.api.dto;
import lombok.Data;
@Data
public class SdJxReportDto {
private boolean isPage=true;
private int pageNo=1;
private int pageSize=5;
private String orgCode="4560886379";
/**
*
*/
private String startTime;
/**
*
*/
private String endTime;
/**
* webservice,
*/
private String patientId;
/**
* 1 3
*/
private String patentTypeCode="1";
}

@ -1,8 +1,12 @@
package com.docus.server.report.api.impl;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.docus.core.util.DateUtil;
import com.docus.core.util.Func;
import com.docus.server.report.api.ShunDePeopleService;
import com.docus.server.report.api.dto.SdJxReportDto;
import com.docus.server.report.api.dto.SdPacsServerConfig;
import com.docus.server.report.client.JaxWsDynamicClient;
import com.docus.server.report.config.SdRyReportQueryConfig;
@ -17,6 +21,7 @@ import org.w3c.dom.NodeList;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
@ -32,17 +37,53 @@ import java.util.concurrent.locks.ReentrantLock;
public class ShunDePeopleServiceImpl implements ShunDePeopleService {
private static final Lock INDEX_LOCK = new ReentrantLock();
private static final Lock PACS_PDF_LOCK = new ReentrantLock();
private static final Lock INSPECT_REPORT_LOCK = new ReentrantLock();
private static final Lock LIS_REPORT_LOCK = new ReentrantLock();
@Resource
private SdRyReportQueryConfig sdRyReportQueryConfig;
public static void main(String[] args) {
ShunDePeopleServiceImpl shunDePeopleService = new ShunDePeopleServiceImpl();
String base64PdfFromPacs = shunDePeopleService.getBase64PdfFromPacs("121", "1");
System.out.println(base64PdfFromPacs);
@Override
public String getInspectReportByJxId(SdJxReportDto sdJxReportDto) {
String requestParam = organizationQuerySdRyInspectReportParam(sdJxReportDto);
String url = organizationQuerySdRyInspectReportUrl(sdRyReportQueryConfig.getReportQueryInspectUrl());
log.info("查询检查报告请求地址:{} ,请求body参数:{}", url, requestParam);
INSPECT_REPORT_LOCK.lock();
try {
String respBody = this.sendPost(url, requestParam);
log.info("查询检查报告请求成功,响应参数:{}", respBody);
TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryInspectInterval());
return respBody;
} catch (Exception ex) {
log.error("查询检查报告失败:"+ex.getMessage(), ex);
return "";
} finally {
INSPECT_REPORT_LOCK.unlock();
}
}
@Override
public List<String> getSdRyReportPatientIds(String sdRyIndex) {
public String getLisReportByJxId(SdJxReportDto sdJxReportDto) {
String requestParam = organizationQuerySdRyLisReportParam(sdJxReportDto);
String url = organizationQuerySdRyLisReportUrl(sdRyReportQueryConfig.getReportQueryInspectUrl());
log.info("查询LIS检验报告请求地址{} ,请求body参数:{}", url, requestParam);
LIS_REPORT_LOCK.lock();
try {
String respBody = this.sendPost(url, requestParam);
log.info("查询LIS检验报告请求成功,响应参数:{}", respBody);
TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryLisInterval());
return respBody;
} catch (Exception ex) {
log.error("查询LIS检验报告失败"+ex.getMessage(), ex);
return "";
} finally {
LIS_REPORT_LOCK.unlock();
}
}
@Override
public List<String> getSdRyReportJxIds(String sdRyIndex) {
List<String> indexes = new ArrayList<>();
try {
String zyParam = organizationQuerySdRyReportIndexParam(sdRyIndex, 3);
@ -91,6 +132,65 @@ public class ShunDePeopleServiceImpl implements ShunDePeopleService {
}
}
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(SdJxReportDto dto) {
String patientId = dto.getPatientId();
if("1".equals(dto.getPatentTypeCode())){
patientId="m"+patientId;
}
if("3".equals(dto.getPatentTypeCode())){
patientId="z"+patientId;
}
HashMap<Object, Object> map = new HashMap<>(7);
map.put("isPage", dto.isPage());
map.put("pageNo", dto.getPageNo());
map.put("pageSize", dto.getPageSize());
map.put("OrgCode", dto.getOrgCode());
map.put("StartTime", dto.getStartTime());
map.put("EndTime", dto.getEndTime());
map.put("PatientId", patientId);
map.put("PatentTypeCode", dto.getPatentTypeCode());
return Func.toJson(map);
}
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(SdJxReportDto dto) {
String patientId = dto.getPatientId();
if("1".equals(dto.getPatentTypeCode())){
patientId="m"+patientId;
}
if("3".equals(dto.getPatentTypeCode())){
patientId="z"+patientId;
}
HashMap<Object, Object> map = new HashMap<>(7);
map.put("isPage", dto.isPage());
map.put("pageNo", dto.getPageNo());
map.put("pageSize", dto.getPageSize());
map.put("OrgCode", dto.getOrgCode());
map.put("StartTime", dto.getStartTime());
map.put("EndTime", dto.getEndTime());
map.put("PatientId", patientId);
map.put("PatentTypeCode", dto.getPatentTypeCode());
return Func.toJson(map);
}
private String getPdfReportBase64InputString(String examNo, String reportNo, SdPacsServerConfig config) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<!-- PDF报告请求消息 -->\n" +
@ -205,4 +305,14 @@ public class ShunDePeopleServiceImpl implements ShunDePeopleService {
"\t</controlActProcess>\n" +
"</PRPA_HIP1179>\n";
}
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();
}
}

@ -0,0 +1,26 @@
package com.docus.server.report.config;
import com.alibaba.fastjson.JSONObject;
import com.docus.server.report.util.TableJsonRead;
public class ZdAssortConfig {
/**
* id
* @param type
* @return id
*/
public static String getZdAssortId(String type){
TableJsonRead jsonRead = new TableJsonRead();
JSONObject tableTypeJson = jsonRead.Read("data-config", "js-table-type.json", JSONObject.class);
return tableTypeJson.getString(type);
}
/**
* id
* @return id
*/
public static String getOtherAssortId(){
return getZdAssortId("other");
}
}

@ -109,19 +109,7 @@ public class ReportDownController {
}
@ApiOperation(value = "report lis job 测试", hidden = true)
@PostMapping("/lisreportJobTest")
public CommonResult<String> LisreportJobTest() {
reportJob.sdRyLisReportQueryJob();
return CommonResult.success("成功");
}
@ApiOperation(value = "report inspect job 测试", hidden = true)
@PostMapping("/inspectReportJobTest")
public CommonResult<String> inspectReportJobTest() {
reportJob.sdRyInspectReportQueryJob();
return CommonResult.success("成功");
}
@ApiOperation(value = "inspect检查报告测试地址", hidden = true)

@ -1,10 +1,6 @@
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;
@ -14,26 +10,32 @@ import com.docus.server.report.api.ShunDePeopleService;
import com.docus.server.report.api.TaskDistributeService;
import com.docus.server.report.api.dto.ReportDownTwoDto;
import com.docus.server.report.api.dto.ReportDto;
import com.docus.server.report.api.dto.SdJxReportDto;
import com.docus.server.report.config.SdRyReportQueryConfig;
import com.docus.server.report.config.ZdAssortConfig;
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 javax.annotation.Resource;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
@ -109,89 +111,6 @@ public class ReportJob {
}
/**
* Lis {@link com.docus.server.report.job.ReportJob#sdRyLisCollectJob }
*/
@XxlJob("SdRyLisReportQueryJob")
@Deprecated
public void sdRyLisReportQueryJob() {
// 顺德人医 Lis 检验报告查询
final String jobType = "SdRyLisReport";
LocalDateTime now = LocalDateTime.now();
// 等待基础数据入库时间
now = now.plusMinutes(-10);
log.info("LIS检验报告报告查询 任务开始了");
// 定义查基础数据 根据基础数据的创建时间
AfJobTime afJobTime = getJobTimeByJobType(jobType);
String queryBasicStartDate = afJobTime.getUpdateTime();
String queryBasicEndDate = DateUtil.formatDateTime(now);
// 查询基础数据定义 分页
int offset = 0;
int pageSize = 50;
boolean loopCondition = true;
try {
do {
List<TBasic> basicList = tBasicMapper.selectBasicListByCreateOrUpdateTime(queryBasicStartDate, queryBasicEndDate, offset, pageSize);
if (Func.isEmpty(basicList)) {
break;
}
if (basicList.size() < pageSize) {
loopCondition = false;
}
queryLisReport(basicList);
offset += pageSize;
} while (loopCondition);
} catch (Exception ex) {
log.error("LIS检验报告报告查询 出错啦!", ex);
}
afJobTime.setUpdateTime(DateUtil.formatDateTime(now));
refreshTime(afJobTime);
log.info("LIS检验报告报告查询 任务结束了,本次查询出院时间段 {} - {}", "", "");
}
/**
* , {@link com.docus.server.report.job.ReportJob#SdRyInspectCollectJob }
*/
@XxlJob("SdRyInspectReportQueryJob")
@Deprecated
public void sdRyInspectReportQueryJob() {
// 顺德人医 检查报告查询
final String jobType = "SdRyInspectReport";
LocalDateTime now = LocalDateTime.now();
// 等待基础数据入库时间
now = now.plusMinutes(-10);
log.info("检查报告报告查询 任务开始了");
// 定义查基础数据 更新时间 开始结束
AfJobTime afJobTime = getJobTimeByJobType(jobType);
String queryBasicStartDate = afJobTime.getUpdateTime();
String queryBasicEndDate = DateUtil.formatDateTime(now);
// 查询基础数据定义 分页
int offset = 0;
int pageSize = 50;
boolean loopCondition = true;
try {
do {
List<TBasic> basicList = tBasicMapper.selectBasicListByCreateOrUpdateTime(queryBasicStartDate, queryBasicEndDate, offset, pageSize);
if (Func.isEmpty(basicList)) {
break;
}
if (basicList.size() < pageSize) {
loopCondition = false;
}
queryInspectReport(basicList);
offset += pageSize;
} while (loopCondition);
} catch (Exception ex) {
log.error("检查报告报告查询 出错啦!", ex);
}
afJobTime.setUpdateTime(DateUtil.formatDateTime(now));
refreshTime(afJobTime);
log.info("检查报告报告查询 任务结束了,本次查询出院时间段 {} - {}", "", "");
}
public List<ReportDto> collectLisReport(TBasic tBasic) {
List<ReportDto> reportDtoList = getLisReportList(tBasic);
if (reportDtoList.isEmpty()) {
@ -209,7 +128,6 @@ public class ReportJob {
}
public void queryLisReport(List<TBasic> basicList) {
for (TBasic tBasic : basicList) {
List<ReportDto> reportDtoList = getLisReportList(tBasic);
@ -236,8 +154,6 @@ public class ReportJob {
}
}
private static Lock inspectReportLock = new ReentrantLock();
private List<ReportDto> getInspectReportList(TBasic tBasic) {
// 根据基础信息查顺德报告业务系统索引,查 交叉索引
List<String> sdRyReportPatientIds = getSdRyReportPatientIds(tBasic.getPatientId());
@ -248,33 +164,54 @@ public class ReportJob {
List<ReportDto> reportDtoList = new ArrayList<>();
// 根据交叉索引查询报告
for (String sdRyReportPatientId : sdRyReportPatientIds) {
List<ReportDto> reportDtoList2 = getInspectReportDtoListBySdRyReportPatientId(sdRyReportPatientId, tBasic);
List<ReportDto> reportDtoList2 = getInspectReportBySdRyJxId(sdRyReportPatientId, tBasic);
reportDtoList.addAll(reportDtoList2);
}
return reportDtoList;
}
private List<ReportDto> getInspectReportDtoListBySdRyReportPatientId(String sdRyReportPatientId, TBasic tBasic) {
private List<ReportDto> getInspectReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
List<ReportDto> list = new ArrayList<>();
List<ReportDto> mzInspectReportBySdRyJxId = getMzInspectReportBySdRyJxId(sdRyReportPatientId, tBasic);
List<ReportDto> zyInspectReportBySdRyJxId = getZyInspectReportBySdRyJxId(sdRyReportPatientId, tBasic);
list.addAll(mzInspectReportBySdRyJxId);
list.addAll(zyInspectReportBySdRyJxId);
return list;
}
private List<ReportDto> getMzInspectReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
try {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
do {
String requestParam = organizationQuerySdRyInspectReportParam(sdRyReportPatientId, tBasic, pageNum, pageSize);
String url = organizationQuerySdRyInspectReportUrl(sdRyReportQueryConfig.getReportQueryInspectUrl());
log.info("查询检查报告请求地址:{} ,请求body参数:{}", url, requestParam);
String respBody = "";
inspectReportLock.lock();
try {
respBody = this.sendPost(url, requestParam);
TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryInspectInterval());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
} finally {
inspectReportLock.unlock();
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
}
log.info("查询检查报告请求成功,响应参数:{}", respBody);
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
SdJxReportDto sdJxReportDto = new SdJxReportDto();
sdJxReportDto.setPage(true);
sdJxReportDto.setPageNo(pageNum);
sdJxReportDto.setPageSize(pageSize);
sdJxReportDto.setPatientId(sdRyReportPatientId);
sdJxReportDto.setStartTime(startTime);
sdJxReportDto.setEndTime(endTime);
sdJxReportDto.setPatentTypeCode("1");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getInspectReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
break;
@ -287,48 +224,59 @@ public class ReportJob {
} while (loopCondition);
return reportDtos;
} catch (Exception ex) {
log.error("查询检查报告出错啦!", ex);
log.error("查询门诊检查报告出错啦!", ex);
return new ArrayList<>();
}
}
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 List<ReportDto> getZyInspectReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
try {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
}
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
SdJxReportDto sdJxReportDto = new SdJxReportDto();
sdJxReportDto.setPage(true);
sdJxReportDto.setPageNo(pageNum);
sdJxReportDto.setPageSize(pageSize);
sdJxReportDto.setPatientId(sdRyReportPatientId);
sdJxReportDto.setStartTime(startTime);
sdJxReportDto.setEndTime(endTime);
sdJxReportDto.setPatentTypeCode("3");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getInspectReportByJxId(sdJxReportDto);
private String organizationQuerySdRyInspectReportParam(String sdRyReportPatientId, TBasic tBasic, int pageNum, int pageSize) {
boolean isPage = true;
String orgCode = "4560886379";
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
List<ReportDto> reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
return reportDtos;
} catch (Exception ex) {
log.error("查询住院检查报告出错啦!", ex);
return new ArrayList<>();
}
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
sdRyReportPatientId = "m" + sdRyReportPatientId;
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
HashMap<Object, Object> 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);
map.put("PatentTypeCode", "1");
return Func.toJson(map);
}
private List<ReportDto> parseQuerySdRyInspectReport(String respBody, TBasic tBasic) {
@ -367,8 +315,19 @@ public class ReportJob {
// 确定报告唯一 报告单号+申请单号
reportDto.setSerialnum(examReportSn + requestSn);
reportDto.setFileTitle(reportName);
reportDto.setDownUrl(pdfUrl);
reportDto.setAssortId(sdRyReportQueryConfig.getReportQueryInspectAssortId());
// 检查报告需要从Pacs接口获取base64
String[] split = examReportSn.split("_");
String fromPacs = shunDePeopleService.getBase64PdfFromPacs(split[0], split[1]);
// 从pacs打印出来
String base64 = parsePacsGetBase64(fromPacs);
if (Func.isBlank(base64)) {
continue;
}
String url = saveBase64(base64);
reportDto.setDownUrl(url);
reportDto.setDowntype(5);
// 根据系统来分类
reportDto.setAssortId(ZdAssortConfig.getZdAssortId(updateBy));
reportDto.setSysFlag(updateBy);
reportDto.setFileSource("1");
reportDto.setFilestoragetype("1");
@ -383,34 +342,51 @@ public class ReportJob {
}
}
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);
private String saveBase64(String base64) throws IOException {
String dir;
try {
File current = new File(".");
String canonicalPath = current.getCanonicalPath();
String dirPath = canonicalPath + File.separator + "base64";
File dirFile = new File(dirPath);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
dir = dirPath;
} catch (Exception e) {
String temp = "C:\\docus\\base64";
File file1 = new File(temp);
if (!file1.exists()) {
file1.mkdirs();
}
dir = temp;
}
if (Func.isBlank(afJobTime.getUpdateTime())) {
afJobTime.setUpdateTime(startTime);
String base64File = dir + File.separator + idService.getDateSeq() + ".txt";
try (FileWriter fileWriter = new FileWriter(base64File);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) {
bufferedWriter.write(base64);
bufferedWriter.flush();
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return null;
}
return base64File;
}
private static String parsePacsGetBase64(String xml) {
try {
XmlUtil xmlUtil = XmlUtil.of(xml);
Node codeNode = xmlUtil.getNode("/Result/Code");
if ("0".equals(codeNode.getTextContent())) {
Node base64Node = xmlUtil.getNode("/Result/Base64");
return base64Node.getTextContent();
}
} catch (Exception ex) {
log.error("解析pacs返回的base64信息失败" + ex.getMessage(), ex);
return null;
}
return afJobTime;
return null;
}
@ -424,41 +400,111 @@ public class ReportJob {
List<ReportDto> reportDtoList = new ArrayList<>();
// 根据交叉索引查询报告
for (String sdRyReportPatientId : sdRyReportPatientIds) {
List<ReportDto> reportDtoList2 = getLisReportDtoListBySdRyReportPatientId(sdRyReportPatientId, tBasic);
List<ReportDto> reportDtoList2 = getLisReportBySdRyJxId(sdRyReportPatientId, tBasic);
reportDtoList.addAll(reportDtoList2);
}
return reportDtoList;
}
private static Lock lisReportLock = new ReentrantLock();
private List<ReportDto> getLisReportDtoListBySdRyReportPatientId(String sdRyReportPatientId, TBasic tBasic) {
private List<ReportDto> getLisReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
List<ReportDto> list = new ArrayList<>();
List<ReportDto> zyLisReportBySdRyJxId = getZyLisReportBySdRyJxId(sdRyReportPatientId, tBasic);
List<ReportDto> mzLisReportBySdRyJxId = getMzLisReportBySdRyJxId(sdRyReportPatientId, tBasic);
list.addAll(mzLisReportBySdRyJxId);
list.addAll(zyLisReportBySdRyJxId);
return list;
}
/**
*
*/
private List<ReportDto> getZyLisReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
try {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
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 = "";
lisReportLock.lock();
try {
respBody = response.body();
TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryLisInterval());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
} finally {
lisReportLock.unlock();
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
}
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
SdJxReportDto sdJxReportDto = new SdJxReportDto();
sdJxReportDto.setPage(true);
sdJxReportDto.setPageNo(pageNum);
sdJxReportDto.setPageSize(pageSize);
sdJxReportDto.setPatientId(sdRyReportPatientId);
sdJxReportDto.setStartTime(startTime);
sdJxReportDto.setEndTime(endTime);
sdJxReportDto.setPatentTypeCode("3");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getLisReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
break;
}
if (reportDtoList.size() < pageSize) {
loopCondition = false;
}
reportDtos.addAll(reportDtoList);
pageNum++;
} while (loopCondition);
return reportDtos;
} catch (Exception ex) {
log.error("查询Lis报告出错啦", ex);
return new ArrayList<>();
}
}
log.info("查询Lis报告请求成功,响应参数:{}", respBody);
/**
*
*/
private List<ReportDto> getMzLisReportBySdRyJxId(String sdRyReportPatientId, TBasic tBasic) {
try {
List<ReportDto> reportDtos = new ArrayList<>();
int pageNum = 1;
final int pageSize = 5;
boolean loopCondition = true;
do {
Date admissDate = tBasic.getAdmissDate();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
}
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
SdJxReportDto sdJxReportDto = new SdJxReportDto();
sdJxReportDto.setPage(true);
sdJxReportDto.setPageNo(pageNum);
sdJxReportDto.setPageSize(pageSize);
sdJxReportDto.setPatientId(sdRyReportPatientId);
sdJxReportDto.setStartTime(startTime);
sdJxReportDto.setEndTime(endTime);
sdJxReportDto.setPatentTypeCode("1");
sdJxReportDto.setOrgCode("4560886379");
String respBody = shunDePeopleService.getLisReportByJxId(sdJxReportDto);
List<ReportDto> reportDtoList = parseQuerySdRyLisReport(respBody, tBasic);
if (reportDtoList.isEmpty()) {
break;
@ -513,7 +559,8 @@ public class ReportJob {
reportDto.setSerialnum(labReportSn + requestSn);
reportDto.setFileTitle(reportTypeName);
reportDto.setDownUrl(pdfUrl);
reportDto.setAssortId(sdRyReportQueryConfig.getReportQueryLisAssortId());
// 根据系统来分类
reportDto.setAssortId(ZdAssortConfig.getZdAssortId(updateBy));
reportDto.setSysFlag(updateBy);
reportDto.setFileSource("1");
reportDto.setFilestoragetype("1");
@ -528,46 +575,6 @@ public class ReportJob {
}
}
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();
Date disDate = tBasic.getDisDate();
if (admissDate == null || disDate == null) {
throw new BaseException("patientId" + tBasic.getPatientId() + "的入院时间为空");
}
ZoneId zoneId = ZoneId.systemDefault();
Instant adminssDateInstant = admissDate.toInstant();
Instant disDateInstant = disDate.toInstant();
sdRyReportPatientId = "m" + sdRyReportPatientId;
// 开始时间去入院前三天
LocalDate admissLocalDate = adminssDateInstant.atZone(zoneId).toLocalDate();
LocalDate startTimeLocalDate = admissLocalDate.plusDays(-3);
LocalDate disLocalDate = disDateInstant.atZone(zoneId).toLocalDate();
String startTime = startTimeLocalDate.toString() + " 00:00:00";
String endTime = disLocalDate.toString() + " 23:59:59";
HashMap<Object, Object> 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);
map.put("PatentTypeCode", "1");
return Func.toJson(map);
}
/**
*
@ -582,7 +589,7 @@ public class ReportJob {
log.warn("归档系统 patientId:{} 未关联到第三方索引", patientId);
return new ArrayList<>();
}
return shunDePeopleService.getSdRyReportPatientIds(sDryIndex);
return shunDePeopleService.getSdRyReportJxIds(sDryIndex);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return new ArrayList<>();
@ -590,8 +597,6 @@ public class ReportJob {
}
private void refreshTime(AfJobTime afJobTime) {
if (afJobTime.getId() == null) {
afJobTime.setId(idService.getDateSeq());

@ -1,10 +1,10 @@
package com.docus.server.report.webservice.impl;
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.server.report.api.dto.ReportDto;
import com.docus.server.report.config.ZdAssortConfig;
import com.docus.server.report.service.ReportService;
import com.docus.server.report.util.IdUtil;
import com.docus.server.report.util.JSXMLResult;
@ -60,7 +60,6 @@ public class SdryReportServerImpl implements IReportServer {
*/
public ReportDto getReportDtoByJSXML(XmlUtil xmlUtil) {
TableJsonRead jsonRead = new TableJsonRead();
JSONObject tableTypeJson = jsonRead.Read("data-config", "js-table-type.json", JSONObject.class);
String jsReportConfigXml = jsonRead.ReadContent("data-config", "js-report-config.xml");
XmlUtil configXmlUtil = XmlUtil.of(jsReportConfigXml);
@ -109,10 +108,10 @@ public class SdryReportServerImpl implements IReportServer {
if (Func.isEmpty(assortIdValueNode)) {
assortId = assortIdValueNode.getNodeValue();
} else {
assortId = tableTypeJson.getString(tableType);
assortId= ZdAssortConfig.getZdAssortId(tableType);
}
if (Func.isBlank(assortId)) {
assortId = tableTypeJson.getString("other");
assortId = ZdAssortConfig.getOtherAssortId();
}
} else {
Node assortIdNode = xmlUtil.getNode(assortIdXpath);

Loading…
Cancel
Save