feat: 添加封存病案根据封存id进行Lis报告采集。

collector-LIS
wyb 2 years ago
parent 64144d74da
commit ea490e6c52

@ -3,6 +3,7 @@ package com.docus.server.collect.collector;
import com.docus.core.util.Func;
import com.docus.server.collect.entity.Jzh;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import com.docus.server.collect.enums.DownWayEnum;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
@ -17,7 +18,9 @@ import org.w3c.dom.NodeList;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
*
@ -75,9 +78,43 @@ public class LisSystemCollector {
}
}
/**
* Lis
*
* @param tSeal
* @param tBasic
* @date 2024/1/10 17:04
* @author YongBin Wen
*/
public void sealCollect(TSeal tSeal, TBasic tBasic) {
Date admissDate = tSeal.getAdmissDate();
String disDateStr = Objects.isNull(tBasic)?null:tBasic.getDisDate();
String jzh = tSeal.getJzh();
if(Objects.isNull(admissDate)){
log.error("封存病案采集失败patientId:{} 患者住院时间为空!", tSeal.getPatientId());
return;
}
// 报告的开始和结束时间就是入院时间 和 出院时间+15天(没有就取现在时间)
String beginDateTime = Func.formatDateTime(admissDate);
String endDateTime = Func.formatDateTime(new Date());
if(Func.isNotBlank(tBasic.getDisDate())){
LocalDateTime endLocalDateTime = Func.parseDateTime(disDateStr).plusDays(15L);
endDateTime = Func.formatDateTime(endLocalDateTime);
}
// 普通的检验报告和 微生物检验报告
String collectDataNormal = collectData(new Jzh(jzh), beginDateTime, endDateTime, 0);
String collectDataMtf = collectData(new Jzh(jzh), beginDateTime, endDateTime, 1);
List<ReportFileInfoDTO> reportFileInfoDTOList = LisSystemCollectConverter.convert(collectDataNormal);
List<ReportFileInfoDTO> reportFileInfoDtoList2 = LisSystemCollectConverter.convert(collectDataMtf);
reportFileInfoDTOList.addAll(reportFileInfoDtoList2);
for (ReportFileInfoDTO reportFileInfoDTO : reportFileInfoDTOList) {
reportFileInfoDTO.setPatientId(tSeal.getPatientId());
reportFileInfoDTO.setAssortId(assortId);
reportFileInfoDTO.setSysFlag(sysFlag);
fileReportService.saveDownloadTaskAndSealReport(reportFileInfoDTO);
}
}
private boolean isBelongToPatient(ReportFileInfoDTO reportFileInfoDTO, TBasic basic) {

@ -7,6 +7,7 @@ import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.collect.collector.LisSystemCollector;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import com.docus.server.collect.feign.api.GdSzyCollectServiceApi;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import lombok.extern.slf4j.Slf4j;
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.Objects;
/**
* @author WYBDEV
@ -62,11 +64,11 @@ public class CollectController implements GdSzyCollectServiceApi {
if (count <= 0) {
return CommonResult.success("本次采集0个患者");
}
final int size=200;
final int size = 200;
int page = PageUtil.totalPage(count, size);
for (int i = 1; i <= page; i++) {
List<TBasic> tBasics = downloadTaskDao.pageBasicInfo(qrDto, (i - 1) * size, size);
if(Func.isNotEmpty(tBasics)){
if (Func.isNotEmpty(tBasics)) {
for (TBasic basic : tBasics) {
if (Func.isBlank(basic.getAdmissDate()) || Func.isBlank(basic.getDisDate())) {
log.error("采集失败jzh:{} 患者住院或者出院时间为空!", basic.getJzh());
@ -79,6 +81,29 @@ public class CollectController implements GdSzyCollectServiceApi {
return CommonResult.success("本次采集" + count + "个患者");
}
@Override
public CommonResult<String> lisSystemCollectBySealId(String sealId) {
log.info("根据 封存id 进行封存病案lis采集,sealId为{}", sealId);
TSeal sealCondition = new TSeal();
sealCondition.setSealId(sealId);
TSeal tSeal = downloadTaskDao.findSealByCondition(sealCondition);
if (Objects.isNull(tSeal)) {
log.error("采集失败封存id{} 没有找到封存病案信息!", sealId);
return CommonResult.failed("封存id" + sealId + " 没有找到封存病案信息!");
}
String jzh = tSeal.getJzh();
if (Func.isBlank(jzh)) {
log.error("采集失败封存id{} 没有找到封存病案记帐号信息!", sealId);
return CommonResult.failed("封存id" + sealId + " 没有找到封存病案记帐号信息!");
}
TBasic basic = new TBasic();
basic.setJzh(jzh);
List<TBasic> basicInfo = downloadTaskDao.getBasicInfo(basic);
TBasic tBasic = Func.isEmpty(basicInfo) ? null : basicInfo.get(0);
lisSystemCollector.sealCollect(tSeal, tBasic);
return CommonResult.success("采集完成!");
}
private void validateDateStr(String dateStr) {
try {
Func.parseDate(dateStr);

@ -0,0 +1,66 @@
package com.docus.server.collect.entity;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author jiashi
* @since 2023-05-16
*/
@Data
@ApiModel(value="TSeal对象", description="在院封存")
public class TSeal implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "在院封存病案主键")
private String patientId;
@ApiModelProperty(value = "封存id")
private String sealId;
@ApiModelProperty(value = "住院号")
private String inpatientNo;
@ApiModelProperty(value = "住院就诊号")
private String jzh;
@ApiModelProperty(value = "患者姓名")
private String name;
@ApiModelProperty(value = "住院时间")
private Date admissDate;
@ApiModelProperty(value = "封存时间")
private Date sealDate;
@ApiModelProperty(value = "文件来源")
private Integer fileSource;
@ApiModelProperty(value = "就诊次数")
private Integer admissTimes;
@ApiModelProperty(value = "纸质是否签名 0否 1是")
private Integer signinfo;
@ApiModelProperty(value = "备注")
private String remark;
public TSeal() {
}
public TSeal(ReportFileInfoDTO dto) {
this.patientId=dto.getPatientId();
this.jzh = dto.getJzh();
this.inpatientNo = dto.getInpatientNo();
this.admissTimes = dto.getAdmisstimes();
}
}

