代码优化
parent
01bbcd0d82
commit
b7324ef6a0
@ -0,0 +1,8 @@
|
||||
package com.docus.server.collection.service;
|
||||
|
||||
import com.docus.server.collection.dto.TBasicDto;
|
||||
|
||||
public interface ITBasicService {
|
||||
|
||||
public void setTBasic(TBasicDto dto) throws Exception;
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.docus.server.collection.service.impl;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.docus.core.util.DateUtil;
|
||||
import com.docus.core.util.Func;
|
||||
import com.docus.infrastructure.redis.service.IdService;
|
||||
import com.docus.server.collection.dto.TBasicDto;
|
||||
import com.docus.server.collection.entity.TBasic;
|
||||
import com.docus.server.collection.mapper.TBasicMapper;
|
||||
import com.docus.server.collection.service.ITBasicService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @BelongsProject: docus-webservice-sdry
|
||||
* @BelongsPackage: com.docus.server.collection.service.impl
|
||||
* @Author: chierhao
|
||||
* @CreateTime: 2023-02-28 08:37
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class TBasicServiceImpl implements ITBasicService {
|
||||
|
||||
@Resource
|
||||
private TBasicMapper tBasicMapper;
|
||||
|
||||
@Resource
|
||||
private IdService idService;
|
||||
|
||||
@Override
|
||||
public void setTBasic(TBasicDto tBasicDto) throws Exception {
|
||||
//判断jzh是否重复
|
||||
Integer num = tBasicMapper.selectOne(tBasicDto.getJzh());
|
||||
if (num>0) {
|
||||
throw new Exception("记帐号已存在");
|
||||
}
|
||||
long patientId = idService.getDateSeq();
|
||||
|
||||
//数据类型转化,格式处理
|
||||
Date admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
||||
Date disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
||||
String admissTimesStr = tBasicDto.getAdmissTimes();
|
||||
Integer admissTimes=null;
|
||||
if(NumberUtil.isInteger(admissTimesStr)){
|
||||
admissTimes=Integer.parseInt(admissTimesStr);
|
||||
}
|
||||
|
||||
//组装数据
|
||||
TBasic tBasic=new TBasic();
|
||||
tBasic.setPatientId(patientId);
|
||||
tBasic.setJzh(tBasicDto.getJzh());
|
||||
tBasic.setInpatientNo(tBasicDto.getInpatientNo());
|
||||
tBasic.setAdmissTimes(admissTimes);
|
||||
tBasic.setName(tBasicDto.getName());
|
||||
tBasic.setAdmissDate(admissDate);
|
||||
tBasic.setDisDate(disDate);
|
||||
tBasic.setAdmissDeptName(tBasicDto.getAdmissDeptName());
|
||||
tBasic.setDisDeptName(tBasicDto.getDisDeptName());
|
||||
tBasic.setAttendingName(tBasicDto.getAttendingName());
|
||||
|
||||
//持久化
|
||||
tBasicMapper.insert(tBasic);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.docus.server.collection.webservice;
|
||||
|
||||
public interface TBasicService {
|
||||
public interface BasicService {
|
||||
|
||||
public String setTBasic(String str);
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package com.docus.server.collection.webservice.impl;
|
||||
|
||||
import com.docus.core.util.Func;
|
||||
import com.docus.server.collection.dto.TBasicDto;
|
||||
import com.docus.server.collection.service.ITBasicService;
|
||||
import com.docus.server.collection.util.Result;
|
||||
import com.docus.server.collection.util.XmlUtil;
|
||||
import com.docus.server.collection.webservice.BasicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.jws.WebService;
|
||||
|
||||
/**
|
||||
* @BelongsProject: docus-webservice-sdry
|
||||
* @BelongsPackage: com.docus.server.collection.webservice
|
||||
* @Author: chierhao
|
||||
* @CreateTime: 2023-02-25 14:52
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
@WebService
|
||||
@Slf4j
|
||||
public class BasicServiceImpl implements BasicService {
|
||||
|
||||
@Resource
|
||||
private ITBasicService tBasicService;
|
||||
|
||||
@Override
|
||||
public String setTBasic(String body) {
|
||||
if (Func.isEmpty(body)) {
|
||||
return Result.failed(null,"参数为空",null,null);
|
||||
}
|
||||
//解析xml
|
||||
TBasicDto tBasicDto = null;
|
||||
try {
|
||||
tBasicDto=getTBasicDto(body);
|
||||
//持久化
|
||||
tBasicService.setTBasic(tBasicDto);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.failed(tBasicDto.getSerialId(),e.getMessage(),tBasicDto.getReceive(),tBasicDto.getSend());
|
||||
}
|
||||
return Result.success(tBasicDto.getSerialId(),tBasicDto.getReceive(),tBasicDto.getSend());
|
||||
}
|
||||
|
||||
|
||||
public TBasicDto getTBasicDto(String str) {
|
||||
XmlUtil xml=XmlUtil.of(str);
|
||||
//id-消息流水号
|
||||
String serialId=null;
|
||||
Node serialIdNode = xml.getNode("/PRPA_HIP0032/id/@extension");
|
||||
if(Func.isNotEmpty(serialIdNode)){
|
||||
serialId=serialIdNode.getNodeValue();
|
||||
}
|
||||
//接受方
|
||||
String receive=null;
|
||||
Node receiveNode = xml.getNode("/PRPA_HIP0032/receiver/device/id/item/@extension");
|
||||
if(Func.isNotEmpty(receiveNode)){
|
||||
receive=receiveNode.getNodeValue();
|
||||
}
|
||||
//发送方
|
||||
String send=null;
|
||||
Node sendNode = xml.getNode("/PRPA_HIP0032/sender/device/id/item/@extension");
|
||||
if(Func.isNotEmpty(sendNode)){
|
||||
send=sendNode.getNodeValue();
|
||||
}
|
||||
//住院流水号
|
||||
String jzh=null;
|
||||
Node jzhNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/item/@extension");
|
||||
if(Func.isNotEmpty(jzhNode)){
|
||||
jzh=jzhNode.getNodeValue();
|
||||
}
|
||||
//住院号标识
|
||||
String inpatientNo=null;
|
||||
Node inpatientNoNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/id/item/@extension");
|
||||
if(Func.isNotEmpty(inpatientNoNode)){
|
||||
inpatientNo=inpatientNoNode.getNodeValue();
|
||||
}
|
||||
//住院次数[]
|
||||
String admissTimes=null;
|
||||
Node admissTimesNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='次']/@value");
|
||||
if(Func.isNotEmpty(admissTimesNode)){
|
||||
admissTimes=admissTimesNode.getNodeValue();
|
||||
}
|
||||
//姓名
|
||||
String name=null;
|
||||
Node nameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/name/item/part/@value");
|
||||
if(Func.isNotEmpty(nameNode)){
|
||||
name=nameNode.getNodeValue();
|
||||
}
|
||||
//入院日期时间
|
||||
String admissDate=null;
|
||||
Node admissDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/low/@value");
|
||||
if(Func.isNotEmpty(admissDateNode)){
|
||||
admissDate=admissDateNode.getNodeValue();
|
||||
}
|
||||
//出院日期时间
|
||||
String disDate=null;
|
||||
Node disDateNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/high/@value");
|
||||
if(Func.isNotEmpty(disDateNode)){
|
||||
disDate=disDateNode.getNodeValue();
|
||||
}
|
||||
//入院诊断科室名称[]
|
||||
String admissDeptName=null;
|
||||
Node admissDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='入院诊断']/section/entry[@displayName='入院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
|
||||
if(Func.isNotEmpty(admissDeptNameNode)){
|
||||
admissDeptNameNode.getTextContent();
|
||||
}
|
||||
//出院诊断科室名称[]
|
||||
String disDeptName=null;
|
||||
Node disDeptNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
|
||||
if(Func.isNotEmpty(disDeptNameNode)){
|
||||
disDeptName=disDeptNameNode.getTextContent();
|
||||
}
|
||||
//主治医师[]
|
||||
String attendingName=null;
|
||||
Node attendingNameNode = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/authenticator[@displayName='主治医师']/assignedEntity/assignedPerson/name");
|
||||
if(Func.isNotEmpty(attendingNameNode)){
|
||||
attendingName=attendingNameNode.getTextContent();
|
||||
}
|
||||
|
||||
//设置dto
|
||||
TBasicDto dto=new TBasicDto();
|
||||
dto.setSerialId(serialId);
|
||||
dto.setSend(send);
|
||||
dto.setReceive(receive);
|
||||
dto.setInpatientNo(inpatientNo);
|
||||
dto.setName(name);
|
||||
dto.setJzh(jzh);
|
||||
dto.setAdmissDeptName(admissDeptName);
|
||||
dto.setDisDeptName(disDeptName);
|
||||
dto.setAdmissDate(admissDate);
|
||||
dto.setDisDate(disDate);
|
||||
dto.setAdmissTimes(admissTimes);
|
||||
dto.setAttendingName(attendingName);
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
@ -1,152 +0,0 @@
|
||||
package com.docus.server.collection.webservice.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.docus.core.util.DateUtil;
|
||||
import com.docus.core.util.Func;
|
||||
import com.docus.infrastructure.redis.service.IdService;
|
||||
import com.docus.server.collection.dto.TBasicDto;
|
||||
import com.docus.server.collection.entity.TBasic;
|
||||
import com.docus.server.collection.mapper.TBasicMapper;
|
||||
import com.docus.server.collection.util.Result;
|
||||
import com.docus.server.collection.util.XmlUtil;
|
||||
import com.docus.server.collection.webservice.TBasicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.jws.WebService;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @BelongsProject: docus-webservice-sdry
|
||||
* @BelongsPackage: com.docus.server.collection.webservice
|
||||
* @Author: chierhao
|
||||
* @CreateTime: 2023-02-25 14:52
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
@WebService
|
||||
@Slf4j
|
||||
public class TBasicServiceImpl implements TBasicService {
|
||||
|
||||
@Resource
|
||||
private TBasicMapper tBasicMapper;
|
||||
|
||||
@Resource
|
||||
private IdService idService;
|
||||
|
||||
@Override
|
||||
public String setTBasic(String body) {
|
||||
if (Func.isEmpty(body)) {
|
||||
return Result.failed(null,"参数为空",null,null);
|
||||
}
|
||||
//解析xml
|
||||
TBasicDto tBasicDto = null;
|
||||
try {
|
||||
tBasicDto=getTBasicDto(body);
|
||||
//判断jzh是否重复
|
||||
Integer num = tBasicMapper.selectOne(tBasicDto.getJzh());
|
||||
if (num>0) {
|
||||
return Result.failed(tBasicDto.getSerialId(),"记帐号已存在",tBasicDto.getReceive(),tBasicDto.getSend());
|
||||
}
|
||||
|
||||
long patientId = idService.getDateSeq();
|
||||
|
||||
//组装数据
|
||||
TBasic tBasic=new TBasic();
|
||||
tBasic.setPatientId(patientId);
|
||||
tBasic.setJzh(tBasicDto.getJzh());
|
||||
tBasic.setInpatientNo(tBasicDto.getInpatientNo());
|
||||
tBasic.setAdmissTimes(Integer.parseInt(tBasicDto.getAdmissTimes()));
|
||||
tBasic.setName(tBasicDto.getName());
|
||||
Date admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
||||
tBasic.setAdmissDate(admissDate);
|
||||
Date disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
||||
tBasic.setDisDate(disDate);
|
||||
tBasic.setAdmissDeptName(tBasicDto.getAdmissDeptName());
|
||||
tBasic.setDisDeptName(tBasicDto.getDisDeptName());
|
||||
tBasic.setAttendingName(tBasicDto.getAttendingName());
|
||||
//持久化
|
||||
tBasicMapper.insert(tBasic);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return Result.success(tBasicDto.getSerialId(),tBasicDto.getReceive(),tBasicDto.getSend());
|
||||
}
|
||||
|
||||
|
||||
public TBasicDto getTBasicDto(String str) {
|
||||
TBasicDto dto=new TBasicDto();
|
||||
XmlUtil xml=XmlUtil.of(str);
|
||||
Node node=null;
|
||||
//id-消息流水号
|
||||
node = xml.getNode("/PRPA_HIP0032/id/@extension");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setSerialId(node.getNodeValue());
|
||||
}
|
||||
//接受方
|
||||
node = xml.getNode("/PRPA_HIP0032/receiver/device/id/item/@extension");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setReceive(node.getNodeValue());
|
||||
}
|
||||
//发送方
|
||||
node = xml.getNode("/PRPA_HIP0032/sender/device/id/item/@extension");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setSend(node.getNodeValue());
|
||||
}
|
||||
//住院流水号
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/item/@extension");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setJzh(node.getNodeValue());
|
||||
}
|
||||
//住院号标识
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/id/item/@extension");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setInpatientNo( node.getNodeValue());
|
||||
}
|
||||
//住院次数[]
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/lengthOfStayQuantity[@unit='次']/@value");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setAdmissTimes(node.getNodeValue());
|
||||
}
|
||||
//姓名
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/subject/patient/patientPerson/name/item/part/@value");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setName(node.getNodeValue());
|
||||
}
|
||||
//入院日期时间
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/low/@value");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setAdmissDate(node.getNodeValue());
|
||||
}
|
||||
//出院日期时间
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/effectiveTime/high/@value");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setDisDate(node.getNodeValue());
|
||||
}
|
||||
//入院诊断科室名称[]
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='入院诊断']/section/entry[@displayName='入院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setAdmissDeptName(node.getTextContent());
|
||||
}
|
||||
//出院诊断科室名称[]
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/component[@displayName='出院诊断']/section/entry[@displayName='出院诊断-西医条目']/observation/performer/assignedEntity/representedOrganization/name");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setDisDeptName(node.getTextContent());
|
||||
}
|
||||
//主治医师[]
|
||||
node = xml.getNode("/PRPA_HIP0032/controlActProcess/subject/encounterEvent/authenticator[@displayName='主治医师']/assignedEntity/assignedPerson/name");
|
||||
if(Func.isNotEmpty(node)){
|
||||
dto.setAttendingName(node.getTextContent());
|
||||
}
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue