feat:英德中医添加电子病历作废ws接收逻辑

master
wyb 1 year ago
parent 968fcd32ce
commit c2085bfdcc

@ -18,7 +18,7 @@ import javax.xml.ws.Endpoint;
@Configuration
public class CxfConfig {
@Autowired
@Qualifier("SzyReportManagerService")
@Qualifier("YdZyyReportManagerService")
private ReportManagerService reportManagerService;
/**

@ -0,0 +1,20 @@
package com.docus.server.reportmanager.dto;
import lombok.Data;
/**
* @author YongBin Wen
* @date 2024/3/19 14:00
*/
@Data
public class BasicQrDto {
private String inpatientNo;
private Integer admissTimes;
private String admissDateBegin;
private String admissDateEnd;
private String disDateBegin;
private String disDateEnd;
private String name;
private String idCard;
private String jzh;
}

@ -8,6 +8,10 @@ import java.util.Date;
public class AfCollectTask {
private Long id;
private String patientId;
/**
*id
*
*/
private Long afArchiveDetailId;
private String sysflag;
private Date startTime;
@ -25,7 +29,15 @@ public class AfCollectTask {
private String C4;
private String C5;
private String C6;
/**
*
* id
*/
private String C7;
/**
*
*
*/
private String C8;
private String C9;
private String C10;

@ -0,0 +1,19 @@
package com.docus.server.reportmanager.entity;
import lombok.Data;
import java.util.Date;
/**
* @author YongBin Wen
* @date 2024/3/20 9:38
*/
@Data
public class AfReportDeleteLog {
private Long id;
private String patientId;
private String deleteContent;
private String type;
private Date createTime;
private Date updateTime;
}

@ -31,4 +31,8 @@ public interface CollectTaskMapper {
* @author YongBin Wen
*/
int cancel(@Param("ids") List<Long> ids);
String getCollectionState();
void updateTaskForRecollect(@Param("taskIds") List<Long> taskIds, @Param("operator") String operator,@Param("state") String state);
}

@ -1,6 +1,7 @@
package com.docus.server.reportmanager.mapper;
import com.docus.server.reportmanager.entity.AfReportDeleteLog;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -31,4 +32,10 @@ public interface ScanAssortMapper {
* @author YongBin Wen
*/
List<Long> getIdByPatientTask(@Param("patientId") String patientId, @Param("taskId") Long taskId);
int updateDleteLog(@Param("delLog") AfReportDeleteLog deleteLog);
int insertDeleteLog(@Param("delLog") AfReportDeleteLog reportDeleteLog);
int cancelBySerialNum(@Param("serials") List<String> serialNum,@Param("patientId")String patientId,@Param("source")String source);
}

@ -0,0 +1,16 @@
package com.docus.server.reportmanager.mapper;
import com.docus.server.reportmanager.dto.BasicQrDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author YongBin Wen
* @date 2024/3/19 13:57
*/
@Mapper
public interface TbasicMapper {
List<String> getPatientIds(@Param("qrDto") BasicQrDto basicQrDto,@Param("offset") int offset,@Param("size") int size);
}

@ -0,0 +1,434 @@
package com.docus.server.reportmanager.service.impl;
import cn.hutool.core.util.StrUtil;
import com.docus.core.util.Func;
import com.docus.infrastructure.core.exception.BaseException;
import com.docus.infrastructure.core.utils.SpringUtil;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.server.reportmanager.dto.BasicQrDto;
import com.docus.server.reportmanager.entity.AfCollectTask;
import com.docus.server.reportmanager.entity.AfReportDeleteLog;
import com.docus.server.reportmanager.mapper.CollectTaskMapper;
import com.docus.server.reportmanager.mapper.ScanAssortMapper;
import com.docus.server.reportmanager.mapper.TbasicMapper;
import com.docus.server.reportmanager.service.ReportManagerService;
import com.docus.server.reportmanager.util.XmlUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.w3c.dom.Node;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
*
*
* @author YongBin Wen
* @date 2024/1/3 16:11
*/
@Service("YdZyyReportManagerService")
@Slf4j
public class YingDeZyyReportManagerServiceImpl implements ReportManagerService {
private final static String operator = "yingde-ws-delete";
@Resource
private CollectTaskMapper collectTaskMapper;
@Resource
private ScanAssortMapper scanAssortMapper;
@Resource
private IdService idService;
@Resource
private TbasicMapper tbasicMapper;
@Override
public String DeleteReport(String message) {
log.info("英德中医报告管理,收到作废报告的信息:{}", message);
try {
AfReportDeleteLog deleteLog = insertDeleteLog(message);
String inpatientNo = null;
Integer admissTimes = null;
String admissDateBegin = null;
String admissDateEnd = null;
String disDateBegin = null;
String disDateEnd = null;
String name = null;
String idCard = null;
String jzh = null;
XmlUtil xmlUtil = XmlUtil.of(message);
Node inpatientNoNode = xmlUtil.getNode("/Request/Msg/INPATIENT_NO");
if (Func.isNotEmpty(inpatientNoNode)) {
inpatientNo = inpatientNoNode.getTextContent();
}
Node admissionsNode = xmlUtil.getNode("/Request/Msg/ADMISSIONS");
if (Func.isNotEmpty(admissionsNode)) {
String admissions = admissionsNode.getTextContent();
if (Func.isNotBlank(admissions)) {
admissTimes = Integer.parseInt(admissions);
}
}
Node admissionDateNode = xmlUtil.getNode("/Request/Msg/ADMISSION_DATE");
if (Func.isNotEmpty(admissionDateNode)) {
String admissDate = admissionDateNode.getTextContent();
if (Func.isNotBlank(admissDate)) {
Date parseAdmissDate = Func.parseDate(admissDate, "yyyy-MM-dd HH:mm:ss");
String formatAdmissDate = Func.formatDate(parseAdmissDate);
admissDateBegin = formatAdmissDate + " 00:00:00";
admissDateEnd = formatAdmissDate + " 23:59:59";
}
}
Node disDateNode = xmlUtil.getNode("/Request/Msg/DIS_DATE");
if (Func.isNotEmpty(disDateNode)) {
String disDate = disDateNode.getTextContent();
if (Func.isNotBlank(disDate)) {
Date parseDisDate = Func.parseDate(disDate, "yyyy-MM-dd HH:mm:ss");
String formatDisDate = Func.formatDate(parseDisDate);
disDateBegin = formatDisDate + " 00:00:00";
disDateEnd = formatDisDate + " 23:59:59";
}
}
Node nameNode = xmlUtil.getNode("/Request/Msg/NAME");
if (Func.isNotEmpty(nameNode)) {
name = nameNode.getTextContent();
}
Node idCardNode = xmlUtil.getNode("/Request/Msg/ID_CARD");
if (Func.isNotEmpty(idCardNode)) {
idCard = idCardNode.getTextContent();
}
Node jzhNode = xmlUtil.getNode("/Request/Msg/JZH");
if (Func.isNotEmpty(jzhNode)) {
jzh = jzhNode.getTextContent();
}
BasicQrDto basicQrDto = new BasicQrDto();
basicQrDto.setInpatientNo(inpatientNo);
basicQrDto.setAdmissTimes(admissTimes);
basicQrDto.setAdmissDateBegin(admissDateBegin);
basicQrDto.setAdmissDateEnd(admissDateEnd);
basicQrDto.setDisDateBegin(disDateBegin);
basicQrDto.setDisDateEnd(disDateEnd);
basicQrDto.setName(name);
basicQrDto.setIdCard(idCard);
basicQrDto.setJzh(jzh);
String patientId = getPatientId(basicQrDto);
deleteLog.setPatientId(patientId);
scanAssortMapper.updateDleteLog(deleteLog);
cancelReport(patientId, xmlUtil);
return success();
} catch (BaseException baseException) {
log.error(baseException.getMessage(), baseException);
return error(baseException.getMessage());
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return error("系统内部错误,请联系开发人员");
}
}
private void cancelReport(String patientId, XmlUtil xmlUtil) {
String reportNo = null;
String bcjlType = null;
String reportName = null;
String reportSource = null;
Node reportNoNode = xmlUtil.getNode("/Request/Msg/REPORT_NO");
if (Func.isNotEmpty(reportNoNode)) {
reportNo = reportNoNode.getTextContent();
}
// 当报告是病程记录或者术后病程记录时,此字段为必传 1、病程记录2、术后病程记录
Node bcjlTypeNode = xmlUtil.getNode("/Request/Msg/BCJL_TYPE");
if (Func.isNotEmpty(bcjlTypeNode)) {
bcjlType = bcjlTypeNode.getTextContent();
}
Node reportNameNode = xmlUtil.getNode("/Request/Msg/CATALOG_NAME");
if (Func.isNotEmpty(reportNameNode)) {
reportName = reportNameNode.getTextContent();
}
// 报告来源类型,为空默认电子病历
Node reportSourceNode = xmlUtil.getNode("/Request/Msg/REPORT_SOURCE");
if (Func.isNotEmpty(reportSourceNode)) {
reportSource = reportSourceNode.getTextContent();
}
if (Objects.isNull(reportNo) || Func.isBlank(reportNo)) {
throw new BaseException("病历报告号不能为空!");
}
if (Objects.isNull(reportName) || Func.isBlank(reportName)) {
throw new BaseException("病历报告名称不能为空!");
}
// 电子病历
if (Func.isBlank(reportSource) || isEmrSource(reportSource)) {
// 病程记录和术后病程记录
final String bcjl = "1";
final String shubcjl = "2";
// 病程记录
if (bcjl.equals(bcjlType)) {
cancelBcjlEMRReport(patientId);
return;
}
// 术后病程记录
if (shubcjl.equals(bcjlType)) {
cancelShuBcjlEMRReport(patientId);
return;
}
// 体温单
if (isTiWenDan(reportName)) {
cancelTiWenDanEMRReport(patientId, reportName);
return;
}
// 医嘱
if (isYiZhu(reportName)) {
cancelYiZhuEMRReport(patientId, reportName);
return;
}
// 会诊申请
if (isHuiZhen(reportName)) {
cancelHuiZhenEMRReport(patientId, reportName);
return;
}
// 普通的电子病历
cancelNormalEMRReport(patientId, reportNo);
return;
}
// 其他来源类型
if (isOtherSource(reportSource)) {
log.warn("该来源:{} 未实现功能!", reportSource);
}
}
private void cancelNormalEMRReport(String patientId, String reportNo) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC7(reportNo);
task.setSysflag("2");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> fileIds = tasks.stream().map(AfCollectTask::getAfArchiveDetailId).collect(Collectors.toList());
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
scanAssortMapper.cancel(fileIds);
collectTaskMapper.cancel(taskIds);
}
private void cancelHuiZhenEMRReport(String patientId, String reportName) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC6(reportName);
task.setSysflag("12");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
List<String> serialNum = tasks.stream().map(t -> patientId + t.getC6()).collect(Collectors.toList());
scanAssortMapper.cancelBySerialNum(serialNum, patientId, "-2");
collectTaskMapper.cancel(taskIds);
}
private void cancelYiZhuEMRReport(String patientId, String reportName) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC6(reportName);
task.setSysflag("12");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
List<String> serialNum = tasks.stream().map(t -> patientId + t.getC6()).collect(Collectors.toList());
scanAssortMapper.cancelBySerialNum(serialNum, patientId, "-2");
collectTaskMapper.cancel(taskIds);
}
private void cancelTiWenDanEMRReport(String patientId, String reportName) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC6(reportName);
task.setSysflag("12");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
List<String> serialNum = tasks.stream().map(t -> patientId + t.getC6()).collect(Collectors.toList());
scanAssortMapper.cancelBySerialNum(serialNum, patientId, "-2");
collectTaskMapper.cancel(taskIds);
}
/**
*
*
* @param patientId
*/
private void cancelBcjlEMRReport(String patientId) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC6("病程记录");
task.setSysflag("2");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> fileIds = tasks.stream().map(AfCollectTask::getAfArchiveDetailId).collect(Collectors.toList());
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
scanAssortMapper.cancel(fileIds);
updateTaskForRecollect(taskIds);
}
/**
*
*
* @param patientId
*/
private void cancelShuBcjlEMRReport(String patientId) {
AfCollectTask task = new AfCollectTask();
task.setPatientId(patientId);
task.setC6("术后病程记录");
task.setSysflag("2");
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
return;
}
List<Long> fileIds = tasks.stream().map(AfCollectTask::getAfArchiveDetailId).collect(Collectors.toList());
List<Long> taskIds = tasks.stream().map(AfCollectTask::getId).collect(Collectors.toList());
scanAssortMapper.cancel(fileIds);
updateTaskForRecollect(taskIds);
}
/**
*
*/
private boolean isHuiZhen(String reportName) {
return reportName.contains("会诊申请");
}
/**
*
*/
private boolean isTiWenDan(String reportName) {
return reportName.contains("体温单");
}
/**
*
*/
private boolean isYiZhu(String reportName) {
return reportName.contains("长期医嘱") ||
reportName.contains("中药医嘱") ||
reportName.contains("临时医嘱");
}
private boolean isOtherSource(String reportSource) {
return true;
}
private boolean isEmrSource(String reportSource) {
return true;
}
private String getPatientId(BasicQrDto basicQrDto) {
List<String> patientIds = tbasicMapper.getPatientIds(basicQrDto, 0, 10);
if (Func.isEmpty(patientIds)) {
throw new BaseException("系统中无此患者,请确认患者信息!");
}
if (patientIds.size() > 1) {
throw new BaseException("系统中找到多条患者信息,请确认患者信息!");
}
return patientIds.get(0);
}
private AfReportDeleteLog insertDeleteLog(String message) {
Date now = new Date();
long id = idService.getDateSeq();
AfReportDeleteLog reportDeleteLog = new AfReportDeleteLog();
reportDeleteLog.setId(id);
reportDeleteLog.setPatientId("");
reportDeleteLog.setType(operator);
reportDeleteLog.setDeleteContent(message);
reportDeleteLog.setCreateTime(now);
reportDeleteLog.setUpdateTime(now);
scanAssortMapper.insertDeleteLog(reportDeleteLog);
return reportDeleteLog;
}
/**
*
*/
private void updateTaskForRecollect(List<Long> taskIds) {
String collectionState = collectTaskMapper.getCollectionState();
String state = "0";
if (StrUtil.isNotBlank(collectionState)) {
state = collectionState;
}
collectTaskMapper.updateTaskForRecollect(taskIds, operator, state);
}
/**
* id 13
*
* @param reportNo
* @date 2024/1/3 17:19
* @author YongBin Wen
*/
private void cancelReport(String reportNo) {
final String sysFlag = "13";
AfCollectTask task = new AfCollectTask();
task.setC1(reportNo);
task.setSysflag(sysFlag);
List<AfCollectTask> tasks = collectTaskMapper.getTasks(task);
if (Func.isEmpty(tasks)) {
throw new BaseException("无纸化系统没有可作废的电生理报告任务:" + reportNo);
}
ArrayList<Long> taskIds = new ArrayList<>();
ArrayList<Long> scanAssortIds = new ArrayList<>();
for (AfCollectTask collectTask : tasks) {
taskIds.add(collectTask.getId());
List<Long> scanAssortIdsByTask = scanAssortMapper.getIdByPatientTask(collectTask.getPatientId(), collectTask.getId());
scanAssortIds.addAll(scanAssortIdsByTask);
}
YingDeZyyReportManagerServiceImpl service = SpringUtil.getBean(YingDeZyyReportManagerServiceImpl.class);
service.cancelReportTaskAndFile(taskIds, scanAssortIds);
}
@Transactional(rollbackFor = Exception.class)
public void cancelReportTaskAndFile(List<Long> taskIds, List<Long> scanAssortIds) {
if (Func.isNotEmpty(taskIds)) {
collectTaskMapper.cancel(taskIds);
}
if (Func.isNotEmpty(scanAssortIds)) {
scanAssortMapper.cancel(scanAssortIds);
}
}
private String error(String msg) {
return "<Response>\n" +
" <RetInfo>\n" +
" <RetCode>1</RetCode>\n" +
" <RetCon>" + msg + "</RetCon>\n" +
" </RetInfo>\n" +
"</Response>";
}
private String success() {
return "<Response>\n" +
" <RetInfo>\n" +
" <RetCode>0</RetCode>\n" +
" <RetCon>成功</RetCon>\n" +
" </RetInfo>\n" +
"</Response>";
}
}

