feat: 肇庆检查检验补偿
parent
166a62ed1f
commit
939f393168
@ -0,0 +1,7 @@
|
||||
{
|
||||
"delayDays": 1,
|
||||
"jobIntervalSeconds": 43200,
|
||||
"lab":"labcode",
|
||||
"pacs":"pacscode",
|
||||
"open": 0
|
||||
}
|
||||
@ -0,0 +1,176 @@
|
||||
package com.docus.server.jobadmin.thread;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.docus.core.util.Func;
|
||||
import com.docus.infrastructure.core.utils.TableJsonRead;
|
||||
import com.docus.infrastructure.redis.service.IdService;
|
||||
import com.docus.infrastructure.web.api.CommonResult;
|
||||
import com.docus.infrastructure.web.api.ResultCode;
|
||||
import com.docus.server.archivemysql.entity.TBasic;
|
||||
import com.docus.server.archivemysql.entity.TaskMakeupOnView;
|
||||
import com.docus.server.archivemysql.mapper.TBasicMapper;
|
||||
import com.docus.server.jobadmin.config.JobAdminConfig;
|
||||
import com.docus.server.rpc.V3ViewTaskCollectService;
|
||||
import com.docus.server.rpc.dto.CompensateTaskDTO;
|
||||
import com.docus.server.zqdyrmyy.entity.ZqDyRmYyOutpatientLisReportView;
|
||||
import com.docus.server.zqdyrmyy.mapper.ZqDyRmYyOutpatientLisReportViewMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 佛山三院医院编目采集任务job
|
||||
*
|
||||
* @author YongBin Wen
|
||||
* @date 2024/1/23 10:59
|
||||
*/
|
||||
|
||||
public class ZqDyRmYyLabPacsCollectTaskHelper {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZqDyRmYyLabPacsCollectTaskHelper.class);
|
||||
private static final ZqDyRmYyLabPacsCollectTaskHelper instance = new ZqDyRmYyLabPacsCollectTaskHelper();
|
||||
|
||||
public static ZqDyRmYyLabPacsCollectTaskHelper getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Thread zqDyRmYyLabPacsCollectTaskThread;
|
||||
private volatile boolean toStop = false;
|
||||
|
||||
public void start() {
|
||||
zqDyRmYyLabPacsCollectTaskThread = new Thread(() -> {
|
||||
TableJsonRead tableJsonRead = new TableJsonRead();
|
||||
ZqDyRmYyOutpatientLisReportViewMapper zqDyRmYyOutpatientLisReportViewMapper = JobAdminConfig.getJobAdminConfig().getZqDyRmYyOutpatientLisReportViewMapper();
|
||||
TBasicMapper tBasicMapper = JobAdminConfig.getJobAdminConfig().gettBasicMapper();
|
||||
IdService idService = JobAdminConfig.getJobAdminConfig().getIdService();
|
||||
V3ViewTaskCollectService v3ViewTaskCollectService = JobAdminConfig.getJobAdminConfig().getV3ViewTaskCollectService();
|
||||
String configPath = "data-config\\jobconfig";
|
||||
String configFileName = "ZqDyRmYyLabPacsCollectTask";
|
||||
while (!toStop) {
|
||||
try {
|
||||
// 读取配置,实时观察配置文件状况
|
||||
JSONObject jobConfig = tableJsonRead.Read(configPath, configFileName, JSONObject.class);
|
||||
int jobIntervalSeconds = jobConfig.getIntValue("jobIntervalSeconds");
|
||||
int delayDays = jobConfig.getIntValue("delayDays");
|
||||
String labSysCode = jobConfig.getString("lab");
|
||||
String pacsSysCode = jobConfig.getString("pacs");
|
||||
int open = jobConfig.getIntValue("open");
|
||||
if (open == 0) {
|
||||
TimeUnit.SECONDS.sleep(60);
|
||||
continue;
|
||||
}
|
||||
LocalDate startDate = LocalDate.now().plusDays(-delayDays);
|
||||
String startDateTime = startDate + " 00:00:00";
|
||||
|
||||
List<ZqDyRmYyOutpatientLisReportView> lisReportViews = zqDyRmYyOutpatientLisReportViewMapper.findOutpatientLisReportByReportDate(startDateTime);
|
||||
|
||||
if (Func.isNotEmpty(lisReportViews)) {
|
||||
Map<String, List<ZqDyRmYyOutpatientLisReportView>> groupPatientReport = new HashMap<>();
|
||||
for (ZqDyRmYyOutpatientLisReportView lisReportView : lisReportViews) {
|
||||
String key = lisReportView.getInpatientNo() + "_" + lisReportView.getAdmissTimes() + "_" + lisReportView.getType();
|
||||
groupPatientReport.computeIfAbsent(key, k -> new ArrayList<>()).add(lisReportView);
|
||||
}
|
||||
|
||||
Set<Map.Entry<String, List<ZqDyRmYyOutpatientLisReportView>>> entries = groupPatientReport.entrySet();
|
||||
for (Map.Entry<String, List<ZqDyRmYyOutpatientLisReportView>> entry : entries) {
|
||||
List<ZqDyRmYyOutpatientLisReportView> views = entry.getValue();
|
||||
ZqDyRmYyOutpatientLisReportView maxReportDateView = views.stream()
|
||||
.max(Comparator.comparing(ZqDyRmYyOutpatientLisReportView::getReportDate))
|
||||
.orElse(null);
|
||||
if (maxReportDateView == null) {
|
||||
continue;
|
||||
}
|
||||
List<TBasic> tBasicList = tBasicMapper.findTbasicByInpatientNo(maxReportDateView.getInpatientNo());
|
||||
if (Func.isEmpty(tBasicList)) {
|
||||
continue;
|
||||
}
|
||||
TBasic basic = tBasicList.stream()
|
||||
.filter(tBasic -> maxReportDateView.getInpatientNo().equalsIgnoreCase(tBasic.getInpatientNo())
|
||||
&& maxReportDateView.getAdmissTimes().equals(tBasic.getAdmissTimes()))
|
||||
.findFirst().orElse(null);
|
||||
if (basic == null) {
|
||||
continue;
|
||||
}
|
||||
String patientId = basic.getPatientId();
|
||||
String collectSys = "检验".equals(maxReportDateView.getType()) ? labSysCode : pacsSysCode;
|
||||
|
||||
TaskMakeupOnView taskMakeup = tBasicMapper.findTaskMakeup(maxReportDateView.getInpatientNo(), maxReportDateView.getAdmissTimes(), collectSys);
|
||||
boolean isUpdate = taskMakeup != null;
|
||||
if (isUpdate) {
|
||||
if (!maxReportDateView.getReportDate().after(taskMakeup.getReportLastModify())) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
taskMakeup = new TaskMakeupOnView();
|
||||
taskMakeup.setId(idService.getDateSeq());
|
||||
taskMakeup.setInpatientNo(maxReportDateView.getInpatientNo());
|
||||
taskMakeup.setAdmissTimes(maxReportDateView.getAdmissTimes());
|
||||
taskMakeup.setName(maxReportDateView.getName());
|
||||
taskMakeup.setCollectSysType(collectSys);
|
||||
|
||||
}
|
||||
taskMakeup.setPatientId(patientId);
|
||||
taskMakeup.setReportLastModify(maxReportDateView.getReportDate());
|
||||
|
||||
List<String> patientIds = Collections.singletonList(patientId);
|
||||
CompensateTaskDTO compensateTaskDTO = new CompensateTaskDTO();
|
||||
compensateTaskDTO.setPatientIds(patientIds);
|
||||
compensateTaskDTO.setCollectorIds(Collections.singletonList(collectSys));
|
||||
compensateTaskDTO.setPriority(3);
|
||||
logger.info("肇庆检查、检验补偿生成队列参数:{}", Func.toJson(compensateTaskDTO));
|
||||
CommonResult<String> result = v3ViewTaskCollectService.compensateTask(compensateTaskDTO);
|
||||
logger.info("肇庆检查、检验补偿生成队列返回结果:{}", Func.toJson(result));
|
||||
if (result != null && result.getCode().equals(ResultCode.SUCCESS.getCode())) {
|
||||
if (isUpdate) {
|
||||
tBasicMapper.update(taskMakeup);
|
||||
} else {
|
||||
tBasicMapper.insert(taskMakeup);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TimeUnit.SECONDS.sleep(jobIntervalSeconds);
|
||||
} catch (Exception ex) {
|
||||
if (!toStop) {
|
||||
logger.error(">>>>>>>>>>> zqDyRmYy LabPacs CollectTask Thread error:" + ex.getMessage(), ex);
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(60);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
logger.info(">>>>>>>>>>> zqDyRmYy LabPacs CollectTask Thread stop");
|
||||
});
|
||||
zqDyRmYyLabPacsCollectTaskThread.setDaemon(true);
|
||||
zqDyRmYyLabPacsCollectTaskThread.setName("zqDyRmYyLabPacsCollectTaskHelper");
|
||||
zqDyRmYyLabPacsCollectTaskThread.start();
|
||||
}
|
||||
|
||||
public void toStop() {
|
||||
toStop = false;
|
||||
zqDyRmYyLabPacsCollectTaskThread.interrupt();
|
||||
try {
|
||||
zqDyRmYyLabPacsCollectTaskThread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
TableJsonRead tableJsonRead = new TableJsonRead();
|
||||
JSONObject config = tableJsonRead.Read("data-config\\jobconfig", "ZqDyRmYyLabPacsCollectTask", JSONObject.class);
|
||||
System.out.println(config);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.docus.server.zqdyrmyy.entity;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author YongBin Wen
|
||||
* @date 2025/8/5 0005 9:48
|
||||
*/
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 湛江附属医院 首页编目数据
|
||||
*
|
||||
* @author YongBin Wen
|
||||
* @date 2024/8/13 16:07
|
||||
*/
|
||||
@ApiModel("肇庆第一人民医院出院患者检查、检验报告更新 数据视图")
|
||||
@Data
|
||||
public class ZqDyRmYyOutpatientLisReportView {
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 住院号
|
||||
*/
|
||||
private String inpatientNo;
|
||||
/**
|
||||
* 住院次数
|
||||
*/
|
||||
private Integer admissTimes;
|
||||
/**
|
||||
* 出院日期
|
||||
*/
|
||||
private Date disDate;
|
||||
/**
|
||||
* 报告最后更新时间
|
||||
*/
|
||||
private Date reportDate;
|
||||
/**
|
||||
* 报告类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package com.docus.server.zqdyrmyy.mapper;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.docus.server.zqdyrmyy.entity.ZqDyRmYyOutpatientLisReportView;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author YongBin Wen
|
||||
* @date 2025/8/5 0005 9:57
|
||||
*/
|
||||
@DS("zqdyrmyy-mdip")
|
||||
public interface ZqDyRmYyOutpatientLisReportViewMapper {
|
||||
|
||||
|
||||
List<ZqDyRmYyOutpatientLisReportView> findOutpatientLisReportByReportDate(@Param("startDateTime") String startDateTime);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.docus.server.zqdyrmyy.mapper.ZqDyRmYyOutpatientLisReportViewMapper">
|
||||
|
||||
|
||||
<select id="findOutpatientLisReportByReportDate"
|
||||
resultType="com.docus.server.zqdyrmyy.entity.ZqDyRmYyOutpatientLisReportView">
|
||||
SELECT PATIENT_NAME AS name,INP_NUM AS inpatientNo, VISIT_NO AS admissTimes,OUT_TIME AS disDate,REPORT_DATE_TIME AS reportDate,CHECK_TYPE AS type
|
||||
FROM MDIP.V_JSWZH_OUTPATIENT_LISREPORT
|
||||
WHERE REPORT_DATE_TIME >= to_date(#{startDateTime}, 'yyyy-MM-dd hh24:mi:ss')
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,18 @@
|
||||
------------------------- 2025年8月5日10:15:52 -----------------------
|
||||
CREATE TABLE docus_archivefile.task_makeup_onview (
|
||||
id BIGINT(19) NOT NULL COMMENT '表主键id',
|
||||
inpatient_no varchar(50) NOT NULL COMMENT '住院号',
|
||||
admiss_times int(11) NULL COMMENT '住院次数',
|
||||
patient_id varchar(50) NULL COMMENT '患者病案主键',
|
||||
dis_date DATETIME NULL COMMENT '出院时间',
|
||||
collect_sys_type varchar(30) NOT NULL COMMENT '采集器类型',
|
||||
name varchar(100) NOT NULL COMMENT '姓名',
|
||||
report_last_modify DATETIME NOT NULL COMMENT '报告最后更新时间',
|
||||
CONSTRAINT task_makeup_onview_pk PRIMARY KEY (id)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
DEFAULT CHARSET=utf8mb4
|
||||
COLLATE=utf8mb4_general_ci
|
||||
COMMENT='根据第三方视图补偿采集任务';
|
||||
CREATE INDEX IDX_task_makeup_onview_patient USING BTREE ON docus_archivefile.task_makeup_onview (inpatient_no,admiss_times,patient_id,dis_date,name);
|
||||
------------------------- 2025年8月5日10:15:52 -----------------------
|
||||
Loading…
Reference in New Issue