|
|
@@ -1,10 +1,14 @@
|
|
|
package com.coffee.bus.controller;
|
|
|
|
|
|
+import cn.dev33.satoken.SaManager;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.stp.StpLogic;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.mapper.Mapper;
|
|
|
+import com.coffee.bus.controller.vo.GetPatientInfoVo;
|
|
|
import com.coffee.bus.controller.vo.MonitorFinishedVo;
|
|
|
import com.coffee.bus.entity.*;
|
|
|
import com.coffee.bus.enums.DeviceStatusEnum;
|
|
|
@@ -15,6 +19,9 @@ import com.coffee.bus.registry.patient.bean.DeviceTimeSmallInfo;
|
|
|
import com.coffee.bus.registry.patient.bean.PatientCacheInfo;
|
|
|
import com.coffee.bus.service.*;
|
|
|
import com.coffee.bus.service.dto.*;
|
|
|
+import com.coffee.bus.utils.WsPublishUtils;
|
|
|
+import com.coffee.common.crud.BaseService;
|
|
|
+import com.coffee.common.crud.controller.BaseQueryController;
|
|
|
import com.coffee.common.exception.CustomException;
|
|
|
import com.coffee.common.result.R;
|
|
|
import com.coffee.common.result.ResultCode;
|
|
|
@@ -36,8 +43,8 @@ import java.util.stream.Collectors;
|
|
|
@RestController
|
|
|
@AllArgsConstructor
|
|
|
@RequestMapping("/bus/patient")
|
|
|
-@Api(tags = "医院病人管理",description = "关于病人的相关操作")
|
|
|
-public class BusPatientController {
|
|
|
+@Api(tags = "医院病人管理",description = "关于病人的相关操作,查询操作权限【bus:patient:query】")
|
|
|
+public class BusPatientController implements BaseQueryController<BusPatientEntity,String> {
|
|
|
private final LocalBusPatientService patientService;
|
|
|
|
|
|
private final LocalBusDeviceRunningService deviceRunningService;
|
|
|
@@ -49,10 +56,12 @@ public class BusPatientController {
|
|
|
private final LocalBusInfusionHistoryService infusionService;
|
|
|
|
|
|
private final LocalBusDeviceManualService manualService;
|
|
|
+
|
|
|
+ private final WsPublishUtils wsPublishUtils;
|
|
|
@PostMapping("/no_page")
|
|
|
@SaCheckPermission("bus:patient:query")
|
|
|
@ApiOperation(value = "输注监控列表",notes = "病人监控管理列表,权限【bus:patient:query】")
|
|
|
- public R<List<PatientMonitorDomain>> selectPage(@RequestBody PatientMonitorQuery query){
|
|
|
+ public R<List<PatientMonitorResult>> selectPage(@RequestBody PatientMonitorQuery query){
|
|
|
return R.success(patientService.selectAll(query));
|
|
|
}
|
|
|
|
|
|
@@ -83,30 +92,51 @@ public class BusPatientController {
|
|
|
@ApiResponse(code = 500,message = "没有选择病号"),
|
|
|
@ApiResponse(code =200 ,message = "若存在不可以结束的临床信息,将会把该临床的主泵信息返回",response = BusDeviceRunningEntity.class)
|
|
|
})
|
|
|
- public R<List<BusDeviceRunningEntity>> judgeFinished(@RequestBody List<String> patientCodes){
|
|
|
+ public R<Boolean> judgeFinished(@RequestBody List<String> patientCodes){
|
|
|
if(CollectionUtil.isEmpty(patientCodes)){
|
|
|
throw new CustomException("请选择一个病患");
|
|
|
}
|
|
|
|
|
|
- return R.success(deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
|
|
|
+ return R.success(CollectionUtil.isNotEmpty(deviceRunningService.list(new QueryWrapper<BusDeviceRunningEntity>()
|
|
|
.lambda()
|
|
|
.select(BusDeviceRunningEntity::getDeviceId,BusDeviceRunningEntity::getPatientCode,BusDeviceRunningEntity::getRunState,BusDeviceRunningEntity::getAlarm)
|
|
|
.eq(BusDeviceRunningEntity::getMaster,true)
|
|
|
.eq(BusDeviceRunningEntity::getMonitorType,true)
|
|
|
.ne(BusDeviceRunningEntity::getRunState, DeviceStatusEnum.Shutdown)
|
|
|
- .in(BusDeviceRunningEntity::getPatientCode,patientCodes)));
|
|
|
+ .in(BusDeviceRunningEntity::getPatientCode,patientCodes))));
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/do/finished")
|
|
|
+ @PostMapping("/do/{monitorType}/finished")
|
|
|
@SaCheckPermission("bus:patient:finished")
|
|
|
@ApiResponse(code = 4001,message = "病号当前绑定了多个设备,不可结束管理")
|
|
|
- @ApiOperation(value = "即结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
|
|
|
- public R finished(@RequestBody MonitorFinishedVo monitorFinishedVo, @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
+ @ApiOperation(value = "结束管理",notes = "病患当前绑定主设备必须要在关机、不在服务器、待机中才能结束管理,权限【bus:patient:finished】")
|
|
|
+ public R finished(@PathVariable("monitorType")@ApiParam(value = "是否为无泵管理 false、无泵 true、有泵",defaultValue = "false" ) boolean haveDevice,
|
|
|
+ @RequestBody MonitorFinishedVo monitorFinishedVo,
|
|
|
+ @RequestAttribute("tenantId")@ApiParam(hidden = true) String tenantId){
|
|
|
+ if(haveDevice){
|
|
|
+ R<Boolean> result = monitorFinished(monitorFinishedVo, tenantId);
|
|
|
+ wsPublishUtils.publishMonitorTotalCount(tenantId);
|
|
|
+ return result;
|
|
|
+ }else {
|
|
|
+ return manualFinished(monitorFinishedVo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 输注监控结束管理(即使用驼人网络泵产品)
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/10 11:48
|
|
|
+ * @param monitorFinishedVo
|
|
|
+ * @param tenantId
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ private R<Boolean> monitorFinished(MonitorFinishedVo monitorFinishedVo, String tenantId){
|
|
|
List<String> patientCodes = monitorFinishedVo.getPatientCodes();
|
|
|
if(CollectionUtil.isEmpty(patientCodes)){
|
|
|
throw new CustomException("请选择一个病患");
|
|
|
}
|
|
|
List<PatientOperator<PatientCacheInfo>> patientOperators = patientCodes.stream().map(code -> patientRegistry.getOperator(tenantId, code)).collect(Collectors.toList());
|
|
|
+
|
|
|
//重复设备
|
|
|
Optional<PatientOperator<PatientCacheInfo>> existRepeatDevice = patientOperators.stream()
|
|
|
.filter(patientOperator -> {
|
|
|
@@ -118,28 +148,41 @@ public class BusPatientController {
|
|
|
})
|
|
|
.findAny();
|
|
|
if(existRepeatDevice.isPresent()){
|
|
|
- return R.result(ResultCode.PATIENT_DEVICE_REPEAT,String.format("病号【%s】当前绑定了多个设备,请将多余设备结束后结束管理",existRepeatDevice.get().getCode()));
|
|
|
+ return R.fail(String.format("病号【%s】当前绑定了多个设备,请将多余设备结束后结束管理",existRepeatDevice.get().getCode()));
|
|
|
}
|
|
|
//组装撤泵信息
|
|
|
List<ManualUndoConfig> undoConfigs = patientOperators.stream().map(operator ->
|
|
|
- ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(), tenantId,true, monitorFinishedVo.getUndo())
|
|
|
+ ManualUndoConfig.of(Collections.singletonList(operator.getBindDeviceId()), operator.getCode(),operator.getClinicId(), tenantId,true, monitorFinishedVo.getUndo())
|
|
|
)
|
|
|
-// .filter(undoConfig -> undoConfig.getDeviceIds() != null && undoConfig.getDeviceIds().size() > 0)
|
|
|
.collect(Collectors.toList());
|
|
|
//病患绑定的有设备,对设备进行撤泵操作,且结束临床
|
|
|
deviceRunningService.batchUndo(undoConfigs,true);
|
|
|
- return R.success();
|
|
|
+ return R.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 描述: 其他监控手动结束管理(即未采用驼人网络泵产品)
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/10 11:49
|
|
|
+ * @param monitorFinishedVo
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ private R<Boolean> manualFinished(MonitorFinishedVo monitorFinishedVo){
|
|
|
+ List<String> clinicIds = monitorFinishedVo.getClinicIds();
|
|
|
+ if (CollectionUtil.isEmpty(clinicIds)) {
|
|
|
+ throw new CustomException("未选择临床信息");
|
|
|
+ }
|
|
|
+ manualService.finishedMonitor(monitorFinishedVo);
|
|
|
+ return R.success(true);
|
|
|
}
|
|
|
|
|
|
|
|
|
- @PostMapping("/monitor/reset/{patientCode}")
|
|
|
+ @PostMapping("/monitor/reset/{clinicId}")
|
|
|
@SaCheckPermission("device:patient:edit")
|
|
|
@ApiOperation(value = "病人当前监控时间重启",notes = "当结束临床后有新的输注信息产生,那么病人监控会重新显示,此时监控时间不会重新计算,需先调用该接口,权限标识为【device:patient:edit】")
|
|
|
- public R reset(@PathVariable("patientCode")String patientCode){
|
|
|
- return R.success(patientService.update(new UpdateWrapper<BusPatientEntity>()
|
|
|
- .lambda()
|
|
|
- .eq(BusPatientEntity::getCode,patientCode)
|
|
|
- .set(BusPatientEntity::getTmpFinished,false)));
|
|
|
+ public R reset(@ApiParam("临床id")@PathVariable("clinicId")String clinicId){
|
|
|
+ return R.success(clinicService.update(new UpdateWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getId,clinicId)
|
|
|
+ .set(BusClinicEntity::getFinished,false)));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -148,6 +191,7 @@ public class BusPatientController {
|
|
|
@ApiOperation(value = "主泵切换的操作,只切换,不结束",notes = "当出现泵重复状态时,若用户想要进行主泵的切换,调用该接口进行操作,主泵切换完成后,会将副泵自动撤泵,权限标识为【device:patient:shift】")
|
|
|
public R shift(@RequestBody DeviceShiftConfig shiftConfig){
|
|
|
deviceRunningService.shift(shiftConfig);
|
|
|
+ wsPublishUtils.publishPatientMonitor(shiftConfig.getPatientCode(),shiftConfig.getTenantId());
|
|
|
return R.success();
|
|
|
}
|
|
|
|
|
|
@@ -158,7 +202,8 @@ public class BusPatientController {
|
|
|
//泵切换完成后,对病号报警解除
|
|
|
deviceRunningService.undo(undoConfig,false);
|
|
|
//判断当前病号下是否还存在副泵
|
|
|
- long count = deviceRunningService.count(new QueryWrapper<BusDeviceRunningEntity>().lambda().eq(BusDeviceRunningEntity::getPatientCode, undoConfig.getPatientCode())
|
|
|
+ long count = deviceRunningService.count(new QueryWrapper<BusDeviceRunningEntity>().lambda()
|
|
|
+ .eq(BusDeviceRunningEntity::getPatientCode, undoConfig.getPatientCode())
|
|
|
.eq(BusDeviceRunningEntity::getTenantId, undoConfig.getTenantId())
|
|
|
.eq(BusDeviceRunningEntity::getMaster, false)
|
|
|
.eq(BusDeviceRunningEntity::getIsUndo, false));
|
|
|
@@ -189,51 +234,83 @@ public class BusPatientController {
|
|
|
}
|
|
|
|
|
|
|
|
|
- @GetMapping("/monitor/{monitorType}/{patientCode}")
|
|
|
+ @GetMapping("/monitor/{monitorType}/{clinicId}")
|
|
|
@SaCheckPermission("device:patient:query")
|
|
|
@ApiOperation(value = "查看病人当前监控详情",notes = "查看病人当前监控详情,权限标识为【device:patient:query】")
|
|
|
- public R<PatientMonitorResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice,@PathVariable("patientCode")@ApiParam(value = "病号") String patientCode){
|
|
|
- PatientMonitorResult result = new PatientMonitorResult();
|
|
|
+ public R<PatientMonitorDetailResult> monitor(@PathVariable("monitorType")@ApiParam(value = "是否为有泵监控",example = "0、无泵,1、有泵") Boolean haveDevice, @PathVariable("clinicId")@ApiParam(value = "临床id")String clinicId){
|
|
|
+ PatientMonitorDetailResult result = new PatientMonitorDetailResult();
|
|
|
+ BusClinicEntity clinic = clinicService.getById(clinicId);
|
|
|
+ result.setClinic(clinic);
|
|
|
+ if(clinic==null){
|
|
|
+ throw new CustomException("该临床信息不存在,请刷新后重试");
|
|
|
+ }
|
|
|
if(haveDevice){
|
|
|
- BusPatientEntity patient = patientService.getOne(new QueryWrapper<BusPatientEntity>().lambda()
|
|
|
- .eq(BusPatientEntity::getCode, patientCode).last("limit 1"));
|
|
|
- BusInfusionHistoryEntity infusion = infusionService.getById(patient.getInfusionId());
|
|
|
- result.setPatient(patient);
|
|
|
+ BusInfusionHistoryEntity infusion = infusionService.getOne(new QueryWrapper<BusInfusionHistoryEntity>().lambda().eq(BusInfusionHistoryEntity::getClinicId,clinic.getId())
|
|
|
+ .orderByDesc(BusInfusionHistoryEntity::getStartTime).last("limit 1"));
|
|
|
+ infusion.setAlias(deviceRunningService.getAliasName(infusion.getDeviceId()));
|
|
|
result.setInfusion(infusion);
|
|
|
if(StrUtil.isNotEmpty(infusion.getClinicId())){
|
|
|
result.setClinic(clinicService.getById(infusion.getClinicId()));
|
|
|
}
|
|
|
}else {
|
|
|
//无泵查看
|
|
|
- BusClinicEntity clinic = clinicService.getOne(new QueryWrapper<BusClinicEntity>().lambda().eq(BusClinicEntity::getPatientCode, patientCode).eq(BusClinicEntity::getMonitorType, false).orderByDesc(BusClinicEntity::getStartTime).last("limit 1"));
|
|
|
- if(clinic!=null){
|
|
|
- result.setClinic(clinic);
|
|
|
- result.setDeviceManual( manualService.getOne(new QueryWrapper<BusDeviceManualEntity>().lambda().eq(BusDeviceManualEntity::getClinicId, clinic.getId())));
|
|
|
- }
|
|
|
+ result.setDeviceManual( manualService.getOne(new QueryWrapper<BusDeviceManualEntity>().lambda().eq(BusDeviceManualEntity::getClinicId, clinic.getId())));
|
|
|
}
|
|
|
return R.success(result);
|
|
|
}
|
|
|
|
|
|
- //todo 使用
|
|
|
- @PostMapping("/syn/{hospitalId}/{patientCode}")
|
|
|
- @ApiOperation(value = "同步更新患者信息,即等待更新完成后返回更新结果")
|
|
|
- public DeferredResult<R> syn(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
|
|
|
- DeferredResult<R> result = new DeferredResult<>();
|
|
|
- result.onCompletion(()->{
|
|
|
+ @PostMapping("/stats/status")
|
|
|
+ @SaCheckPermission("device:patient:query")
|
|
|
+ @ApiOperation(value = "按照状态统计病人监控状态数量",notes = "权限【device:patient:query】")
|
|
|
+ public R<MonitorStatusStatsCountResult> statsStatus(){
|
|
|
+ return R.success(patientService.statusStats(null));
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
- result.onTimeout(()->{
|
|
|
- R.fail("响应超时");
|
|
|
- });
|
|
|
- return result;
|
|
|
+
|
|
|
+ @PostMapping("/stats/time")
|
|
|
+ @SaCheckPermission("device:patient:query")
|
|
|
+ @ApiOperation(value = "按照时间统计病人监控数量",notes = "权限【device:patient:query】")
|
|
|
+ public R<MonitorTimeStatsCountResult> statsTime(){
|
|
|
+ return R.success(patientService.timeStats(null));
|
|
|
}
|
|
|
|
|
|
- //todo
|
|
|
- @PostMapping("/async/{hospitalId}/{patientCode}")
|
|
|
- @ApiOperation(value = "异步更新患者信息,即立刻返回更新结果")
|
|
|
- public R async(@PathVariable("hospitalId") String hospitalId, @PathVariable("patientCode")String patientCode){
|
|
|
- return R.success();
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/pull/async")
|
|
|
+ @SaCheckPermission("device:patient:pull")
|
|
|
+ @ApiOperation(value = "同步更新患者信息,超时时间默认为10s,超时后数据返回继续处理,输注监控",notes = "权限标识为【bus:patient:pull】")
|
|
|
+ public DeferredResult<R<BusClinicEntity>> syn(@RequestAttribute("tenantId") String tenantId, @RequestBody GetPatientInfoVo vo){
|
|
|
+ return patientService.getPatientInfoFromHis(tenantId,vo.getPatientCode(),vo.getTimeout(),false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 描述:
|
|
|
+ * @author lifang
|
|
|
+ * @date 2022/5/15 21:56
|
|
|
+ * @param tenantId
|
|
|
+ * @param vo
|
|
|
+ * @return R
|
|
|
+ */
|
|
|
+ @PostMapping("/pull/sync")
|
|
|
+ @SaCheckPermission("device:patient:pull")
|
|
|
+ @ApiOperation(value = "同步更新患者信息,超时时间默认为10s,超时后数据返回则不进行处理,无泵更新",notes = "权限标识为【bus:patient:pull】")
|
|
|
+ public DeferredResult<R<BusClinicEntity>> async(@RequestAttribute("tenantId") String tenantId, @RequestBody GetPatientInfoVo vo){
|
|
|
+ return patientService.getPatientInfoFromHis(tenantId,vo.getPatientCode(),vo.getTimeout(),true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BaseService<? extends Mapper<BusPatientEntity>, BusPatientEntity, String> getService() {
|
|
|
+ return patientService;
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getPermissionPrefix() {
|
|
|
+ return "bus:patient:";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public StpLogic getStpLogin() {
|
|
|
+ return SaManager.getStpLogic("");
|
|
|
+ }
|
|
|
}
|