|
@@ -3,6 +3,7 @@ package com.coffee.bus.registry.patient;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
import com.coffee.bus.entity.BusClinicEntity;
|
|
|
import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
import com.coffee.bus.entity.BusDeviceRunningEntity;
|
|
|
import com.coffee.bus.entity.BusInfusionHistoryEntity;
|
|
import com.coffee.bus.entity.BusInfusionHistoryEntity;
|
|
@@ -59,43 +60,45 @@ public class ClusterPatientRegistry implements PatientRegistry {
|
|
|
.lambda().eq(BusPatientEntity::getCode, patientCode)
|
|
.lambda().eq(BusPatientEntity::getCode, patientCode)
|
|
|
.eq(BusPatientEntity::getTenantId, hospitalId));
|
|
.eq(BusPatientEntity::getTenantId, hospitalId));
|
|
|
boolean insert=false;
|
|
boolean insert=false;
|
|
|
|
|
+ BusClinicEntity clinic=new BusClinicEntity();
|
|
|
if(patient==null){
|
|
if(patient==null){
|
|
|
|
|
+ clinic.setId(IdWorker.getIdStr());
|
|
|
|
|
+ clinic.setPatientCode(patientCode);
|
|
|
|
|
+ clinic.setTenantId(hospitalId);
|
|
|
|
|
+ //当用户不存在时,创建用户,并给与用户一个空的临床信息
|
|
|
insert=true;
|
|
insert=true;
|
|
|
patient=new BusPatientEntity();
|
|
patient=new BusPatientEntity();
|
|
|
patient.setCode(patientCode);
|
|
patient.setCode(patientCode);
|
|
|
- //默认为空字符串
|
|
|
|
|
- patient.setClinicId("");
|
|
|
|
|
patient.setTenantId(hospitalId);
|
|
patient.setTenantId(hospitalId);
|
|
|
|
|
+ //异步拉取his信息
|
|
|
|
|
+ clinicService.asyncFromHis(hospitalId,patientCode);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ clinic = clinicService.recentClinicByPatientCode(hospitalId, patientCode);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
patientOperator.setCode(patientCode);
|
|
patientOperator.setCode(patientCode);
|
|
|
patientOperator.setTenantId(hospitalId);
|
|
patientOperator.setTenantId(hospitalId);
|
|
|
patientOperator.setName(patient.getName());
|
|
patientOperator.setName(patient.getName());
|
|
|
patientOperator.setGender(patient.getGender());
|
|
patientOperator.setGender(patient.getGender());
|
|
|
|
|
|
|
|
- BusClinicEntity clinic = clinicService.recentClinicByPatientCode(hospitalId, patientCode);
|
|
|
|
|
- //不存在临床或临床已结束
|
|
|
|
|
- if(clinic==null||Boolean.TRUE.equals(clinic.getFinished())){
|
|
|
|
|
- clinicService.asyncFromHis(hospitalId,patientCode);
|
|
|
|
|
- patient.setClinicId("");
|
|
|
|
|
- patientOperator.setClinicId("");
|
|
|
|
|
- }else {
|
|
|
|
|
- //填充临床信息
|
|
|
|
|
- patient.setName(clinic.getName());
|
|
|
|
|
- patient.setTmpFinished(clinic.getFinished());
|
|
|
|
|
- patient.setClinicId(clinic.getId());
|
|
|
|
|
- patient.setTmpFinished(clinic.getFinished());
|
|
|
|
|
|
|
+ //填充临床信息
|
|
|
|
|
+ patient.setName(clinic.getName());
|
|
|
|
|
+ patient.setClinicId(clinic.getId());
|
|
|
|
|
|
|
|
- patientOperator.setWard(clinic.getWard());
|
|
|
|
|
- patientOperator.setBedNo(clinic.getBedNo());
|
|
|
|
|
- patientOperator.setClinicId(clinic.getId());
|
|
|
|
|
- patientOperator.setFinished(clinic.getFinished());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ patientOperator.setWard(clinic.getWard());
|
|
|
|
|
+ patientOperator.setBedNo(clinic.getBedNo());
|
|
|
|
|
+ patientOperator.setClinicId(clinic.getId());
|
|
|
|
|
+ patientOperator.setFinished(clinic.getFinished());
|
|
|
//填充输注信息
|
|
//填充输注信息
|
|
|
- BusInfusionHistoryEntity infusion = infusionService.recentInfusionByPatientCode(hospitalId, patientCode);
|
|
|
|
|
- if(infusion!=null){
|
|
|
|
|
- patient.setInfusionId(infusion.getId());
|
|
|
|
|
- patient.setMonitorStartTime(infusion.getStartTime());
|
|
|
|
|
- patient.setMonitorEndTime(infusion.getUndoTime());
|
|
|
|
|
|
|
+ BusInfusionHistoryEntity recentInfusion = infusionService.recentInfusionByPatientCode(hospitalId, patientCode);
|
|
|
|
|
+ if(recentInfusion!=null){
|
|
|
|
|
+ patient.setInfusionId(recentInfusion.getId());
|
|
|
|
|
+ clinic.setMonitorStartTime(recentInfusion.getStartTime());
|
|
|
|
|
+ //监护已结束
|
|
|
|
|
+ if(Boolean.TRUE.equals(recentInfusion.getIsUndo())){
|
|
|
|
|
+ clinic.setEndTime(recentInfusion.getUndoTime());
|
|
|
|
|
+ clinic.setFinished(true);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//填充主副泵信息
|
|
//填充主副泵信息
|
|
|
List<BusDeviceRunningEntity> runningList = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode, patientCode).eq(BusDeviceRunningEntity::getTenantId, hospitalId));
|
|
List<BusDeviceRunningEntity> runningList = deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode, patientCode).eq(BusDeviceRunningEntity::getTenantId, hospitalId));
|
|
@@ -114,9 +117,12 @@ public class ClusterPatientRegistry implements PatientRegistry {
|
|
|
try {
|
|
try {
|
|
|
log.info("医院[{}]新增病号数据[{}]",hospitalId,patientCode);
|
|
log.info("医院[{}]新增病号数据[{}]",hospitalId,patientCode);
|
|
|
patientService.save(patient);
|
|
patientService.save(patient);
|
|
|
|
|
+ clinicService.save(clinic);
|
|
|
}catch (DuplicateKeyException e){
|
|
}catch (DuplicateKeyException e){
|
|
|
log.warn("病号重复插入,医院id:[{}],病号:[{}]",hospitalId,patientCode);
|
|
log.warn("病号重复插入,医院id:[{}],病号:[{}]",hospitalId,patientCode);
|
|
|
}
|
|
}
|
|
|
|
|
+ }else {
|
|
|
|
|
+ clinicService.updateById(clinic);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return patientOperator;
|
|
return patientOperator;
|