|
|
|
@ -1,34 +1,40 @@
|
|
|
|
|
package com.docus.server.message.busservice.impl;
|
|
|
|
|
|
|
|
|
|
import com.docus.core.util.FileUtil;
|
|
|
|
|
import com.docus.core.util.Func;
|
|
|
|
|
import com.docus.infrastructure.core.exception.BaseException;
|
|
|
|
|
import com.docus.infrastructure.web.api.CommonResult;
|
|
|
|
|
import com.docus.infrastructure.web.api.ResultCode;
|
|
|
|
|
import com.docus.server.message.busservice.SdBusinessService;
|
|
|
|
|
import com.docus.server.message.config.CollectTaskConfig;
|
|
|
|
|
import com.docus.server.message.consts.StaticResourceMapping;
|
|
|
|
|
import com.docus.server.message.controller.vo.SdRyBloodReportVO;
|
|
|
|
|
import com.docus.server.message.converters.WsNurseSubmitMessageConvert;
|
|
|
|
|
import com.docus.server.message.converters.WsRecordSubmitMessageConvert;
|
|
|
|
|
import com.docus.server.message.dto.Message;
|
|
|
|
|
import com.docus.server.message.dto.MessageResponse;
|
|
|
|
|
import com.docus.server.message.dto.RecordSubmitDTO;
|
|
|
|
|
import com.docus.server.message.dto.WsNurseSubmitDTO;
|
|
|
|
|
import com.docus.server.message.dto.*;
|
|
|
|
|
import com.docus.server.message.feign.dto.CompensateTasRequest;
|
|
|
|
|
import com.docus.server.message.feign.dto.HospitalSubmitNodeLogAddDTO;
|
|
|
|
|
import com.docus.server.message.feign.enums.HospitalSubmitNodeEnum;
|
|
|
|
|
import com.docus.server.message.feign.service.CollectTaskService;
|
|
|
|
|
import com.docus.server.message.feign.service.HospitalSubmitNodeServiceApi;
|
|
|
|
|
import com.docus.server.message.mapper.SdRyBloodMapper;
|
|
|
|
|
import com.docus.server.message.mapper.SdRyIcuMapper;
|
|
|
|
|
import com.docus.server.message.mapper.TBasicMapper;
|
|
|
|
|
import com.docus.server.message.rpc.ShunDePeopleRpc;
|
|
|
|
|
import com.docus.server.message.rpc.dto.HisZyCyYzDTO;
|
|
|
|
|
import com.docus.server.message.rpc.request.HisZyCyYzRequest;
|
|
|
|
|
import com.docus.server.message.rpc.response.HisZyCyYzResponse;
|
|
|
|
|
import com.docus.server.message.util.TableJsonRead;
|
|
|
|
|
import com.docus.server.message.validate.RecordSubmitValidate;
|
|
|
|
|
import com.docus.server.message.validate.WsNurseSubmitValidate;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
@ -36,6 +42,11 @@ import java.util.Objects;
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
@Value("${ip}")
|
|
|
|
|
private String localIp;
|
|
|
|
|
@Value("${server.port}")
|
|
|
|
|
private String port;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CollectTaskService collectTaskService;
|
|
|
|
|
@Autowired
|
|
|
|
@ -46,6 +57,8 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
private SdRyIcuMapper sdRyIcuMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private HospitalSubmitNodeServiceApi hospitalSubmitNodeServiceApi;
|
|
|
|
|
@Autowired
|
|
|
|
|
private SdRyBloodMapper sdRyBloodMapper;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public MessageResponse recordSubmitHandle(Message message) {
|
|
|
|
@ -68,13 +81,13 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
nodeLogAddDTO.setCreaterName("电子病历提交");
|
|
|
|
|
hospitalSubmitNodeServiceApi.addLog(nodeLogAddDTO);
|
|
|
|
|
|
|
|
|
|
if(!isDischargeAndUpdDisDate(patientIds.get(0),recordSubmitDto.getInHospIndexNo(), recordSubmitDto.getVisitNo())){
|
|
|
|
|
if (!isDischargeAndUpdDisDate(patientIds.get(0), recordSubmitDto.getInHospIndexNo(), recordSubmitDto.getVisitNo())) {
|
|
|
|
|
throw new BaseException("此患者未出院!");
|
|
|
|
|
}
|
|
|
|
|
tBasicMapper.insertOrUpdateDoctorSubmitTime(patientIds.get(0), recordSubmitDto.getSubmitTime());
|
|
|
|
|
log.info("补偿电子病历任务 patientIds:{} collectId:{}", patientIds, taskConfig.getCollectorIds());
|
|
|
|
|
compensateTask(patientIds, taskConfig.getCollectorIds());
|
|
|
|
|
tBasicMapper.updateEmrSubmitState(patientIds.get(0),1);
|
|
|
|
|
tBasicMapper.updateEmrSubmitState(patientIds.get(0), 1);
|
|
|
|
|
return new MessageResponse(ResultCode.SUCCESS.getCode(), success());
|
|
|
|
|
} catch (BaseException baseException) {
|
|
|
|
|
log.error(baseException.getMessage(), baseException);
|
|
|
|
@ -109,19 +122,19 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
// 添加提交内容
|
|
|
|
|
HospitalSubmitNodeLogAddDTO nodeLogAddDTO = new HospitalSubmitNodeLogAddDTO();
|
|
|
|
|
nodeLogAddDTO.setPatientId(patientIds.get(0));
|
|
|
|
|
nodeLogAddDTO.setContent(new String[]{nurseSubmitDTO.getDutyNurse(),nurseSubmitDTO.getQcNurse(),Func.formatDateTime(nurseSubmitDTO.getSubmitTime()),nurseSubmitDTO.getFilesCount().toString()});
|
|
|
|
|
nodeLogAddDTO.setContent(new String[]{nurseSubmitDTO.getDutyNurse(), nurseSubmitDTO.getQcNurse(), Func.formatDateTime(nurseSubmitDTO.getSubmitTime()), nurseSubmitDTO.getFilesCount().toString()});
|
|
|
|
|
nodeLogAddDTO.setSubmitNodeEnum(HospitalSubmitNodeEnum.NURSE);
|
|
|
|
|
nodeLogAddDTO.setCreater("护理提交");
|
|
|
|
|
nodeLogAddDTO.setCreaterName("护理提交");
|
|
|
|
|
hospitalSubmitNodeServiceApi.addLog(nodeLogAddDTO);
|
|
|
|
|
|
|
|
|
|
if(!isDischargeAndUpdDisDate(patientIds.get(0), inHospIndexNo, visitNo)){
|
|
|
|
|
if (!isDischargeAndUpdDisDate(patientIds.get(0), inHospIndexNo, visitNo)) {
|
|
|
|
|
throw new BaseException("此患者未出院!");
|
|
|
|
|
}
|
|
|
|
|
// 如果是重症患者,如果没有重症报告的话,不能提交
|
|
|
|
|
if (isIcuRecord(inHospIndexNo, visitNo)) {
|
|
|
|
|
// 更新重症标识
|
|
|
|
|
confirmAndUpdIcuRecordState(inHospIndexNo,visitNo);
|
|
|
|
|
confirmAndUpdIcuRecordState(inHospIndexNo, visitNo);
|
|
|
|
|
if (!hasIcuFile(patientIds.get(0))) {
|
|
|
|
|
throw new BaseException("重症患者,未采集重症文件,不允许提交!");
|
|
|
|
|
}
|
|
|
|
@ -129,7 +142,7 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
|
|
|
|
|
tBasicMapper.insertOrUpdateNurseSubmitTime(patientIds.get(0), nurseSubmitDTO.getSubmitTime());
|
|
|
|
|
tBasicMapper.insertOrUpdateNurseFileCount(patientIds.get(0), nurseSubmitDTO.getFilesCount());
|
|
|
|
|
tBasicMapper.insertOrUpdateNurse(patientIds.get(0), nurseSubmitDTO.getQcNurse(),nurseSubmitDTO.getDutyNurse());
|
|
|
|
|
tBasicMapper.insertOrUpdateNurse(patientIds.get(0), nurseSubmitDTO.getQcNurse(), nurseSubmitDTO.getDutyNurse());
|
|
|
|
|
log.info("补偿护理任务 patientIds:{} collectId:{}", patientIds, taskConfig.getCollectorIds());
|
|
|
|
|
compensateTask(patientIds, taskConfig.getCollectorIds());
|
|
|
|
|
return new MessageResponse(ResultCode.SUCCESS.getCode(), success());
|
|
|
|
@ -150,6 +163,7 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据病案,查找是否有icu来源,未作废的文件数量>0
|
|
|
|
|
*
|
|
|
|
|
* @param patientId 病案主键
|
|
|
|
|
* @return 是否有icu来源,未作废的文件数量>0
|
|
|
|
|
*/
|
|
|
|
@ -160,8 +174,9 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据病案主键和来源,统计未作废的文件数量
|
|
|
|
|
*
|
|
|
|
|
* @param patientId 病案主键
|
|
|
|
|
* @param source 系统/采集来源
|
|
|
|
|
* @param source 系统/采集来源
|
|
|
|
|
* @return 未作废文件数量
|
|
|
|
|
*/
|
|
|
|
|
private int getFileCountByPatientAndSource(String patientId, String source) {
|
|
|
|
@ -178,7 +193,50 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean isIcuRecord(String inpatientNo, Integer admissTimes) {
|
|
|
|
|
Integer count = sdRyIcuMapper.countByInpNoAndAdmissTimes(inpatientNo, admissTimes);
|
|
|
|
|
return count>0;
|
|
|
|
|
return count > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<SdRyBloodReportVO> getBloodView(String inpatientNo, Integer admissTimes) {
|
|
|
|
|
String disDate = tBasicMapper.getDischargeDateByInpatientNoAndTimes(inpatientNo, admissTimes);
|
|
|
|
|
if(Func.isBlank(disDate)){
|
|
|
|
|
disDate="18010203";
|
|
|
|
|
}
|
|
|
|
|
// 视图数据
|
|
|
|
|
List<SdRyBloodReportDTO> bloodReportDtoList = sdRyBloodMapper.getByInpatientNoAndAdmissions(inpatientNo, admissTimes);
|
|
|
|
|
if (Func.isEmpty(bloodReportDtoList)) {
|
|
|
|
|
return new ArrayList<>();
|
|
|
|
|
}
|
|
|
|
|
List<SdRyBloodReportVO> vos = new ArrayList<>();
|
|
|
|
|
for (SdRyBloodReportDTO dto : bloodReportDtoList) {
|
|
|
|
|
// 查询报告转换本地映射网络请求路径
|
|
|
|
|
byte[] fileBytes = shunDePeopleRpc.getBloodReport(dto.getFileName());
|
|
|
|
|
String filePath = TableJsonRead.currentPath(StaticResourceMapping.STATIC_RESOURCE_PREFIX + File.separator + StaticResourceMapping.BLOOD)
|
|
|
|
|
+ File.separator
|
|
|
|
|
+ disDate
|
|
|
|
|
+ File.separator
|
|
|
|
|
+ inpatientNo + "_" + admissTimes
|
|
|
|
|
+ File.separator
|
|
|
|
|
+ dto.getFileName();
|
|
|
|
|
File file = new File(filePath);
|
|
|
|
|
if (!file.getParentFile().exists()) {
|
|
|
|
|
file.getParentFile().mkdirs();
|
|
|
|
|
}
|
|
|
|
|
FileUtil.toFile(new ByteArrayInputStream(fileBytes), file);
|
|
|
|
|
// 与静态资源配置匹配
|
|
|
|
|
String fileUrl = localIp + ":" + port + "/" + StaticResourceMapping.BLOOD + "/" + disDate + "/" + inpatientNo + "_" + admissTimes + "/" + dto.getFileName();
|
|
|
|
|
// 设置返回数据
|
|
|
|
|
SdRyBloodReportVO vo = new SdRyBloodReportVO();
|
|
|
|
|
vo.setFileUrl(fileUrl);
|
|
|
|
|
vo.setAdmissions(dto.getAdmissions());
|
|
|
|
|
vo.setInpatientNo(dto.getInpatientNo());
|
|
|
|
|
vo.setFileDesc(dto.getFileDesc());
|
|
|
|
|
vo.setFileName(dto.getFileName());
|
|
|
|
|
vo.setFileId(dto.getFileId());
|
|
|
|
|
vos.add(vo);
|
|
|
|
|
}
|
|
|
|
|
return vos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void compensateTask(List<String> patientIds, List<String> collectorIds) {
|
|
|
|
@ -251,11 +309,12 @@ public class SdBusinessServiceImpl implements SdBusinessService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断医嘱返回结果是否是空
|
|
|
|
|
*
|
|
|
|
|
* @param response 医嘱返回结果
|
|
|
|
|
* @return 没有医嘱数据放回true
|
|
|
|
|
*/
|
|
|
|
|
private boolean isNullYzData(HisZyCyYzResponse response) {
|
|
|
|
|
return Objects.isNull(response) || Func.isEmpty(response.getData()) || Objects.isNull(response.getData().get(0));
|
|
|
|
|
return Objects.isNull(response) || Func.isEmpty(response.getData()) || Objects.isNull(response.getData().get(0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|