|
@@ -2,13 +2,26 @@ package org.jeecg.modules.medical.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.modules.medical.common.bo.before.PatientInformationResponse;
|
|
|
+import org.jeecg.modules.medical.entity.AdvanceWarningAudit;
|
|
|
import org.jeecg.modules.medical.entity.AdvanceWarningAuditDetail;
|
|
|
+import org.jeecg.modules.medical.entity.AfterwardsAudit;
|
|
|
+import org.jeecg.modules.medical.entity.AfterwardsAuditDetail;
|
|
|
import org.jeecg.modules.medical.mapper.AdvanceWarningAuditDetailMapper;
|
|
|
import org.jeecg.modules.medical.service.IAdvanceWarningAuditDetailService;
|
|
|
+import org.jeecg.modules.medical.service.IAdvanceWarningAuditService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
+import java.time.Instant;
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -17,6 +30,7 @@ import java.util.List;
|
|
|
* @Date: 2023-05-09 14:37:22
|
|
|
* @Version: V1.0
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
public class AdvanceWarningAuditDetailServiceImpl extends ServiceImpl<AdvanceWarningAuditDetailMapper, AdvanceWarningAuditDetail> implements IAdvanceWarningAuditDetailService {
|
|
|
|
|
@@ -33,4 +47,45 @@ public class AdvanceWarningAuditDetailServiceImpl extends ServiceImpl<AdvanceWar
|
|
|
.eq(AdvanceWarningAuditDetail::getAdvanceWarningAuditId, id);
|
|
|
return list(queryWrapper);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PatientInformationResponse loadPatientInfoById(Integer advanceWarningAuditId, IAdvanceWarningAuditService advanceWarningAuditService) {
|
|
|
+ AdvanceWarningAudit advanceWarningAudit = advanceWarningAuditService.getById(advanceWarningAuditId);
|
|
|
+// AfterwardsAudit afterwardsAudit = advanceWarningAuditService.getById(advanceWarningAuditId);
|
|
|
+ if (advanceWarningAudit == null) {
|
|
|
+ log.error("找不到事前工单id={}", advanceWarningAuditId);
|
|
|
+ throw new JeecgBootException("找不到工单id");
|
|
|
+ }
|
|
|
+ PatientInformationResponse result = baseMapper.loadPatientInfoById(advanceWarningAuditId);
|
|
|
+ if (null != result) {
|
|
|
+ //查一次就诊流水号
|
|
|
+ List<AdvanceWarningAuditDetail> detailList = loadDetailList(advanceWarningAuditId);//baseMapper.loadAdvanceWarningAuditDetail(id);
|
|
|
+ if (!CollectionUtils.isEmpty(detailList)) {
|
|
|
+ AdvanceWarningAuditDetail advanceWarningAuditDetail = detailList.get(0);
|
|
|
+ String outpatientNumber = advanceWarningAuditDetail.getOutpatientNumber();
|
|
|
+ result.setVisitSerialNumber(outpatientNumber);
|
|
|
+ result.setMedicalInsurance(advanceWarningAuditDetail.getMedicalInsuranceMark());
|
|
|
+ }
|
|
|
+ //计算患者年龄
|
|
|
+ Date birthday = result.getBirthday();
|
|
|
+ if (null != birthday) {
|
|
|
+
|
|
|
+ Instant instant = birthday.toInstant();
|
|
|
+ LocalDate usageLocalDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
|
|
|
+ LocalDate now = LocalDate.now();
|
|
|
+ // 获取两个日期天数相差
|
|
|
+ long until = usageLocalDate.until(now, ChronoUnit.YEARS) + 1;
|
|
|
+ result.setAge(String.valueOf(until));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<AdvanceWarningAuditDetail> loadDetailList(Integer advanceWarningAuditId) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<AdvanceWarningAuditDetail> queryWrapper = Wrappers.<AdvanceWarningAuditDetail>lambdaQuery()
|
|
|
+ .eq(AdvanceWarningAuditDetail::getAdvanceWarningAuditId, advanceWarningAuditId);
|
|
|
+ return this.list(queryWrapper);
|
|
|
+
|
|
|
+ }
|
|
|
}
|