|
@@ -3,10 +3,8 @@ package org.dromara.web.service.impl;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.enums.biz.PatientType;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
@@ -14,7 +12,6 @@ import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
|
|
|
-import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.system.config.RedisUtil;
|
|
|
import org.dromara.system.domain.SysDept;
|
|
|
import org.dromara.system.domain.vo.SysDeptVo;
|
|
@@ -26,20 +23,18 @@ import org.dromara.system.service.ISysDeptService;
|
|
|
import org.dromara.system.service.ISysDiseaseLabelService;
|
|
|
import org.dromara.web.domain.NutritionDiagnosis;
|
|
|
import org.dromara.web.domain.PatientAccount;
|
|
|
+import org.dromara.web.domain.PatientMedicalRecord;
|
|
|
import org.dromara.web.domain.SysPatient;
|
|
|
-import org.dromara.web.domain.TreatmentUser;
|
|
|
-import org.dromara.web.domain.bo.TreatmentUserBo;
|
|
|
+import org.dromara.web.domain.bo.PatientMedicalRecordBo;
|
|
|
import org.dromara.web.domain.vo.NutritionDiagnosisVo;
|
|
|
-import org.dromara.web.domain.vo.TreatmentUserVo;
|
|
|
+import org.dromara.web.domain.vo.PatientMedicalRecordVo;
|
|
|
import org.dromara.web.mapper.NutritionDiagnosisMapper;
|
|
|
import org.dromara.web.mapper.PatientAccountMapper;
|
|
|
import org.dromara.web.mapper.SysPatientMapper;
|
|
|
-import org.dromara.web.mapper.TreatmentUserMapper;
|
|
|
-import org.dromara.web.service.ITreatmentUserService;
|
|
|
+import org.dromara.web.mapper.PatientMedicalRecordMapper;
|
|
|
+import org.dromara.web.service.IPatientMedicalRecordService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.net.URLDecoder;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -52,9 +47,9 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
+public class PatientMedicalRecordServiceImpl implements IPatientMedicalRecordService {
|
|
|
|
|
|
- private final TreatmentUserMapper baseMapper;
|
|
|
+ private final PatientMedicalRecordMapper baseMapper;
|
|
|
|
|
|
private final ISysDeptService deptService;
|
|
|
|
|
@@ -77,16 +72,16 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
* @return 【请填写功能名称】
|
|
|
*/
|
|
|
@Override
|
|
|
- public TreatmentUserVo queryById(Long id) {
|
|
|
- TreatmentUserVo treatmentUserVo = baseMapper.selectVoById(id);
|
|
|
+ public PatientMedicalRecordVo queryById(Long id) {
|
|
|
+ PatientMedicalRecordVo patientMedicalRecordVo = baseMapper.selectVoById(id);
|
|
|
SysDeptVo deptVo = null;
|
|
|
- if (null != treatmentUserVo) {
|
|
|
- deptVo = deptService.selectDeptById(treatmentUserVo.getDoorId());
|
|
|
+ if (null != patientMedicalRecordVo) {
|
|
|
+ deptVo = deptService.selectDeptById(patientMedicalRecordVo.getDoorId());
|
|
|
if (null != deptVo) {
|
|
|
- treatmentUserVo.setDeptName(deptVo.getDeptName());
|
|
|
+ patientMedicalRecordVo.setDeptName(deptVo.getDeptName());
|
|
|
}
|
|
|
}
|
|
|
- return treatmentUserVo;
|
|
|
+ return patientMedicalRecordVo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -97,13 +92,13 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
* @return 【请填写功能名称】分页列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public TableDataInfo<TreatmentUserVo> queryPageList(TreatmentUserBo bo, PageQuery pageQuery) {
|
|
|
- LambdaQueryWrapper<TreatmentUser> lqw = buildQueryWrapper(bo);
|
|
|
+ public TableDataInfo<PatientMedicalRecordVo> queryPageList(PatientMedicalRecordBo bo, PageQuery pageQuery) {
|
|
|
+ LambdaQueryWrapper<PatientMedicalRecord> lqw = buildQueryWrapper(bo);
|
|
|
List<SysDept> deptlList = deptMapper.selectList(Wrappers.lambdaQuery(SysDept.class).select(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
Map<Long, String> deptMap = deptlList.stream().collect(Collectors.toMap(k1 -> k1.getDeptId(), k2 -> String.valueOf(k2.getDeptName()), (k1, k2) -> k1));
|
|
|
- List<TreatmentUserVo> result = baseMapper.selectVoList(lqw);
|
|
|
+ List<PatientMedicalRecordVo> result = baseMapper.selectVoList(lqw);
|
|
|
if (null != result) {
|
|
|
- for (TreatmentUserVo vo : result) {
|
|
|
+ for (PatientMedicalRecordVo vo : result) {
|
|
|
vo.setDeptName(deptMap.get(vo.getDoorId()));
|
|
|
}
|
|
|
}
|
|
@@ -117,31 +112,31 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
* @return 【请填写功能名称】列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<TreatmentUserVo> queryList(TreatmentUserBo bo) {
|
|
|
- LambdaQueryWrapper<TreatmentUser> lqw = buildQueryWrapper(bo);
|
|
|
+ public List<PatientMedicalRecordVo> queryList(PatientMedicalRecordBo bo) {
|
|
|
+ LambdaQueryWrapper<PatientMedicalRecord> lqw = buildQueryWrapper(bo);
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
|
|
|
- private LambdaQueryWrapper<TreatmentUser> buildQueryWrapper(TreatmentUserBo bo) {
|
|
|
+ private LambdaQueryWrapper<PatientMedicalRecord> buildQueryWrapper(PatientMedicalRecordBo bo) {
|
|
|
Map<String, Object> params = bo.getParams();
|
|
|
- LambdaQueryWrapper<TreatmentUser> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.orderByAsc(TreatmentUser::getId);
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getType()), TreatmentUser::getType, bo.getType());
|
|
|
- lqw.eq(bo.getDoorId() != null, TreatmentUser::getDoorId, bo.getDoorId());
|
|
|
- lqw.eq(bo.getEvaluationStatus() != null, TreatmentUser::getEvaluationStatus, bo.getEvaluationStatus());
|
|
|
- lqw.eq(bo.getTreatmentUserStatus() != null, TreatmentUser::getTreatmentUserStatus, bo.getTreatmentUserStatus());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getTreatNum()), TreatmentUser::getTreatNum, bo.getTreatNum());
|
|
|
- lqw.eq(StringUtils.isNotBlank(bo.getOutpatientNo()), TreatmentUser::getOutpatientNo, bo.getOutpatientNo());
|
|
|
+ LambdaQueryWrapper<PatientMedicalRecord> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.orderByAsc(PatientMedicalRecord::getId);
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getType()), PatientMedicalRecord::getType, bo.getType());
|
|
|
+ lqw.eq(bo.getDoorId() != null, PatientMedicalRecord::getDoorId, bo.getDoorId());
|
|
|
+ lqw.eq(bo.getEvaluationStatus() != null, PatientMedicalRecord::getEvaluationStatus, bo.getEvaluationStatus());
|
|
|
+ lqw.eq(bo.getTreatmentUserStatus() != null, PatientMedicalRecord::getTreatmentUserStatus, bo.getTreatmentUserStatus());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getTreatNum()), PatientMedicalRecord::getTreatNum, bo.getTreatNum());
|
|
|
+ lqw.eq(StringUtils.isNotBlank(bo.getOutpatientNo()), PatientMedicalRecord::getOutpatientNo, bo.getOutpatientNo());
|
|
|
// 添加searchFlag的多字段模糊查询
|
|
|
if (StringUtils.isNotBlank(bo.getSearchFlag())) {
|
|
|
lqw.and(wrapper ->
|
|
|
- wrapper.like(TreatmentUser::getTreatName, bo.getSearchFlag())
|
|
|
+ wrapper.like(PatientMedicalRecord::getTreatName, bo.getSearchFlag())
|
|
|
.or()
|
|
|
- .like(TreatmentUser::getOutpatientNo, bo.getSearchFlag())
|
|
|
+ .like(PatientMedicalRecord::getOutpatientNo, bo.getSearchFlag())
|
|
|
.or()
|
|
|
- .like(TreatmentUser::getIdCard, bo.getSearchFlag())
|
|
|
+ .like(PatientMedicalRecord::getIdCard, bo.getSearchFlag())
|
|
|
.or()
|
|
|
- .like(TreatmentUser::getOutpatientNo, bo.getSearchFlag()));
|
|
|
+ .like(PatientMedicalRecord::getOutpatientNo, bo.getSearchFlag()));
|
|
|
}
|
|
|
return lqw;
|
|
|
}
|
|
@@ -153,7 +148,7 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
* @return 是否新增成功
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean insertByBo(TreatmentUserBo bo) {
|
|
|
+ public Boolean insertByBo(PatientMedicalRecordBo bo) {
|
|
|
// 1. 创建患者基本信息
|
|
|
SysPatient patient = createSysPatient(bo);
|
|
|
boolean patientInserted = patientMapper.insert(patient) > 0;
|
|
@@ -164,16 +159,16 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
|
|
|
try {
|
|
|
// 2. 创建治疗用户信息
|
|
|
- TreatmentUser treatmentUser = createTreatmentUser(bo, patient.getTreatNum());
|
|
|
- boolean userInserted = baseMapper.insert(treatmentUser) > 0;
|
|
|
+ PatientMedicalRecord patientMedicalRecord = createTreatmentUser(bo, patient.getTreatNum());
|
|
|
+ boolean userInserted = baseMapper.insert(patientMedicalRecord) > 0;
|
|
|
|
|
|
if (!userInserted) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
// 3. 创建患者账户信息
|
|
|
- createPatientAccount(treatmentUser);
|
|
|
- bo.setId(treatmentUser.getId());
|
|
|
+ createPatientAccount(patientMedicalRecord);
|
|
|
+ bo.setId(patientMedicalRecord.getId());
|
|
|
|
|
|
return true;
|
|
|
} catch (Exception e) {
|
|
@@ -184,7 +179,7 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- private SysPatient createSysPatient(TreatmentUserBo bo) {
|
|
|
+ private SysPatient createSysPatient(PatientMedicalRecordBo bo) {
|
|
|
SysPatient patient = new SysPatient();
|
|
|
patient.setTreatNum(RedisUtil.generatePatientNumber("M"));
|
|
|
patient.setPatientName(bo.getTreatName());
|
|
@@ -201,59 +196,59 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
return patient;
|
|
|
}
|
|
|
|
|
|
- private TreatmentUser createTreatmentUser(TreatmentUserBo bo, String treatNum) {
|
|
|
- TreatmentUser treatmentUser = MapstructUtils.convert(bo, TreatmentUser.class);
|
|
|
- treatmentUser.setTreatNum(treatNum);
|
|
|
+ private PatientMedicalRecord createTreatmentUser(PatientMedicalRecordBo bo, String treatNum) {
|
|
|
+ PatientMedicalRecord patientMedicalRecord = MapstructUtils.convert(bo, PatientMedicalRecord.class);
|
|
|
+ patientMedicalRecord.setTreatNum(treatNum);
|
|
|
|
|
|
// 设置门诊号
|
|
|
- if (StringUtils.isNotBlank(treatmentUser.getType())) {
|
|
|
- String prefix = PatientType.OUTPATIENT.getCode().equals(treatmentUser.getType()) ? "2" : "1";
|
|
|
- treatmentUser.setOutpatientNo(RedisUtil.generatePatientNumber(prefix));
|
|
|
+ if (StringUtils.isNotBlank(patientMedicalRecord.getType())) {
|
|
|
+ String prefix = PatientType.OUTPATIENT.getCode().equals(patientMedicalRecord.getType()) ? "2" : "1";
|
|
|
+ patientMedicalRecord.setOutpatientNo(RedisUtil.generatePatientNumber(prefix));
|
|
|
}
|
|
|
|
|
|
// 设置病房信息
|
|
|
if (bo.getWardId() != null) {
|
|
|
SysWardVo wardVo = wardMapper.selectVoById(bo.getWardId());
|
|
|
if (wardVo != null) {
|
|
|
- treatmentUser.setWardName(wardVo.getWardName());
|
|
|
+ patientMedicalRecord.setWardName(wardVo.getWardName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- treatmentUser.setBirthday(bo.getBirthday());
|
|
|
- treatmentUser.setPhoneNum(bo.getPhoneNum());
|
|
|
- validEntityBeforeSave(treatmentUser);
|
|
|
+ patientMedicalRecord.setBirthday(bo.getBirthday());
|
|
|
+ patientMedicalRecord.setPhoneNum(bo.getPhoneNum());
|
|
|
+ validEntityBeforeSave(patientMedicalRecord);
|
|
|
|
|
|
- return treatmentUser;
|
|
|
+ return patientMedicalRecord;
|
|
|
}
|
|
|
|
|
|
- private void createPatientAccount(TreatmentUser treatmentUser) {
|
|
|
+ private void createPatientAccount(PatientMedicalRecord patientMedicalRecord) {
|
|
|
PatientAccount account = new PatientAccount();
|
|
|
account.setSerialNo(RedisUtil.generatePatientNumber("A"));
|
|
|
- account.setPatientId(treatmentUser.getId());
|
|
|
- account.setPatientName(treatmentUser.getTreatName());
|
|
|
- account.setIdCard(treatmentUser.getIdCard());
|
|
|
+ account.setPatientId(patientMedicalRecord.getId());
|
|
|
+ account.setPatientName(patientMedicalRecord.getTreatName());
|
|
|
+ account.setIdCard(patientMedicalRecord.getIdCard());
|
|
|
|
|
|
// 修复类型转换问题
|
|
|
- if (StringUtils.isNotBlank(treatmentUser.getSex())) {
|
|
|
- account.setSex(Long.valueOf(treatmentUser.getSex()));
|
|
|
+ if (StringUtils.isNotBlank(patientMedicalRecord.getSex())) {
|
|
|
+ account.setSex(Long.valueOf(patientMedicalRecord.getSex()));
|
|
|
}
|
|
|
|
|
|
- account.setPhone(treatmentUser.getPhoneNum());
|
|
|
- account.setDoorId(treatmentUser.getDoorId());
|
|
|
+ account.setPhone(patientMedicalRecord.getPhoneNum());
|
|
|
+ account.setDoorId(patientMedicalRecord.getDoorId());
|
|
|
|
|
|
// 设置部门信息
|
|
|
- if (treatmentUser.getDoorId() != null) {
|
|
|
- SysDeptVo deptVo = deptMapper.selectVoById(treatmentUser.getDoorId());
|
|
|
+ if (patientMedicalRecord.getDoorId() != null) {
|
|
|
+ SysDeptVo deptVo = deptMapper.selectVoById(patientMedicalRecord.getDoorId());
|
|
|
if (deptVo != null) {
|
|
|
account.setDeptName(deptVo.getDeptName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- account.setVisitType(treatmentUser.getType());
|
|
|
- account.setWardId(treatmentUser.getWardId());
|
|
|
- account.setWardName(treatmentUser.getWardName());
|
|
|
- account.setTreatNum(treatmentUser.getTreatNum());
|
|
|
- account.setPatientNo(treatmentUser.getOutpatientNo());
|
|
|
+ account.setVisitType(patientMedicalRecord.getType());
|
|
|
+ account.setWardId(patientMedicalRecord.getWardId());
|
|
|
+ account.setWardName(patientMedicalRecord.getWardName());
|
|
|
+ account.setTreatNum(patientMedicalRecord.getTreatNum());
|
|
|
+ account.setPatientNo(patientMedicalRecord.getOutpatientNo());
|
|
|
|
|
|
accountMapper.insert(account);
|
|
|
}
|
|
@@ -324,12 +319,12 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
* @return 是否修改成功
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean updateByBo(TreatmentUserBo bo) {
|
|
|
+ public Boolean updateByBo(PatientMedicalRecordBo bo) {
|
|
|
SysWardVo wardVo = wardMapper.selectVoById(bo.getWardId());
|
|
|
if (null != wardVo) {
|
|
|
bo.setWardName(wardVo.getWardName());
|
|
|
}
|
|
|
- TreatmentUser update = MapstructUtils.convert(bo, TreatmentUser.class);
|
|
|
+ PatientMedicalRecord update = MapstructUtils.convert(bo, PatientMedicalRecord.class);
|
|
|
update.setBirthday(bo.getBirthday());
|
|
|
update.setPhoneNum(bo.getPhoneNum());
|
|
|
validEntityBeforeSave(update);
|
|
@@ -339,18 +334,18 @@ public class TreatmentUserServiceImpl implements ITreatmentUserService {
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(TreatmentUser entity) {
|
|
|
+ private void validEntityBeforeSave(PatientMedicalRecord entity) {
|
|
|
//TODO 做一些数据校验,如唯一约束
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TreatmentUserVo> queryListByTreatNum(String treatNum) {
|
|
|
- List<TreatmentUserVo> userVoList = baseMapper.selectVoList(new LambdaQueryWrapper<TreatmentUser>().eq(TreatmentUser::getTreatNum, treatNum));
|
|
|
+ public List<PatientMedicalRecordVo> queryListByTreatNum(String treatNum) {
|
|
|
+ List<PatientMedicalRecordVo> userVoList = baseMapper.selectVoList(new LambdaQueryWrapper<PatientMedicalRecord>().eq(PatientMedicalRecord::getTreatNum, treatNum));
|
|
|
NutritionDiagnosisVo diagnosis =null;
|
|
|
String labelIdsStr = null;
|
|
|
List<String> labelNames = null;
|
|
|
if (CollUtil.isNotEmpty(userVoList)) {
|
|
|
- for (TreatmentUserVo vo : userVoList) {
|
|
|
+ for (PatientMedicalRecordVo vo : userVoList) {
|
|
|
diagnosis = diagnosisMapper.selectVoOne(new LambdaQueryWrapper<NutritionDiagnosis>().eq(NutritionDiagnosis::getTreatmentUserId, vo.getId()).orderByDesc(BaseEntity::getCreateTime).last("LIMIT 1"));
|
|
|
if (null != diagnosis) {
|
|
|
labelIdsStr = diagnosis.getDiagnosisLableId();
|