|
|
|
@ -2,24 +2,32 @@ package com.emr.service.ipml;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
|
|
import com.emr.dao.ArchiveOtherExtMapper;
|
|
|
|
|
import com.emr.dao.Archive_DetailMapper;
|
|
|
|
|
import com.emr.dao.Archive_MasterMapper;
|
|
|
|
|
import com.emr.dao.PushInfoMapper;
|
|
|
|
|
import com.emr.entity.Archive_Master;
|
|
|
|
|
import com.emr.entity.Archive_Master_Vo;
|
|
|
|
|
import com.emr.entity.*;
|
|
|
|
|
import com.emr.service.PushInfoService;
|
|
|
|
|
import com.emr.util.CommonResult;
|
|
|
|
|
import com.emr.util.Msg;
|
|
|
|
|
import com.emr.util.RedisMq;
|
|
|
|
|
import com.emr.vo.ArchiveOtherExtVo;
|
|
|
|
|
import com.emr.vo.PrintParam;
|
|
|
|
|
import com.emr.vo.PushInfoVo;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @ClassName pushInfoServiceImpl
|
|
|
|
@ -29,6 +37,7 @@ import java.util.List;
|
|
|
|
|
* @Version 1.0
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -36,13 +45,22 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PushInfoMapper pushInfoMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ArchiveOtherExtMapper archiveOtherExtMapper;
|
|
|
|
|
private String redisKey = "docus:task:topic_collect_%s_queue:%s";
|
|
|
|
|
@Autowired(required = false)
|
|
|
|
|
private RedisMq redisMq;
|
|
|
|
|
@Value("${doctorFlag}")
|
|
|
|
|
private String doctorFlag;
|
|
|
|
|
@Value("${pacsSavePath}")
|
|
|
|
|
private String pacsSavePath;
|
|
|
|
|
@Value("${detailPath}")
|
|
|
|
|
private String detailPath;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private Archive_DetailMapper archiveDetailMapper;
|
|
|
|
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(PushInfoServiceImpl.class);
|
|
|
|
|
@Value("${nurseFlag}")
|
|
|
|
|
private String nurseFlag;
|
|
|
|
|
|
|
|
|
@ -63,6 +81,7 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
printParam.setDeptName(list.get(0).getDeptName());
|
|
|
|
|
printParam.setDischargeDateTime(list.get(0).getDischargeDateTime());
|
|
|
|
|
printParam.setName(list.get(0).getName());
|
|
|
|
|
printParam.setAdmissionDateTime(list.get(0).getAdmissionDateTime());
|
|
|
|
|
//判断类型为电子病历或护理记录接1.电子病历2.护理记录
|
|
|
|
|
if (pushInfoVo.getDataType() == 1) {
|
|
|
|
|
int i = archiveMasterMapper.updateCmtDoctorByInpNoAndVisitId(pushInfoVo.getInpNo(), pushInfoVo.getVisitId(), pushInfoVo.getSubmitTime(), pushInfoVo.getSubmitCode());
|
|
|
|
@ -77,6 +96,25 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
//存放队列消息
|
|
|
|
|
GenerateQueue(printParam, 5, doctorId);
|
|
|
|
|
}
|
|
|
|
|
//pacs记录存到任务表中并且判断是否存在存在则不变动
|
|
|
|
|
List<ArchiveOtherExtVo> otherList = archiveOtherExtMapper.getOtherExtNumByMidAndSysFlag(list.get(0).getId(), 3);
|
|
|
|
|
//判断是否为空
|
|
|
|
|
if (CollectionUtils.isEmpty(otherList)) {
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
ArchiveOtherExtDto archiveOtherExt = new ArchiveOtherExtDto();
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSSS");
|
|
|
|
|
Long id = Long.valueOf(sdf.format(System.currentTimeMillis()));
|
|
|
|
|
SimpleDateFormat SycTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
archiveOtherExt.setId(id);
|
|
|
|
|
archiveOtherExt.setSyctime(SycTime.format(date));
|
|
|
|
|
archiveOtherExt.setSysflag(3);
|
|
|
|
|
archiveOtherExt.setSysupdatetime(SycTime.format(date));
|
|
|
|
|
archiveOtherExt.setJzh(list.get(0).getPatientId());
|
|
|
|
|
archiveOtherExt.setZyh(list.get(0).getInpNo());
|
|
|
|
|
archiveOtherExt.setStatusflag(0);
|
|
|
|
|
archiveOtherExt.setMid(list.get(0).getId());
|
|
|
|
|
archiveOtherExtMapper.addSelective(archiveOtherExt);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (pushInfoVo.getDataType() == 2) {
|
|
|
|
|
int i = archiveMasterMapper.updateCmtNurseByInpNoAndVisitId(pushInfoVo.getInpNo(), pushInfoVo.getVisitId(), pushInfoVo.getSubmitTime(), pushInfoVo.getSubmitCode());
|
|
|
|
@ -92,6 +130,7 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
GenerateQueue(printParam, 5, nurseId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logger.info(list.get(0).getId() + "电子病历、护理、pacs已加到队列中");
|
|
|
|
|
return exist;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,12 +153,16 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean repairTask(String masterId) {
|
|
|
|
|
public Msg repairTask(String masterId) {
|
|
|
|
|
boolean exist = false;
|
|
|
|
|
//补偿所有采集器id集合
|
|
|
|
|
List<String> idList = Arrays.asList(collectIdList.split(","));
|
|
|
|
|
//获取患者基础信息
|
|
|
|
|
List<Archive_Master> list = archiveMasterMapper.getArchiveMasterByMasterId(masterId);
|
|
|
|
|
if(list.size()==0){
|
|
|
|
|
logger.info("没有当前病历:"+masterId);
|
|
|
|
|
return Msg.fail("没有当前病历");
|
|
|
|
|
}
|
|
|
|
|
PrintParam printParam = new PrintParam();
|
|
|
|
|
printParam.setMasterId(list.get(0).getId());
|
|
|
|
|
printParam.setInpNo(list.get(0).getInpNo());
|
|
|
|
@ -127,12 +170,133 @@ public class PushInfoServiceImpl implements PushInfoService {
|
|
|
|
|
printParam.setDeptName(list.get(0).getDeptName());
|
|
|
|
|
printParam.setDischargeDateTime(list.get(0).getDischargeDateTime());
|
|
|
|
|
printParam.setName(list.get(0).getName());
|
|
|
|
|
printParam.setAdmissionDateTime(list.get(0).getAdmissionDateTime());
|
|
|
|
|
//存放队列消息
|
|
|
|
|
for (String id : idList) {
|
|
|
|
|
GenerateQueue(printParam, 10, id);
|
|
|
|
|
exist = true;
|
|
|
|
|
}
|
|
|
|
|
return exist;
|
|
|
|
|
if (exist){
|
|
|
|
|
logger.info("补偿成功:"+masterId);
|
|
|
|
|
return Msg.pushSuccess("补偿成功:"+masterId);
|
|
|
|
|
}
|
|
|
|
|
logger.info("补偿失败:"+masterId);
|
|
|
|
|
return Msg.pushFail("补偿失败:"+masterId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Msg repairTaskByCollectId(String masterId, String collectId) {
|
|
|
|
|
//获取患者基础信息
|
|
|
|
|
List<Archive_Master> list = archiveMasterMapper.getArchiveMasterByMasterId(masterId);
|
|
|
|
|
if (list.size()==0){
|
|
|
|
|
logger.info("没有当前患者信息");
|
|
|
|
|
return Msg.pushFail("没有当前患者信息");
|
|
|
|
|
}
|
|
|
|
|
//如果是pacs任务需要查询是否有任务
|
|
|
|
|
if (collectId=="3"){
|
|
|
|
|
List<ArchiveOtherExtVo> otherList = archiveOtherExtMapper.getOtherExtNumByMidAndSysFlag(list.get(0).getId(), 3);
|
|
|
|
|
if (otherList.size()==0){
|
|
|
|
|
logger.info("pacs没有加到任务表中提交后在补偿");
|
|
|
|
|
return Msg.pushFail("pacs没有加到任务表中提交后在补偿");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
PrintParam printParam = new PrintParam();
|
|
|
|
|
printParam.setMasterId(list.get(0).getId());
|
|
|
|
|
printParam.setInpNo(list.get(0).getInpNo());
|
|
|
|
|
printParam.setVisitId(list.get(0).getVisitId());
|
|
|
|
|
printParam.setDeptName(list.get(0).getDeptName());
|
|
|
|
|
printParam.setDischargeDateTime(list.get(0).getDischargeDateTime());
|
|
|
|
|
printParam.setName(list.get(0).getName());
|
|
|
|
|
printParam.setAdmissionDateTime(list.get(0).getAdmissionDateTime());
|
|
|
|
|
//存放队列消息
|
|
|
|
|
if (StringUtils.isNotBlank(collectId)) {
|
|
|
|
|
GenerateQueue(printParam, 10, collectId);
|
|
|
|
|
return Msg.pushSuccess("补偿成功");
|
|
|
|
|
}
|
|
|
|
|
return Msg.pushFail("补偿失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean fileUpload(MultipartFile file, FileUpload dto) {
|
|
|
|
|
//使用yyyyMMddHHmmssSSS格式作为文件名
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
|
|
|
|
String newDate = format.format(date);
|
|
|
|
|
//文件更新时间
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
//文件保存目录
|
|
|
|
|
String filePathdir = pacsSavePath + "\\" + dto.getMasterid();
|
|
|
|
|
File filePath = new File(filePathdir);
|
|
|
|
|
//判断文件夹是否存在不存在创建文件夹
|
|
|
|
|
if (!filePath.exists()) {
|
|
|
|
|
filePath.mkdirs();
|
|
|
|
|
}
|
|
|
|
|
String saveFilePath = filePathdir + "/" + newDate + ".pdf";
|
|
|
|
|
//文件地址
|
|
|
|
|
String saveDetailPath = detailPath + File.separatorChar + dto.getMasterid() + File.separatorChar + newDate + ".pdf";
|
|
|
|
|
try {
|
|
|
|
|
file.transferTo(new File(saveFilePath));
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
logger.info("保存文件失败流水号:" + dto.getSerialNumber());
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
//判断文件表是否存在流水号存则更新
|
|
|
|
|
List<Archive_Detail> archiveDetailList = archiveDetailMapper.getArchiveDetailBySerialNumber(dto.getSerialNumber());
|
|
|
|
|
if (archiveDetailList.size() != 0) {
|
|
|
|
|
for (Archive_Detail archiveDetail : archiveDetailList) {
|
|
|
|
|
int i = archiveDetailMapper.deleteByPrimaryKey(archiveDetail.getId());
|
|
|
|
|
if (i == 1) {
|
|
|
|
|
File file1 = new File(archiveDetail.getPdfPath());
|
|
|
|
|
try {
|
|
|
|
|
file1.delete(); // 删除照片
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//保存文件表
|
|
|
|
|
Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
|
archiveDetail.setId(newDate);
|
|
|
|
|
archiveDetail.setPdfPath(saveDetailPath);
|
|
|
|
|
archiveDetail.setMasterid(dto.getMasterid());
|
|
|
|
|
archiveDetail.setUploaddatetime(dateFormat.format(new Date()));
|
|
|
|
|
archiveDetail.setAssortid(dto.getAssortid());
|
|
|
|
|
archiveDetail.setSource(dto.getSource());
|
|
|
|
|
archiveDetail.setSubassort(dto.getSubassort());
|
|
|
|
|
archiveDetail.setTitle(dto.getTitle());
|
|
|
|
|
archiveDetail.setSerialNumber(dto.getSerialNumber());
|
|
|
|
|
archiveDetail.setFlag("0");
|
|
|
|
|
if (archiveDetailMapper.insertSel(archiveDetail) == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//保存文件表
|
|
|
|
|
Archive_Detail archiveDetail = new Archive_Detail();
|
|
|
|
|
archiveDetail.setId(newDate);
|
|
|
|
|
archiveDetail.setPdfPath(saveDetailPath);
|
|
|
|
|
archiveDetail.setMasterid(dto.getMasterid());
|
|
|
|
|
archiveDetail.setUploaddatetime(dateFormat.format(new Date()));
|
|
|
|
|
archiveDetail.setAssortid(dto.getAssortid());
|
|
|
|
|
archiveDetail.setSource(dto.getSource());
|
|
|
|
|
archiveDetail.setSubassort(dto.getSubassort());
|
|
|
|
|
archiveDetail.setTitle(dto.getTitle());
|
|
|
|
|
archiveDetail.setSerialNumber(dto.getSerialNumber());
|
|
|
|
|
archiveDetail.setFlag("0");
|
|
|
|
|
if (archiveDetailMapper.insertSel(archiveDetail) == 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateArchiveOtherExt(updateTaskDto dto) {
|
|
|
|
|
if (archiveOtherExtMapper.updateByMid(dto)==1){
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|