保存门诊号

master
wyb 2 years ago
parent 23dc187bf0
commit 539ccdbdd8

@ -1,12 +1,6 @@
package com.docus.server;
import com.docus.core.util.Func;
import com.docus.core.util.SpringUtils;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.server.message.feign.dto.HospitalSubmitNodeLogAddDTO;
import com.docus.server.message.feign.enums.HospitalSubmitNodeEnum;
import com.docus.server.message.feign.service.HospitalSubmitNodeServiceApi;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
@ -14,7 +8,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.scheduling.annotation.EnableAsync;
import java.util.Date;
import java.util.Properties;
@ -30,17 +23,6 @@ public class AppRunBootstrap {
props.setProperty("UseSunHttpHandler", "true");
System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
SpringApplication.run(AppRunBootstrap.class, args);
}
private static void test(){
HospitalSubmitNodeServiceApi hospitalSubmitNodeServiceApi = SpringUtils.getBean(HospitalSubmitNodeServiceApi.class);
HospitalSubmitNodeLogAddDTO dto = new HospitalSubmitNodeLogAddDTO();
dto.setPatientId("1008611");
dto.setContent(new String[]{"责任护士尔豪","质控护士豪尔", Func.formatDateTime(new Date()),"10"});
dto.setCreaterName("护理提交");
dto.setCreater("护理提交");
dto.setSubmitNodeEnum(HospitalSubmitNodeEnum.NURSE);
CommonResult<String> commonResult = hospitalSubmitNodeServiceApi.addLog(dto);
log.info(Func.toJson(commonResult));
}
}

@ -23,6 +23,12 @@ public interface SdBusinessService {
*/
MessageResponse wsNurseSubmitHandle(Message message);
/**
*
* @param patientId
*/
void trInpatientOutPatient(String patientId);
/**
* ,
*
@ -47,4 +53,7 @@ public interface SdBusinessService {
* @return
*/
List<SdRyBloodReportVO> getBloodView(String inpatientNo, Integer admissTimes);
}