@ -11,11 +11,25 @@
#{id}
</foreach>
</update>
<update id="updateTaskForRecollect">
UPDATE `docus_archivefile`.`af_collect_task`
SET `state` = #{state},
`C9`='1',
`recollect_name`=#{operator},
`sync_time`=now(),
`recollect_time`=now()
WHERE `id` in
<foreach collection="taskIds" item="taskId" separator="," open="(" close=")">
#{taskId}
</foreach>
</update>
<select id="getTasks" resultType="com.docus.server.reportmanager.entity.AfCollectTask">
SELECT
id,
patient_id as patientId
patient_id as patientId,
af_archive_detail_id,
C1,C2,C4,C6,C7,C8
FROM
`docus_archivefile`.`af_collect_task`
<where>
@ -28,6 +42,28 @@
<if test="task.C1 !=null and task.C1 != ''">
and C1=#{task.C1}
</if>
<if test="task.C2 !=null and task.C2 != ''">
and C2=#{task.C2}
</if>
<if test="task.C4 !=null and task.C4 != ''">
and C4=#{task.C4}
</if>
<if test="task.C6 !=null and task.C6 != ''">
and C6=#{task.C6}
</if>
<if test="task.C7 !=null and task.C7 != ''">
and C7=#{task.C7}
</if>
<if test="task.C8 !=null and task.C8 != ''">
and C8=#{task.C8}
</if>
</where>
</select>
<select id="getCollectionState" resultType="java.lang.String">
SELECT
collectionstate
FROM
`docus_archivefile`.`af_system_config`
LIMIT 1
</select>
</mapper>