@ -28,6 +28,13 @@ public interface GdSzyCollectServiceApi {
CommonResult<String> lisSystemCollectByJzh(@RequestParam("empId") String empId);
@ApiOperation("LIS 检验报告采集,根据封存id进行封存病案的采集")
@ApiImplicitParams({
@ApiImplicitParam(name ="sealId",value = "封存id",required = true,paramType = "query",dataTypeClass = String.class)
})
@GetMapping(PREFIX + "/lisBySealId")
CommonResult<String> lisSystemCollectBySealId(@RequestParam("sealId") String sealId);
@ApiOperation("LIS 检验报告采集,根据出院区间")
@ApiImplicitParams({
@ApiImplicitParam(name ="disDateStart",value = "出院时间 开始区间 yyyy-MM-dd",required = true,paramType = "query",dataTypeClass = String.class),

@ -18,4 +18,8 @@ public interface DownloadPlatformService {
@ApiOperation("病案上报文件(通用)")
@RequestMapping(value = "/api/downplatform/report",method = RequestMethod.POST)
public CommonResult report(@RequestBody ReportDownDto resources);
@ApiOperation("封存病历上报文件(省中医使用)")
@RequestMapping(value = "/api/downplatform/sealReport",method = RequestMethod.POST)
public CommonResult sealReport(@RequestBody ReportDownDto resources);
}

@ -4,6 +4,7 @@ import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -66,4 +67,13 @@ public interface DownloadTaskDao extends IBaseDao<DownloadTask> {
* @return idid
*/
Long getDownloadTaskIdFromDownFile(String patientId, String source, String serialNum);
/**
*
* @date 2024/1/10 16:52
* @author YongBin Wen
* @param seal
* @return com.docus.server.collect.entity.TSeal
*/
TSeal findSealByCondition(TSeal seal);
}

@ -6,6 +6,7 @@ import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import com.docus.server.collect.infrastructure.mapper.DownloadTaskMapper;
import org.springframework.stereotype.Repository;
@ -60,4 +61,9 @@ public class DownloadTaskDaoImpl extends BaseDaoImpl<DownloadTaskMapper, Downloa
public Long getDownloadTaskIdFromDownFile(String patientId, String source, String serialNum) {
return baseMapper.getDownloadTaskIdFromDownFile(patientId, source, serialNum);
}
@Override
public TSeal findSealByCondition(TSeal seal) {
return baseMapper.findSealByCondition(seal);
}
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.collect.dto.TBasicQrDto;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -21,6 +22,7 @@ public interface DownloadTaskMapper extends BaseMapper<DownloadTask> {
/**
*
*
* @param qrDto
* @return
*/
@ -28,27 +30,41 @@ public interface DownloadTaskMapper extends BaseMapper<DownloadTask> {
/**
*
* @param qrDto
*
* @param qrDto
* @param offset
* @param size
* @param size
* @return
*/
List<TBasic> pageBasicInfo(@Param("dto") TBasicQrDto qrDto,@Param("offset") long offset,@Param("size") long size);
List<TBasic> pageBasicInfo(@Param("dto") TBasicQrDto qrDto, @Param("offset") long offset, @Param("size") long size);
/**
* idid
*
* @param patientId
* @param source
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromSanAssort(@Param("patientId") String patientId, @Param("source") String source, @Param("serialNum") String serialNum);
/**
* idid
*
* @param patientId
* @param source
* @param source
* @param serialNum
* @return idid
*/
Long getDownloadTaskIdFromDownFile(@Param("patientId") String patientId, @Param("source") String source, @Param("serialNum") String serialNum);
/**
*
*
* @param seal
* @return com.docus.server.collect.entity.TSeal
* @date 2024/1/10 16:52
* @author YongBin Wen
*/
TSeal findSealByCondition(@Param("seal") TSeal seal);
}

@ -15,6 +15,13 @@ public interface FileReportService {
*/
void saveDownloadTaskAndReport(ReportFileInfoDTO fileInfoDTO);
/**
*
* | t_seal
* @param fileInfoDTO
*/
void saveDownloadTaskAndSealReport(ReportFileInfoDTO fileInfoDTO);
/**
* idid
* patientIdpatientId
@ -22,4 +29,5 @@ public interface FileReportService {
* @return id
*/
Long getDownloadTaskId(DownloadTask downloadTask);
}

@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.docus.core.util.Func;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.collect.converter.FileReportConverter;
import com.docus.server.collect.entity.DownloadTask;
import com.docus.server.collect.entity.TBasic;
import com.docus.server.collect.entity.TSeal;
import com.docus.server.collect.infrastructure.client.DownloadPlatformService;
import com.docus.server.collect.infrastructure.client.dto.ReportDownDto;
import com.docus.server.collect.infrastructure.dao.DownloadTaskDao;
import com.docus.server.collect.service.FileReportService;
import com.docus.server.collect.service.dto.ReportFileInfoDTO;
@ -62,19 +65,39 @@ public class FileReportServiceImpl implements FileReportService {
report(downloadTask);
}
@Override
public void saveDownloadTaskAndSealReport(ReportFileInfoDTO fileInfoDTO) {
// TODO 封存病案
TSeal sealCondition = new TSeal(fileInfoDTO);
// 查询基础数据,更新新的病案信息
TSeal seal = downloadTaskDao.findSealByCondition(sealCondition);
// 如果找到患者基础数据并且刚好为1条
fileInfoDTO.setPatientId(seal.getPatientId());
fileInfoDTO.setInpatientNo(seal.getInpatientNo());
fileInfoDTO.setAdmisstimes(seal.getAdmissTimes());
fileInfoDTO.setJzh(seal.getJzh());
// 转换下载任务对象
DownloadTask downloadTask = fileReportConverter.convertDownloadTask(fileInfoDTO, 2);
// 查询旧的下载任务id,更新/保存任务信息
Long downloadTaskId = Optional.ofNullable(getDownloadTaskId(downloadTask)).orElse(idService.getDateSeq());
downloadTask.setId(downloadTaskId);
downloadTaskDao.saveOrUpdate(downloadTask);
reportSeal(downloadTask);
}
@Override
public Long getDownloadTaskId(DownloadTask downloadTask) {
String patientId = downloadTask.getPatientId();
if(StrUtil.isNotBlank(patientId)){
if (StrUtil.isNotBlank(patientId)) {
String serialNum = downloadTask.getFileSerialNum();
String source = downloadTask.getSource();
// 从文件表获取
Long downloadTaskId = downloadTaskDao.getDownloadTaskIdFromSanAssort(patientId,source,serialNum);
Long downloadTaskId = downloadTaskDao.getDownloadTaskIdFromSanAssort(patientId, source, serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
// 从下载记录表获取
downloadTaskId = downloadTaskDao.getDownloadTaskIdFromDownFile(patientId,source,serialNum);
downloadTaskId = downloadTaskDao.getDownloadTaskIdFromDownFile(patientId, source, serialNum);
if (Func.isNotEmpty(downloadTaskId)) {
return downloadTaskId;
}
@ -91,7 +114,36 @@ public class FileReportServiceImpl implements FileReportService {
private void report(DownloadTask downloadTask) {
threadPoolExecutor.execute(() -> {
if (downloadTask.getBasicDataType().equals(0)) {
downloadPlatformService.report(fileReportConverter.convertDownloadPlatformParam(downloadTask));
ReportDownDto reportDownDto = fileReportConverter.convertDownloadPlatformParam(downloadTask);
String paramJson = Func.toJson(reportDownDto);
try {
log.info("基础病案上报文件,参数:{}", paramJson);
CommonResult result = downloadPlatformService.report(reportDownDto);
log.info("基础病案上报文件,返回结果:{}", Func.toJson(result));
} catch (Exception ex) {
log.error("基础病案上报文件发生未知错误,参数:" + paramJson, ex);
}
}
});
}
/**
*
*
* @param downloadTask
*/
private void reportSeal(DownloadTask downloadTask) {
threadPoolExecutor.execute(() -> {
if (downloadTask.getBasicDataType().equals(2)) {
ReportDownDto reportDownDto = fileReportConverter.convertDownloadPlatformParam(downloadTask);
String paramJson = Func.toJson(reportDownDto);
try {
log.info("封存病案上报文件,参数:{}", paramJson);
CommonResult result = downloadPlatformService.sealReport(reportDownDto);
log.info("封存病案上报文件,返回结果:{}", Func.toJson(result));
} catch (Exception ex) {
log.error("封存病案上报文件发生未知错误,参数:" + paramJson, ex);
}
}
});
}

@ -117,4 +117,18 @@
order by `create_time` desc limit 1
</select>
<select id="findSealByCondition" resultType="com.docus.server.collect.entity.TSeal">
SELECT *
FROM
`docus_medicalrecord`.`t_seal`
where
1=1
<if test="seal.sealId != null and seal.sealId != ''">
AND seal_id=#{seal.sealId}
</if>
<if test="seal.patientId != null and seal.patientId != ''">
AND patient_id=#{seal.patientId}
</if>
</select>
</mapper>

Loading…
Cancel
Save