|
|
|
@ -2,6 +2,7 @@ package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
@ -14,7 +15,14 @@ import com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.MrReportErrorMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
|
|
|
|
|
import com.docus.bgts.utils.*;
|
|
|
|
|
import com.docus.bgts.rpc.DownloadPlatformRpc;
|
|
|
|
|
import com.docus.bgts.rpc.dto.ReportDownDto;
|
|
|
|
|
import com.docus.bgts.rpc.dto.ReportDownPatientDto;
|
|
|
|
|
import com.docus.bgts.rpc.dto.ReportDownScanFileDto;
|
|
|
|
|
import com.docus.bgts.utils.FileUtils;
|
|
|
|
|
import com.docus.bgts.utils.HttpUtils;
|
|
|
|
|
import com.docus.bgts.utils.SnowflakeIdWorker;
|
|
|
|
|
import com.docus.bgts.utils.XmlUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
|
|
@ -22,12 +30,11 @@ import org.apache.cxf.transport.http.HTTPConduit;
|
|
|
|
|
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
import org.dom4j.*;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
|
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.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
@ -71,6 +78,9 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ThreadPoolExecutor threadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private DownloadPlatformRpc downloadPlatformRpc;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collect(String empId) throws Exception {
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
@ -101,7 +111,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
String admiss = sim.format(ad);
|
|
|
|
|
String dis = sim.format(di);
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
|
List<String[]> exams = getExamNo(empId, admiss, dis);
|
|
|
|
|
List<String[]> exams = getExamNoByInpNo(empId, admiss, dis);
|
|
|
|
|
String jzh = afCollectTaskService.getJzhByInpatientNo(empId,times);
|
|
|
|
|
if (null == jzh) {
|
|
|
|
|
logger.info("通过住院号与住院次数未匹配到患者");
|
|
|
|
@ -115,6 +125,68 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectSealPacs(String sealId) throws Exception{
|
|
|
|
|
TSeal seal = getSealAndCheckBySealId(sealId);
|
|
|
|
|
if (Objects.isNull(seal.getAdmissDate())) {
|
|
|
|
|
throw new RuntimeException("sealId:" + sealId + " 封存病案信息 入院日期 为空!");
|
|
|
|
|
}
|
|
|
|
|
String jzh = seal.getJzh();
|
|
|
|
|
if (StrUtil.isBlank(jzh)) {
|
|
|
|
|
throw new RuntimeException("sealId:" + sealId + " 封存病案信息 记账号 为空!");
|
|
|
|
|
}
|
|
|
|
|
String inpatientNo = seal.getInpatientNo();
|
|
|
|
|
if (StrUtil.isBlank(inpatientNo)) {
|
|
|
|
|
throw new RuntimeException("sealId:" + sealId + " 封存病案信息 病案号 为空!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Date admissDate = seal.getAdmissDate();
|
|
|
|
|
// 如果是在院的,默认出院时间为现在
|
|
|
|
|
Date disDate = new Date();
|
|
|
|
|
|
|
|
|
|
// 获取如果有出院的基础信息,得到真实的出院时间
|
|
|
|
|
TBasic basicCondition = new TBasic();
|
|
|
|
|
basicCondition.setJzh(jzh);
|
|
|
|
|
List<TBasic> basicInfo = afCollectTaskService.getBasicInfo(basicCondition);
|
|
|
|
|
if (CollUtil.isNotEmpty(basicInfo)) {
|
|
|
|
|
TBasic basic = basicInfo.get(0);
|
|
|
|
|
if (ObjectUtil.isNotNull(basic.getDisDate())) {
|
|
|
|
|
disDate = basic.getDisDate();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String pattern = "yyyy-MM-dd";
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
|
|
|
|
List<String[]> exams = getExamNoByInpNo(inpatientNo, sdf.format(admissDate), sdf.format(disDate));
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = sealGetUrlCreateReportDto(exams, seal.getPatientId());
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
//通过报告单号集合采集
|
|
|
|
|
downloadPlatformRpc.sealReport(reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据封存id获取封存病案信息并且校验
|
|
|
|
|
*
|
|
|
|
|
* @param sealId 封存id
|
|
|
|
|
* @return com.docus.bgts.entity.TSeal
|
|
|
|
|
* @date 2024/1/11 10:47
|
|
|
|
|
* @author YongBin Wen
|
|
|
|
|
*/
|
|
|
|
|
private TSeal getSealAndCheckBySealId(String sealId) {
|
|
|
|
|
TSeal condition = new TSeal();
|
|
|
|
|
condition.setSealId(sealId);
|
|
|
|
|
TSeal seal = afCollectTaskService.findSealByCondition(condition);
|
|
|
|
|
if (Objects.isNull(seal)) {
|
|
|
|
|
throw new RuntimeException("sealId:" + sealId + " 未找到封存病案信息!");
|
|
|
|
|
}
|
|
|
|
|
return seal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectEcg(String empId, String admissDate, String disDate, String times) throws Exception {
|
|
|
|
|
Map<String, String> smCollectionTime = getSmCollectionTimeEcg(admissDate, disDate);
|
|
|
|
@ -493,6 +565,49 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 封存病案,获取图片url,并返回插入表对象
|
|
|
|
|
*
|
|
|
|
|
* @param exams
|
|
|
|
|
* @param patientId 封存病案主键
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private ReportDownDto sealGetUrlCreateReportDto(List<String[]> exams, String patientId) throws Exception {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
reportDownPatientDto.setPatientid(patientId);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto;
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
for (String[] exam : exams) {
|
|
|
|
|
try {
|
|
|
|
|
reportDownScanFileDto = getScanByExam(exam);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
//过滤pacs中病理报告
|
|
|
|
|
if (collectorid.equals("3")) {
|
|
|
|
|
if (!reportDownScanFileDto.getDownurl().contains("病理")
|
|
|
|
|
&& !reportDownScanFileDto.getDownurl().contains("胃肠镜")
|
|
|
|
|
&& !reportDownScanFileDto.getDownurl().contains("心电")) {
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
logger.error(exam[0]+"调用明细错误信息-----"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
return reportDownDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取图片url,病返回插入表对象
|
|
|
|
|
*
|
|
|
|
@ -737,17 +852,17 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过empId获取报告单号集合 pacs
|
|
|
|
|
* 通过住院号获取报告单号集合 pacs
|
|
|
|
|
*
|
|
|
|
|
* @param empId
|
|
|
|
|
* @param inpatientNo 住院号
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNo(String empId, String admissDate, String disDate) throws Exception {
|
|
|
|
|
private List<String[]> getExamNoByInpNo(String inpatientNo, String admissDate, String disDate) throws Exception {
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
// Map<String, String> Time = getSmCollectionTime(admissDate, disDate);
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
|
|
reqElement.element("INHOSP_INDEX_NO").setText(empId);
|
|
|
|
|
reqElement.element("INHOSP_INDEX_NO").setText(inpatientNo);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(String.valueOf(admissDate));
|
|
|
|
|
reqElement.element("END_DATE").setText(String.valueOf(disDate));
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|