|
|
@@ -9,6 +9,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.web.api.entity.BusClinicEntity;
|
|
|
import com.nb.web.api.entity.BusDeviceEntity;
|
|
|
@@ -41,9 +42,12 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
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.web.context.request.async.DeferredResult;
|
|
|
|
|
|
+import javax.validation.constraints.NotNull;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.util.*;
|
|
|
@@ -233,29 +237,57 @@ public class LocalBusPatientService extends BaseService<BusPatientMapper, BusPat
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * t
|
|
|
+ *
|
|
|
* 根据医院和住院号获取一个患者
|
|
|
*
|
|
|
* @param tenantId
|
|
|
* @param patientCode
|
|
|
* @return
|
|
|
*/
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
- public BusPatientEntity getOneByHospitalAndPatientCode(String tenantId, String patientCode) {
|
|
|
- BusPatientEntity patient = this.getOne(new QueryWrapper<BusPatientEntity>().lambda()
|
|
|
+ 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()
|
|
|
.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.setInfusionId(recentInfusion.getId());
|
|
|
}
|
|
|
return patient;
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 病人手动更新当前监控的临床信息
|
|
|
*
|