|
|
|
@ -0,0 +1,208 @@
|
|
|
|
|
package com.docus.server.report.api.impl;
|
|
|
|
|
|
|
|
|
|
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.SdPacsServerConfig;
|
|
|
|
|
import com.docus.server.report.client.JaxWsDynamicClient;
|
|
|
|
|
import com.docus.server.report.config.SdRyReportQueryConfig;
|
|
|
|
|
import com.docus.server.report.util.IdUtil;
|
|
|
|
|
import com.docus.server.report.util.TableJsonRead;
|
|
|
|
|
import com.docus.server.report.util.XmlUtil;
|
|
|
|
|
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.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 顺德人医调用
|
|
|
|
|
*
|
|
|
|
|
* @author wyb
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class ShunDePeopleServiceImpl implements ShunDePeopleService {
|
|
|
|
|
private static final Lock INDEX_LOCK = new ReentrantLock();
|
|
|
|
|
private static final Lock PACS_PDF_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 List<String> getSdRyReportPatientIds(String sdRyIndex) {
|
|
|
|
|
List<String> indexes = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String zyParam = organizationQuerySdRyReportIndexParam(sdRyIndex, 3);
|
|
|
|
|
String mzParam = organizationQuerySdRyReportIndexParam(sdRyIndex, 1);
|
|
|
|
|
String[] zyParams = {"HIP1179", zyParam};
|
|
|
|
|
String[] mzParams = {"HIP1179", mzParam};
|
|
|
|
|
List<String> zyIndex = getIndex(zyParams);
|
|
|
|
|
indexes.addAll(zyIndex);
|
|
|
|
|
List<String> mzIndex = getIndex(mzParams);
|
|
|
|
|
indexes.addAll(mzIndex);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(ex.getMessage(), ex);
|
|
|
|
|
}
|
|
|
|
|
return indexes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getBase64PdfFromPacs(String examNo, String reportNo) {
|
|
|
|
|
TableJsonRead jsonRead = new TableJsonRead();
|
|
|
|
|
SdPacsServerConfig config = jsonRead.Read("data-config", "sdry-pacs-server.json", SdPacsServerConfig.class);
|
|
|
|
|
String url = config.getUrl();
|
|
|
|
|
String namespaceUri = config.getNamespaceUri();
|
|
|
|
|
String operationName = config.getOperationName();
|
|
|
|
|
String functionType = config.getFunctionType();
|
|
|
|
|
String functionName = config.getFunctionName();
|
|
|
|
|
String caller = config.getCaller();
|
|
|
|
|
int interval = config.getInterval();
|
|
|
|
|
String inputString = getPdfReportBase64InputString(examNo, reportNo, config);
|
|
|
|
|
// 参数1(FunctionName):此参数用于区分不同的场景,具体看每个场景说明
|
|
|
|
|
// 参数2(InputString):请求消息串,看具体场景说明
|
|
|
|
|
// 参数3(FunctionType):传空,暂未启用
|
|
|
|
|
// 参数4(Caller):服务调用者名称,由PACS提供,验证令牌时
|
|
|
|
|
String[] param = {functionName, inputString, functionType, caller};
|
|
|
|
|
PACS_PDF_LOCK.lock();
|
|
|
|
|
try {
|
|
|
|
|
String result = JaxWsDynamicClient.send(url, namespaceUri, operationName, param);
|
|
|
|
|
if (interval > 0) {
|
|
|
|
|
TimeUnit.MILLISECONDS.sleep(interval);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(ex.getMessage(), ex);
|
|
|
|
|
return null;
|
|
|
|
|
} finally {
|
|
|
|
|
PACS_PDF_LOCK.unlock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getPdfReportBase64InputString(String examNo, String reportNo, SdPacsServerConfig config) {
|
|
|
|
|
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
|
|
|
|
"<!-- PDF报告请求消息 -->\n" +
|
|
|
|
|
"<QueryInfo>\n" +
|
|
|
|
|
"<!-- 调用系统 -->\n" +
|
|
|
|
|
"\t<LicenseInfo>\n" +
|
|
|
|
|
"\t\t<!-- 调用系统 -->\n" +
|
|
|
|
|
"\t\t<Caller>" + config.getLicenseInfo().getCaller() + "</Caller>\n" +
|
|
|
|
|
"\t\t<!-- 调用令牌(由PACS提供) -->\n" +
|
|
|
|
|
"\t\t<License>" + config.getLicenseInfo().getLicense() + "</License>\n" +
|
|
|
|
|
"\t</LicenseInfo>\n" +
|
|
|
|
|
"\t<!-- 检查流水号 -->\n" +
|
|
|
|
|
"\t<ExamNo>" + examNo + "</ExamNo>\n" +
|
|
|
|
|
"\t<!-- 报告序号 -->\n" +
|
|
|
|
|
"\t<ReportNo>" + reportNo + "</ReportNo>\n" +
|
|
|
|
|
"</QueryInfo>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<String> getIndex(String[] params) {
|
|
|
|
|
INDEX_LOCK.lock();
|
|
|
|
|
try {
|
|
|
|
|
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<>();
|
|
|
|
|
}
|
|
|
|
|
TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getQueryReportIndexInterval());
|
|
|
|
|
return parseQuerySdRyReportIndex(result);
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
log.error(ex.getMessage(), ex);
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
} finally {
|
|
|
|
|
INDEX_LOCK.unlock();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<String> 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<String> 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<>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组织顺德人医查询交叉索引的请求参数
|
|
|
|
|
*
|
|
|
|
|
* @param sDryIndex 顺德人医关联索引
|
|
|
|
|
* @param type 1:门诊 3:住院
|
|
|
|
|
* @return 顺德人医查询交叉索引的请求参数
|
|
|
|
|
*/
|
|
|
|
|
private String organizationQuerySdRyReportIndexParam(String sDryIndex, int type) {
|
|
|
|
|
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 "<PRPA_HIP1179 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ITSVersion=\"XML_1.0\" xmlns=\"urn:hl7-org:v3\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/PRPA_IN201306UV02.xsd\">\n" +
|
|
|
|
|
"\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
|
|
|
|
|
"\t<creationTime value=\"" + now + "\"/>\n" +
|
|
|
|
|
"\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"PRPA_IHIP1179\"/>\n" +
|
|
|
|
|
"\t<processingCode code=\"P\"/>\n" +
|
|
|
|
|
"\t<processingModeCode/>\n" +
|
|
|
|
|
"\t<acceptAckCode code=\"AL\"/>\n" +
|
|
|
|
|
"\t<receiver typeCode=\"RCV\">\n" +
|
|
|
|
|
"\t\t<telecom/>\n" +
|
|
|
|
|
"\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
|
|
|
|
|
"\t\t\t<id>\n" +
|
|
|
|
|
"\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
|
|
|
|
|
"\t\t\t</id>\n" +
|
|
|
|
|
"\t\t</device>\n" +
|
|
|
|
|
"\t</receiver>\n" +
|
|
|
|
|
"\t<sender typeCode=\"SND\">\n" +
|
|
|
|
|
"\t\t<telecom/>\n" +
|
|
|
|
|
"\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
|
|
|
|
|
"\t\t\t<id>\n" +
|
|
|
|
|
"\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
|
|
|
|
|
"\t\t\t</id>\n" +
|
|
|
|
|
"\t\t</device>\n" +
|
|
|
|
|
"\t</sender>\n" +
|
|
|
|
|
"\t<controlActProcess classCode=\"CACT\" moodCode=\"EVN\">\n" +
|
|
|
|
|
"\t\t<code code=\"empiIndexQuery\">\n" +
|
|
|
|
|
"\t\t\t<displayName value=\"交叉索引查询\"/>\n" +
|
|
|
|
|
"\t\t</code>\n" +
|
|
|
|
|
"\t\t<queryByParameter>\n" +
|
|
|
|
|
"\t\t\t<!-- 查询条件:type:类型 value:值 -->\n" +
|
|
|
|
|
"\t\t\t<!--type 1:患者id 2:身份证 3::电子健康码-->\n" +
|
|
|
|
|
"\t\t\t<queryParam type=\"1\" value=\"" + sDryIndex + "\"/>\n" +
|
|
|
|
|
"\t\t\t<!--1:门诊 3:住院-->\n" +
|
|
|
|
|
"\t\t\t<visitType type=\"" + type + "\"/>\n" +
|
|
|
|
|
"\t\t</queryByParameter>\n" +
|
|
|
|
|
"\t</controlActProcess>\n" +
|
|
|
|
|
"</PRPA_HIP1179>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|