|
|
@ -3,6 +3,7 @@ package com.ccsens.tcm.service; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ccsens.tcm.bean.dto.BiologicalSamplesDto; |
|
|
|
import com.ccsens.tcm.bean.dto.ConRecDto; |
|
|
|
import com.ccsens.tcm.bean.dto.PatientDto; |
|
|
@ -81,16 +82,7 @@ public class PatientService implements IPatientService { |
|
|
|
} |
|
|
|
log.info("医院:{},对照组:{}", hospital, inpatient); |
|
|
|
// 生成编号
|
|
|
|
DecimalFormat df=new DecimalFormat("000"); |
|
|
|
String num = hospital.getCode() + inpatient.getCode() + df.format(param.getCodeNum()); |
|
|
|
log.info("编号:{}", num); |
|
|
|
// 判断住院号是否存在
|
|
|
|
PatientInformationExample patientInformationExample=new PatientInformationExample(); |
|
|
|
patientInformationExample.createCriteria().andCodeEqualTo(num); |
|
|
|
long l = patientInformationMapper.countByExample(patientInformationExample); |
|
|
|
if(l>0){ |
|
|
|
throw new BaseException(CodeEnum.ZHUYUANIDCHONGFU); |
|
|
|
} |
|
|
|
String num = getNumber(inpatient.getCode(), hospital.getCode(), param.getCodeNum(), null); |
|
|
|
|
|
|
|
|
|
|
|
PatientInformation patientInformation=new PatientInformation(); |
|
|
@ -489,5 +481,60 @@ public class PatientService implements IPatientService { |
|
|
|
return new PageInfo<>(recentAnalysisVOS); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PatientVo.Basic getById(PatientDto.Id param, Long userId) { |
|
|
|
PatientInformation information = patientInformationMapper.selectByPrimaryKey(param.getPatientId()); |
|
|
|
if (information == null) { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
PatientVo.Basic basic = new PatientVo.Basic(); |
|
|
|
BeanUtils.copyProperties(information, basic); |
|
|
|
basic.setCodeNum(StrUtil.isNotBlank(basic.getCode()) && basic.getCode().length() > 2 ? basic.getCode().substring(2) : ""); |
|
|
|
return basic; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void upPatient(PatientDto.UpdatePatient param, Long userId) { |
|
|
|
PatientInformation information = patientInformationMapper.selectByPrimaryKey(param.getId()); |
|
|
|
if (information == null) { |
|
|
|
log.info("没有对应的病例信息:{}", param.getId()); |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
Inpatient inpatient = inpatientDao.selectByPrimaryKey(param.getInpatientId()); |
|
|
|
if (inpatient == null) { |
|
|
|
log.info("没有对照组信息:{}", param.getInpatientId()); |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
|
log.info("病例信息:{},对照组:{}", information, inpatient); |
|
|
|
// 获取医院
|
|
|
|
Hospital hospital = hospitalMapper.selectByPrimaryKey(information.getHospitalId()); |
|
|
|
// 生成编号
|
|
|
|
String num = getNumber(inpatient.getCode(), hospital.getCode(), param.getCodeNum(), information.getId()); |
|
|
|
// 修改数据
|
|
|
|
PatientInformation patientInformation=new PatientInformation(); |
|
|
|
patientInformation.setId(param.getId()); |
|
|
|
patientInformation.setHospitalization(param.getHospitalization()); |
|
|
|
patientInformation.setInpatientId(param.getInpatientId()); |
|
|
|
patientInformation.setCode(num); |
|
|
|
patientInformationMapper.updateByPrimaryKeySelective(patientInformation); |
|
|
|
} |
|
|
|
|
|
|
|
private String getNumber(String inpatientCode, String hospitalCode, int codeNum, Long id) { |
|
|
|
DecimalFormat df = new DecimalFormat("000"); |
|
|
|
String num = hospitalCode + inpatientCode + df.format(codeNum); |
|
|
|
log.info("编号:{}", num); |
|
|
|
// 判断编号是否存在
|
|
|
|
PatientInformationExample patientInformationExample = new PatientInformationExample(); |
|
|
|
PatientInformationExample.Criteria criteria = patientInformationExample.createCriteria().andCodeEqualTo(num); |
|
|
|
if (id != null && id != 0) { |
|
|
|
criteria.andIdNotEqualTo(id); |
|
|
|
} |
|
|
|
long l = patientInformationMapper.countByExample(patientInformationExample); |
|
|
|
if (l > 0) { |
|
|
|
throw new BaseException(CodeEnum.ZHUYUANIDCHONGFU); |
|
|
|
} |
|
|
|
return num; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|