|
@ -16,6 +16,7 @@ import net.sf.json.xml.XMLSerializer;
|
|
import org.dom4j.Document;
|
|
import org.dom4j.Document;
|
|
import org.dom4j.Element;
|
|
import org.dom4j.Element;
|
|
import org.dom4j.io.SAXReader;
|
|
import org.dom4j.io.SAXReader;
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
@ -29,6 +30,7 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public String transport(String RPCRequestXml) {
|
|
public String transport(String RPCRequestXml) {
|
|
|
|
RPCResponseResult r = null;
|
|
try {
|
|
try {
|
|
|
|
|
|
//解析xml
|
|
//解析xml
|
|
@ -46,30 +48,67 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
String cardNo = root.element("Data").element("CardNo").toString();
|
|
String cardNo = root.element("Data").element("CardNo").toString();
|
|
String cardType = root.element("Data").element("CardType").toString();
|
|
String cardType = root.element("Data").element("CardType").toString();
|
|
String patientId = root.element("Data").element("PatientId").toString();
|
|
String patientId = root.element("Data").element("PatientId").toString();
|
|
|
|
String hospitalId = root.element("Data").element("HospitalId").toString();
|
|
|
|
if (StringUtils.isEmpty(cardNo)) {
|
|
|
|
throw new Exception("cardNo为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(cardType)) {
|
|
|
|
throw new Exception("cardType为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(patientId)) {
|
|
|
|
throw new Exception("patientId为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(hospitalId)) {
|
|
|
|
throw new Exception("HospitalId为空");
|
|
|
|
}
|
|
|
|
//映射orgcode
|
|
|
|
String orgCode = getOrgCodeBy(hospitalId);
|
|
//查询病人基本信息
|
|
//查询病人基本信息
|
|
patientInformation(cardNo, cardType, patientId);
|
|
|
|
|
|
patientInformation(cardNo, cardType, patientId,orgCode);
|
|
} else if (trancode.equals(Constant.PUSHREPORT)) {
|
|
} else if (trancode.equals(Constant.PUSHREPORT)) {
|
|
//检查检验报告
|
|
//检查检验报告
|
|
String reportType = root.element("Data").element("ReportType").toString();
|
|
String reportType = root.element("Data").element("ReportType").toString();
|
|
String reportId = root.element("Data").element("ReportId").toString();
|
|
String reportId = root.element("Data").element("ReportId").toString();
|
|
pushreport(reportType, reportId);
|
|
|
|
|
|
String cardNo = root.element("Data").element("CardNo").toString();
|
|
|
|
String cardType = root.element("Data").element("CardType").toString();
|
|
|
|
String hospitalId = root.element("Data").element("HospitalId").toString();
|
|
|
|
if (StringUtils.isEmpty(reportType)) {
|
|
|
|
throw new Exception("reportType为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(reportId)) {
|
|
|
|
throw new Exception("reportId为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(cardNo)) {
|
|
|
|
throw new Exception("cardNo为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(cardType)) {
|
|
|
|
throw new Exception("cardType为空");
|
|
|
|
}
|
|
|
|
if (StringUtils.isEmpty(hospitalId)) {
|
|
|
|
throw new Exception("HospitalId为空");
|
|
|
|
}
|
|
|
|
//映射orgcode
|
|
|
|
String orgCode = getOrgCodeBy(hospitalId);
|
|
|
|
pushreport(reportType, reportId, cardNo, cardType, orgCode);
|
|
}
|
|
}
|
|
|
|
|
|
RPCResponseResult r = RPCResponseResult.success();
|
|
|
|
|
|
r = RPCResponseResult.success();
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
r = RPCResponseResult.error();
|
|
|
|
r.setRespMessage(e.getMessage());
|
|
|
|
r.setRespCode("20001");
|
|
}
|
|
}
|
|
return "你也好";
|
|
|
|
|
|
return JSONObject.fromObject(r).toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询病人基本信息
|
|
//查询病人基本信息
|
|
private void patientInformation(String cardNo, String cardType, String patientId) throws Exception {
|
|
|
|
|
|
private void patientInformation(String cardNo, String cardType, String patientId,String hospitalId) throws Exception {
|
|
String param = "<Req><TransactionCode>1001</TransactionCode>" +
|
|
String param = "<Req><TransactionCode>1001</TransactionCode>" +
|
|
"<Data>" +
|
|
"<Data>" +
|
|
"<CardType>"+cardType+"</CardType>" +
|
|
|
|
"<CardNo>"+cardNo+"</CardNo>" +
|
|
|
|
"<PatientName>zhengmy" +"</PatientName>" +
|
|
|
|
|
|
"<CardType>" + cardType + "</CardType>" +
|
|
|
|
"<CardNo>" + cardNo + "</CardNo>" +
|
|
|
|
"<PatientId>" + patientId + "</PatientId>" +
|
|
"</Data>" +
|
|
"</Data>" +
|
|
"</Req>";
|
|
"</Req>";
|
|
String apiparam = "{\"ChannelId\"=\"100123\"," +
|
|
String apiparam = "{\"ChannelId\"=\"100123\"," +
|
|
@ -78,7 +117,7 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
"\"Guid\"=\"" + "00000001111111" + "\"," +
|
|
"\"Guid\"=\"" + "00000001111111" + "\"," +
|
|
"\"V\"=\"3.0.0\"," +
|
|
"\"V\"=\"3.0.0\"," +
|
|
"\"OutType\"=0n ," +
|
|
"\"OutType\"=0n ," +
|
|
"\"HospitalId\"=\"1026333\"}";
|
|
|
|
|
|
"\"HospitalId\"=\""+hospitalId+"\"}";
|
|
Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.QueryUserInfo", apiparam);
|
|
Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.QueryUserInfo", apiparam);
|
|
//解析xml
|
|
//解析xml
|
|
SAXReader saxReader = new SAXReader();
|
|
SAXReader saxReader = new SAXReader();
|
|
@ -86,12 +125,22 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
Element root = document.getRootElement();
|
|
Element root = document.getRootElement();
|
|
if ("10000".equals(root.element("RespCode"))) {
|
|
if ("10000".equals(root.element("RespCode"))) {
|
|
//xml轉json
|
|
//xml轉json
|
|
|
|
Element dataXML = root.element("Data");
|
|
JSONObject obj = xml2json(root.element("Data"));
|
|
JSONObject obj = xml2json(root.element("Data"));
|
|
|
|
obj.put("CardType", cardType);
|
|
|
|
obj.put("CardNo", cardNo);
|
|
|
|
obj.put("PatientId", patientId);
|
|
|
|
obj.put("OrgCode", hospitalId);
|
|
//調用接口存入mongo
|
|
//調用接口存入mongo
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
params.put("dataset", "HDSA00_01");
|
|
|
|
params.put("data", obj.toString());
|
|
httpClientUtil.doPost(Config.monogoUrl, params, null, null);
|
|
httpClientUtil.doPost(Config.monogoUrl, params, null, null);
|
|
//出發採集上傳
|
|
//出發採集上傳
|
|
params = new HashMap<String, Object>();
|
|
params = new HashMap<String, Object>();
|
|
|
|
params.put("orgCode", hospitalId);
|
|
|
|
params.put("cardNo", cardNo);
|
|
|
|
params.put("eventNo", patientId);
|
|
httpClientUtil.doPost(Config.startCollect, params, null, null);
|
|
httpClientUtil.doPost(Config.startCollect, params, null, null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@ -103,7 +152,7 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
}
|
|
}
|
|
|
|
|
|
//检查检验报告
|
|
//检查检验报告
|
|
private void pushreport(String reportType, String reportId) throws Exception {
|
|
|
|
|
|
private void pushreport(String reportType, String reportId, String cardNo, String cardType, String hospitalId) throws Exception {
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
String data =
|
|
String data =
|
|
"<Req>" +
|
|
"<Req>" +
|
|
@ -119,7 +168,7 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
"\"Guid\"=\"" + "00000001111111" + "\"," +
|
|
"\"Guid\"=\"" + "00000001111111" + "\"," +
|
|
"\"V\"=\"3.0.0\"," +
|
|
"\"V\"=\"3.0.0\"," +
|
|
"\"OutType\"=0," +
|
|
"\"OutType\"=0," +
|
|
"\"HospitalId\"=\"1026333\"}";
|
|
|
|
|
|
"\"HospitalId\"=\""+hospitalId+"\"}";
|
|
Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.GetReportInfo", apiparam);
|
|
Object s = RPCUtil.getRPCData("ZEUS.HosHOPWs.GetReportInfo", apiparam);
|
|
//解析xml
|
|
//解析xml
|
|
SAXReader saxReader = new SAXReader();
|
|
SAXReader saxReader = new SAXReader();
|
|
@ -135,22 +184,29 @@ public class ResourceRpcImpl implements IResourceRpc {
|
|
if (elements != null && elements.size() > 0) {
|
|
if (elements != null && elements.size() > 0) {
|
|
for (Object obj1 : elements) {
|
|
for (Object obj1 : elements) {
|
|
Element data1XML = (Element) obj1;
|
|
Element data1XML = (Element) obj1;
|
|
|
|
//从表节点
|
|
|
|
JSONObject objData = xml2json(data1XML);
|
|
|
|
objData.put("CardType", cardType);
|
|
|
|
objData.put("CardNo", cardNo);
|
|
|
|
objData.put("ReportId", reportId);
|
|
|
|
objData.put("ReportType", reportType);
|
|
|
|
objData.put("OrgCode", hospitalId);
|
|
|
|
//添加主表的所有信息
|
|
|
|
objData.putAll(xml2json(dataXml));
|
|
//調用接口存入mongo
|
|
//調用接口存入mongo
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
params.put("dataset", "HDSD01_01");
|
|
|
|
params.put("data", objData.toString());
|
|
httpClientUtil.doPost(Config.monogoUrl, params, null, null);
|
|
httpClientUtil.doPost(Config.monogoUrl, params, null, null);
|
|
//出發採集上傳
|
|
//出發採集上傳
|
|
params = new HashMap<String, Object>();
|
|
params = new HashMap<String, Object>();
|
|
|
|
params.put("orgCode", hospitalId);
|
|
|
|
params.put("cardNo", cardNo);
|
|
|
|
params.put("eventNo", StringUtils.isEmpty(objData.get("ClinicNo")) ? objData.get("HosUserNo") : objData.get("ClinicNo"));
|
|
httpClientUtil.doPost(Config.startCollect, params, null, null);
|
|
httpClientUtil.doPost(Config.startCollect, params, null, null);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
obj.put(root.getName(), iterateElement(root));
|
|
|
|
String jsonString = obj.toString();
|
|
|
|
//調用接口存入mongo
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
httpClientUtil.doPost(Config.monogoUrl, params, null, null);
|
|
|
|
//出發採集上傳
|
|
|
|
params = new HashMap<String, Object>();
|
|
|
|
httpClientUtil.doPost(Config.startCollect, params, null, null);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|