@ -13,9 +13,11 @@ import com.docus.server.message.consts.StaticResourceMapping;
import com.docus.server.message.controller.vo.SdRyBloodReportVO;
import com.docus.server.message.converters.WsNurseSubmitMessageConvert;
import com.docus.server.message.converters.WsRecordSubmitMessageConvert;
import com.docus.server.message.dao.TrInpatientOutpatientDao;
import com.docus.server.message.dto.*;
import com.docus.server.message.entity.MaternalInfantRelationship;
import com.docus.server.message.entity.TBasic;
import com.docus.server.message.entity.TrInpatientOutpatient;
import com.docus.server.message.feign.dto.CompensateTasRequest;
import com.docus.server.message.feign.dto.HospitalSubmitNodeLogAddDTO;
import com.docus.server.message.feign.enums.HospitalSubmitNodeEnum;
@ -35,10 +37,13 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -60,6 +65,8 @@ public class SdBusinessServiceImpl implements SdBusinessService {
private HospitalSubmitNodeServiceApi hospitalSubmitNodeServiceApi;
@Autowired
private SdRyBloodMapper sdRyBloodMapper;
@Resource
private TrInpatientOutpatientDao trInpatientOutpatientDao;
private static final TableJsonRead JSON_READ = new TableJsonRead();
@ -84,6 +91,8 @@ public class SdBusinessServiceImpl implements SdBusinessService {
nodeLogAddDTO.setCreaterName("电子病历提交");
hospitalSubmitNodeServiceApi.addLog(nodeLogAddDTO);
trInpatientOutPatient(patientIds.get(0));
if (!isDischargeAndUpdDisDate(patientIds.get(0), recordSubmitDto.getInHospIndexNo(), recordSubmitDto.getVisitNo())) {
throw new BaseException("此患者未出院!");
}
@ -108,6 +117,33 @@ public class SdBusinessServiceImpl implements SdBusinessService {
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void trInpatientOutPatient(String patientId) {
String sdRyIndex = tBasicMapper.getSdRyIndex(patientId);
if (Func.isBlank(sdRyIndex)) {
log.warn("patientId{} 没有患者索引!", patientId);
return;
}
List<String> mzReportJxIds = shunDePeopleRpc.getSdRyMzReportJxIds(sdRyIndex);
if (Func.isEmpty(mzReportJxIds)) {
log.warn("patientId{} 患者索引:{} ,未查询到门诊号!", patientId, sdRyIndex);
return;
}
List<TrInpatientOutpatient> trInpatientOutpatientList = mzReportJxIds.stream()
.distinct()
.map(outNO -> {
TrInpatientOutpatient outpatient = new TrInpatientOutpatient();
outpatient.setOutpatientNo(outNO);
outpatient.setPatientId(patientId);
return outpatient;
}).collect(Collectors.toList());
trInpatientOutpatientDao.deleteTrInpatientOutpatientByInpatientId(patientId);
trInpatientOutpatientDao.insertOrUpdateTrInpatientOutpatient(trInpatientOutpatientList);
log.info("patientId{} 保存门诊号关系成功!", patientId);
}
@Override
public MessageResponse wsNurseSubmitHandle(Message message) {

@ -0,0 +1,31 @@
package com.docus.server.message.config;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
*
*
* @author wyb
*/
@Component
@Getter
@Setter
public class SdRyReportQueryConfig {
/**
*
*/
public static String BABY_COLLECTOR_ID_SUFFIX = "_B";
@Value("${sdry.report-index-query.wsdl-addr:}")
private String queryReportIndexWsdlAddr;
@Value("${sdry.report-index-query.namespace-uri:}")
private String queryReportIndexWsdlNamespaceUri;
@Value("${sdry.report-index-query.operationName:}")
private String queryReportIndexWsdlOperationName;
@Value("${sdry.report-index-query.interval:1000}")
private int queryReportIndexInterval;
}

@ -0,0 +1,23 @@
package com.docus.server.message.dao;
import com.docus.infrastructure.core.db.dao.IBaseDao;
import com.docus.server.message.entity.TrInpatientOutpatient;
import java.util.List;
/**
* @author wyb
*/
public interface TrInpatientOutpatientDao extends IBaseDao<TrInpatientOutpatient> {
/**
*
* @param trInpatientOutpatientList
*/
void insertOrUpdateTrInpatientOutpatient(List<TrInpatientOutpatient> trInpatientOutpatientList);
/**
*
* @param inpatientId
*/
void deleteTrInpatientOutpatientByInpatientId(String inpatientId);
}

@ -0,0 +1,39 @@
package com.docus.server.message.dao.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.docus.infrastructure.core.db.dao.impl.BaseDaoImpl;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.server.message.dao.TrInpatientOutpatientDao;
import com.docus.server.message.entity.TrInpatientOutpatient;
import com.docus.server.message.mapper.TrInpatientOutpatientMapper;
import org.springframework.stereotype.Repository;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
/**
* @author wyb
*/
@Repository
public class TrInpatientOutpatientDaoImpl extends BaseDaoImpl<TrInpatientOutpatientMapper, TrInpatientOutpatient> implements TrInpatientOutpatientDao {
@Resource
private IdService idService;
@Override
public void insertOrUpdateTrInpatientOutpatient(List<TrInpatientOutpatient> trInpatientOutpatientList) {
for (TrInpatientOutpatient tr : trInpatientOutpatientList) {
if (Objects.isNull(tr.getId())) {
tr.setId(idService.getDateSeq());
}
}
saveOrUpdateBatch(trInpatientOutpatientList, 1000);
}
@Override
public void deleteTrInpatientOutpatientByInpatientId(String inpatientId) {
LambdaQueryWrapper<TrInpatientOutpatient> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TrInpatientOutpatient::getPatientId, inpatientId);
baseMapper.delete(wrapper);
}
}

@ -0,0 +1,31 @@
package com.docus.server.message.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* @author wyb
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "TrInpatientOutpatient对象", description = "住院和门诊关联关系表")
public class TrInpatientOutpatient implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@ApiModelProperty("病案主键")
private String patientId;
@ApiModelProperty("门诊号")
private String outpatientNo;
}

@ -0,0 +1,9 @@
package com.docus.server.message.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.server.message.entity.TrInpatientOutpatient;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface TrInpatientOutpatientMapper extends BaseMapper<TrInpatientOutpatient> {
}

@ -3,6 +3,8 @@ package com.docus.server.message.rpc;
import com.docus.server.message.rpc.request.HisZyCyYzRequest;
import com.docus.server.message.rpc.response.HisZyCyYzResponse;
import java.util.List;
/**
*
* @author wyb
@ -21,4 +23,13 @@ public interface ShunDePeopleRpc {
* @return
*/
byte[] getBloodReport(String fileName);
/**
* ()
*
* @param sdRyIndex
* @return
*/
List<String> getSdRyMzReportJxIds(String sdRyIndex);
}