@ -3,6 +3,11 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.reportmanager.mapper.ScanAssortMapper">
<insert id="insertDeleteLog">
INSERT INTO `docus_archivefile`.`af_report_delete_log`
(`id`, `patient_id`, `delete_content`, `type`, `create_time`, `update_time`)
VALUES (#{delLog.id}, #{delLog.patientId}, #{delLog.deleteContent}, #{delLog.type}, #{delLog.createTime}, #{delLog.updateTime})
</insert>
<update id="cancel">
UPDATE `docus_archivefile`.`t_scan_assort`
@ -12,6 +17,27 @@
#{id}
</foreach>
</update>
<update id="updateDleteLog">
UPDATE `docus_archivefile`.`af_report_delete_log`
SET `patient_id` = #{delLog.patientId},
`delete_content` = #{delLog.deleteContent},
`type` = #{delLog.type},
`create_time` = #{delLog.createTime},
`update_time` = #{delLog.updateTime}
WHERE `id` = #{delLog.id}
</update>
<update id="cancelBySerialNum">
UPDATE `docus_archivefile`.`t_scan_assort`
SET `is_del` = 1
WHERE
patient_id=#{patientId}
AND source=#{source}
AND `file_column_1` in
<foreach collection="serials" item="serial" separator="," open="(" close=")">
#{serial}
</foreach>
</update>
<select id="getIdByPatientTask" resultType="java.lang.Long">
select id
from `docus_archivefile`.`t_scan_assort`

@ -0,0 +1,34 @@
<?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.reportmanager.mapper.TbasicMapper">
<select id="getPatientIds" resultType="java.lang.String">
select patient_id
from docus_medicalrecord.t_basic
WHERE 1=1
<if test="qrDto.inpatientNo != null and qrDto.inpatientNo != ''">
and inpatient_no=#{qrDto.inpatientNo}
</if>
<if test="qrDto.admissTimes != null ">
and admiss_times=#{qrDto.admissTimes}
</if>
<if test="qrDto.admissDateBegin != null and qrDto.admissDateBegin != ''">
and admiss_date BETWEEN #{qrDto.admissDateBegin} and #{qrDto.admissDateEnd}
</if>
<if test="qrDto.disDateBegin != null and qrDto.disDateBegin != ''">
and dis_date BETWEEN #{qrDto.disDateBegin} and #{qrDto.disDateEnd}
</if>
<if test="qrDto.name != null and qrDto.name != ''">
and name=#{qrDto.name}
</if>
<if test="qrDto.idCard != null and qrDto.idCard != ''">
and id_card=#{qrDto.idCard}
</if>
<if test="qrDto.jzh != null and qrDto.jzh != ''">
and jzh=#{qrDto.jzh}
</if>
LIMIT ${offset},${size}
</select>
</mapper>
Loading…
Cancel
Save