|
|
@@ -4,10 +4,11 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.nb.mq.entity.PcAnalgesicScoreEntity;
|
|
|
import com.nb.mq.entity.PcPatientEntity;
|
|
|
import com.nb.mq.entity.PcPumpEntity;
|
|
|
-import com.nb.web.api.feign.IClinicEvalClient;
|
|
|
-import com.nb.web.api.feign.IDeviceClient;
|
|
|
-import com.nb.web.api.feign.IIotMsgHandler;
|
|
|
-import com.nb.web.api.feign.IPatientClient;
|
|
|
+import com.nb.web.api.entity.BusClinicEntity;
|
|
|
+import com.nb.web.api.entity.BusEvaluationEntity;
|
|
|
+import com.nb.web.api.entity.BusInfusionHistoryEntity;
|
|
|
+import com.nb.web.api.feign.*;
|
|
|
+import com.nb.web.api.feign.result.PatientMonitorDetailResult;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
|
|
@@ -15,6 +16,9 @@ import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
import org.springframework.messaging.handler.annotation.Payload;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Optional;
|
|
|
+
|
|
|
/**
|
|
|
* @author lifang
|
|
|
* @version 1.0.0
|
|
|
@@ -26,10 +30,9 @@ import org.springframework.stereotype.Component;
|
|
|
@Slf4j
|
|
|
@AllArgsConstructor
|
|
|
public class RabbitMqListener {
|
|
|
- private final IIotMsgHandler iotMsgHandler;
|
|
|
- private final IDeviceClient deviceService;
|
|
|
private final IPatientClient patientClient;
|
|
|
private final IClinicEvalClient clinicEvalClient;
|
|
|
+ private final IClinicClient clinicClient;
|
|
|
/**
|
|
|
* 描述: 监听病人队列
|
|
|
* @author lifang
|
|
|
@@ -41,7 +44,23 @@ public class RabbitMqListener {
|
|
|
public void patientQueue(@Payload String body) {
|
|
|
log.info("消息队列中,病人队列{cloud.patient},接受消息:{}",body);
|
|
|
PcPatientEntity source = JSONUtil.toBean(body, PcPatientEntity.class);
|
|
|
-
|
|
|
+ String patientId = patientClient.lookPatientId(source.getHospitalCode(), source.getPatientCode());
|
|
|
+ BusClinicEntity clinic= source.toClinic(patientId);
|
|
|
+ PatientMonitorDetailResult patientDetail = patientClient.lookPatientDetail(patientId);
|
|
|
+ BusClinicEntity existClinic = patientDetail.getClinic();
|
|
|
+ clinic.setStartTime(existClinic.getStartTime()==null?new Date():existClinic.getStartTime());
|
|
|
+ if(Boolean.TRUE.equals(clinic.getFinished())){
|
|
|
+ //进行撤泵处理
|
|
|
+ clinicClient.finish(existClinic.getId(),existClinic.getTenantId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //当上一个临床状态为已结束时,生成新的临床信息
|
|
|
+ if(Boolean.TRUE.equals(existClinic.getFinished())){
|
|
|
+ clinic=clinicClient.insertFromHis(clinic);
|
|
|
+ }else {
|
|
|
+ clinic.setId(existClinic.getId());
|
|
|
+ }
|
|
|
+ clinicClient.setCurrentClinicByHis(clinic);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -55,6 +74,7 @@ public class RabbitMqListener {
|
|
|
public void pumpQueue(@Payload String body) {
|
|
|
log.info("消息队列中,网络泵队列{cloud.pump},接受消息:{}",body);
|
|
|
PcPumpEntity source = JSONUtil.toBean(body, PcPumpEntity.class);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -69,6 +89,17 @@ public class RabbitMqListener {
|
|
|
log.info("消息队列中,评分队列{cloud.analgesicScore},接受消息:{}",body);
|
|
|
PcAnalgesicScoreEntity source = JSONUtil.toBean(body, PcAnalgesicScoreEntity.class);
|
|
|
|
|
|
+ String patientId = patientClient.lookPatientId(source.getHospitalCode(), source.getPatientCode());
|
|
|
+
|
|
|
+ PatientMonitorDetailResult patientDetail = patientClient.lookPatientDetail(patientId);
|
|
|
+
|
|
|
+ BusInfusionHistoryEntity infusion = Optional.ofNullable(patientDetail.getInfusion()).orElse(new BusInfusionHistoryEntity());
|
|
|
+
|
|
|
+ BusEvaluationEntity eval = source.toEval(patientId,
|
|
|
+ infusion.getDeviceId(),
|
|
|
+ infusion.getId(),
|
|
|
+ patientDetail.getClinic().getId());
|
|
|
+ clinicEvalClient.save(eval);
|
|
|
}
|
|
|
|
|
|
}
|