@ -4,16 +4,26 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.docus.core.util.DateUtil;
import com.docus.core.util.Func;
import com.docus.server.message.config.SdRyReportQueryConfig;
import com.docus.server.message.config.ShunDePeopleInterfaceConfig;
import com.docus.server.message.rpc.ShunDePeopleRpc;
import com.docus.server.message.rpc.request.HisZyCyYzRequest;
import com.docus.server.message.rpc.response.HisZyCyYzResponse;
import com.docus.server.message.util.HttpUrlUtil;
import com.docus.server.message.util.IdUtil;
import com.docus.server.message.util.JaxWsDynamicClient;
import com.docus.server.message.util.XmlUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -23,6 +33,8 @@ import java.util.Map;
@Slf4j
@Service
public class ShunDePeopleRpcImpl implements ShunDePeopleRpc {
@Resource
private SdRyReportQueryConfig sdRyReportQueryConfig;
@Override
public HisZyCyYzResponse hisZyCyYz(HisZyCyYzRequest request) {
@ -67,6 +79,119 @@ public class ShunDePeopleRpcImpl implements ShunDePeopleRpc {
.execute().bodyBytes();
}
@Override
public List<String> getSdRyMzReportJxIds(String sdRyIndex) {
List<String> indexes = new ArrayList<>();
try {
String mzParam = organizationQuerySdRyReportIndexParam(sdRyIndex, 1);
String[] mzParams = {"HIP1179", mzParam};
return getSdRyReportJxIds(mzParams);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return indexes;
}
/**
*
*
* @param sDryIndex
* @param type 1: 3:
* @return
*/
private String organizationQuerySdRyReportIndexParam(String sDryIndex, int type) {
sDryIndex = sDryIndex.toLowerCase()
.replace("m", "")
.replace("z", "");
String receiver = "Orion-001";
String sender = "PaperlessManagementMRIS-001";
String now = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
return "<PRPA_HIP1179 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ITSVersion=\"XML_1.0\" xmlns=\"urn:hl7-org:v3\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/PRPA_IN201306UV02.xsd\">\n" +
"\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
"\t<creationTime value=\"" + now + "\"/>\n" +
"\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"PRPA_IHIP1179\"/>\n" +
"\t<processingCode code=\"P\"/>\n" +
"\t<processingModeCode/>\n" +
"\t<acceptAckCode code=\"AL\"/>\n" +
"\t<receiver typeCode=\"RCV\">\n" +
"\t\t<telecom/>\n" +
"\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
"\t\t\t<id>\n" +
"\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
"\t\t\t</id>\n" +
"\t\t</device>\n" +
"\t</receiver>\n" +
"\t<sender typeCode=\"SND\">\n" +
"\t\t<telecom/>\n" +
"\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
"\t\t\t<id>\n" +
"\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
"\t\t\t</id>\n" +
"\t\t</device>\n" +
"\t</sender>\n" +
"\t<controlActProcess classCode=\"CACT\" moodCode=\"EVN\">\n" +
"\t\t<code code=\"empiIndexQuery\">\n" +
"\t\t\t<displayName value=\"交叉索引查询\"/>\n" +
"\t\t</code>\n" +
"\t\t<queryByParameter>\n" +
"\t\t\t<!-- 查询条件type类型 value值 -->\n" +
"\t\t\t<!--type 1:患者id 2:身份证 3::电子健康码-->\n" +
"\t\t\t<queryParam type=\"1\" value=\"" + sDryIndex + "\"/>\n" +
"\t\t\t<!--1:门诊 3:住院-->\n" +
"\t\t\t<visitType type=\"" + type + "\"/>\n" +
"\t\t</queryByParameter>\n" +
"\t</controlActProcess>\n" +
"</PRPA_HIP1179>\n";
}
private List<String> getSdRyReportJxIds(String[] qrIndexParams) {
List<String> indexes = new ArrayList<>();
try {
List<String> zyIndex = getIndex(qrIndexParams);
indexes.addAll(zyIndex);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return indexes;
}
private List<String> getIndex(String[] params) {
try {
String namespaceUri = sdRyReportQueryConfig.getQueryReportIndexWsdlNamespaceUri();
String wsdlAddr = sdRyReportQueryConfig.getQueryReportIndexWsdlAddr();
String operationName = sdRyReportQueryConfig.getQueryReportIndexWsdlOperationName();
String result = JaxWsDynamicClient.send(wsdlAddr, namespaceUri, operationName, params);
log.info("查询顺德人医患者交叉索引数据,返回值:{}", result);
if (result == null) {
return new ArrayList<>();
}
return parseQuerySdRyReportIndex(result);
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
return new ArrayList<>();
}
}
private List<String> parseQuerySdRyReportIndex(String result) {
try {
XmlUtil xmlUtil = XmlUtil.of(result);
NodeList nodeList = xmlUtil.getNodeList("/PRPA_HIP1179/controlActProcess/subject/empiIndex/patientIds/patientId");
int nodeListLength = nodeList.getLength();
ArrayList<String> patientIds = new ArrayList<>();
if (nodeListLength > 0) {
for (int i = 0; i < nodeListLength; i++) {
Node node = nodeList.item(i);
String patientId = node.getTextContent();
if (Func.isNotBlank(patientId)) {
patientIds.add(patientId);
}
}
}
return patientIds;
} catch (Exception ex) {
log.error("顺德人医解析患者交叉索引失败。", ex);
return new ArrayList<>();
}
}
public static void main(String[] args) {
}

@ -0,0 +1,68 @@
package com.docus.server.message.util;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.namespace.QName;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* 使JaxWsDynamicClientFactory webservice
* @author wyb
*/
public class JaxWsDynamicClient {
private static final JaxWsDynamicClientFactory CLIENT_FACTORY = JaxWsDynamicClientFactory.newInstance();
private static final Map<String, Client> CLIENT_MAP=new ConcurrentHashMap<>();
private static final Logger logger= LoggerFactory.getLogger(JaxWsDynamicClient.class);
public static String send(String wsdlUrl,String namespaceUri,String operationName,Object[] params){
logger.debug("wsdlUrl" + wsdlUrl +" ,namespaceUri: "+namespaceUri+ " operationName" + operationName + "param:" + Arrays.toString(params));
try {
Client client = getClient(wsdlUrl);
Object[] result;
if (namespaceUri == null || namespaceUri.isEmpty()) {
result = client.invoke(operationName, params);
} else {
QName qName = new QName(namespaceUri, operationName);
result = client.invoke(qName, params);
}
if (result == null || result[0] == null) {
return null;
}
return String.valueOf(result[0]);
} catch (Exception ex) {
ex.printStackTrace();
logger.error("wsdlUrl" + wsdlUrl +",namespaceUri: "+namespaceUri+ " operationName" + operationName + "param:" + Arrays.toString(params)+" 调用失败了!", ex);
return null;
}
}
public static Client getClient(String wsdlUrl){
if(CLIENT_MAP.get(wsdlUrl)==null){
synchronized (JaxWsDynamicClient.class){
if(CLIENT_MAP.get(wsdlUrl)==null){
Client client = CLIENT_FACTORY.createClient(wsdlUrl);
setClientParam(client);
CLIENT_MAP.put(wsdlUrl,client);
}
}
}
return CLIENT_MAP.get(wsdlUrl);
}
private static void setClientParam(Client client) {
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(30000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(30000);
HTTPConduit clientConduit = (HTTPConduit) client.getConduit();
clientConduit.setClient(httpClientPolicy);
}
}

@ -126,3 +126,10 @@ xxl:
port: 19312
logretentiondays: 30
logpath: D:/xxl-job/inspection
sdry:
# 顺德人医查询检查、检验报告之前查患者交叉索引的wsdl配置
report-index-query:
wsdl-addr: http://127.0.0.1:9311/webservice/api?wsdl
namespace-uri: http://impl.webservice.collection.server.docus.com/
operationName: querySdJxIndexTest

Loading…
Cancel
Save