|
|
|
@ -5,19 +5,27 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import com.docus.core.util.DateUtil;
|
|
|
|
|
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.collection.dto.BedDoctorDto;
|
|
|
|
|
import com.docus.server.collection.dto.TBasicDto;
|
|
|
|
|
import com.docus.server.collection.entity.TBasic;
|
|
|
|
|
import com.docus.server.collection.entity.TBasicExtend;
|
|
|
|
|
import com.docus.server.collection.mapper.TBasicMapper;
|
|
|
|
|
import com.docus.server.collection.service.ITBasicService;
|
|
|
|
|
import com.docus.server.collection.util.BackPushEventEntity;
|
|
|
|
|
import com.docus.server.report.entity.MaternalInfantRelationship;
|
|
|
|
|
import com.docus.server.rpc.SdRyHospitalRpc;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
@ -45,56 +53,64 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
@Resource
|
|
|
|
|
private ThreadPoolExecutor threadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ApplicationEventPublisher applicationEventPublisher;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public void setTBasic(TBasicDto tBasicDto) throws Exception {
|
|
|
|
|
//判断jzh是否重复
|
|
|
|
|
Integer num = tBasicMapper.selectOne(tBasicDto.getJzh());
|
|
|
|
|
if (num>0) {
|
|
|
|
|
if (num > 0) {
|
|
|
|
|
updateTBasic(tBasicDto);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Long patientId = idService.getDateSeq();
|
|
|
|
|
|
|
|
|
|
//数据类型转化,格式处理
|
|
|
|
|
Date admissDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getAdmissDate())){
|
|
|
|
|
Date admissDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getAdmissDate())) {
|
|
|
|
|
admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
Date disDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getDisDate())){
|
|
|
|
|
Date disDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getDisDate())) {
|
|
|
|
|
disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
String admissTimesStr = tBasicDto.getAdmissTimes();
|
|
|
|
|
Integer admissTimes=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissTimesStr)){
|
|
|
|
|
admissTimes=Integer.parseInt(admissTimesStr);
|
|
|
|
|
Integer admissTimes = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissTimesStr)) {
|
|
|
|
|
admissTimes = Integer.parseInt(admissTimesStr);
|
|
|
|
|
}
|
|
|
|
|
String ageStr = tBasicDto.getAge();
|
|
|
|
|
if(Func.isNotEmpty(ageStr)){
|
|
|
|
|
ageStr =ageStr.substring(0,ageStr.length()-1);
|
|
|
|
|
if (Func.isNotEmpty(ageStr)) {
|
|
|
|
|
ageStr = ageStr.substring(0, ageStr.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
Integer age=null;
|
|
|
|
|
if(NumberUtil.isInteger(ageStr)){
|
|
|
|
|
age=Integer.parseInt(ageStr);
|
|
|
|
|
Integer age = null;
|
|
|
|
|
if (NumberUtil.isInteger(ageStr)) {
|
|
|
|
|
age = Integer.parseInt(ageStr);
|
|
|
|
|
}
|
|
|
|
|
String sexName=tBasicDto.getSexName();
|
|
|
|
|
if(Func.isNotEmpty(sexName)&&sexName.length()>1){
|
|
|
|
|
sexName=sexName.substring(0,1);
|
|
|
|
|
String sexName = tBasicDto.getSexName();
|
|
|
|
|
if (Func.isNotEmpty(sexName) && sexName.length() > 1) {
|
|
|
|
|
sexName = sexName.substring(0, 1);
|
|
|
|
|
}
|
|
|
|
|
String admissDaysStr = tBasicDto.getAdmissDays();
|
|
|
|
|
Integer admissDays=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissDaysStr)){
|
|
|
|
|
admissDays=Integer.parseInt(admissDaysStr);
|
|
|
|
|
Integer admissDays = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissDaysStr)) {
|
|
|
|
|
admissDays = Integer.parseInt(admissDaysStr);
|
|
|
|
|
}
|
|
|
|
|
String isDeadStr = tBasicDto.getIsDead();
|
|
|
|
|
Integer isDead=0;
|
|
|
|
|
if("死亡".equals(isDeadStr)){
|
|
|
|
|
isDead=1;
|
|
|
|
|
Integer isDead = 0;
|
|
|
|
|
if ("告死亡".equals(isDeadStr)) {
|
|
|
|
|
isDead = 1;
|
|
|
|
|
}
|
|
|
|
|
String leaveMethodStr = tBasicDto.getLeaveMethod();
|
|
|
|
|
Integer leaveMethod = null;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(leaveMethodStr)&&NumberUtil.isInteger(leaveMethodStr)) {
|
|
|
|
|
leaveMethod=Integer.parseInt(leaveMethodStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装数据
|
|
|
|
|
TBasic tBasic=new TBasic();
|
|
|
|
|
TBasic tBasic = new TBasic();
|
|
|
|
|
tBasic.setPatientId(patientId.toString());
|
|
|
|
|
tBasic.setJzh(tBasicDto.getJzh());
|
|
|
|
|
tBasic.setInpatientNo(tBasicDto.getInpatientNo());
|
|
|
|
@ -120,22 +136,23 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
|
|
|
|
|
//设置是否婴儿
|
|
|
|
|
String inpatientNo = tBasicDto.getInpatientNo();
|
|
|
|
|
if(inpatientNo.contains("B")||inpatientNo.contains("b")){
|
|
|
|
|
if (inpatientNo.contains("B") || inpatientNo.contains("b")) {
|
|
|
|
|
tBasic.setIsOther(1);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
tBasic.setIsOther(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TBasicExtend tBasicExtend=new TBasicExtend();
|
|
|
|
|
String sdryIndex = tBasicDto.getSdryIndex();
|
|
|
|
|
TBasicExtend tBasicExtend = new TBasicExtend();
|
|
|
|
|
tBasicExtend.setPatientId(patientId.toString());
|
|
|
|
|
tBasicExtend.setWardCode(tBasicDto.getWardCode());
|
|
|
|
|
tBasicExtend.setWardName(tBasicDto.getWardName());
|
|
|
|
|
tBasicExtend.setSdryIndex(tBasicDto.getSdryIndex());
|
|
|
|
|
tBasicExtend.setSdryIndex(sdryIndex == null ? null : sdryIndex.replace("z", "").replace("m", ""));
|
|
|
|
|
tBasicExtend.setLeaveMethod(leaveMethod);
|
|
|
|
|
|
|
|
|
|
//持久化
|
|
|
|
|
tBasicMapper.insert(tBasic);
|
|
|
|
|
tBasicMapper.insertExtend(tBasicExtend);
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(),tBasic.getAdmissTimes());
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(), tBasic.getAdmissTimes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -149,44 +166,48 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//数据类型转化,格式处理
|
|
|
|
|
Date admissDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getAdmissDate())){
|
|
|
|
|
Date admissDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getAdmissDate())) {
|
|
|
|
|
admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
Date disDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getDisDate())){
|
|
|
|
|
Date disDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getDisDate())) {
|
|
|
|
|
disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
String admissTimesStr = tBasicDto.getAdmissTimes();
|
|
|
|
|
Integer admissTimes=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissTimesStr)){
|
|
|
|
|
admissTimes=Integer.parseInt(admissTimesStr);
|
|
|
|
|
Integer admissTimes = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissTimesStr)) {
|
|
|
|
|
admissTimes = Integer.parseInt(admissTimesStr);
|
|
|
|
|
}
|
|
|
|
|
String ageStr = tBasicDto.getAge();
|
|
|
|
|
if(Func.isNotEmpty(ageStr)){
|
|
|
|
|
ageStr =ageStr.substring(0,ageStr.length()-1);
|
|
|
|
|
if (Func.isNotEmpty(ageStr)) {
|
|
|
|
|
ageStr = ageStr.substring(0, ageStr.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
Integer age=null;
|
|
|
|
|
if(NumberUtil.isInteger(ageStr)){
|
|
|
|
|
age=Integer.parseInt(ageStr);
|
|
|
|
|
Integer age = null;
|
|
|
|
|
if (NumberUtil.isInteger(ageStr)) {
|
|
|
|
|
age = Integer.parseInt(ageStr);
|
|
|
|
|
}
|
|
|
|
|
String sexName=tBasicDto.getSexName();
|
|
|
|
|
if(Func.isNotEmpty(sexName)&&sexName.length()>1){
|
|
|
|
|
sexName=sexName.substring(0,1);
|
|
|
|
|
String sexName = tBasicDto.getSexName();
|
|
|
|
|
if (Func.isNotEmpty(sexName) && sexName.length() > 1) {
|
|
|
|
|
sexName = sexName.substring(0, 1);
|
|
|
|
|
}
|
|
|
|
|
String admissDaysStr = tBasicDto.getAdmissDays();
|
|
|
|
|
Integer admissDays=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissDaysStr)){
|
|
|
|
|
admissDays=Integer.parseInt(admissDaysStr);
|
|
|
|
|
Integer admissDays = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissDaysStr)) {
|
|
|
|
|
admissDays = Integer.parseInt(admissDaysStr);
|
|
|
|
|
}
|
|
|
|
|
String isDeadStr = tBasicDto.getIsDead();
|
|
|
|
|
Integer isDead=0;
|
|
|
|
|
if("死亡".equals(isDeadStr)){
|
|
|
|
|
isDead=1;
|
|
|
|
|
Integer isDead = 0;
|
|
|
|
|
if ("死亡".equals(isDeadStr)||"告死亡".equals(isDeadStr)) {
|
|
|
|
|
isDead = 1;
|
|
|
|
|
}
|
|
|
|
|
String leaveMethodStr = tBasicDto.getLeaveMethod();
|
|
|
|
|
Integer leaveMethod = null;
|
|
|
|
|
if (ObjectUtil.isNotEmpty(leaveMethodStr)&&NumberUtil.isInteger(leaveMethodStr)) {
|
|
|
|
|
leaveMethod=Integer.parseInt(leaveMethodStr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装数据
|
|
|
|
|
TBasic tBasic=new TBasic();
|
|
|
|
|
TBasic tBasic = new TBasic();
|
|
|
|
|
|
|
|
|
|
tBasic.setJzh(tBasicDto.getJzh());
|
|
|
|
|
tBasic.setPatientId(patientId);
|
|
|
|
@ -213,23 +234,113 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
tBasic.setIsOther(tBasicDto.getIsOther());
|
|
|
|
|
//设置是否婴儿
|
|
|
|
|
String inpatientNo = tBasicDto.getInpatientNo();
|
|
|
|
|
if(tBasic.getIsOther()==0&&(inpatientNo.contains("B")||inpatientNo.contains("b"))){
|
|
|
|
|
if (tBasic.getIsOther() == 0 && (inpatientNo.contains("B") || inpatientNo.contains("b"))) {
|
|
|
|
|
tBasic.setIsOther(1);
|
|
|
|
|
}else if(tBasic.getIsOther()==0){
|
|
|
|
|
} else if (tBasic.getIsOther() == 0) {
|
|
|
|
|
tBasic.setIsOther(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String sdryIndex = tBasicDto.getSdryIndex();
|
|
|
|
|
TBasicExtend tBasicExtend = new TBasicExtend();
|
|
|
|
|
tBasicExtend.setPatientId(patientId);
|
|
|
|
|
tBasicExtend.setWardCode(tBasicDto.getWardCode());
|
|
|
|
|
tBasicExtend.setWardName(tBasicDto.getWardName());
|
|
|
|
|
tBasicExtend.setSdryIndex(sdryIndex == null ? null : sdryIndex.replace("z", "").replace("m",""));
|
|
|
|
|
tBasicExtend.setSdryIndex(sdryIndex == null ? null : sdryIndex.replace("z", "").replace("m", ""));
|
|
|
|
|
tBasicExtend.setLeaveMethod(leaveMethod);
|
|
|
|
|
|
|
|
|
|
//持久化
|
|
|
|
|
tBasicMapper.update(tBasic);
|
|
|
|
|
tBasicMapper.updateExtend(tBasicExtend);
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(),tBasic.getAdmissTimes());
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(), tBasic.getAdmissTimes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void cancelHospital(TBasicDto tBasicDto) throws Exception {
|
|
|
|
|
//判断jzh是否存在
|
|
|
|
|
String patientId = tBasicMapper.getPatientId(tBasicDto.getJzh());
|
|
|
|
|
if (Func.isEmpty(patientId)) {
|
|
|
|
|
throw new BaseException("取消住院出错 jzh:"+tBasicDto.getJzh()+"不存在记录");
|
|
|
|
|
}
|
|
|
|
|
//数据类型转化,格式处理
|
|
|
|
|
//数据类型转化,格式处理
|
|
|
|
|
Date admissDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getAdmissDate())) {
|
|
|
|
|
admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
Date disDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getDisDate())) {
|
|
|
|
|
disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
String admissTimesStr = tBasicDto.getAdmissTimes();
|
|
|
|
|
Integer admissTimes = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissTimesStr)) {
|
|
|
|
|
admissTimes = Integer.parseInt(admissTimesStr);
|
|
|
|
|
}
|
|
|
|
|
String ageStr = tBasicDto.getAge();
|
|
|
|
|
if (Func.isNotEmpty(ageStr)) {
|
|
|
|
|
ageStr = ageStr.substring(0, ageStr.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
Integer age = null;
|
|
|
|
|
if (NumberUtil.isInteger(ageStr)) {
|
|
|
|
|
age = Integer.parseInt(ageStr);
|
|
|
|
|
}
|
|
|
|
|
String sexName = tBasicDto.getSexName();
|
|
|
|
|
if (Func.isNotEmpty(sexName) && sexName.length() > 1) {
|
|
|
|
|
sexName = sexName.substring(0, 1);
|
|
|
|
|
}
|
|
|
|
|
String admissDaysStr = tBasicDto.getAdmissDays();
|
|
|
|
|
Integer admissDays = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissDaysStr)) {
|
|
|
|
|
admissDays = Integer.parseInt(admissDaysStr);
|
|
|
|
|
}
|
|
|
|
|
String isDeadStr = tBasicDto.getIsDead();
|
|
|
|
|
Integer isDead = 0;
|
|
|
|
|
if ("死亡".equals(isDeadStr)) {
|
|
|
|
|
isDead = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装数据
|
|
|
|
|
TBasic tBasic = new TBasic();
|
|
|
|
|
|
|
|
|
|
tBasic.setJzh(tBasicDto.getJzh());
|
|
|
|
|
tBasic.setPatientId(patientId);
|
|
|
|
|
tBasic.setInpatientNo(tBasicDto.getInpatientNo());
|
|
|
|
|
tBasic.setAdmissTimes(admissTimes);
|
|
|
|
|
tBasic.setName(tBasicDto.getName());
|
|
|
|
|
tBasic.setAdmissDate(admissDate);
|
|
|
|
|
tBasic.setDisDate(disDate);
|
|
|
|
|
tBasic.setAdmissDept(tBasicDto.getAdmissDept());
|
|
|
|
|
tBasic.setAdmissDeptName(tBasicDto.getAdmissDeptName());
|
|
|
|
|
tBasic.setDisDeptName(tBasicDto.getDisDeptName());
|
|
|
|
|
tBasic.setAttending(tBasicDto.getAttending());
|
|
|
|
|
tBasic.setAttendingName(tBasicDto.getAttendingName());
|
|
|
|
|
tBasic.setAge(age);
|
|
|
|
|
tBasic.setSex(tBasicDto.getSex());
|
|
|
|
|
tBasic.setIdCard(tBasicDto.getIdCard());
|
|
|
|
|
tBasic.setDisDept(tBasicDto.getDisDept());
|
|
|
|
|
tBasic.setSexName(sexName);
|
|
|
|
|
tBasic.setBedNum(tBasicDto.getBedNum());
|
|
|
|
|
tBasic.setAdmissDays(admissDays);
|
|
|
|
|
tBasic.setIsDead(isDead);
|
|
|
|
|
tBasic.setWardCode(tBasicDto.getWardCode());
|
|
|
|
|
tBasic.setWardName(tBasicDto.getWardName());
|
|
|
|
|
tBasic.setIsOther(tBasicDto.getIsOther());
|
|
|
|
|
//设置是否婴儿
|
|
|
|
|
String inpatientNo = tBasicDto.getInpatientNo();
|
|
|
|
|
if (tBasic.getIsOther() == 0 && (inpatientNo.contains("B") || inpatientNo.contains("b"))) {
|
|
|
|
|
tBasic.setIsOther(1);
|
|
|
|
|
} else if (tBasic.getIsOther() == 0) {
|
|
|
|
|
tBasic.setIsOther(0);
|
|
|
|
|
}
|
|
|
|
|
//是否取消住院
|
|
|
|
|
if ("2".equals(tBasicDto.getStatu())) {
|
|
|
|
|
applicationEventPublisher.publishEvent(new BackPushEventEntity(this, tBasic));
|
|
|
|
|
tBasic.setDisDate(null);
|
|
|
|
|
//持久化
|
|
|
|
|
tBasicMapper.cancelHospital(tBasic);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
throw new BaseException("未取消住院,状态 statusCode:"+tBasicDto.getStatu());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -240,50 +351,51 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
if (Func.isEmpty(patientId)) {
|
|
|
|
|
throw new BaseException("数据不存在,更新失败");
|
|
|
|
|
}
|
|
|
|
|
if("2".equals(tBasicDto.getStatu())){
|
|
|
|
|
if ("2".equals(tBasicDto.getStatu())) {
|
|
|
|
|
tBasicMapper.deleteByPatientId(patientId);
|
|
|
|
|
log.info("入院信息删除jzh:{},patientId:{},statusCode:{}",tBasicDto.getJzh(),patientId,tBasicDto.getStatu());
|
|
|
|
|
tBasicMapper.deleteExtend(patientId);
|
|
|
|
|
log.info("入院信息删除jzh:{},patientId:{},statusCode:{}", tBasicDto.getJzh(), patientId, tBasicDto.getStatu());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//数据类型转化,格式处理
|
|
|
|
|
Date admissDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getAdmissDate())){
|
|
|
|
|
Date admissDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getAdmissDate())) {
|
|
|
|
|
admissDate = Func.parseDate(tBasicDto.getAdmissDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
Date disDate=null;
|
|
|
|
|
if(Func.isNotEmpty(tBasicDto.getDisDate())){
|
|
|
|
|
Date disDate = null;
|
|
|
|
|
if (Func.isNotEmpty(tBasicDto.getDisDate())) {
|
|
|
|
|
disDate = Func.parseDate(tBasicDto.getDisDate(), DateUtil.PATTERN_DATETIME_MINI);
|
|
|
|
|
}
|
|
|
|
|
String admissTimesStr = tBasicDto.getAdmissTimes();
|
|
|
|
|
Integer admissTimes=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissTimesStr)){
|
|
|
|
|
admissTimes=Integer.parseInt(admissTimesStr);
|
|
|
|
|
Integer admissTimes = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissTimesStr)) {
|
|
|
|
|
admissTimes = Integer.parseInt(admissTimesStr);
|
|
|
|
|
}
|
|
|
|
|
String ageStr = tBasicDto.getAge();
|
|
|
|
|
if(Func.isNotEmpty(ageStr)){
|
|
|
|
|
ageStr =ageStr.substring(0,ageStr.length()-1);
|
|
|
|
|
if (Func.isNotEmpty(ageStr)) {
|
|
|
|
|
ageStr = ageStr.substring(0, ageStr.length() - 1);
|
|
|
|
|
}
|
|
|
|
|
Integer age=null;
|
|
|
|
|
if(NumberUtil.isInteger(ageStr)){
|
|
|
|
|
age=Integer.parseInt(ageStr);
|
|
|
|
|
Integer age = null;
|
|
|
|
|
if (NumberUtil.isInteger(ageStr)) {
|
|
|
|
|
age = Integer.parseInt(ageStr);
|
|
|
|
|
}
|
|
|
|
|
String sexName=tBasicDto.getSexName();
|
|
|
|
|
if(Func.isNotEmpty(sexName)&&sexName.length()>1){
|
|
|
|
|
sexName=sexName.substring(0,1);
|
|
|
|
|
String sexName = tBasicDto.getSexName();
|
|
|
|
|
if (Func.isNotEmpty(sexName) && sexName.length() > 1) {
|
|
|
|
|
sexName = sexName.substring(0, 1);
|
|
|
|
|
}
|
|
|
|
|
String admissDaysStr = tBasicDto.getAdmissDays();
|
|
|
|
|
Integer admissDays=null;
|
|
|
|
|
if(NumberUtil.isInteger(admissDaysStr)){
|
|
|
|
|
admissDays=Integer.parseInt(admissDaysStr);
|
|
|
|
|
Integer admissDays = null;
|
|
|
|
|
if (NumberUtil.isInteger(admissDaysStr)) {
|
|
|
|
|
admissDays = Integer.parseInt(admissDaysStr);
|
|
|
|
|
}
|
|
|
|
|
String isDeadStr = tBasicDto.getIsDead();
|
|
|
|
|
Integer isDead=0;
|
|
|
|
|
if("死亡".equals(isDeadStr)){
|
|
|
|
|
isDead=1;
|
|
|
|
|
Integer isDead = 0;
|
|
|
|
|
if ("死亡".equals(isDeadStr)) {
|
|
|
|
|
isDead = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//组装数据
|
|
|
|
|
TBasic tBasic=new TBasic();
|
|
|
|
|
TBasic tBasic = new TBasic();
|
|
|
|
|
|
|
|
|
|
tBasic.setJzh(tBasicDto.getJzh());
|
|
|
|
|
tBasic.setPatientId(patientId);
|
|
|
|
@ -310,40 +422,69 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
tBasic.setIsOther(tBasicDto.getIsOther());
|
|
|
|
|
//设置是否婴儿
|
|
|
|
|
String inpatientNo = tBasicDto.getInpatientNo();
|
|
|
|
|
if(tBasic.getIsOther()==0&&(inpatientNo.contains("B")||inpatientNo.contains("b"))){
|
|
|
|
|
if (tBasic.getIsOther() == 0 && (inpatientNo.contains("B") || inpatientNo.contains("b"))) {
|
|
|
|
|
tBasic.setIsOther(1);
|
|
|
|
|
}else if(tBasic.getIsOther()==0){
|
|
|
|
|
} else if (tBasic.getIsOther() == 0) {
|
|
|
|
|
tBasic.setIsOther(0);
|
|
|
|
|
}
|
|
|
|
|
String sdryIndex = tBasicDto.getSdryIndex();
|
|
|
|
|
TBasicExtend tBasicExtend=new TBasicExtend();
|
|
|
|
|
TBasicExtend tBasicExtend = new TBasicExtend();
|
|
|
|
|
tBasicExtend.setPatientId(patientId);
|
|
|
|
|
tBasicExtend.setWardCode(tBasicDto.getWardCode());
|
|
|
|
|
tBasicExtend.setWardName(tBasicDto.getWardName());
|
|
|
|
|
tBasicExtend.setSdryIndex(sdryIndex==null?null:sdryIndex.replace("z","").replace("m",""));
|
|
|
|
|
tBasicExtend.setSdryIndex(sdryIndex == null ? null : sdryIndex.replace("z", "").replace("m", ""));
|
|
|
|
|
|
|
|
|
|
//持久化
|
|
|
|
|
tBasicMapper.update(tBasic);
|
|
|
|
|
tBasicMapper.updateExtend(tBasicExtend);
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(),tBasic.getAdmissTimes());
|
|
|
|
|
confirmAndUpdIcuRecordState(tBasic.getInpatientNo(), tBasic.getAdmissTimes());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setBedDoctor(BedDoctorDto dto) throws Exception {
|
|
|
|
|
String inpatientNo = dto.getInpatientNo();
|
|
|
|
|
Integer admissTimes = dto.getAdmissTimes();
|
|
|
|
|
String bedDoctor = dto.getBedDoctor();
|
|
|
|
|
String bedDoctorName = dto.getBedDoctorName();
|
|
|
|
|
if(Func.isEmpty(inpatientNo)){
|
|
|
|
|
throw new BaseException("病案号为空,更新失败");
|
|
|
|
|
}
|
|
|
|
|
if(Func.isEmpty(admissTimes)){
|
|
|
|
|
throw new BaseException("住院次数为空,更新失败");
|
|
|
|
|
}
|
|
|
|
|
if(Func.isEmpty(bedDoctor)){
|
|
|
|
|
throw new BaseException("管床医生工号为空,更新失败");
|
|
|
|
|
}
|
|
|
|
|
if(Func.isEmpty(bedDoctorName)){
|
|
|
|
|
throw new BaseException("管床医生姓名为空,更新失败");
|
|
|
|
|
}
|
|
|
|
|
//判断病案是否存在
|
|
|
|
|
List<String> patientIds = tBasicMapper.getPatientIds(inpatientNo,admissTimes);
|
|
|
|
|
if (Func.isEmpty(patientIds)) {
|
|
|
|
|
throw new BaseException("数据不存在,更新失败");
|
|
|
|
|
}
|
|
|
|
|
tBasicMapper.setBedDoctor(patientIds,bedDoctor,bedDoctorName);
|
|
|
|
|
log.info("主键{}管床医生更新成功",patientIds.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TBasic getSdRyParentPatientInfo(String babyPatientId) {
|
|
|
|
|
// 宝宝索引
|
|
|
|
|
String babyIndex=tBasicMapper.getSdRyIndex(babyPatientId);
|
|
|
|
|
if (Func.isBlank(babyIndex)){
|
|
|
|
|
String babyIndex = tBasicMapper.getSdRyIndex(babyPatientId);
|
|
|
|
|
if (Func.isBlank(babyIndex)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 宝宝索引查妈妈索引
|
|
|
|
|
String parentSdRyIndex= tBasicMapper.getParentSdRyIndex(babyIndex);
|
|
|
|
|
if(Func.isBlank(parentSdRyIndex)){
|
|
|
|
|
// 宝宝索引查妈妈索引 和住院次数
|
|
|
|
|
MaternalInfantRelationship infantRelationship = tBasicMapper.getMaternalInfantRelationship(babyIndex);
|
|
|
|
|
|
|
|
|
|
if (Objects.isNull(infantRelationship) || Func.isBlank(infantRelationship.getMomId())) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 通过索引查病案主键
|
|
|
|
|
String parentPatientId=tBasicMapper.getPatientIdBySdRyIndex(parentSdRyIndex);
|
|
|
|
|
if(Func.isBlank(parentPatientId)){
|
|
|
|
|
String parentSdRyIndex = infantRelationship.getMomId();
|
|
|
|
|
// 通过索引和住院次数查病案主键
|
|
|
|
|
String parentPatientId = tBasicMapper.getPatientIdBySdRyIndexAndAdmissTimes(parentSdRyIndex, infantRelationship.getParentTimes());
|
|
|
|
|
if (Func.isBlank(parentPatientId)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 通过病案主键查基础信息
|
|
|
|
@ -352,20 +493,53 @@ public class TBasicServiceImpl implements ITBasicService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean getIsBabyBasic(String patientId) {
|
|
|
|
|
TBasic tBasic= tBasicMapper.getByPatientId(patientId);
|
|
|
|
|
TBasic tBasic = tBasicMapper.getByPatientId(patientId);
|
|
|
|
|
return Func.isNotEmpty(tBasic) && Func.isNotBlank(tBasic.getInpatientNo()) && tBasic.getInpatientNo().toUpperCase().contains("B");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Integer matchingAdmissTimesByInpNoAndReportTime(String inpatientNo, Date reportDate, long timeRangeAddedHour) {
|
|
|
|
|
List<TBasic> basicList = tBasicMapper.selectBasicListByInpNo(inpatientNo);
|
|
|
|
|
if (Func.isEmpty(basicList)) {
|
|
|
|
|
log.warn("住院号:{} 未查询到患者基础数据!", inpatientNo);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 转换毫秒范围进行比较运算
|
|
|
|
|
long timeRangeAddedMillis = timeRangeAddedHour * 60 * 60 * 1000;
|
|
|
|
|
long reportDateTimeMillis = reportDate.getTime();
|
|
|
|
|
for (TBasic basic : basicList) {
|
|
|
|
|
Date admissDate = basic.getAdmissDate();
|
|
|
|
|
Date disDate = basic.getDisDate();
|
|
|
|
|
if (Objects.isNull(admissDate)) {
|
|
|
|
|
log.warn("住院号:{} 有入院时间为空的基础数据!", inpatientNo);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 入院时间大于报告时间,不匹配
|
|
|
|
|
if (admissDate.getTime() > reportDateTimeMillis) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// 报告时间大于等于入院时间,出院时间为空或者 报告时间小于等于出院时间+时间范围差,则匹配该条数据
|
|
|
|
|
if (Objects.isNull(disDate) || reportDateTimeMillis <= (disDate.getTime() + timeRangeAddedMillis)) {
|
|
|
|
|
if (Objects.isNull(basic.getAdmissTimes())) {
|
|
|
|
|
log.warn("住院号:{} ,报告时间:{},范围添加 {} 小时,匹配患者数据patientId为:{},但是住院次数为空!", inpatientNo, Func.formatDateTime(reportDate), timeRangeAddedHour, basic.getPatientId());
|
|
|
|
|
}
|
|
|
|
|
return basic.getAdmissTimes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
log.warn("住院号:{},报告时间:{},范围添加 {} 小时,未匹配到患者基础数据具体住院次数!", inpatientNo, Func.formatDateTime(reportDate), timeRangeAddedHour);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void confirmAndUpdIcuRecordState(String inpatientNo,Integer admissTimes){
|
|
|
|
|
threadPoolExecutor.execute(()->{
|
|
|
|
|
public void confirmAndUpdIcuRecordState(String inpatientNo, Integer admissTimes) {
|
|
|
|
|
threadPoolExecutor.execute(() -> {
|
|
|
|
|
// 此处异步,睡眠一秒保证事务提交
|
|
|
|
|
try {
|
|
|
|
|
TimeUnit.SECONDS.sleep(1);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
sdRyHospitalRpc.confirmAndUpdIcuRecordState(inpatientNo,admissTimes);
|
|
|
|
|
sdRyHospitalRpc.confirmAndUpdIcuRecordState(inpatientNo, admissTimes);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|