|
@@ -7,6 +7,7 @@ import cn.tr.module.phototherapy.common.po.BusTherapyPlanPO;
|
|
|
import cn.tr.module.phototherapy.common.po.BusTherapyRecordPO;
|
|
import cn.tr.module.phototherapy.common.po.BusTherapyRecordPO;
|
|
|
import cn.tr.module.phototherapy.common.repository.BusTherapyPlanRepository;
|
|
import cn.tr.module.phototherapy.common.repository.BusTherapyPlanRepository;
|
|
|
import cn.tr.module.phototherapy.common.repository.BusTherapyRecordRepository;
|
|
import cn.tr.module.phototherapy.common.repository.BusTherapyRecordRepository;
|
|
|
|
|
+import cn.tr.module.phototherapy.common.vo.PatientTherapyDetailVO;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -37,203 +38,155 @@ import cn.tr.core.exception.TRExcCode;
|
|
|
public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusClinicPO> implements IBusClinicService {
|
|
public class BusClinicServiceImpl extends ServiceImpl<BusClinicRepository, BusClinicPO> implements IBusClinicService {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private BusTherapyPlanRepository therapyPlanRepository;
|
|
|
|
|
-
|
|
|
|
|
- @Resource
|
|
|
|
|
- private BusTherapyRecordRepository therapyRecordRepository;
|
|
|
|
|
|
|
+ private BusClinicRepository busClinicRepository;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据条件查询临床表
|
|
|
|
|
- * @param query 查询参数
|
|
|
|
|
- * @author CodeGenerator
|
|
|
|
|
- * @date 2026-01-12
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ * 根据条件查询临床表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param query 查询参数
|
|
|
|
|
+ * @author CodeGenerator
|
|
|
|
|
+ * @date 2026-01-12
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
- public List<BusClinicDTO> selectBusClinicList(BusClinicQueryDTO query){
|
|
|
|
|
|
|
+ public List<BusClinicDTO> selectBusClinicList(BusClinicQueryDTO query) {
|
|
|
return BusClinicMapper.INSTANCE.convertDtoList(
|
|
return BusClinicMapper.INSTANCE.convertDtoList(
|
|
|
this.list(new LambdaQueryWrapper<BusClinicPO>()
|
|
this.list(new LambdaQueryWrapper<BusClinicPO>()
|
|
|
- .eq(ObjectUtil.isNotNull(query.getId()), BusClinicPO::getId, query.getId())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getPatientUniqueId()), BusClinicPO::getPatientUniqueId, query.getPatientUniqueId())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getUserId()), BusClinicPO::getUserId, query.getUserId())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getLastTreatmentTime()), BusClinicPO::getLastTreatmentTime, query.getLastTreatmentTime())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getTherapyPlanId()), BusClinicPO::getTherapyPlanId, query.getTherapyPlanId())
|
|
|
|
|
- .like(ObjectUtil.isNotNull(query.getPatientName()), BusClinicPO::getPatientName, query.getPatientName())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getPatientAge()), BusClinicPO::getPatientAge, query.getPatientAge())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getPatientGender()), BusClinicPO::getPatientGender, query.getPatientGender())
|
|
|
|
|
- .like(ObjectUtil.isNotNull(query.getPatientPhone()), BusClinicPO::getPatientPhone, query.getPatientPhone())
|
|
|
|
|
- .like(ObjectUtil.isNotNull(query.getPatientAddress()), BusClinicPO::getPatientAddress, query.getPatientAddress())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getDeviceId()), BusClinicPO::getDeviceId, query.getDeviceId())
|
|
|
|
|
- .eq(ObjectUtil.isNotNull(query.getTenantId()), BusClinicPO::getTenantId, query.getTenantId())
|
|
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getId()), BusClinicPO::getId, query.getId())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getPatientUniqueId()), BusClinicPO::getPatientUniqueId, query.getPatientUniqueId())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getUserId()), BusClinicPO::getUserId, query.getUserId())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getLastTreatmentTime()), BusClinicPO::getLastTreatmentTime, query.getLastTreatmentTime())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTherapyPlanId()), BusClinicPO::getTherapyPlanId, query.getTherapyPlanId())
|
|
|
|
|
+ .like(ObjectUtil.isNotNull(query.getPatientName()), BusClinicPO::getPatientName, query.getPatientName())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getPatientAge()), BusClinicPO::getPatientAge, query.getPatientAge())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getPatientGender()), BusClinicPO::getPatientGender, query.getPatientGender())
|
|
|
|
|
+ .like(ObjectUtil.isNotNull(query.getPatientPhone()), BusClinicPO::getPatientPhone, query.getPatientPhone())
|
|
|
|
|
+ .like(ObjectUtil.isNotNull(query.getPatientAddress()), BusClinicPO::getPatientAddress, query.getPatientAddress())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getDeviceId()), BusClinicPO::getDeviceId, query.getDeviceId())
|
|
|
|
|
+ .eq(ObjectUtil.isNotNull(query.getTenantId()), BusClinicPO::getTenantId, query.getTenantId())
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 根据id查询临床表
|
|
|
|
|
- * @param id 主键id
|
|
|
|
|
- * @author CodeGenerator
|
|
|
|
|
- * @date 2026-01-12
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ * 根据id查询临床表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 主键id
|
|
|
|
|
+ * @author CodeGenerator
|
|
|
|
|
+ * @date 2026-01-12
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
- public BusClinicDTO selectBusClinicById(String id){
|
|
|
|
|
|
|
+ public BusClinicDTO selectBusClinicById(String id) {
|
|
|
return BusClinicMapper.INSTANCE.convertDto(this.getById(id));
|
|
return BusClinicMapper.INSTANCE.convertDto(this.getById(id));
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 编辑临床表
|
|
|
|
|
- * @param source 编辑实体类
|
|
|
|
|
- * @author CodeGenerator
|
|
|
|
|
- * @date 2026-01-12
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ * 编辑临床表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param source 编辑实体类
|
|
|
|
|
+ * @author CodeGenerator
|
|
|
|
|
+ * @date 2026-01-12
|
|
|
|
|
+ */
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
@Override
|
|
|
- public boolean updateBusClinicById(BusClinicDTO source){
|
|
|
|
|
- return this.updateById(BusClinicMapper.INSTANCE.convertPO(source));
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ public boolean updateBusClinicById(BusClinicDTO source) {
|
|
|
|
|
+ return this.updateById(BusClinicMapper.INSTANCE.convertPO(source));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 新增临床表
|
|
|
|
|
- * @param source 新增实体类
|
|
|
|
|
- * @author CodeGenerator
|
|
|
|
|
- * @date 2026-01-12
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ * 新增临床表
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param source 新增实体类
|
|
|
|
|
+ * @author CodeGenerator
|
|
|
|
|
+ * @date 2026-01-12
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean insertBusClinic(BusClinicDTO source){
|
|
|
|
|
|
|
+ public boolean insertBusClinic(BusClinicDTO source) {
|
|
|
return this.save(BusClinicMapper.INSTANCE.convertPO(source));
|
|
return this.save(BusClinicMapper.INSTANCE.convertPO(source));
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 删除临床表详情
|
|
|
|
|
- * @param ids 删除主键集合
|
|
|
|
|
- * @author CodeGenerator
|
|
|
|
|
- * @date 2026-01-12
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ * 删除临床表详情
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param ids 删除主键集合
|
|
|
|
|
+ * @author CodeGenerator
|
|
|
|
|
+ * @date 2026-01-12
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public boolean removeBusClinicByIds(Collection<String> ids){
|
|
|
|
|
- if(CollectionUtil.isEmpty(ids)){
|
|
|
|
|
- throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"请选择要删除的数据");
|
|
|
|
|
|
|
+ public boolean removeBusClinicByIds(Collection<String> ids) {
|
|
|
|
|
+ if (CollectionUtil.isEmpty(ids)) {
|
|
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "请选择要删除的数据");
|
|
|
}
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
return this.removeByIds(ids);
|
|
|
- };
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ;
|
|
|
|
|
|
|
|
/***
|
|
/***
|
|
|
* 根据临床表id获取患者治疗详情
|
|
* 根据临床表id获取患者治疗详情
|
|
|
- * @param clinicId
|
|
|
|
|
|
|
+ * @param patientUniqueId
|
|
|
* @date 2026-01-20
|
|
* @date 2026-01-20
|
|
|
**/
|
|
**/
|
|
|
@Override
|
|
@Override
|
|
|
- public PatientTherapyDetailDTO getPatientTherapyDetailById(String clinicId) {
|
|
|
|
|
- // 查询临床信息
|
|
|
|
|
- BusClinicPO clinicPO = this.getById(clinicId);
|
|
|
|
|
- if (ObjectUtil.isNull(clinicPO)) {
|
|
|
|
|
- throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "临床信息不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public PatientTherapyDetailDTO getPatientTherapyDetailById(String patientUniqueId) {
|
|
|
|
|
+ // 通过多表联查获取数据
|
|
|
|
|
+ PatientTherapyDetailVO detailVO = busClinicRepository.selectPatientTherapyDetailById(patientUniqueId);
|
|
|
|
|
|
|
|
- // 查询治疗方案信息
|
|
|
|
|
- BusTherapyPlanPO therapyPlanPO = therapyPlanRepository.selectById(clinicPO.getTherapyPlanId());
|
|
|
|
|
-
|
|
|
|
|
- // 查询治疗记录信息
|
|
|
|
|
- LambdaQueryWrapper<BusTherapyRecordPO> therapyRecordQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- therapyRecordQuery.eq(BusTherapyRecordPO::getClinicId, clinicId)
|
|
|
|
|
- .eq(BusTherapyRecordPO::getIsDelete, 0)
|
|
|
|
|
- .orderByDesc(BusTherapyRecordPO::getTherapyStartTime);
|
|
|
|
|
-
|
|
|
|
|
- List<BusTherapyRecordPO> therapyRecords = therapyRecordRepository.selectList(therapyRecordQuery);
|
|
|
|
|
|
|
+ if (detailVO == null) {
|
|
|
|
|
+ throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001, "患者临床信息不存在");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // 组装患者治疗详情DTO
|
|
|
|
|
|
|
+ // 转换为 DTO 并进行必要的业务逻辑处理
|
|
|
PatientTherapyDetailDTO detailDTO = new PatientTherapyDetailDTO();
|
|
PatientTherapyDetailDTO detailDTO = new PatientTherapyDetailDTO();
|
|
|
|
|
|
|
|
- // 设置患者信息(来自bus_clinic表)
|
|
|
|
|
- detailDTO.setPatientName(clinicPO.getPatientName());
|
|
|
|
|
- detailDTO.setPatientAge(clinicPO.getPatientAge());
|
|
|
|
|
- detailDTO.setPatientGender(clinicPO.getPatientGender());
|
|
|
|
|
- detailDTO.setPatientUniqueId(clinicPO.getPatientUniqueId());
|
|
|
|
|
- detailDTO.setPatientPhone(clinicPO.getPatientPhone());
|
|
|
|
|
- detailDTO.setPatientAddress(clinicPO.getPatientAddress());
|
|
|
|
|
- detailDTO.setLastTreatmentTime(clinicPO.getLastTreatmentTime());
|
|
|
|
|
- detailDTO.setGroupType(clinicPO.getGroupType());
|
|
|
|
|
-
|
|
|
|
|
- // 统计治疗次数(按天求和)
|
|
|
|
|
- Set<Date> therapyDays = new HashSet<>();
|
|
|
|
|
- if (CollectionUtil.isNotEmpty(therapyRecords)) {
|
|
|
|
|
- for (BusTherapyRecordPO record : therapyRecords) {
|
|
|
|
|
- if (ObjectUtil.isNotNull(record.getTherapyStartTime())) {
|
|
|
|
|
- therapyDays.add(record.getTherapyStartTime());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 基本信息直接复制
|
|
|
|
|
+ detailDTO.setPatientName(detailVO.getPatientName());
|
|
|
|
|
+ detailDTO.setPatientAge(detailVO.getPatientAge());
|
|
|
|
|
+ detailDTO.setPatientGender(detailVO.getPatientGender());
|
|
|
|
|
+ detailDTO.setPatientUniqueId(detailVO.getPatientUniqueId());
|
|
|
|
|
+ detailDTO.setPatientPhone(detailVO.getPatientPhone());
|
|
|
|
|
+ detailDTO.setPatientAddress(detailVO.getPatientAddress());
|
|
|
|
|
+ detailDTO.setLastTreatmentTime(detailVO.getLastTreatmentTime());
|
|
|
|
|
+ detailDTO.setGroupType(detailVO.getGroupType());
|
|
|
|
|
+ detailDTO.setTherapyCount(detailVO.getTherapyCount());
|
|
|
|
|
+ detailDTO.setTherapyStatus(String.valueOf(detailVO.getTherapyStatus())); // 转换为字符串
|
|
|
|
|
+ detailDTO.setStartTime(detailVO.getStartTime());
|
|
|
|
|
+ detailDTO.setPhaseType(detailVO.getPhaseType());
|
|
|
|
|
+
|
|
|
|
|
+ // 拼接治疗方案
|
|
|
|
|
+ StringBuilder therapyPlan = new StringBuilder();
|
|
|
|
|
+ if (detailVO.getPhaseFreq() != null && !detailVO.getPhaseFreq().trim().isEmpty()) {
|
|
|
|
|
+ therapyPlan.append(detailVO.getPhaseFreq());
|
|
|
}
|
|
}
|
|
|
- detailDTO.setTherapyCount(therapyDays.size());
|
|
|
|
|
-
|
|
|
|
|
-/* // 计算依从性(这里简化处理,实际需要根据治疗记录和计划计算)
|
|
|
|
|
- detailDTO.setCompliance(0);*/
|
|
|
|
|
-
|
|
|
|
|
- // 判断今日治疗状态
|
|
|
|
|
- LocalDate today = LocalDate.now();
|
|
|
|
|
- LambdaQueryWrapper<BusTherapyRecordPO> todayTherapyQuery = new LambdaQueryWrapper<>();
|
|
|
|
|
- todayTherapyQuery.eq(BusTherapyRecordPO::getClinicId, clinicId)
|
|
|
|
|
- .ge(BusTherapyRecordPO::getTherapyStartTime, today.atStartOfDay())
|
|
|
|
|
- .le(BusTherapyRecordPO::getTherapyStartTime, today.atTime(23, 59, 59))
|
|
|
|
|
- .eq(BusTherapyRecordPO::getIsDelete, 0);
|
|
|
|
|
-
|
|
|
|
|
- List<BusTherapyRecordPO> todayTherapyRecords = therapyRecordRepository.selectList(todayTherapyQuery);
|
|
|
|
|
- if (CollectionUtil.isEmpty(todayTherapyRecords)) {
|
|
|
|
|
- detailDTO.setTherapyStatus(TherapyStatusEnum.NOT_STARTED.getText()); // 状态为未进行
|
|
|
|
|
- } else {
|
|
|
|
|
- // 根据最新的治疗记录判断状态
|
|
|
|
|
- BusTherapyRecordPO latestTherapyRecord = todayTherapyRecords.get(0);
|
|
|
|
|
- if (ObjectUtil.isNotNull(latestTherapyRecord.getTherapyStatus())) {
|
|
|
|
|
- TherapyStatusEnum statusEnum = TherapyStatusEnum.getByValue(latestTherapyRecord.getTherapyStatus());
|
|
|
|
|
- if (ObjectUtil.isNotNull(statusEnum)) {
|
|
|
|
|
- detailDTO.setTherapyStatus(statusEnum.getText()); // 不为空,获取当前状态
|
|
|
|
|
- } else {
|
|
|
|
|
- detailDTO.setTherapyStatus("未知");
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- detailDTO.setTherapyStatus("未知");
|
|
|
|
|
|
|
+ if (detailVO.getPhaseDurationMin() != null) {
|
|
|
|
|
+ if (therapyPlan.length() > 0) {
|
|
|
|
|
+ therapyPlan.append("; ");
|
|
|
}
|
|
}
|
|
|
|
|
+ therapyPlan.append("每次").append(detailVO.getPhaseDurationMin()).append("min");
|
|
|
}
|
|
}
|
|
|
|
|
+ detailDTO.setTherapyPlan(therapyPlan.toString());
|
|
|
|
|
|
|
|
- // 设置光疗方案信息
|
|
|
|
|
- if (ObjectUtil.isNotNull(therapyPlanPO)) {
|
|
|
|
|
- // 使用继承的createTime字段
|
|
|
|
|
- if (ObjectUtil.isNotNull(therapyPlanPO.getCreateTime())) {
|
|
|
|
|
- detailDTO.setStartTime(therapyPlanPO.getCreateTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
|
|
|
|
|
- }
|
|
|
|
|
- detailDTO.setPhaseType(therapyPlanPO.getPhaseType());
|
|
|
|
|
-
|
|
|
|
|
- // 组装治疗方案描述
|
|
|
|
|
- String therapyPlan = "";
|
|
|
|
|
- if (ObjectUtil.isNotNull(therapyPlanPO.getPhaseFreq())) {
|
|
|
|
|
- therapyPlan += therapyPlanPO.getPhaseFreq();
|
|
|
|
|
- }
|
|
|
|
|
- if (ObjectUtil.isNotNull(therapyPlanPO.getPhaseDurationMin())) {
|
|
|
|
|
- therapyPlan += "; 每次" + therapyPlanPO.getPhaseDurationMin() + "min";
|
|
|
|
|
- }
|
|
|
|
|
- detailDTO.setTherapyPlan(therapyPlan);
|
|
|
|
|
-
|
|
|
|
|
- detailDTO.setPlanDoctor(therapyPlanPO.getPlanDoctor());
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ detailDTO.setPlanDoctor(detailVO.getPlanDoctor());
|
|
|
|
|
|
|
|
- // 设置设备信息
|
|
|
|
|
- detailDTO.setDeviceId(clinicPO.getDeviceId());
|
|
|
|
|
-
|
|
|
|
|
- // 查询设备绑定信息
|
|
|
|
|
- // 查询设备绑定信息 - 使用clinic表中的isCurrentBind字段判断是否为当前绑定
|
|
|
|
|
- if (ObjectUtil.isNotNull(clinicPO.getDeviceId()) &&
|
|
|
|
|
- ObjectUtil.isNotNull(clinicPO.getIsCurrentBind()) &&
|
|
|
|
|
- clinicPO.getIsCurrentBind().equals(IsCurrentBindEnum.CURRENT_BIND.getValue()) &&
|
|
|
|
|
- ObjectUtil.isNotNull(clinicPO.getBindStartTime())) {
|
|
|
|
|
- // 如果是当前绑定,则显示绑定开始时间
|
|
|
|
|
- detailDTO.setBindStartTime(clinicPO.getBindStartTime());
|
|
|
|
|
|
|
+ // 设备信息处理 - 根据当前绑定状态决定是否显示设备
|
|
|
|
|
+ if (detailVO.getDeviceId() != null &&
|
|
|
|
|
+ detailVO.getBindStartTime() != null) {
|
|
|
|
|
+ detailDTO.setDeviceId(detailVO.getDeviceId());
|
|
|
|
|
+ detailDTO.setBindStartTime(detailVO.getBindStartTime());
|
|
|
} else {
|
|
} else {
|
|
|
- // 如果不是当前绑定,显示无设备
|
|
|
|
|
- detailDTO.setDeviceId(null); // TODO设置为"无设备"等提示信息
|
|
|
|
|
|
|
+ detailDTO.setDeviceId(null);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return detailDTO;
|
|
return detailDTO;
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|