@ -1,35 +1,15 @@
/ * *
* Copyright ( C ) , 2015 - 2019
* Author : HJL
* Date : 2019 / 7 / 19 14 : 39
* Description : 病 案 召 回
* /
package com.emr.controller ;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.emr.annotation.OptionalLog ;
import com.emr.dto.PushStorageDto ;
import com.emr.entity.* ;
import com.emr.service.* ;
import com.emr.util.Logger ;
import com.emr.util.ThreadExcelUtils ;
import com.google.common.collect.Lists ;
import org.apache.commons.lang3.StringUtils ;
import org.apache.http.HttpRequest ;
import org.apache.http.NameValuePair ;
import org.apache.http.client.HttpClient ;
import org.apache.http.client.entity.UrlEncodedFormEntity ;
import org.apache.http.client.methods.CloseableHttpResponse ;
import org.apache.http.client.methods.HttpPost ;
import org.apache.http.entity.StringEntity ;
import org.apache.http.impl.client.CloseableHttpClient ;
import org.apache.http.impl.client.HttpClients ;
import org.apache.http.message.BasicNameValuePair ;
import org.apache.http.util.EntityUtils ;
import org.apache.shiro.SecurityUtils ;
import org.apache.shiro.session.Session ;
import org.apache.shiro.subject.Subject ;
import org.apache.cxf.endpoint.Client ;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory ;
import org.springframework.beans.factory.annotation.Autowired ;
import org.springframework.beans.factory.annotation.Value ;
import org.springframework.context.annotation.PropertySource ;
@ -39,28 +19,23 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping ;
import org.springframework.web.bind.annotation.ResponseBody ;
import javax.servlet.http.HttpServletRequest ;
import javax.servlet.http.HttpServletResponse ;
import java.io.IOException ;
import java.io.UnsupportedEncodingException ;
import java.net.URI ;
import java.text.SimpleDateFormat ;
import java.util.ArrayList ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.List ;
import static com.emr.controller.signListController.sendGet ;
import static com.emr.util.HttpClientTool.doPost ;
import static com.emr.util.HttpClientUtils.doPostJson ;
import static com.emr.util.HttpClientUtils.httpPost ;
@PropertySource ( value = "classpath:config/jdbc.properties" , encoding = "UTF-8" )
@Controller
@RequestMapping ( "/storage" )
public class storageController {
@Autowired
private Emr_Fault_DetailService emrFaultDetailService ;
private static Logger logger = new Logger ( ) ;
@Autowired
private Emr_DictionaryService emrDictionaryService ;
@ -77,6 +52,9 @@ public class storageController {
@Value ( "${MedicalRecordSealingUrl}" )
private String MedicalRecordUrl ;
@Value ( "${MedicalRecordSealingName}" )
private String MedicalRecordSealingName ;
@ResponseBody
@ -183,7 +161,7 @@ public class storageController {
pushStorageDto . setPATIENT_NAME ( emrFaultDetail . getName ( ) ) ;
pushStorageDto . setOPERATOR ( handleName ) ;
pushStorageDto . setOPERATOR_ID ( username ) ;
pushStorageDto . set SEQUESTRATION_RESION ( nowTime ) ;
pushStorageDto . set OperationTime ( nowTime ) ;
pushStorageDto . setSEQUESTRATION_RESION ( emrFaultDetail . getRecallReason ( ) ) ;
pushStorage ( pushStorageDto ) ;
} else if ( archiveMaster . getArchivestate ( ) . equals ( "已归档" ) ) { // if (archiveMaster.getArchivestate().equals("已归档"))
@ -196,14 +174,14 @@ public class storageController {
archiveMasterFollowing . setRemark ( emrFaultDetail . getRecallReason ( ) ) ;
bol = archiveMasterFollowingService . insertSelective ( archiveMasterFollowing ) ;
//向电子病历发送取消封存消息
pushStorageDto . setPATIENT_STATUS ( 2 ) ;
pushStorageDto . setPATIENT_STATUS ( 0 ) ;
pushStorageDto . setINP_NO ( emrFaultDetail . getInpNo ( ) ) ;
pushStorageDto . setPATIENT_ID ( emrFaultDetail . getPatientId ( ) ) ;
pushStorageDto . setVISIT_ID ( Integer . parseInt ( emrFaultDetail . getVisitId ( ) ) ) ;
pushStorageDto . setPATIENT_NAME ( emrFaultDetail . getName ( ) ) ;
pushStorageDto . setOPERATOR ( handleName ) ;
pushStorageDto . setOPERATOR_ID ( username ) ;
pushStorageDto . set SEQUESTRATION_RESION ( nowTime ) ;
pushStorageDto . set OperationTime ( nowTime ) ;
pushStorageDto . setSEQUESTRATION_RESION ( emrFaultDetail . getRecallReason ( ) ) ;
pushStorage ( pushStorageDto ) ;
}
@ -232,29 +210,35 @@ public class storageController {
//向电子病历推送封存消息
private void pushStorage ( PushStorageDto pushStorageDto ) {
try {
logger . log ( "开始封存:" + 1 ) ;
//组织xml参数
String xmlContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<REQUEST>" +
"<PATIENT_STATUS>" + pushStorageDto . getPATIENT_STATUS ( ) + "</PATIENT_STATUS>" +
"<INP_NO>" + pushStorageDto . getINP_NO ( ) + "</INP_NO>" +
"<PATIENT_ID>" + pushStorageDto . getPATIENT_ID ( ) + "</PATIENT_ID>" +
"< VISIT_ID >" + pushStorageDto . getVISIT_ID ( ) + " </VISIT_ID >" +
"<PATIENT_NAME>" + pushStorageDto . getPATIENT_NAME ( ) + "</PATIENT_NAME>" +
"<OPERATOR>" + pushStorageDto . getOPERATOR ( ) + "</OPERATOR>" +
"<OPERATOR_ID>" + pushStorageDto . getOPERATOR_ID ( ) + "</OPERATOR_ID>" +
"<OperationTime>" + pushStorageDto . getOperationTime ( ) + "</OperationTime>" +
"<SEQUESTRATION_RESION>" + pushStorageDto . getSEQUESTRATION_RESION ( ) + "</SEQUESTRATION_RESION>" +
String xmlContent =
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<REQUEST>" +
"<PATIENT_STATUS>" + pushStorageDto . getPATIENT_STATUS ( ) + "</PATIENT_STATUS>" +
"<INP_NO>" + pushStorageDto . getINP_NO ( ) + "</INP_NO>" +
"<PATIENT_ID>" + pushStorageDto . getPATIENT_ID ( ) + "</PATIENT_ID>" +
"<VISIT_ID>" + pushStorageDto . getVISIT_ID ( ) + "</VISIT_ID>" +
"<PATIENT_NAME>" + pushStorageDto . getPATIENT_NAME ( ) + "</PATIENT_NAME>" +
"<OPERATOR>" + pushStorageDto . getOPERATOR ( ) + "</OPERATOR>" +
"<OPERATOR_ID>" + pushStorageDto . getOPERATOR_ID ( ) + "</OPERATOR_ID>" +
"<OperationTime>" + pushStorageDto . getOperationTime ( ) + "</OperationTime>" +
"<SEQUESTRATION_RESION>" + pushStorageDto . getSEQUESTRATION_RESION ( ) + "</SEQUESTRATION_RESION>" +
"</REQUEST>" ;
try ( CloseableHttpClient httpClient = HttpClients . createDefault ( ) ) {
HttpPost httpPost = new HttpPost ( MedicalRecordUrl ) ;
httpPost . setHeader ( "Content-Type" , "application/xml" ) ;
StringEntity entity = new StringEntity ( xmlContent ) ;
httpPost . setEntity ( entity ) ;
try ( CloseableHttpResponse response = httpClient . execute ( httpPost ) ) {
EntityUtils . consume ( response . getEntity ( ) ) ;
}
String endpoint = MedicalRecordUrl ;
String method = MedicalRecordSealingName ;
logger . log ( "endpoint:" + endpoint ) ;
logger . log ( "method:" + method ) ;
logger . log ( "xmlContent:" + xmlContent ) ;
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory . newInstance ( ) ;
Client client = dcf . createClient ( endpoint ) ;
Object [ ] res = null ;
res = client . invoke ( method , xmlContent ) ;
logger . log ( "封存返回:" + res ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
logger. log ( "异常处理:" + e . getMessage ( ) + e ) ;
}
}