|
|
@@ -8,9 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.nb.core.Value;
|
|
|
import com.nb.web.api.entity.BusClinicEntity;
|
|
|
import com.nb.web.api.entity.BusDeviceEntity;
|
|
|
import com.nb.web.api.entity.BusInfusionHistoryEntity;
|
|
|
@@ -38,18 +36,12 @@ import com.nb.core.exception.CustomException;
|
|
|
import com.nb.core.result.R;
|
|
|
import com.nb.core.utils.ExceptionUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.redisson.api.RLock;
|
|
|
-import org.redisson.api.RedissonClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Isolation;
|
|
|
-import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.web.context.request.async.DeferredResult;
|
|
|
|
|
|
-import javax.validation.constraints.NotNull;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.*;
|
|
|
@@ -135,6 +127,10 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
, 2, TimeUnit.SECONDS);
|
|
|
}
|
|
|
|
|
|
+ public DeferredResult<R<BusClinicEntity>> getPatientInfoFromHis(String hospitalId, String patientCode, long timeout, boolean sync) {
|
|
|
+ return this.getPatientInfoFromHis(hospitalId,patientCode,timeout,sync,false);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取病人信息
|
|
|
*
|
|
|
@@ -142,7 +138,8 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
* @param patientCode 病号
|
|
|
* @param sync 是否为同步操作
|
|
|
*/
|
|
|
- public DeferredResult<R<BusClinicEntity>> getPatientInfoFromHis(String hospitalId, String patientCode, long timeout, boolean sync) {
|
|
|
+ @Override
|
|
|
+ public DeferredResult<R<BusClinicEntity>> getPatientInfoFromHis(String hospitalId, String patientCode, long timeout, boolean sync,boolean ignoreOnline) {
|
|
|
BusHospitalEntity hospital = hospitalService.getById(hospitalId);
|
|
|
HospitalManager hospitalManager = hospitalManagerRegister.get(hospitalId);
|
|
|
HisScriptSession hisScriptSession = hospitalManager.getScriptSession();
|
|
|
@@ -154,7 +151,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
throw new CustomException("医院系统对接未配置【对接脚本】,请到【信息维护】->【系统对接】配置对接脚本并发布");
|
|
|
}
|
|
|
log.info("医院【{}】,开始拉取病号【{}】信息,拉取方式【{}】", hospitalId, patientCode, sync ? "同步" : "异步");
|
|
|
- return sync ? hisScriptSession.syncGetPatientInfo(patientCode, timeout, TimeUnit.SECONDS) : hisScriptSession.asyncGetPatientInfo(patientCode, timeout, TimeUnit.SECONDS, true);
|
|
|
+ return sync ? hisScriptSession.syncGetPatientInfo(patientCode, timeout, TimeUnit.SECONDS,ignoreOnline) : hisScriptSession.asyncGetPatientInfo(patientCode, timeout, TimeUnit.SECONDS, true,ignoreOnline);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -234,54 +231,25 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ * t
|
|
|
* 根据医院和住院号获取一个患者
|
|
|
*
|
|
|
* @param tenantId
|
|
|
* @param patientCode
|
|
|
* @return
|
|
|
*/
|
|
|
- public BusPatientEntity getOneByHospitalAndPatientCode(@NotNull String tenantId, @NotNull String patientCode) {
|
|
|
- return getOneByHospitalAndPatientCode(tenantId,patientCode,new Date(),true);
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(propagation = Propagation.REQUIRES_NEW,isolation = Isolation.SERIALIZABLE,rollbackFor = Exception.class)
|
|
|
- public BusPatientEntity getOneByHospitalAndPatientCode(@NotNull String tenantId,@NotNull String patientCode, Date monitorStartTime, boolean monitorType) {
|
|
|
- BusPatientEntity patient =null;
|
|
|
- patient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda()
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public BusPatientEntity getOneByHospitalAndPatientCode(String tenantId, String patientCode) {
|
|
|
+ BusPatientEntity patient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda()
|
|
|
.eq(BusPatientEntity::getTenantId, tenantId)
|
|
|
.eq(BusPatientEntity::getCode, patientCode));
|
|
|
- BusInfusionHistoryEntity recentInfusion = infusionService.lastInfusionByPatientCode(tenantId, patientCode);
|
|
|
// 如果患者不存在则新增一个患者
|
|
|
if (Objects.isNull(patient)) {
|
|
|
patient = new BusPatientEntity();
|
|
|
patient.setTenantId(tenantId);
|
|
|
patient.setCode(patientCode);
|
|
|
patient.setOriginCode(patientCode);
|
|
|
- patient.setId(IdWorker.getIdStr());
|
|
|
- BusClinicEntity clinic=new BusClinicEntity();
|
|
|
- clinic.setPatientId(patient.getId());
|
|
|
- clinic.setId(IdWorker.getIdStr());
|
|
|
- clinic.setPatientCode(patientCode);
|
|
|
- clinic.setPatientId(patient.getId());
|
|
|
- clinic.setTenantId(tenantId);
|
|
|
- clinic.setMonitorType(monitorType);
|
|
|
- clinic.setMonitorStartTime(monitorStartTime);
|
|
|
- patient.setClinicId(clinic.getId());
|
|
|
- if (Boolean.TRUE.equals(monitorType)&&recentInfusion!=null) {
|
|
|
- patient.setInfusionId(recentInfusion.getId());
|
|
|
- clinic.setMonitorStartTime(recentInfusion.getStartTime());
|
|
|
- //监护已结束
|
|
|
- if(Boolean.TRUE.equals(recentInfusion.getIsUndo())){
|
|
|
- clinic.setEndTime(recentInfusion.getUndoTime());
|
|
|
- clinic.setFinished(true);
|
|
|
- };
|
|
|
- }
|
|
|
this.save(patient);
|
|
|
- clinicService.save(clinic);
|
|
|
- }
|
|
|
- if(recentInfusion!=null){
|
|
|
- patient.setBindDeviceId(recentInfusion.getId());
|
|
|
}
|
|
|
return patient;
|
|
|
}
|
|
|
@@ -512,18 +480,18 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
|
|
|
BusClinicEntity clinic = clinicService.getById(patient.getClinicId());
|
|
|
String infusionId=patient.getInfusionId();
|
|
|
-
|
|
|
- BusInfusionHistoryEntity infusion =null;
|
|
|
-
|
|
|
+ BusInfusionHistoryEntity infusion=null;
|
|
|
if(StrUtil.isNotEmpty(infusionId)){
|
|
|
- infusion=infusionService.getById(infusionId);
|
|
|
- }
|
|
|
- if(infusion!=null){
|
|
|
- BusDeviceEntity device = deviceService.getByDeviceId(infusion.getDeviceId());
|
|
|
- if(device!=null){
|
|
|
- infusion.setAlias(device.getAlias());
|
|
|
+ infusion =infusionService.getById(infusionId);
|
|
|
+ if(ObjectUtil.isNotNull(infusion)&&StrUtil.isNotEmpty(infusion.getId())){
|
|
|
+ BusDeviceEntity device = deviceService.getByDeviceId(infusion.getDeviceId());
|
|
|
+ if(ObjectUtil.isNotNull(device)){
|
|
|
+ infusion.setAlias(device.getAlias());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
clinic.setPatientCode(patient.getCode());
|
|
|
|
|
|
result.setInfusion(infusion);
|