|
@ -1,7 +1,9 @@
|
|
package com.yihu.hos.rest.controllers;
|
|
package com.yihu.hos.rest.controllers;
|
|
|
|
|
|
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
|
|
import com.yihu.ehr.dbhelper.jdbc.DBHelper;
|
|
|
|
import com.yihu.hos.core.constants.CoreConstant;
|
|
import com.yihu.hos.core.datatype.DateUtil;
|
|
import com.yihu.hos.core.datatype.DateUtil;
|
|
|
|
import com.yihu.hos.core.http.HttpClientKit;
|
|
import com.yihu.hos.rest.common.configuration.CrawlerConfiguration;
|
|
import com.yihu.hos.rest.common.configuration.CrawlerConfiguration;
|
|
import com.yihu.hos.rest.common.configuration.QLCConfiguration;
|
|
import com.yihu.hos.rest.common.configuration.QLCConfiguration;
|
|
import com.yihu.wsgw.api.ServiceBus;
|
|
import com.yihu.wsgw.api.ServiceBus;
|
|
@ -35,19 +37,45 @@ import java.util.Map;
|
|
@RequestMapping(value = "/api/v1.0/qlc", produces = {"application/json;charset=UTF-8"})//
|
|
@RequestMapping(value = "/api/v1.0/qlc", produces = {"application/json;charset=UTF-8"})//
|
|
@Api(protocols = "http", value = "hibernate", hidden = false, description = "ȫ���̶Խӽӿ�")
|
|
@Api(protocols = "http", value = "hibernate", hidden = false, description = "ȫ���̶Խӽӿ�")
|
|
public class QLCController {
|
|
public class QLCController {
|
|
|
|
final Logger logger = LoggerFactory.getLogger(QLCController.class);
|
|
private DBHelper dbHelper = new DBHelper();
|
|
private DBHelper dbHelper = new DBHelper();
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private QLCConfiguration qlcConfiguration;
|
|
private QLCConfiguration qlcConfiguration;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private CrawlerConfiguration crawlerConfiguration;
|
|
private CrawlerConfiguration crawlerConfiguration;
|
|
|
|
|
|
final Logger logger = LoggerFactory.getLogger(QLCController.class);
|
|
|
|
|
|
/**
|
|
|
|
* xml轉json
|
|
|
|
*
|
|
|
|
* @param xml
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private static String XML2JsonData(String xml) throws Exception {
|
|
|
|
JSONArray object = new JSONArray();
|
|
|
|
try {
|
|
|
|
SAXReader saxReader = new SAXReader(false);
|
|
|
|
Document document = DocumentHelper.parseText(xml);
|
|
|
|
Element root = document.getRootElement();
|
|
|
|
List<Element> elements = root.elements("Data");
|
|
|
|
for (Element element : elements) {
|
|
|
|
List<Element> elementTemps = element.elements();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
for (Element elementTemp : elementTemps) {
|
|
|
|
if (elementTemp.hasContent()) {
|
|
|
|
jo.put(elementTemp.getName(), elementTemp.getText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object.add(jo);
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new Exception("返回的xml转JSON错误");
|
|
|
|
}
|
|
|
|
return object.toString();
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 院方_挂号事件推送
|
|
* 院方_挂号事件推送
|
|
*http://localhost:8081/gateway/transfer?api=17¶m={EventType:"1",EventNo:"1",CardType:"1",CardNo:"6001",PatientId:"10001",HospitalId:"1026333"}&requestId="目前没用随便写"
|
|
|
|
|
|
* http://localhost:8081/gateway/transfer?api=17¶m={EventType:"1",EventNo:"1",CardType:"1",CardNo:"6001",PatientId:"10001",HospitalId:"1026333"}&requestId="目前没用随便写"
|
|
*/
|
|
*/
|
|
@RequestMapping(value = "/queryUserInfo", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/queryUserInfo", method = RequestMethod.POST)
|
|
@ApiOperation(value = "挂号事件推送", response = Object.class, produces = "application/json", notes = "挂号事件推送")
|
|
@ApiOperation(value = "挂号事件推送", response = Object.class, produces = "application/json", notes = "挂号事件推送")
|
|
@ -80,136 +108,6 @@ public class QLCController {
|
|
return paramMap;
|
|
return paramMap;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
* 得到挂号信息的病人基本信息入mongo
|
|
|
|
* @param CardType
|
|
|
|
* @param CardNo
|
|
|
|
* @param HospitalId
|
|
|
|
* @return 返回就诊时间RegDate yyyy-MM-dd HH:mm:ss
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
private String getRegAndUserInfo(String CardType, String CardNo, String HospitalId) throws Exception {
|
|
|
|
//-----------------------------得到挂号信息--start
|
|
|
|
//拼凑RPC参数
|
|
|
|
String regDate;
|
|
|
|
// String param = "<Req><TransactionCode>5003</TransactionCode><Data><CardType>"+CardType+"</CardType><CardNo>"+CardNo+"</CardNo><IdCardNo></IdCardNo><OrderId></OrderId><ClinicCard></ClinicCard><TimeSlice></TimeSlice><StartTime></StartTime><EndTime></EndTime><RegFlag>2</RegFlag></Data></Req>";
|
|
|
|
// String apiparam = "{\"ChannelId\"=\"" + qlcConfiguration.getChannelId() + "\"," +
|
|
|
|
// "\"ParamType\"=1," +
|
|
|
|
// "\"Params\"=\"" + param + "\"," +
|
|
|
|
// "\"Guid\"=\"00000001111111\"," +
|
|
|
|
// "\"V\"=\"3.0.0\"," +
|
|
|
|
// "\"OutType\"=1," +
|
|
|
|
// "\"HospitalId\"=\"" + HospitalId + "\"}";
|
|
|
|
|
|
|
|
// Object s = getRPCData(qlcConfiguration.getIp() + CoreConstant.COLON + qlcConfiguration.getPort(), qlcConfiguration.getAppId(), "ZEUS.HosHOPWs.QueryRegInfo", apiparam);
|
|
|
|
Object s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
|
|
|
|
"<Resp> \n" +
|
|
|
|
"<TransactionCode></TransactionCode> \n" +
|
|
|
|
"<RespCode>10000</RespCode>\n" +
|
|
|
|
"<RespMessage>成功</RespMessage>\n" +
|
|
|
|
"<Data>\n" +
|
|
|
|
" <OrderId>1026333</OrderId>\n" +
|
|
|
|
" <IdCardNo>350181199101251517</IdCardNo>\n" +
|
|
|
|
" <BirthDay>1991-01-25</BirthDay>\n" +
|
|
|
|
" <Mobile>15805935227</Mobile>\n" +
|
|
|
|
" <Name>zlf</Name>\n" +
|
|
|
|
" <Sex>男</Sex>\n" +
|
|
|
|
" <Address></Address>\n" +
|
|
|
|
" <ClinicCard>6001</ClinicCard>\n" +
|
|
|
|
" <ClinicName></ClinicName>\n" +
|
|
|
|
" <DoctorName></DoctorName>\n" +
|
|
|
|
" <DoctorCode></DoctorCode>\n" +
|
|
|
|
" <DeptCode></DeptCode>\n" +
|
|
|
|
" <DeptName></DeptName>\n" +
|
|
|
|
" <PayFee></PayFee>\n" +
|
|
|
|
" <RegFee></RegFee>\n" +
|
|
|
|
" <ClinicFee></ClinicFee>\n" +
|
|
|
|
" <OtherFee></OtherFee>\n" +
|
|
|
|
" <OperatorId></OperatorId>\n" +
|
|
|
|
" <OperatorName></OperatorName>\n" +
|
|
|
|
" <RegDate>2016-08-23 17:00:00</RegDate>\n" +
|
|
|
|
" <TimeSlice></TimeSlice>\n" +
|
|
|
|
" <SqNo></SqNo>\n" +
|
|
|
|
" <Remark></Remark>\n" +
|
|
|
|
"<RegFlag>true</RegFlag>\n" +
|
|
|
|
"</Data>\n" +
|
|
|
|
"</Resp>";
|
|
|
|
//解析xml
|
|
|
|
Document document = DocumentHelper.parseText(s.toString());
|
|
|
|
Element root = document.getRootElement();
|
|
|
|
String respCode=root.element("RespCode").getText();
|
|
|
|
if ("10000".equals(respCode)) {
|
|
|
|
//調用接口存入mongo--挂号信息
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
params.put("dataset", "HDSC01_02");
|
|
|
|
params.put("data", XML2JsonData(root.asXML()));
|
|
|
|
params.put("orgCode", HospitalId);
|
|
|
|
String storageUrl = HttpClientUtil.getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientUtil.doPost(storageUrl, params, null, null);
|
|
|
|
monogoUrlValid(storageInfo, "挂号信息mongo入库失败");
|
|
|
|
//得到时间 yyyy-MM-dd
|
|
|
|
regDate=root.element("Data").element("RegDate").getText();
|
|
|
|
//转换成 yyyy-MM-dd HH:mm:ss
|
|
|
|
regDate = DateUtil.changeFormat(regDate, DateUtil.DEFAULT_DATE_YMD_FORMAT, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
|
} else {
|
|
|
|
throw new Exception(s.toString());
|
|
|
|
}
|
|
|
|
//-----------------------------得到挂号信息--end
|
|
|
|
//-----------------------------得到人口学信息--start
|
|
|
|
//拼凑RPC参数
|
|
|
|
// param = "<Req><TransactionCode>5003</TransactionCode><Data><CardType>"+CardType+"</CardType><CardNo>"+CardNo+"</CardNo><Mobile>123</Mobile><PatientId></PatientId></Data></Req>";
|
|
|
|
// apiparam = "{\"ChannelId\"=\"" + qlcConfiguration.getChannelId() + "\"," +
|
|
|
|
// "\"ParamType\"=1," +
|
|
|
|
// "\"Params\"=\"" + param + "\"," +
|
|
|
|
// "\"Guid\"=\"00000001111111\"," +
|
|
|
|
// "\"V\"=\"3.0.0\"," +
|
|
|
|
// "\"OutType\"=1," +
|
|
|
|
// "\"HospitalId\"=\"" + HospitalId + "\"}";
|
|
|
|
// s = getRPCData(qlcConfiguration.getIp() + CoreConstant.COLON + qlcConfiguration.getPort(), qlcConfiguration.getAppId(), "ZEUS.HosHOPWs.QueryUserInfo", apiparam);
|
|
|
|
s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
|
|
|
|
"<Resp>\n" +
|
|
|
|
"<TransactionCode></TransactionCode>\n" +
|
|
|
|
"<RespMessage>成功</RespMessage>\n" +
|
|
|
|
"<RespCode>10000</RespCode>\n" +
|
|
|
|
"<Data>\n" +
|
|
|
|
"<PatientId>10001</PatientId>\n" +
|
|
|
|
"<ClinicCard>6001</ClinicCard>\n" +
|
|
|
|
"<Name>zlf</Name>\n" +
|
|
|
|
"<Mobile>123456</Mobile>\n" +
|
|
|
|
"<McardNo>6001</McardNo>\n" +
|
|
|
|
"<Address>Address</Address>\n" +
|
|
|
|
"<Sex>男</Sex>\n" +
|
|
|
|
"<Fee>100</Fee>\n" +
|
|
|
|
"<BirthDay>1991.1.25</BirthDay>\n" +
|
|
|
|
"<Country>中国</Country>\n" +
|
|
|
|
"<Nation>汉</Nation>\n" +
|
|
|
|
"<BloodCode1>A</BloodCode1>\n" +
|
|
|
|
"<BloodCode2></BloodCode2>\n" +
|
|
|
|
"<Allergens></Allergens>\n" +
|
|
|
|
"<IdCardId>350181199101251517</IdCardId>\n" +
|
|
|
|
"</Data>\n" +
|
|
|
|
"</Resp>";
|
|
|
|
//解析xml
|
|
|
|
document = DocumentHelper.parseText(s.toString());
|
|
|
|
root = document.getRootElement();
|
|
|
|
respCode=root.element("RespCode").getText();
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
if ("10000".equals(respCode)) {
|
|
|
|
//調用接口存入mongo--人口学信息
|
|
|
|
params.put("dataset", "HDSA00_01");
|
|
|
|
params.put("data", XML2JsonData(root.asXML()));
|
|
|
|
params.put("orgCode", HospitalId);
|
|
|
|
String storageUrl = HttpClientUtil.getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientUtil.doPost(storageUrl, params, null, null);
|
|
|
|
monogoUrlValid(storageInfo, "人口学信息mongo入库失败");
|
|
|
|
} else {
|
|
|
|
throw new Exception(s.toString());
|
|
|
|
}
|
|
|
|
//-----------------------------得到人口学信息--end
|
|
|
|
return regDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 院方_检查/检验报告单推送---数据说明
|
|
* 院方_检查/检验报告单推送---数据说明
|
|
* 检验:http://localhost:8081/gateway/transfer?api=18¶m={CardType:"1",CardNo:"10003",ReportType:"1",ReportId:"123",State:"2",HospitalId:"1026333"}&requestId="目前没用随便写"
|
|
* 检验:http://localhost:8081/gateway/transfer?api=18¶m={CardType:"1",CardNo:"10003",ReportType:"1",ReportId:"123",State:"2",HospitalId:"1026333"}&requestId="目前没用随便写"
|
|
@ -224,7 +122,7 @@ public class QLCController {
|
|
@ApiParam(value = "报告单状态1 报告未出 2报告已出", required = true) @RequestParam(value = "State") String State,
|
|
@ApiParam(value = "报告单状态1 报告未出 2报告已出", required = true) @RequestParam(value = "State") String State,
|
|
@ApiParam(value = "医院ID", required = true) @RequestParam(value = "HospitalId") String HospitalId,
|
|
@ApiParam(value = "医院ID", required = true) @RequestParam(value = "HospitalId") String HospitalId,
|
|
@ApiParam(value = "就诊时间", required = true) @RequestParam(value = "RegDate") String RegDate) {
|
|
@ApiParam(value = "就诊时间", required = true) @RequestParam(value = "RegDate") String RegDate) {
|
|
Map<String,Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
Object s = null;
|
|
Object s = null;
|
|
try {
|
|
try {
|
|
isEmpty(CardType, "CardType is null");
|
|
isEmpty(CardType, "CardType is null");
|
|
@ -304,64 +202,64 @@ public class QLCController {
|
|
Element root = document.getRootElement();
|
|
Element root = document.getRootElement();
|
|
if ("10000".equals(root.element("RespCode").getText())) {
|
|
if ("10000".equals(root.element("RespCode").getText())) {
|
|
///分割數據
|
|
///分割數據
|
|
List<Element> elements=root.elements("Data");
|
|
|
|
JSONArray jsonArray1=new JSONArray();//檢驗圖片報告單
|
|
|
|
for(Element element:elements){
|
|
|
|
JSONArray jsonArray=new JSONArray();//檢驗主表
|
|
|
|
List<Element> elementTemps=element.elements();
|
|
|
|
JSONObject jo=new JSONObject();
|
|
|
|
|
|
List<Element> elements = root.elements("Data");
|
|
|
|
JSONArray jsonArray1 = new JSONArray();//檢驗圖片報告單
|
|
|
|
for (Element element : elements) {
|
|
|
|
JSONArray jsonArray = new JSONArray();//檢驗主表
|
|
|
|
List<Element> elementTemps = element.elements();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
//檢驗主表
|
|
//檢驗主表
|
|
for(Element elementTemp:elementTemps){
|
|
|
|
if(elementTemp.hasContent()){
|
|
|
|
jo.put(elementTemp.getName(),elementTemp.getText());
|
|
|
|
|
|
for (Element elementTemp : elementTemps) {
|
|
|
|
if (elementTemp.hasContent()) {
|
|
|
|
jo.put(elementTemp.getName(), elementTemp.getText());
|
|
}
|
|
}
|
|
//檢驗圖片報告單
|
|
//檢驗圖片報告單
|
|
if("Data_1".equals(elementTemp.getName())){
|
|
|
|
JSONObject jo1=new JSONObject();
|
|
|
|
List<Element> elementTemps1=elementTemp.elements();
|
|
|
|
for(Element elementTemp1:elementTemps1){
|
|
|
|
if(elementTemp1.hasContent()){
|
|
|
|
jo1.put(elementTemp1.getName(),elementTemp1.getText());
|
|
|
|
|
|
if ("Data_1".equals(elementTemp.getName())) {
|
|
|
|
JSONObject jo1 = new JSONObject();
|
|
|
|
List<Element> elementTemps1 = elementTemp.elements();
|
|
|
|
for (Element elementTemp1 : elementTemps1) {
|
|
|
|
if (elementTemp1.hasContent()) {
|
|
|
|
jo1.put(elementTemp1.getName(), elementTemp1.getText());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
jsonArray1.add(jo1);
|
|
jsonArray1.add(jo1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
String evenNo="";
|
|
|
|
if(StringUtils.isEmpty(jo.get("ClinicNo"))){
|
|
|
|
evenNo=jo.get("HosUserNo").toString();
|
|
|
|
}else{
|
|
|
|
evenNo=jo.get("ClinicNo").toString();
|
|
|
|
|
|
String evenNo = "";
|
|
|
|
if (StringUtils.isEmpty(jo.get("ClinicNo"))) {
|
|
|
|
evenNo = jo.get("HosUserNo").toString();
|
|
|
|
} else {
|
|
|
|
evenNo = jo.get("ClinicNo").toString();
|
|
}
|
|
}
|
|
jsonArray.add(jo);
|
|
jsonArray.add(jo);
|
|
if(ReportType.equals("1")){
|
|
|
|
|
|
if (ReportType.equals("1")) {
|
|
//检验报告
|
|
//检验报告
|
|
//上傳主表
|
|
//上傳主表
|
|
addMongo("HDSD02_01", evenNo, CardNo, HospitalId, jsonArray);
|
|
addMongo("HDSD02_01", evenNo, CardNo, HospitalId, jsonArray);
|
|
//给每个细表都添加Even_No
|
|
//给每个细表都添加Even_No
|
|
for(Object o:jsonArray1){
|
|
|
|
JSONObject jsonObject=(JSONObject)o;
|
|
|
|
jsonObject.put("EventNo",evenNo);
|
|
|
|
jsonObject.put("PatientId",CardNo);
|
|
|
|
|
|
for (Object o : jsonArray1) {
|
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
|
jsonObject.put("EventNo", evenNo);
|
|
|
|
jsonObject.put("PatientId", CardNo);
|
|
}
|
|
}
|
|
//上傳細表
|
|
//上傳細表
|
|
addMongo("HDSD02_03", evenNo, CardNo, HospitalId, jsonArray1);
|
|
addMongo("HDSD02_03", evenNo, CardNo, HospitalId, jsonArray1);
|
|
}else{
|
|
|
|
for(Object o:jsonArray){
|
|
|
|
JSONObject jsonObject=(JSONObject)o;
|
|
|
|
jsonObject.put("EventNo",evenNo);
|
|
|
|
jsonObject.put("PatientId",CardNo);
|
|
|
|
|
|
} else {
|
|
|
|
for (Object o : jsonArray) {
|
|
|
|
JSONObject jsonObject = (JSONObject) o;
|
|
|
|
jsonObject.put("EventNo", evenNo);
|
|
|
|
jsonObject.put("PatientId", CardNo);
|
|
}
|
|
}
|
|
//检查报告
|
|
//检查报告
|
|
addMongo("HDSD01_01", evenNo, CardNo, HospitalId, jsonArray);
|
|
addMongo("HDSD01_01", evenNo, CardNo, HospitalId, jsonArray);
|
|
}
|
|
}
|
|
//出發採集上傳
|
|
//出發採集上傳
|
|
|
|
|
|
String jsonObject="{\"orgCode\":\""+HospitalId+"\",\"eventNo\":\""+evenNo+"\",\"patientId\":\""+CardNo+"\",\"referenceTime\":\""+RegDate+"\"}";
|
|
|
|
|
|
String jsonObject = "{\"orgCode\":\"" + HospitalId + "\",\"eventNo\":\"" + evenNo + "\",\"patientId\":\"" + CardNo + "\",\"referenceTime\":\"" + RegDate + "\"}";
|
|
params.put("patient", jsonObject);
|
|
params.put("patient", jsonObject);
|
|
|
|
|
|
String uploadUrl = HttpClientUtil.getUrl(crawlerConfiguration.getUploadIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getUploadApi());
|
|
|
|
String uploadInfo = HttpClientUtil.doPost(uploadUrl, params, null, null);
|
|
|
|
|
|
String uploadUrl = getUrl(crawlerConfiguration.getUploadIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getUploadApi());
|
|
|
|
String uploadInfo = HttpClientKit.post(uploadUrl, params).getBody();
|
|
|
|
|
|
monogoUrlValid(uploadInfo, "数据上传失败");
|
|
monogoUrlValid(uploadInfo, "数据上传失败");
|
|
}
|
|
}
|
|
@ -375,13 +273,143 @@ public class QLCController {
|
|
return params;
|
|
return params;
|
|
}
|
|
}
|
|
|
|
|
|
private String addMongo(String tableName,String evenNo,String CardNo,String HospitalId, JSONArray jsonArray) throws Exception {
|
|
|
|
Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
|
|
/**
|
|
|
|
* 得到挂号信息的病人基本信息入mongo
|
|
|
|
*
|
|
|
|
* @param CardType
|
|
|
|
* @param CardNo
|
|
|
|
* @param HospitalId
|
|
|
|
* @return 返回就诊时间RegDate yyyy-MM-dd HH:mm:ss
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
private String getRegAndUserInfo(String CardType, String CardNo, String HospitalId) throws Exception {
|
|
|
|
//-----------------------------得到挂号信息--start
|
|
|
|
//拼凑RPC参数
|
|
|
|
String regDate;
|
|
|
|
// String param = "<Req><TransactionCode>5003</TransactionCode><Data><CardType>"+CardType+"</CardType><CardNo>"+CardNo+"</CardNo><IdCardNo></IdCardNo><OrderId></OrderId><ClinicCard></ClinicCard><TimeSlice></TimeSlice><StartTime></StartTime><EndTime></EndTime><RegFlag>2</RegFlag></Data></Req>";
|
|
|
|
// String apiparam = "{\"ChannelId\"=\"" + qlcConfiguration.getChannelId() + "\"," +
|
|
|
|
// "\"ParamType\"=1," +
|
|
|
|
// "\"Params\"=\"" + param + "\"," +
|
|
|
|
// "\"Guid\"=\"00000001111111\"," +
|
|
|
|
// "\"V\"=\"3.0.0\"," +
|
|
|
|
// "\"OutType\"=1," +
|
|
|
|
// "\"HospitalId\"=\"" + HospitalId + "\"}";
|
|
|
|
|
|
|
|
// Object s = getRPCData(qlcConfiguration.getIp() + CoreConstant.COLON + qlcConfiguration.getPort(), qlcConfiguration.getAppId(), "ZEUS.HosHOPWs.QueryRegInfo", apiparam);
|
|
|
|
Object s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
|
|
|
|
"<Resp> \n" +
|
|
|
|
"<TransactionCode></TransactionCode> \n" +
|
|
|
|
"<RespCode>10000</RespCode>\n" +
|
|
|
|
"<RespMessage>成功</RespMessage>\n" +
|
|
|
|
"<Data>\n" +
|
|
|
|
" <OrderId>1026333</OrderId>\n" +
|
|
|
|
" <IdCardNo>350181199101251517</IdCardNo>\n" +
|
|
|
|
" <BirthDay>1991-01-25</BirthDay>\n" +
|
|
|
|
" <Mobile>15805935227</Mobile>\n" +
|
|
|
|
" <Name>zlf</Name>\n" +
|
|
|
|
" <Sex>男</Sex>\n" +
|
|
|
|
" <Address></Address>\n" +
|
|
|
|
" <ClinicCard>6001</ClinicCard>\n" +
|
|
|
|
" <ClinicName></ClinicName>\n" +
|
|
|
|
" <DoctorName></DoctorName>\n" +
|
|
|
|
" <DoctorCode></DoctorCode>\n" +
|
|
|
|
" <DeptCode></DeptCode>\n" +
|
|
|
|
" <DeptName></DeptName>\n" +
|
|
|
|
" <PayFee></PayFee>\n" +
|
|
|
|
" <RegFee></RegFee>\n" +
|
|
|
|
" <ClinicFee></ClinicFee>\n" +
|
|
|
|
" <OtherFee></OtherFee>\n" +
|
|
|
|
" <OperatorId></OperatorId>\n" +
|
|
|
|
" <OperatorName></OperatorName>\n" +
|
|
|
|
" <RegDate>2016-08-23 17:00:00</RegDate>\n" +
|
|
|
|
" <TimeSlice></TimeSlice>\n" +
|
|
|
|
" <SqNo></SqNo>\n" +
|
|
|
|
" <Remark></Remark>\n" +
|
|
|
|
"<RegFlag>true</RegFlag>\n" +
|
|
|
|
"</Data>\n" +
|
|
|
|
"</Resp>";
|
|
|
|
//解析xml
|
|
|
|
Document document = DocumentHelper.parseText(s.toString());
|
|
|
|
Element root = document.getRootElement();
|
|
|
|
String respCode = root.element("RespCode").getText();
|
|
|
|
if ("10000".equals(respCode)) {
|
|
|
|
//調用接口存入mongo--挂号信息
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
params.put("dataset", "HDSC01_02");
|
|
|
|
params.put("data", XML2JsonData(root.asXML()));
|
|
|
|
params.put("orgCode", HospitalId);
|
|
|
|
String storageUrl = getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientKit.post(storageUrl, params).getBody();
|
|
|
|
monogoUrlValid(storageInfo, "挂号信息mongo入库失败");
|
|
|
|
//得到时间 yyyy-MM-dd
|
|
|
|
regDate = root.element("Data").element("RegDate").getText();
|
|
|
|
//转换成 yyyy-MM-dd HH:mm:ss
|
|
|
|
regDate = DateUtil.changeFormat(regDate, DateUtil.DEFAULT_DATE_YMD_FORMAT, DateUtil.DEFAULT_YMDHMSDATE_FORMAT);
|
|
|
|
} else {
|
|
|
|
throw new Exception(s.toString());
|
|
|
|
}
|
|
|
|
//-----------------------------得到挂号信息--end
|
|
|
|
//-----------------------------得到人口学信息--start
|
|
|
|
//拼凑RPC参数
|
|
|
|
// param = "<Req><TransactionCode>5003</TransactionCode><Data><CardType>"+CardType+"</CardType><CardNo>"+CardNo+"</CardNo><Mobile>123</Mobile><PatientId></PatientId></Data></Req>";
|
|
|
|
// apiparam = "{\"ChannelId\"=\"" + qlcConfiguration.getChannelId() + "\"," +
|
|
|
|
// "\"ParamType\"=1," +
|
|
|
|
// "\"Params\"=\"" + param + "\"," +
|
|
|
|
// "\"Guid\"=\"00000001111111\"," +
|
|
|
|
// "\"V\"=\"3.0.0\"," +
|
|
|
|
// "\"OutType\"=1," +
|
|
|
|
// "\"HospitalId\"=\"" + HospitalId + "\"}";
|
|
|
|
// s = getRPCData(qlcConfiguration.getIp() + CoreConstant.COLON + qlcConfiguration.getPort(), qlcConfiguration.getAppId(), "ZEUS.HosHOPWs.QueryUserInfo", apiparam);
|
|
|
|
s = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
|
|
|
|
"<Resp>\n" +
|
|
|
|
"<TransactionCode></TransactionCode>\n" +
|
|
|
|
"<RespMessage>成功</RespMessage>\n" +
|
|
|
|
"<RespCode>10000</RespCode>\n" +
|
|
|
|
"<Data>\n" +
|
|
|
|
"<PatientId>10001</PatientId>\n" +
|
|
|
|
"<ClinicCard>6001</ClinicCard>\n" +
|
|
|
|
"<Name>zlf</Name>\n" +
|
|
|
|
"<Mobile>123456</Mobile>\n" +
|
|
|
|
"<McardNo>6001</McardNo>\n" +
|
|
|
|
"<Address>Address</Address>\n" +
|
|
|
|
"<Sex>男</Sex>\n" +
|
|
|
|
"<Fee>100</Fee>\n" +
|
|
|
|
"<BirthDay>1991.1.25</BirthDay>\n" +
|
|
|
|
"<Country>中国</Country>\n" +
|
|
|
|
"<Nation>汉</Nation>\n" +
|
|
|
|
"<BloodCode1>A</BloodCode1>\n" +
|
|
|
|
"<BloodCode2></BloodCode2>\n" +
|
|
|
|
"<Allergens></Allergens>\n" +
|
|
|
|
"<IdCardId>350181199101251517</IdCardId>\n" +
|
|
|
|
"</Data>\n" +
|
|
|
|
"</Resp>";
|
|
|
|
//解析xml
|
|
|
|
document = DocumentHelper.parseText(s.toString());
|
|
|
|
root = document.getRootElement();
|
|
|
|
respCode = root.element("RespCode").getText();
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
if ("10000".equals(respCode)) {
|
|
|
|
//調用接口存入mongo--人口学信息
|
|
|
|
params.put("dataset", "HDSA00_01");
|
|
|
|
params.put("data", XML2JsonData(root.asXML()));
|
|
|
|
params.put("orgCode", HospitalId);
|
|
|
|
String storageUrl = getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientKit.post(storageUrl, params).getBody();
|
|
|
|
monogoUrlValid(storageInfo, "人口学信息mongo入库失败");
|
|
|
|
} else {
|
|
|
|
throw new Exception(s.toString());
|
|
|
|
}
|
|
|
|
//-----------------------------得到人口学信息--end
|
|
|
|
return regDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
private String addMongo(String tableName, String evenNo, String CardNo, String HospitalId, JSONArray jsonArray) throws Exception {
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
params.put("dataset", tableName);
|
|
params.put("dataset", tableName);
|
|
params.put("data", jsonArray.toString());
|
|
params.put("data", jsonArray.toString());
|
|
params.put("orgCode", HospitalId);
|
|
params.put("orgCode", HospitalId);
|
|
String storageUrl = HttpClientUtil.getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientUtil.doPost(storageUrl, params, null, null);
|
|
|
|
|
|
String storageUrl = getUrl(crawlerConfiguration.getStorageIp(), crawlerConfiguration.getStoragePort(), crawlerConfiguration.getStorageApi());
|
|
|
|
String storageInfo = HttpClientKit.post(storageUrl, params).getBody();
|
|
monogoUrlValid(storageInfo, "mongo入库失败");
|
|
monogoUrlValid(storageInfo, "mongo入库失败");
|
|
return storageInfo;
|
|
return storageInfo;
|
|
}
|
|
}
|
|
@ -391,60 +419,30 @@ public class QLCController {
|
|
return listSYSTEM.get(0).get("code").toString();
|
|
return listSYSTEM.get(0).get("code").toString();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
* xml轉json
|
|
|
|
*
|
|
|
|
* @param xml
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
private static String XML2JsonData(String xml) throws Exception{
|
|
|
|
JSONArray object=new JSONArray();
|
|
|
|
try {
|
|
|
|
SAXReader saxReader = new SAXReader(false);
|
|
|
|
Document document = DocumentHelper.parseText(xml);
|
|
|
|
Element root = document.getRootElement();
|
|
|
|
List<Element> elements=root.elements("Data");
|
|
|
|
for (Element element:elements){
|
|
|
|
List<Element> elementTemps=element.elements();
|
|
|
|
JSONObject jo=new JSONObject();
|
|
|
|
for(Element elementTemp:elementTemps){
|
|
|
|
if(elementTemp.hasContent()){
|
|
|
|
jo.put(elementTemp.getName(),elementTemp.getText());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
object.add(jo);
|
|
|
|
}
|
|
|
|
}catch (Exception e){
|
|
|
|
throw new Exception("返回的xml转JSON错误");
|
|
|
|
}
|
|
|
|
return object.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Object XML2JsonData1(String xml) throws Exception{
|
|
|
|
JSONArray object=new JSONArray();
|
|
|
|
|
|
private Object XML2JsonData1(String xml) throws Exception {
|
|
|
|
JSONArray object = new JSONArray();
|
|
try {
|
|
try {
|
|
SAXReader saxReader = new SAXReader(false);
|
|
SAXReader saxReader = new SAXReader(false);
|
|
Document document = DocumentHelper.parseText(xml);
|
|
Document document = DocumentHelper.parseText(xml);
|
|
Element root = document.getRootElement();
|
|
Element root = document.getRootElement();
|
|
List<Element> elements=root.elements("Data");
|
|
|
|
for (Element element:elements){
|
|
|
|
|
|
List<Element> elements = root.elements("Data");
|
|
|
|
for (Element element : elements) {
|
|
//得到data节点下面的data_1节点下面的数据
|
|
//得到data节点下面的data_1节点下面的数据
|
|
List<Element> elementsData1s=element.elements();
|
|
|
|
for (Element elementsData1:elementsData1s){
|
|
|
|
if(element.getName().equals("Data_1")){
|
|
|
|
List<Element> elementTemps=elementsData1.elements();
|
|
|
|
JSONObject jo=new JSONObject();
|
|
|
|
for(Element elementTemp:elementTemps){
|
|
|
|
if(elementTemp.hasContent()){
|
|
|
|
jo.put(elementTemp.getName(),elementTemp.getText());
|
|
|
|
|
|
List<Element> elementsData1s = element.elements();
|
|
|
|
for (Element elementsData1 : elementsData1s) {
|
|
|
|
if (element.getName().equals("Data_1")) {
|
|
|
|
List<Element> elementTemps = elementsData1.elements();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
for (Element elementTemp : elementTemps) {
|
|
|
|
if (elementTemp.hasContent()) {
|
|
|
|
jo.put(elementTemp.getName(), elementTemp.getText());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
object.add(jo);
|
|
object.add(jo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
|
|
|
|
} catch (Exception e) {
|
|
throw new Exception("返回的xml转JSON错误");
|
|
throw new Exception("返回的xml转JSON错误");
|
|
}
|
|
}
|
|
return object.toString();
|
|
return object.toString();
|
|
@ -477,13 +475,14 @@ public class QLCController {
|
|
throw new Exception(message);
|
|
throw new Exception(message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//{"successFlg":true,"message":"数据入库成功!(表:HDSA00_01)","errorCode":0}
|
|
//{"successFlg":true,"message":"数据入库成功!(表:HDSA00_01)","errorCode":0}
|
|
private boolean monogoUrlValid(String info,String message) throws Exception {
|
|
|
|
|
|
private boolean monogoUrlValid(String info, String message) throws Exception {
|
|
JSONObject jo = JSONObject.fromObject(info);
|
|
JSONObject jo = JSONObject.fromObject(info);
|
|
if ((Boolean) jo.get("successFlg")) {
|
|
if ((Boolean) jo.get("successFlg")) {
|
|
return true;
|
|
return true;
|
|
} else {
|
|
} else {
|
|
throw new Exception(message+" --- "+jo.get("message").toString());
|
|
|
|
|
|
throw new Exception(message + " --- " + jo.get("message").toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@ -493,4 +492,11 @@ public class QLCController {
|
|
appId).call(api, apiparam);
|
|
appId).call(api, apiparam);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private String getUrl(String ip, String port, String api) {
|
|
|
|
String url = CoreConstant.HTTP + CoreConstant.COLON + CoreConstant.BACKSLASH +
|
|
|
|
CoreConstant.BACKSLASH + ip + CoreConstant.COLON + port +
|
|
|
|
CoreConstant.BACKSLASH + api;
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|