|
|
@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
@@ -41,8 +42,6 @@ import com.nb.core.result.R;
|
|
|
import com.nb.core.utils.ExceptionUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.cache.annotation.CacheEvict;
|
|
|
-import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
@@ -58,6 +57,8 @@ import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collector;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author lifang
|
|
|
@@ -181,7 +182,7 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
public long monitorTotalCount(String tenantId) {
|
|
|
PatientMonitorQuery patientMonitorQuery = new PatientMonitorQuery();
|
|
|
patientMonitorQuery.setTenantId(tenantId);
|
|
|
- return CollUtil.size(this.baseMapper.selectMonitor(Page.of(0,500,false),patientMonitorQuery).getRecords());
|
|
|
+ return CollUtil.size(this.baseMapper.selectMonitor(Page.of(0,9999,false),patientMonitorQuery).getRecords());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -229,32 +230,88 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
|
|
|
@Override
|
|
|
public List<PatientMonitorResult> selectAll(PatientMonitorQuery query) {
|
|
|
- if(Boolean.TRUE.equals(query.selectAll())){
|
|
|
- return patientService.selectAll(query.getTenantId());
|
|
|
- }
|
|
|
Page<PatientMonitorResult> page = new Page<>(0, 9999, false);
|
|
|
- IPage<PatientMonitorResult> result = this.baseMapper.selectMonitor(page, query);
|
|
|
- if (CollectionUtil.isNotEmpty(result.getRecords())) {
|
|
|
- result.getRecords().forEach(PatientMonitorResult::handleWarn);
|
|
|
+
|
|
|
+ List<BusDeviceEntity> deviceList = deviceService.getBaseMapper().selectList(new LambdaQueryWrapper<BusDeviceEntity>()
|
|
|
+ .select(BusDeviceEntity::getDeviceId,BusDeviceEntity::getAlias,BusDeviceEntity::getProductNo)
|
|
|
+ .eq(BusDeviceEntity::getTenantId,query.getTenantId())
|
|
|
+ .nested(StrUtil.isNotBlank(query.getBlurry()),i-> i.like(StrUtil.isNotBlank(query.getDeviceId()), BusDeviceEntity::getDeviceId, query.getDeviceId())
|
|
|
+ .or()
|
|
|
+ .like(StrUtil.isNotBlank(query.getDeviceAlias()), BusDeviceEntity::getAlias, query.getDeviceAlias())));
|
|
|
+ Map<String, BusDeviceEntity> deviceMap=new HashMap<>();
|
|
|
+ if(CollectionUtil.isNotEmpty(deviceList)){
|
|
|
+ deviceMap = deviceList.stream()
|
|
|
+ .collect(Collectors.groupingBy(BusDeviceEntity::getDeviceId, Collectors.collectingAndThen(Collectors.toList(), CollectionUtil::getFirst)));
|
|
|
}
|
|
|
- return result.getRecords();
|
|
|
- }
|
|
|
|
|
|
- @Cacheable(value = "patientList",key = "#tenantId")
|
|
|
- public List<PatientMonitorResult> selectAll(String tenantId){
|
|
|
- PatientMonitorQuery query = new PatientMonitorQuery();
|
|
|
- Page<PatientMonitorResult> page = new Page<>(0, 9999, false);
|
|
|
IPage<PatientMonitorResult> result = this.baseMapper.selectMonitor(page, query);
|
|
|
- if (CollectionUtil.isNotEmpty(result.getRecords())) {
|
|
|
- result.getRecords().forEach(PatientMonitorResult::handleWarn);
|
|
|
+
|
|
|
+ List<PatientMonitorResult> records = result.getRecords();
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(records)) {
|
|
|
+ List<PatientMonitorResult> removeList = new ArrayList<>();
|
|
|
+ for (PatientMonitorResult record : records) {
|
|
|
+ if (!allowResult(record,query,deviceMap)) {
|
|
|
+ removeList.add(record);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ record.handleWarn();
|
|
|
+ }
|
|
|
+ records.removeAll(removeList);
|
|
|
}
|
|
|
- return result.getRecords();
|
|
|
+ return records;
|
|
|
}
|
|
|
|
|
|
- @CacheEvict(value = "patientList",key = "#tenantId")
|
|
|
- public void deleteAllCache(String tenantId){
|
|
|
+ private boolean allowResult(PatientMonitorResult result, PatientMonitorQuery query, Map<String, BusDeviceEntity> deviceMap){
|
|
|
+ boolean search=false;
|
|
|
+ BusDeviceEntity device = deviceMap.get(result.getDeviceId());
|
|
|
+ if(ObjectUtil.isNotNull(device)){
|
|
|
+ result.setDeviceAlias(device.getAlias());
|
|
|
+ result.setProductNo(device.getProductNo());
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(StrUtil.isNotBlank(query.getBlurry())){
|
|
|
+ search=true;
|
|
|
+ boolean pattern = StrUtil.contains(result.getBedNo(), query.getBlurry()) ||
|
|
|
+ StrUtil.contains(result.getPatientName(), query.getBlurry()) ||
|
|
|
+ StrUtil.contains(result.getPatientCode(), query.getBlurry());
|
|
|
+ if(pattern){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(query.getAnaDoctor())) {
|
|
|
+ search=true;
|
|
|
+ if(StrUtil.contains(result.getAnaDoctor(),query.getAnaDoctor())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(query.getSurgeName())) {
|
|
|
+ search=true;
|
|
|
+ if(StrUtil.contains(result.getSurgeryName(),query.getSurgeName())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StrUtil.isNotBlank(query.getAnaType())) {
|
|
|
+ search=true;
|
|
|
+ if(StrUtil.contains(result.getAnaType(),query.getAnaType())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ if (ObjectUtil.isNotNull(query.getGender())) {
|
|
|
+ search=true;
|
|
|
+ if(ObjectUtil.isNotNull(result.getGender())&&ObjectUtil.equals(result.getGender().getValue(),query.getGender())){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return !search;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* 根据医院和住院号获取一个患者
|
|
|
@@ -332,7 +389,6 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
this.updateById(patient);
|
|
|
patientOperator.setClinicId(patient.getClinicId());
|
|
|
wsPublishUtils.publishPatientMonitor(originPatientInfo.getId(), patient.getTenantId());
|
|
|
- patientService.deleteAllCache(patient.getTenantId());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -579,7 +635,6 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
CompletableFuture.runAsync(()-> wsPublishUtils.publishPatientMonitor(clinic.getPatientId(),clinic.getTenantId()));
|
|
|
SpringUtil.publishEvent(new ClinicManageEvent(this,clinic.getTenantId(),clinic.getPatientId(),manageEnum));
|
|
|
}
|
|
|
- patientService.deleteAllCache(clinic.getTenantId());
|
|
|
return result;
|
|
|
}
|
|
|
|