From 6f65d02714dd45ad0b8c6cbc900f692c0be3efa4 Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Wed, 4 Sep 2024 17:30:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8B=B1=E5=BE=B7=E4=B8=AD=E5=8C=BB?= =?UTF-8?q?=E9=99=A2=EF=BC=8Cpacs=E8=A7=86=E5=9B=BE=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data-config/ydzyy-pacs-collect-job | 1 + .../server/archive/entity/AfCollectTask.java | 160 ++++++++++ .../docus/server/archive/entity/TBasic.java | 298 ++++++++++++++++++ .../server/archive/mapper/TBasicMapper.java | 19 ++ .../ydzyy/dto/YdZyyPacsViewCondition.java | 40 +++ .../server/ydzyy/entity/YdZyyPacsView.java | 70 ++++ .../server/ydzyy/job/PacsCollectJob.java | 264 ++++++++++++++++ .../ydzyy/mapper/YdZyyPacsViewMapper.java | 25 ++ src/main/resources/bootstrap.yml | 22 ++ src/main/resources/mapper/TBasicMapper.xml | 42 ++- .../resources/mapper/YdZyyPacsViewMapper.xml | 45 +++ 11 files changed, 985 insertions(+), 1 deletion(-) create mode 100644 data-config/ydzyy-pacs-collect-job create mode 100644 src/main/java/com/docus/server/archive/entity/AfCollectTask.java create mode 100644 src/main/java/com/docus/server/archive/entity/TBasic.java create mode 100644 src/main/java/com/docus/server/ydzyy/dto/YdZyyPacsViewCondition.java create mode 100644 src/main/java/com/docus/server/ydzyy/entity/YdZyyPacsView.java create mode 100644 src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java create mode 100644 src/main/java/com/docus/server/ydzyy/mapper/YdZyyPacsViewMapper.java create mode 100644 src/main/resources/mapper/YdZyyPacsViewMapper.xml diff --git a/data-config/ydzyy-pacs-collect-job b/data-config/ydzyy-pacs-collect-job new file mode 100644 index 0000000..8fedff7 --- /dev/null +++ b/data-config/ydzyy-pacs-collect-job @@ -0,0 +1 @@ +{"startTime":"","deviationSeconds":1800} \ No newline at end of file diff --git a/src/main/java/com/docus/server/archive/entity/AfCollectTask.java b/src/main/java/com/docus/server/archive/entity/AfCollectTask.java new file mode 100644 index 0000000..1511e31 --- /dev/null +++ b/src/main/java/com/docus/server/archive/entity/AfCollectTask.java @@ -0,0 +1,160 @@ +package com.docus.server.archive.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 病案采集任务 + *

