|
|
@@ -102,6 +102,11 @@ public class HisScriptSession {
|
|
|
public BusHospitalEntity getHospitalInfo(){
|
|
|
return clusterConfigStorage.getConfig("info").as(BusHospitalEntity.class);
|
|
|
}
|
|
|
+
|
|
|
+ public DeferredResult<R<BusClinicEntity>> syncGetPatientInfo(String patientCode, long timeout, TimeUnit unit){
|
|
|
+ return this.syncGetPatientInfo(patientCode,timeout,unit,false);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 描述: 同步拉取病人信息,超时后该次请求不再处理
|
|
|
* @author lifang
|
|
|
@@ -109,15 +114,27 @@ public class HisScriptSession {
|
|
|
* @param patientCode
|
|
|
* @param timeout
|
|
|
* @param unit
|
|
|
+ * @param ignoreOnline 是否忽略对于医院在线状态的判断
|
|
|
* @return BusClinicEntity
|
|
|
*/
|
|
|
- public DeferredResult<R<BusClinicEntity>> syncGetPatientInfo(String patientCode, long timeout, TimeUnit unit){
|
|
|
- if (!isOnline()) {
|
|
|
+ public DeferredResult<R<BusClinicEntity>> syncGetPatientInfo(String patientCode, long timeout, TimeUnit unit,boolean ignoreOnline){
|
|
|
+ boolean online = isOnline();
|
|
|
+ if (!ignoreOnline&&online) {
|
|
|
log.warn("医院【{}】不在线,拉取【{}】信息失败,拉取方式【同步】",hospitalId,patientCode);
|
|
|
throw new CustomException("医院不在线,拉取信息失败");
|
|
|
}
|
|
|
- String messageId = IdWorker.getIdStr();
|
|
|
DeferredResult<R<BusClinicEntity>> result = new DeferredResult<>(unit.toMillis(timeout));
|
|
|
+ if(!online){
|
|
|
+ BusClinicEntity clinic = clinicService.recentClinicByPatientCode(hospitalId, patientCode);
|
|
|
+ if(clinic==null){
|
|
|
+ result.setResult(R.fail("拉取信息超时,请稍后再试"));
|
|
|
+ }else {
|
|
|
+ result.setResult(R.success(clinic));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ String messageId = IdWorker.getIdStr();
|
|
|
+
|
|
|
HisRequest request = HisRequest.builder()
|
|
|
.messageId(messageId)
|
|
|
.patientCode(patientCode)
|
|
|
@@ -142,6 +159,10 @@ public class HisScriptSession {
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+ public DeferredResult<R<BusClinicEntity>> asyncGetPatientInfo(String patientCode,long timeout, TimeUnit unit,boolean needResult){
|
|
|
+ return this.asyncGetPatientInfo(patientCode,timeout,unit,needResult,false);
|
|
|
+ }
|
|
|
/**
|
|
|
* 描述: 异步拉取病人信息
|
|
|
* 当异步拉取超时时,若需要返回临床信息,则从数据库中拉取最新数据返回
|
|
|
@@ -151,16 +172,27 @@ public class HisScriptSession {
|
|
|
* @param timeout 超时时间
|
|
|
* @param unit 时间单位
|
|
|
* @param needResult 是否需要返回结果
|
|
|
+ * @param ignoreOnline 是否忽略在线判断
|
|
|
* @return BusClinicEntity
|
|
|
*/
|
|
|
- public DeferredResult<R<BusClinicEntity>> asyncGetPatientInfo(String patientCode,long timeout, TimeUnit unit,boolean needResult){
|
|
|
- if(!isOnline()){
|
|
|
+ public DeferredResult<R<BusClinicEntity>> asyncGetPatientInfo(String patientCode,long timeout, TimeUnit unit,boolean needResult,boolean ignoreOnline){
|
|
|
+ boolean online = isOnline();
|
|
|
+ if(!ignoreOnline&&!isOnline()){
|
|
|
//将请求缓存
|
|
|
log.warn("医院【{}】不在线,拉取【{}】信息失败,是否为用户拉取【{}】,拉取方式【异步】",hospitalId,patientCode,needResult);
|
|
|
throw new CustomException("医院不在线,拉取信息失败");
|
|
|
}
|
|
|
- String messageId = IdWorker.getIdStr();
|
|
|
DeferredResult<R<BusClinicEntity>> result = new DeferredResult<>(unit.toMillis(timeout));
|
|
|
+ if(!online){
|
|
|
+ BusClinicEntity clinic = clinicService.recentClinicByPatientCode(hospitalId, patientCode);
|
|
|
+ if(clinic==null){
|
|
|
+ result.setResult(R.fail("拉取信息超时,请稍后再试"));
|
|
|
+ }else {
|
|
|
+ result.setResult(R.success(clinic));
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ String messageId = IdWorker.getIdStr();
|
|
|
HisRequest request = HisRequest.builder()
|
|
|
.messageId(messageId)
|
|
|
.patientCode(patientCode)
|