+ * + * @author jersey + * @since 2023-11-28 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="AfCollectTask对象", description="病案采集任务") +public class AfCollectTask implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "id 雪花算法") + private Long id; + + @ApiModelProperty(value = "病案主键") + private String patientId; + + @ApiModelProperty(value = "af_archive_detail表id") + private Long afArchiveDetailId; + + @ApiModelProperty(value = "来源 1护理文书,2 (HIS)电子病历,3 Pacs检查,4心电系统,5手麻系统,6 Lis检验,7临床首页,8长期医嘱, 9临时医嘱,10 省病案统计系统首页,11 扫描首页;") + private String sysflag; + + @ApiModelProperty(value = "开始时间") + private Date startTime; + + @ApiModelProperty(value = "结束时间") + private Date endTime; + + @ApiModelProperty(value = "任务耗时") + private Long consumingTime; + + @ApiModelProperty(value = "任务状态 0:未开始,1:正在采集,2:采集错误,3采集完成,4:作废") + private String state; + + @ApiModelProperty(value = "同步时间") + private Date syncTime; + + @ApiModelProperty(value = "最新重新采集时间") + private Date recollectTime; + + @ApiModelProperty(value = "最新重新采集人") + private String recollectName; + + @ApiModelProperty(value = "备注") + private String remark; + + @TableField("pResult") + private String presult; + + @ApiModelProperty(value = "报告唯一单号") + @TableField("C1") + private String c1; + + @ApiModelProperty(value = "文件名称") + @TableField("C2") + private String c2; + + @ApiModelProperty(value = "记账号") + @TableField("C3") + private String c3; + + @TableField("C4") + private String c4; + + @TableField("C5") + private String c5; + + @TableField("C6") + private String c6; + + @TableField("C7") + private String c7; + + @TableField("C8") + private String c8; + + @TableField("C9") + private String c9; + + @ApiModelProperty(value = "采集器完成任务时的采集器key") + @TableField("C10") + private String c10; + + @TableField("N1") + private Double n1; + + @TableField("N2") + private Double n2; + + @TableField("N3") + private Double n3; + + + private Double n4; + + private Double n5; + + + private Date t1; + + + private Date t2; + + + private Date t3; + + + private Date t4; + + + private Date t5; + + private Date t6; + + private String c11; + + + private String c12; + + private String c13; + + + private String c14; + + + private String c15; + + + private String c16; + + private String c17; + + private String c18; + + + private String c19; + + + private String c20; + + private Date createTime; + + +} diff --git a/src/main/java/com/docus/server/archive/entity/TBasic.java b/src/main/java/com/docus/server/archive/entity/TBasic.java new file mode 100644 index 0000000..6611dc4 --- /dev/null +++ b/src/main/java/com/docus/server/archive/entity/TBasic.java @@ -0,0 +1,298 @@ +package com.docus.server.archive.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; +import java.util.Date; + +/** + *

+ * 病案基本信息 + *

+ * + * @author jersey + * @since 2023-11-28 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="TBasic对象", description="病案基本信息") +public class TBasic implements Serializable { + + private static final long serialVersionUID = 1L; + + + private String patientId; + + @ApiModelProperty(value = "住院次数") + private Integer admissTimes; + + @ApiModelProperty(value = "病案号") + private String inpatientNo; + + @ApiModelProperty(value = "住院ID号") + private String admissId; + + @ApiModelProperty(value = "患者姓名") + private String name; + + @ApiModelProperty(value = "盘号") + private String ph; + + @ApiModelProperty(value = "患者姓名首拼") + private String nameSpell; + + @ApiModelProperty(value = "性别") + private String sex; + + @ApiModelProperty(value = "年龄_岁") + private Integer age; + + @ApiModelProperty(value = "年龄_月") + private Integer ageMonth; + + @ApiModelProperty(value = "年龄_天") + private Integer ageDay; + + @ApiModelProperty(value = "身份证") + private String idCard; + + @ApiModelProperty(value = "手机号码") + private String telphone; + + @ApiModelProperty(value = "住院日期") + private Date admissDate; + + @ApiModelProperty(value = "住院科室") + private String admissDept; + + @ApiModelProperty(value = "住院科室名称") + private String admissDeptName; + + @ApiModelProperty(value = "出院日期") + private Date disDate; + + @ApiModelProperty(value = "出院科室") + private String disDept; + + @ApiModelProperty(value = "出院科室名称") + private String disDeptName; + + @ApiModelProperty(value = "实际住院天数") + private Integer admissDays; + + @ApiModelProperty(value = "主管医生") + private String attending; + + @ApiModelProperty(value = "主管医生名称") + private String attendingName; + + @ApiModelProperty(value = "主要诊断编码") + private String mainDiagCode; + + @ApiModelProperty(value = "主要诊断名称") + private String mainDiagName; + + @ApiModelProperty(value = "主要手术编码") + private String mainOperateCode; + + @ApiModelProperty(value = "主要手术名称") + private String mainOperateName; + + @ApiModelProperty(value = "是否死亡") + private Integer isDead; + + @ApiModelProperty(value = "是否作废(0:否,1:是)") + private Integer isCancel; + + @ApiModelProperty(value = "签收时间") + private Date signTime; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "修改时间") + private Date updateTime; + + @ApiModelProperty(value = "是否归档 1:已归档,0:未归档") + private Integer isArchive; + + @ApiModelProperty(value = "归档时间") + private Date archiveTime; + + @ApiModelProperty(value = " 1 归档采集(pdf),2 异地扫描(图片),3 现场扫描(pdf),4 其他来源") + private Integer fileSource; + + @ApiModelProperty(value = "完整性描述") + private String integrityDesc; + + @ApiModelProperty(value = "扫描生产软件-视频脑电图号") + private String bColumn1; + + @ApiModelProperty(value = "扫描生产软件-ep号") + private String bColumn2; + + @ApiModelProperty(value = "茂名流水号") + private String bColumn3; + + @ApiModelProperty(value = "扫描生产软件-门诊号") + private String bColumn4; + + @ApiModelProperty(value = "顺德人医新jzh查询") + private String bColumn5; + + private Integer bColumn6; + + private Integer bColumn7; + + private Integer bColumn8; + + private Integer bColumn9; + + private Integer bColumn10; + + @ApiModelProperty(value = "性别名称") + private String sexName; + + @ApiModelProperty(value = "记账号(省中医住院就诊号)") + private String jzh; + + @ApiModelProperty(value = "省中医患者主索引号") + private String empId; + + @ApiModelProperty(value = "就诊类别代码") + private String visitTypeCode; + + @ApiModelProperty(value = "就诊类别名称") + private String visitTypeName; + + @ApiModelProperty(value = "中医诊断代码") + private String tcmDiagCode; + + @ApiModelProperty(value = "中医诊断名称") + private String tcmDiagName; + + @ApiModelProperty(value = "所在院区") + private String wardPalce; + + @ApiModelProperty(value = "床号位") + private String bedNum; + + @ApiModelProperty(value = "责任护士") + private String dutyNurse; + + @ApiModelProperty(value = "是否手术") + private String isOper; + + @ApiModelProperty(value = "现住址") + private String homeAddr; + + @ApiModelProperty(value = "损伤中毒") + private String poisoningName; + + @ApiModelProperty(value = "病理诊断") + private String pathologyName; + + @ApiModelProperty(value = "其他诊断") + private String otherDiagName; + + @ApiModelProperty(value = "联系方式") + private String homeTel; + + @ApiModelProperty(value = "接收时间,目前澄海人医 使用") + private Date receiveTime; + + @ApiModelProperty(value = "状态 1:封存,3:锁定") + private Integer state; + + @ApiModelProperty(value = "是否扫描 2否 1是") + private String scanSource; + + @ApiModelProperty(value = "暂缓审核配置id ,隔开") + private String cqcDeferAuditConfigId; + + @ApiModelProperty(value = "病案是否批注 0:没有批注 1:有批注") + private Integer commentStatus; + + @ApiModelProperty(value = "医生提交状态(0:未提交,1:已提交)") + private Integer doctorState; + + @ApiModelProperty(value = "护士提交状态") + private Integer nurseState; + + @ApiModelProperty(value = "纸质签收 0:未签收 1:已签收") + private Integer cqcSigninfo; + + @ApiModelProperty(value = "审核状态 0:否 1:是") + private Integer tagState; + + @ApiModelProperty(value = "是否转科 0否;1是") + private Integer convertDept; + + @ApiModelProperty(value = "上架号") + private String groundingNo; + + @ApiModelProperty(value = "外部id,通过导入等需要留存原来数据的主键") + private String externalId; + + @ApiModelProperty(value = "扫描上传状态,0:未扫描、1:待质检、2:已退回、3:系统通过、4:人工通过,5:已返工") + private Integer scanUploadState; + + @ApiModelProperty(value = "是否退回过,0:否,1:是") + private Integer isBackScan; + + @ApiModelProperty(value = "扫描上传时间") + private Date scanUploadTime; + + @ApiModelProperty(value = "返工上传时间") + private Date reUploadTime; + + @ApiModelProperty(value = "当前操作节点 多个以,分隔") + private String currentNodes; + + @ApiModelProperty(value = "档案文件存储类型,1:pdf(默认)2:图片") + private Integer archiveFileStorageType; + + @ApiModelProperty(value = "护理采集状态 0否,1是") + private Integer nursCollect; + + @ApiModelProperty(value = "重症采集状态 0否,1是") + private Integer icuCollect; + + @ApiModelProperty(value = "是否重症病人 0否,1是") + private Integer isIcu; + + @ApiModelProperty(value = "电子病历提交状态 0否,1是") + private Integer emrSubmit; + + @ApiModelProperty(value = "是否标记编码 0否,1是") + private Integer isCoder; + + @ApiModelProperty(value = "病区编号") + private String wardCode; + + @ApiModelProperty(value = "病区名称") + private String wardName; + + @ApiModelProperty(value = "是否其他数据 0否,1是婴儿,2医疗保险类别是家庭病床") + private Integer isOther; + + @ApiModelProperty(value = "是否退回 0否 1是") + private Integer isBack; + + @ApiModelProperty(value = "是否签出 0否 1是") + private Integer signOut; + + @ApiModelProperty(value = "是否返修 0否 1是") + private Integer backRepair; + + @ApiModelProperty(value = "婴儿母亲住院流水号") + private String motherInpatientNo; + + @ApiModelProperty(value = "是否打印 0否 1是") + private Integer isPrint; + + +} diff --git a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java index 0b50efc..410c40f 100644 --- a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java @@ -1,12 +1,31 @@ package com.docus.server.archive.mapper; +import com.docus.server.archive.entity.AfCollectTask; +import com.docus.server.archive.entity.TBasic; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + @Mapper public interface TBasicMapper { int invalidFileBySource(@Param("patientId") String patientId,@Param("collectorId") String collectorId); + + List getTbasicByReportTimeAndInpNoOrIdCard(@Param("sendDateStr") String sendDateStr,@Param("idCard") String idCard,@Param("inpatientNo") String inpatientNo); + + + int deleteTaskByPatAndSource(@Param("patientId")String patientId, @Param("collectorId")String collectorId); + + int flushPatTaskEndTime(@Param("patientId")String patientId,@Param("dateTime")String dateTime); + + List getCollectTaskByPatAndSource(@Param("patientId")String patientId, @Param("collectorId") String collectorId); + + int delTaskById(@Param("id") Long id); + + int insertCollectTask(@Param("task") AfCollectTask task); + + int updateTaskById(@Param("task") AfCollectTask task); } diff --git a/src/main/java/com/docus/server/ydzyy/dto/YdZyyPacsViewCondition.java b/src/main/java/com/docus/server/ydzyy/dto/YdZyyPacsViewCondition.java new file mode 100644 index 0000000..8c287b7 --- /dev/null +++ b/src/main/java/com/docus/server/ydzyy/dto/YdZyyPacsViewCondition.java @@ -0,0 +1,40 @@ +package com.docus.server.ydzyy.dto; + +import lombok.Data; + +/** + * pacs视图查询条件 + * + * @author YongBin Wen + * @date 2024/9/4 12:08 + */ +@Data +public class YdZyyPacsViewCondition { + /** + * 最后修改时间开始,格式 yyyy-MM-dd HH:mm:ss + */ + private String changeTimeStart; + /** + * 最后修改时间结束,格式 yyyy-MM-dd HH:mm:ss + */ + private String changeTimeEnd; + + /** + * 出入院时间匹配字段,时间开始 + */ + private String sendDateStart; + + /** + * 出入院时间匹配字段,时间结束 + */ + private String sendDateEnd; + + /** + * 住院号 + */ + private String inpNo; + /** + * 身份证号码 + */ + private String idCard; +} diff --git a/src/main/java/com/docus/server/ydzyy/entity/YdZyyPacsView.java b/src/main/java/com/docus/server/ydzyy/entity/YdZyyPacsView.java new file mode 100644 index 0000000..e1d9e54 --- /dev/null +++ b/src/main/java/com/docus/server/ydzyy/entity/YdZyyPacsView.java @@ -0,0 +1,70 @@ +package com.docus.server.ydzyy.entity; + +import lombok.Data; + +import java.util.Date; + +/** + * @date 2024/9/4 11:30 + */ +@Data +public class YdZyyPacsView { + + /** + * 主键key(唯一码) 主键 + */ + private String REMARK; + + + /** + * 申请号(与电子病历系统对应) + */ + private String REGISTER_NUM; + + /** + * 住院号 + */ + private String NP_NO; + /** + * 检查号 + */ + private String ACCNO; + /** + * 报告日期 + */ + private String CREATETIMESTR; + /** + * 报告医生 + */ + private String REPORTDOC; + /** + * 报告名称 + */ + private String REPORTNAME; + /** + * 患者姓名 + */ + private String NAME; + /** + * 审核日期 + */ + private Date ADUITTIME; + /** + * 文件网络路径 + */ + private String FILEPATH; + /** + * 报告最后修改时间(如果有最好) + */ + private Date STATUSCHGTIME; + /** + * 报告时间,出入院时间内 + */ + private Date SENDDATE; + /** + * 身份证号 + */ + private String IDCARD; + + private Long taskId; +} diff --git a/src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java b/src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java new file mode 100644 index 0000000..aaae2e4 --- /dev/null +++ b/src/main/java/com/docus/server/ydzyy/job/PacsCollectJob.java @@ -0,0 +1,264 @@ +package com.docus.server.ydzyy.job; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.docus.core.util.Func; +import com.docus.infrastructure.redis.service.IdService; +import com.docus.server.archive.entity.AfCollectTask; +import com.docus.server.archive.entity.TBasic; +import com.docus.server.archive.mapper.TBasicMapper; +import com.docus.server.rpc.DownPlatformService; +import com.docus.server.rpc.dto.ReportDownDto; +import com.docus.server.rpc.dto.ReportDownPatientDto; +import com.docus.server.rpc.dto.ReportDownScanFileDto; +import com.docus.server.util.TableJsonRead; +import com.docus.server.ydzyy.dto.YdZyyPacsViewCondition; +import com.docus.server.ydzyy.entity.YdZyyPacsView; +import com.docus.server.ydzyy.mapper.YdZyyPacsViewMapper; +import com.xxl.job.core.handler.annotation.XxlJob; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.time.LocalDateTime; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * pacs系统采集任务 + * + * @author YongBin Wen + * @date 2024/9/4 11:27 + */ +@Component +@Slf4j +public class PacsCollectJob { + @Resource + private TBasicMapper tBasicMapper; + + @Resource + private YdZyyPacsViewMapper ydZyyPacsViewMapper; + + @Resource + private DownPlatformService downPlatformService; + + @Resource + private IdService idService; + + + @XxlJob("Ydzyy-CollectPacsByModifyTime") + public void collectPacsByModifyTime() { + LocalDateTime jobRunTime = LocalDateTime.now(); + // 查询视图 ,根据视图信息查询患者,再根据患者同步 所有的任务、文件 + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,开始任务!"); + try { + String configPath="data-config"; + String configName="ydzyy-pacs-collect-job"; + TableJsonRead tableJsonRead = new TableJsonRead(); + JSONObject jobConfig = tableJsonRead.Read(configPath, configName, JSONObject.class); + String startTime = jobConfig.getString("startTime"); + int deviationSeconds = jobConfig.getIntValue("deviationSeconds"); + if (Func.isBlank(startTime)) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,配置开始时间为空!"); + return; + } + YdZyyPacsViewCondition pacsViewCondition = new YdZyyPacsViewCondition(); + pacsViewCondition.setChangeTimeStart(startTime); + String conditionJsonStr = JSON.toJSONString(pacsViewCondition); + List ydZyyPacsViews = ydZyyPacsViewMapper.pacsViews(pacsViewCondition); + if (Func.isEmpty(ydZyyPacsViews)) { + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,参数:{} ,未查询到数据,结束任务!", conditionJsonStr); + } + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,参数:{} ,查询到数据 {} 条", conditionJsonStr, ydZyyPacsViews.size()); + List tBasicList = new ArrayList<>(); + Set patientIdSet = new HashSet<>(); + for (YdZyyPacsView ydZyyPacsView : ydZyyPacsViews) { + String idCard = ydZyyPacsView.getIDCARD(); + String inpatientNo = ydZyyPacsView.getNP_NO(); + if (Func.isBlank(idCard) && Func.isBlank(inpatientNo)) { + continue; + } + Date sendDate = ydZyyPacsView.getSENDDATE(); + if (Func.isEmpty(sendDate)) { + continue; + } + String sendDateStr = Func.formatDateTime(sendDate); + + List tBasicListByPacsCondition = tBasicMapper.getTbasicByReportTimeAndInpNoOrIdCard(sendDateStr, Func.isBlank(idCard) ? inpatientNo : idCard, Func.isBlank(inpatientNo) ? idCard : inpatientNo); + if (Func.isEmpty(tBasicListByPacsCondition)) { + log.warn(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,pacs视图数据,未匹配到患者基础数据,请检查!数据:{}", JSON.toJSONString(ydZyyPacsView)); + continue; + } + if (tBasicListByPacsCondition.size() > 1) { + log.warn(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,pacs视图数据,匹配到多个患者基础数据,请检查!数据:{}", JSON.toJSONString(ydZyyPacsView)); + return; + } + TBasic basic = tBasicListByPacsCondition.get(0); + String patientId = basic.getPatientId(); + if (patientIdSet.contains(patientId)) { + continue; + } + patientIdSet.add(patientId); + tBasicList.add(basic); + } + for (TBasic basic : tBasicList) { + collectPacs(basic); + } + LocalDateTime nextStartTime = jobRunTime.plusSeconds(-deviationSeconds); + jobConfig.put("startTime", Func.formatDateTime(nextStartTime)); + tableJsonRead.Save(configPath,configName,jobConfig.toJSONString()); + } catch (Exception ex) { + log.error(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集jobc出现异常,结束任务!" + ex.getMessage(), ex); + } + + log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>英德中医院pacs视图采集job,结束任务!"); + } + + public static void main(String[] args) { + System.out.println(Func.formatDateTime(new Date()).substring(0, 10)); + } + + private void collectPacs(TBasic basic) { + String collectorId = "3"; + String assortId = "AC2C8F4A88884DC894630302C61C6A07"; + String patientId = basic.getPatientId(); + String inpatientNo = basic.getInpatientNo(); + String idCard = basic.getIdCard(); + Date admissDate = basic.getAdmissDate(); + Date disDate = basic.getDisDate(); + String admissDateStr = Func.formatDateTime(admissDate).substring(0, 10); + String disDateStr = disDate == null ? null : Func.formatDateTime(disDate); + + + YdZyyPacsViewCondition pacsViewCondition = new YdZyyPacsViewCondition(); + pacsViewCondition.setInpNo(inpatientNo); + pacsViewCondition.setSendDateStart(admissDateStr); + pacsViewCondition.setSendDateEnd(disDateStr); + // 住院pacs + List zyPacsViews = ydZyyPacsViewMapper.pacsViews(pacsViewCondition); + + pacsViewCondition.setInpNo(null); + pacsViewCondition.setIdCard(idCard); + // 所有的pacs + List allPacsViews = ydZyyPacsViewMapper.pacsViews(pacsViewCondition); + allPacsViews.addAll(zyPacsViews); + + if (Func.isEmpty(allPacsViews)) { + tBasicMapper.invalidFileBySource(patientId, collectorId); + tBasicMapper.deleteTaskByPatAndSource(patientId, collectorId); + // 刷新结束时间只是因为要校验完整性 + tBasicMapper.flushPatTaskEndTime(patientId, Func.formatDateTime(new Date())); + return; + } + + + List finalPacsViews = new ArrayList<>(); + Set reamarks = new HashSet<>(); + for (YdZyyPacsView pacsView : allPacsViews) { + if (reamarks.contains(pacsView.getREMARK())) { + continue; + } + reamarks.add(pacsView.getREMARK()); + finalPacsViews.add(pacsView); + } + // 排序 + finalPacsViews = finalPacsViews.stream() + .sorted(Comparator.comparing(YdZyyPacsView::getCREATETIMESTR)) + .collect(Collectors.toList()); + Map pacsViewMap = finalPacsViews.stream().collect(Collectors.toMap(YdZyyPacsView::getREMARK, Function.identity())); + + List collectTaskList = tBasicMapper.getCollectTaskByPatAndSource(patientId, collectorId); + List delTaskList = collectTaskList.stream() + .filter(task -> !reamarks.contains(task.getC1())) + .collect(Collectors.toList()); + List updateTaskList = collectTaskList.stream() + .filter(task -> reamarks.contains(task.getC1())) + .collect(Collectors.toList()); + List taskC1s = collectTaskList.stream().map(AfCollectTask::getC1).collect(Collectors.toList()); + + List addTaskList = new ArrayList<>(); + for (YdZyyPacsView pacsView : finalPacsViews) { + if (taskC1s.contains(pacsView.getREMARK())) { + continue; + } + AfCollectTask task = new AfCollectTask(); + task.setId(idService.getDateSeq()); + task.setAfArchiveDetailId(0L); + task.setPatientId(patientId); + task.setSysflag(collectorId); + task.setSyncTime(new Date()); + task.setCreateTime(new Date()); + task.setState("0"); + task.setC1(pacsView.getREMARK()); + task.setC2(pacsView.getREGISTER_NUM()); + task.setC3(pacsView.getNP_NO()); + task.setC4(pacsView.getACCNO()); + task.setC5(basic.getJzh()); + task.setC6(pacsView.getREPORTNAME()); + task.setC7(pacsView.getNAME()); + task.setT1(Func.parseDate(pacsView.getCREATETIMESTR(),"yyyy-MM-dd")); + task.setT2(pacsView.getADUITTIME()); + task.setT3(pacsView.getSTATUSCHGTIME()); + addTaskList.add(task); + pacsView.setTaskId(task.getId()); + } + + + if (Func.isNotEmpty(delTaskList)) { + for (AfCollectTask task : delTaskList) { + tBasicMapper.delTaskById(task.getId()); + } + } + + if (Func.isNotEmpty(updateTaskList)) { + for (AfCollectTask task : updateTaskList) { + YdZyyPacsView pacsView = pacsViewMap.get(task.getC1()); + pacsView.setTaskId(task.getId()); + task.setSyncTime(new Date()); + task.setC2(pacsView.getREGISTER_NUM()); + task.setC3(pacsView.getNP_NO()); + task.setC4(pacsView.getACCNO()); + task.setC5(basic.getJzh()); + task.setC6(pacsView.getREPORTNAME()); + task.setC7(pacsView.getNAME()); + task.setT1(Func.parseDate(pacsView.getCREATETIMESTR(),"yyyy-MM-dd")); + task.setT2(pacsView.getADUITTIME()); + task.setT3(pacsView.getSTATUSCHGTIME()); + tBasicMapper.updateTaskById(task); + } + } + + if (Func.isNotEmpty(addTaskList)) { + for (AfCollectTask task : addTaskList) { + tBasicMapper.insertCollectTask(task); + } + } + + tBasicMapper.invalidFileBySource(patientId, collectorId); + + ReportDownPatientDto patient = new ReportDownPatientDto(); + patient.setPatientid(patientId); + + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setAssortid(assortId); + reportDownDto.setCollectorid(collectorId); + reportDownDto.setIp("java-collect-pacs"); + reportDownDto.setPatient(patient); + for (YdZyyPacsView pacsView : finalPacsViews) { + ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setDownurl(pacsView.getFILEPATH()); + reportDownScanFileDto.setFiletitle(pacsView.getREPORTNAME()); + reportDownScanFileDto.setSerialnum(pacsView.getREMARK()); + reportDownScanFileDto.setFilesource(1); + reportDownScanFileDto.setFiletype(4); + reportDownScanFileDto.setFilestoragetype(1); + reportDownScanFileDto.setTaskid(pacsView.getTaskId()); + List scanFiles = Collections.singletonList(reportDownScanFileDto); + reportDownDto.setScanfiles(scanFiles); + downPlatformService.report(reportDownDto); + } + } + + +} diff --git a/src/main/java/com/docus/server/ydzyy/mapper/YdZyyPacsViewMapper.java b/src/main/java/com/docus/server/ydzyy/mapper/YdZyyPacsViewMapper.java new file mode 100644 index 0000000..9ff32d1 --- /dev/null +++ b/src/main/java/com/docus/server/ydzyy/mapper/YdZyyPacsViewMapper.java @@ -0,0 +1,25 @@ +package com.docus.server.ydzyy.mapper; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.docus.server.ydzyy.dto.YdZyyPacsViewCondition; +import com.docus.server.ydzyy.entity.YdZyyPacsView; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author YongBin Wen + * @date 2024/9/4 11:30 + */ +@DS("ydzyy-pacs") +@Mapper +public interface YdZyyPacsViewMapper { + /** + * 根据pacs视图查询条件进行视图数据查询,timeStart <= STATUSCHGTIME < timeEnd + * + + * @return pacs 视图数据 + */ + List pacsViews(@Param("condition")YdZyyPacsViewCondition condition); +} diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index acad337..845c6f9 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -55,6 +55,28 @@ spring: test-on-borrow: false test-on-return: false validation-query: select 1 + ydzyy-pacs: + url: jdbc:sqlserver://10.10.100.105;DatabaseName=pacsdb + username: wzhpacs + password: huaeasepacs + driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver + type: com.alibaba.druid.pool.DruidDataSource + # 初始化配置 + initial-size: 3 + # 最小连接数 + min-idle: 3 + # 最大连接数 + max-active: 10 + # 获取连接超 时时间 + max-wait: 5000 + # 连接有效性检测时间 + time-between-eviction-runs-millis: 90000 + # 最大空闲时间 + min-evictable-idle-time-millis: 1800000 + test-while-idle: true + test-on-borrow: false + test-on-return: false + validation-query: select 1 redis: host: redis.docus.cn password: JSdocus@702 diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 5ae4ce4..0d77f65 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -3,10 +3,50 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + + INSERT INTO docus_archivefile.af_collect_task (id, patient_id, af_archive_detail_id, sysflag, state, + sync_time, C1, C2, C3, C4, C5, C6, C7, T1, T2, T3, create_time) + VALUES(#{task.id},#{task.patientId},#{task.afArchiveDetailId},#{task.sysflag},#{task.state}, + #{task.syncTime},#{task.c1},#{task.c2},#{task.c3},#{task.c4}, + #{task.c5},#{task.c6},#{task.c7},#{task.t1},#{task.t2},#{task.t3},#{task.createTime}) + + + update docus_archivefile.af_collect_task set sync_time=#{task.syncTime}, C2=#{task.c2}, C3=#{task.c3}, C4=#{task.c4}, C5=#{task.c5}, + C6=#{task.c6}, C7=#{task.c7},T1=#{task.t1}, T2=#{task.t2}, T3=#{task.t3} + where id=#{task.id} + update docus_archivefile.t_scan_assort set is_del=1 where patient_id =#{patientId} and source= #{collectorId} + + update docus_archivefile.af_collect_task set end_time=#{dateTime} where patient_id=#{patientId} + + + + delete from docus_archivefile.af_collect_task where patient_id=#{patientId} and sysflag=#{collectorId} + + + delete from docus_archivefile.af_collect_task where id=#{id} + + + diff --git a/src/main/resources/mapper/YdZyyPacsViewMapper.xml b/src/main/resources/mapper/YdZyyPacsViewMapper.xml new file mode 100644 index 0000000..5f6afa5 --- /dev/null +++ b/src/main/resources/mapper/YdZyyPacsViewMapper.xml @@ -0,0 +1,45 @@ + + + + + + +