Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -29,6 +29,8 @@ import com.openhis.web.chargemanage.dto.PatientMetadata;
|
|||||||
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
|
import com.openhis.web.chargemanage.dto.PractitionerMetadata;
|
||||||
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
|
import com.openhis.web.chargemanage.dto.ReprintRegistrationDto;
|
||||||
import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper;
|
import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||||
|
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
|
||||||
import com.openhis.web.paymentmanage.appservice.IPaymentRecService;
|
import com.openhis.web.paymentmanage.appservice.IPaymentRecService;
|
||||||
import com.openhis.web.paymentmanage.dto.CancelPaymentDto;
|
import com.openhis.web.paymentmanage.dto.CancelPaymentDto;
|
||||||
import com.openhis.web.paymentmanage.dto.CancelRegPaymentDto;
|
import com.openhis.web.paymentmanage.dto.CancelRegPaymentDto;
|
||||||
@@ -38,12 +40,15 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门诊挂号 应用实现类
|
* 门诊挂号 应用实现类
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistrationAppService {
|
public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistrationAppService {
|
||||||
|
|
||||||
@@ -77,6 +82,9 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
|||||||
@Resource
|
@Resource
|
||||||
IPatientIdentifierService patientIdentifierService;
|
IPatientIdentifierService patientIdentifierService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
TriageCandidateExclusionService triageCandidateExclusionService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 门诊挂号 - 查询患者信息
|
* 门诊挂号 - 查询患者信息
|
||||||
*
|
*
|
||||||
@@ -308,6 +316,47 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
|||||||
new Page<>(pageNo, pageSize), EncounterClass.AMB.getValue(), EncounterStatus.IN_PROGRESS.getValue(),
|
new Page<>(pageNo, pageSize), EncounterClass.AMB.getValue(), EncounterStatus.IN_PROGRESS.getValue(),
|
||||||
ParticipantType.ADMITTER.getCode(), ParticipantType.REGISTRATION_DOCTOR.getCode(), queryWrapper,
|
ParticipantType.ADMITTER.getCode(), ParticipantType.REGISTRATION_DOCTOR.getCode(), queryWrapper,
|
||||||
ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
|
ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
|
||||||
|
|
||||||
|
// 过滤候选池排除列表(如果是从智能候选池查询,排除已加入队列的患者)
|
||||||
|
// 检查请求参数 excludeFromCandidatePool,如果为 true 或未设置,则过滤排除列表
|
||||||
|
String excludeParam = request.getParameter("excludeFromCandidatePool");
|
||||||
|
boolean shouldExclude = excludeParam == null || "true".equalsIgnoreCase(excludeParam);
|
||||||
|
if (shouldExclude && currentDayEncounter != null && !currentDayEncounter.getRecords().isEmpty()) {
|
||||||
|
try {
|
||||||
|
// 获取当前租户和日期
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
LocalDate today = LocalDate.now();
|
||||||
|
|
||||||
|
// 查询排除列表
|
||||||
|
List<TriageCandidateExclusion> exclusions = triageCandidateExclusionService.list(
|
||||||
|
new LambdaQueryWrapper<TriageCandidateExclusion>()
|
||||||
|
.eq(TriageCandidateExclusion::getTenantId, tenantId)
|
||||||
|
.eq(TriageCandidateExclusion::getExclusionDate, today)
|
||||||
|
.eq(TriageCandidateExclusion::getDeleteFlag, "0")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (exclusions != null && !exclusions.isEmpty()) {
|
||||||
|
// 构建排除的 encounterId 集合
|
||||||
|
Set<Long> excludedEncounterIds = exclusions.stream()
|
||||||
|
.map(TriageCandidateExclusion::getEncounterId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 过滤结果
|
||||||
|
List<CurrentDayEncounterDto> filteredRecords = currentDayEncounter.getRecords().stream()
|
||||||
|
.filter(e -> e.getEncounterId() == null || !excludedEncounterIds.contains(e.getEncounterId()))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 更新分页结果
|
||||||
|
currentDayEncounter.setRecords(filteredRecords);
|
||||||
|
currentDayEncounter.setTotal(filteredRecords.size());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 如果过滤失败,记录日志但不影响正常查询
|
||||||
|
log.warn("过滤候选池排除列表失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
currentDayEncounter.getRecords().forEach(e -> {
|
currentDayEncounter.getRecords().forEach(e -> {
|
||||||
// 性别
|
// 性别
|
||||||
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
e.setGenderEnum_enumText(EnumUtils.getInfoByValue(AdministrativeGender.class, e.getGenderEnum()));
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.appservice;
|
||||||
|
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueActionReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAddReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAdjustReq;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
public interface TriageQueueAppService {
|
||||||
|
R<?> list(Long organizationId, LocalDate date);
|
||||||
|
R<?> add(TriageQueueAddReq req);
|
||||||
|
R<?> remove(Long id);
|
||||||
|
R<?> adjust(TriageQueueAdjustReq req);
|
||||||
|
/** 选呼:将之前叫号中置为完成,选中的置为叫号中 */
|
||||||
|
R<?> call(TriageQueueActionReq req);
|
||||||
|
/** 完成:叫号中 -> 完成(移出列表),并自动推进下一个等待为叫号中 */
|
||||||
|
R<?> complete(TriageQueueActionReq req);
|
||||||
|
/** 过号重排:叫号中 -> 跳过并移到末尾,并自动推进下一个等待为叫号中 */
|
||||||
|
R<?> requeue(TriageQueueActionReq req);
|
||||||
|
/** 跳过:兼容前端按钮(当前实现等同于过号重排) */
|
||||||
|
R<?> skip(TriageQueueActionReq req);
|
||||||
|
/** 下一患者:当前叫号中 -> 完成,下一位等待 -> 叫号中 */
|
||||||
|
R<?> next(TriageQueueActionReq req);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,556 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.appservice.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.core.common.utils.SecurityUtils;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||||
|
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||||
|
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
|
||||||
|
import com.openhis.web.triageandqueuemanage.appservice.TriageQueueAppService;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueActionReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAddReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAdjustReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueEncounterItem;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TriageQueueAppServiceImpl implements TriageQueueAppService {
|
||||||
|
|
||||||
|
private static final String STATUS_WAITING = "WAITING";
|
||||||
|
private static final String STATUS_CALLING = "CALLING";
|
||||||
|
private static final String STATUS_SKIPPED = "SKIPPED";
|
||||||
|
private static final String STATUS_COMPLETED = "COMPLETED";
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TriageQueueItemService triageQueueItemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TriageCandidateExclusionService triageCandidateExclusionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public R<?> list(Long organizationId, LocalDate date) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
// 只查询今天的患者
|
||||||
|
LocalDate qd = date != null ? date : LocalDate.now();
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> wrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getQueueDate, qd)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED)
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder);
|
||||||
|
|
||||||
|
// 如果指定了科室,按科室过滤;否则查询所有科室(全科模式)
|
||||||
|
if (organizationId != null) {
|
||||||
|
wrapper.eq(TriageQueueItem::getOrganizationId, organizationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TriageQueueItem> list = triageQueueItemService.list(wrapper);
|
||||||
|
|
||||||
|
// 双重保险:再次过滤掉 COMPLETED 状态的患者(防止数据库中有异常数据)
|
||||||
|
if (list != null && !list.isEmpty()) {
|
||||||
|
int beforeSize = list.size();
|
||||||
|
list = list.stream()
|
||||||
|
.filter(item -> !STATUS_COMPLETED.equals(item.getStatus()))
|
||||||
|
.collect(java.util.stream.Collectors.toList());
|
||||||
|
if (beforeSize != list.size()) {
|
||||||
|
System.out.println(">>> [TriageQueue] list() 警告:过滤掉了 " + (beforeSize - list.size()) + " 条 COMPLETED 状态的记录");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 调试日志:检查状态值
|
||||||
|
if (list != null && !list.isEmpty()) {
|
||||||
|
System.out.println(">>> [TriageQueue] list() 返回 " + list.size() + " 条记录(已排除 COMPLETED)");
|
||||||
|
for (int i = 0; i < Math.min(3, list.size()); i++) {
|
||||||
|
TriageQueueItem item = list.get(i);
|
||||||
|
System.out.println(" [" + i + "] patientName=" + item.getPatientName()
|
||||||
|
+ ", status=" + item.getStatus()
|
||||||
|
+ ", organizationId=" + item.getOrganizationId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return R.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> add(TriageQueueAddReq req) {
|
||||||
|
if (req == null || ObjectUtil.isNull(req.getOrganizationId())) {
|
||||||
|
return R.fail("organizationId 不能为空");
|
||||||
|
}
|
||||||
|
if (CollUtil.isEmpty(req.getItems())) {
|
||||||
|
return R.fail("items 不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
LocalDate qd = LocalDate.now();
|
||||||
|
Long orgId = req.getOrganizationId();
|
||||||
|
|
||||||
|
List<TriageQueueItem> existing = triageQueueItemService.list(new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||||
|
.eq(TriageQueueItem::getQueueDate, qd)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED));
|
||||||
|
|
||||||
|
int maxOrder = existing.stream().map(TriageQueueItem::getQueueOrder).filter(Objects::nonNull).max(Integer::compareTo).orElse(0);
|
||||||
|
|
||||||
|
int added = 0;
|
||||||
|
for (TriageQueueEncounterItem it : req.getItems()) {
|
||||||
|
if (it == null || it.getEncounterId() == null) continue;
|
||||||
|
boolean exists = existing.stream().anyMatch(e -> Objects.equals(e.getEncounterId(), it.getEncounterId()));
|
||||||
|
if (exists) continue;
|
||||||
|
|
||||||
|
TriageQueueItem qi = new TriageQueueItem()
|
||||||
|
.setTenantId(tenantId)
|
||||||
|
.setQueueDate(qd)
|
||||||
|
.setOrganizationId(orgId)
|
||||||
|
.setOrganizationName(req.getOrganizationName())
|
||||||
|
.setEncounterId(it.getEncounterId())
|
||||||
|
.setPatientId(it.getPatientId())
|
||||||
|
.setPatientName(it.getPatientName())
|
||||||
|
.setHealthcareName(it.getHealthcareName())
|
||||||
|
.setPractitionerName(it.getPractitionerName())
|
||||||
|
.setStatus(STATUS_WAITING)
|
||||||
|
.setQueueOrder(++maxOrder)
|
||||||
|
.setDeleteFlag("0")
|
||||||
|
.setCreateTime(LocalDateTime.now())
|
||||||
|
.setUpdateTime(LocalDateTime.now());
|
||||||
|
|
||||||
|
triageQueueItemService.save(qi);
|
||||||
|
|
||||||
|
// 记录到候选池排除列表(避免刷新后重新出现在候选池)
|
||||||
|
TriageCandidateExclusion exclusion = triageCandidateExclusionService.getOne(
|
||||||
|
new LambdaQueryWrapper<TriageCandidateExclusion>()
|
||||||
|
.eq(TriageCandidateExclusion::getTenantId, tenantId)
|
||||||
|
.eq(TriageCandidateExclusion::getExclusionDate, qd)
|
||||||
|
.eq(TriageCandidateExclusion::getEncounterId, it.getEncounterId())
|
||||||
|
.eq(TriageCandidateExclusion::getDeleteFlag, "0")
|
||||||
|
);
|
||||||
|
if (exclusion == null) {
|
||||||
|
exclusion = new TriageCandidateExclusion()
|
||||||
|
.setTenantId(tenantId)
|
||||||
|
.setExclusionDate(qd)
|
||||||
|
.setEncounterId(it.getEncounterId())
|
||||||
|
.setPatientId(it.getPatientId())
|
||||||
|
.setPatientName(it.getPatientName())
|
||||||
|
.setOrganizationId(orgId)
|
||||||
|
.setOrganizationName(req.getOrganizationName())
|
||||||
|
.setReason("ADDED_TO_QUEUE")
|
||||||
|
.setDeleteFlag("0")
|
||||||
|
.setCreateTime(LocalDateTime.now())
|
||||||
|
.setUpdateTime(LocalDateTime.now());
|
||||||
|
triageCandidateExclusionService.save(exclusion);
|
||||||
|
}
|
||||||
|
|
||||||
|
added++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return R.ok(added);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> remove(Long id) {
|
||||||
|
if (id == null) return R.fail("id 不能为空");
|
||||||
|
TriageQueueItem item = triageQueueItemService.getById(id);
|
||||||
|
if (item == null) return R.fail("队列项不存在");
|
||||||
|
|
||||||
|
// 逻辑删除队列项
|
||||||
|
item.setDeleteFlag("1").setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(item);
|
||||||
|
|
||||||
|
// 从排除列表中删除记录,使患者重新出现在候选池中
|
||||||
|
Integer tenantId = item.getTenantId();
|
||||||
|
LocalDate exclusionDate = item.getQueueDate();
|
||||||
|
Long encounterId = item.getEncounterId();
|
||||||
|
|
||||||
|
if (tenantId != null && exclusionDate != null && encounterId != null) {
|
||||||
|
TriageCandidateExclusion exclusion = triageCandidateExclusionService.getOne(
|
||||||
|
new LambdaQueryWrapper<TriageCandidateExclusion>()
|
||||||
|
.eq(TriageCandidateExclusion::getTenantId, tenantId)
|
||||||
|
.eq(TriageCandidateExclusion::getExclusionDate, exclusionDate)
|
||||||
|
.eq(TriageCandidateExclusion::getEncounterId, encounterId)
|
||||||
|
.eq(TriageCandidateExclusion::getDeleteFlag, "0")
|
||||||
|
);
|
||||||
|
|
||||||
|
if (exclusion != null) {
|
||||||
|
// 逻辑删除排除记录
|
||||||
|
exclusion.setDeleteFlag("1").setUpdateTime(LocalDateTime.now());
|
||||||
|
triageCandidateExclusionService.updateById(exclusion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
recalcOrders(item.getOrganizationId(), item.getQueueDate());
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> adjust(TriageQueueAdjustReq req) {
|
||||||
|
if (req == null || req.getId() == null) return R.fail("id 不能为空");
|
||||||
|
if (!"up".equalsIgnoreCase(req.getDirection()) && !"down".equalsIgnoreCase(req.getDirection())) {
|
||||||
|
return R.fail("direction 只能是 up/down");
|
||||||
|
}
|
||||||
|
TriageQueueItem cur = triageQueueItemService.getById(req.getId());
|
||||||
|
if (cur == null) return R.fail("队列项不存在");
|
||||||
|
|
||||||
|
List<TriageQueueItem> list = listInternal(cur.getOrganizationId(), cur.getQueueDate());
|
||||||
|
list.sort(Comparator.comparing(TriageQueueItem::getQueueOrder).thenComparing(TriageQueueItem::getId));
|
||||||
|
int idx = -1;
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
if (Objects.equals(list.get(i).getId(), cur.getId())) { idx = i; break; }
|
||||||
|
}
|
||||||
|
if (idx == -1) return R.fail("队列项不在当前队列");
|
||||||
|
|
||||||
|
int targetIdx = "up".equalsIgnoreCase(req.getDirection()) ? idx - 1 : idx + 1;
|
||||||
|
if (targetIdx < 0 || targetIdx >= list.size()) return R.ok(false);
|
||||||
|
|
||||||
|
TriageQueueItem other = list.get(targetIdx);
|
||||||
|
Integer tmp = cur.getQueueOrder();
|
||||||
|
cur.setQueueOrder(other.getQueueOrder()).setUpdateTime(LocalDateTime.now());
|
||||||
|
other.setQueueOrder(tmp).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(cur);
|
||||||
|
triageQueueItemService.updateById(other);
|
||||||
|
|
||||||
|
recalcOrders(cur.getOrganizationId(), cur.getQueueDate());
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> call(TriageQueueActionReq req) {
|
||||||
|
if (req == null || req.getId() == null) return R.fail("id 不能为空");
|
||||||
|
TriageQueueItem selected = triageQueueItemService.getById(req.getId());
|
||||||
|
if (selected == null) return R.fail("队列项不存在");
|
||||||
|
|
||||||
|
// 只将"等待"状态的患者转为"叫号中",允许有多个"叫号中"的患者
|
||||||
|
if (STATUS_WAITING.equals(selected.getStatus())) {
|
||||||
|
selected.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(selected);
|
||||||
|
return R.ok(true);
|
||||||
|
} else if (STATUS_CALLING.equals(selected.getStatus())) {
|
||||||
|
// 如果已经是"叫号中"状态,直接返回成功(不做任何操作)
|
||||||
|
return R.ok(true);
|
||||||
|
} else {
|
||||||
|
// 其他状态(如 SKIPPED、COMPLETED)不能选呼
|
||||||
|
return R.fail("只能选呼\"等待\"状态的患者,当前患者状态为:" + selected.getStatus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> complete(TriageQueueActionReq req) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
TriageQueueItem calling = null;
|
||||||
|
|
||||||
|
// 关键改进:如果提供了 id,直接通过ID获取(像 call 方法一样),不依赖查询条件
|
||||||
|
if (req != null && req.getId() != null) {
|
||||||
|
calling = triageQueueItemService.getById(req.getId());
|
||||||
|
if (calling == null) {
|
||||||
|
return R.fail("队列项不存在");
|
||||||
|
}
|
||||||
|
// 验证状态
|
||||||
|
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||||
|
return R.fail("只能完成\"叫号中\"状态的患者,当前患者状态为:" + calling.getStatus());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有提供 id,通过查询条件查找(兼容旧逻辑)
|
||||||
|
Long orgId = req != null && req.getOrganizationId() != null ? req.getOrganizationId() : null;
|
||||||
|
System.out.println(">>> [TriageQueue] complete() 开始执行(不限制日期,通过查询条件), tenantId=" + tenantId + ", orgId=" + orgId);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
if (orgId != null) {
|
||||||
|
callingWrapper.eq(TriageQueueItem::getOrganizationId, orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
calling = triageQueueItemService.getOne(callingWrapper, false);
|
||||||
|
|
||||||
|
System.out.println(">>> [TriageQueue] complete() 查询叫号中患者(不限制日期): orgId=" + orgId + ", 结果=" + (calling != null ? calling.getPatientName() + "(status=" + calling.getStatus() + ", queueDate=" + calling.getQueueDate() + ")" : "null"));
|
||||||
|
|
||||||
|
if (calling == null) {
|
||||||
|
return R.fail("当前没有叫号中的患者");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用实际找到的科室ID
|
||||||
|
Long actualOrgId = calling.getOrganizationId();
|
||||||
|
|
||||||
|
// 1) 叫号中 -> 完成(移出列表)
|
||||||
|
calling.setStatus(STATUS_COMPLETED).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(calling);
|
||||||
|
|
||||||
|
// 2) 自动推进下一个等待为叫号中(同一科室,包含跳过状态,不限制日期)
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||||
|
.or()
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
// 如果指定了科室ID,则按科室过滤;否则查询所有科室(全科模式)
|
||||||
|
if (actualOrgId != null) {
|
||||||
|
nextWrapper.eq(TriageQueueItem::getOrganizationId, actualOrgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||||
|
|
||||||
|
System.out.println(">>> [TriageQueue] complete() 查询等待患者(不限制日期): actualOrgId=" + actualOrgId + ", 结果=" + (next != null ? next.getPatientName() + "(status=" + next.getStatus() + ")" : "null"));
|
||||||
|
|
||||||
|
if (next != null) {
|
||||||
|
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
recalcOrders(actualOrgId, null);
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> requeue(TriageQueueActionReq req) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
TriageQueueItem calling = null;
|
||||||
|
|
||||||
|
|
||||||
|
if (req != null && req.getId() != null) {
|
||||||
|
calling = triageQueueItemService.getById(req.getId());
|
||||||
|
if (calling == null) {
|
||||||
|
return R.fail("队列项不存在");
|
||||||
|
}
|
||||||
|
// 验证状态
|
||||||
|
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||||
|
return R.fail("只能对\"叫号中\"状态的患者进行过号重排,当前患者状态为:" + calling.getStatus());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有提供 id,通过查询条件查找(兼容旧逻辑)
|
||||||
|
Long orgId = req != null && req.getOrganizationId() != null ? req.getOrganizationId() : null;
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
if (orgId != null) {
|
||||||
|
callingWrapper.eq(TriageQueueItem::getOrganizationId, orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
calling = triageQueueItemService.getOne(callingWrapper, false);
|
||||||
|
|
||||||
|
if (calling == null) return R.fail("当前没有叫号中的患者");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用实际找到的科室ID
|
||||||
|
Long actualOrgId = calling.getOrganizationId();
|
||||||
|
|
||||||
|
// 关键改进:在执行"跳过"操作之前,先检查是否有等待中的患者(判断队列状态)
|
||||||
|
// 如果没有等待中的患者,就不应该执行"过号重排"操作
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||||
|
.or()
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
// 如果指定了科室ID,则按科室过滤;否则查询所有科室(全科模式)
|
||||||
|
if (actualOrgId != null) {
|
||||||
|
nextWrapper.eq(TriageQueueItem::getOrganizationId, actualOrgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||||
|
|
||||||
|
// 调试日志:检查查询结果
|
||||||
|
System.out.println(">>> [TriageQueue] requeue() 查询等待中的患者:");
|
||||||
|
System.out.println(">>> - 科室ID: " + actualOrgId);
|
||||||
|
System.out.println(">>> - 找到的等待患者: " + (next != null ? next.getPatientName() + " (状态: " + next.getStatus() + ")" : "null"));
|
||||||
|
|
||||||
|
// 如果找不到等待中的患者,直接返回失败(不执行跳过操作)
|
||||||
|
if (next == null) {
|
||||||
|
System.out.println(">>> [TriageQueue] requeue() 失败:没有等待中的患者");
|
||||||
|
return R.fail("当前没有等待中的患者");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 找末尾序号(同一科室,不限制日期)
|
||||||
|
Integer maxOrder = triageQueueItemService.list(new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getOrganizationId, actualOrgId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED))
|
||||||
|
.stream()
|
||||||
|
.map(TriageQueueItem::getQueueOrder)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.max(Integer::compareTo)
|
||||||
|
.orElse(0);
|
||||||
|
|
||||||
|
// 1) 叫号中 -> 跳过,并移到末尾
|
||||||
|
calling.setStatus(STATUS_SKIPPED).setQueueOrder(maxOrder + 1).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(calling);
|
||||||
|
|
||||||
|
// 2) 自动推进下一个等待为叫号中
|
||||||
|
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(next);
|
||||||
|
|
||||||
|
recalcOrders(actualOrgId, null);
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> skip(TriageQueueActionReq req) {
|
||||||
|
// 当前业务“跳过”按“过号重排”处理:叫号中 -> 跳过并移到末尾,自动推进下一等待
|
||||||
|
return requeue(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public R<?> next(TriageQueueActionReq req) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
TriageQueueItem calling = null;
|
||||||
|
|
||||||
|
System.out.println(">>> [TriageQueue] next() 开始执行(不限制日期), tenantId=" + tenantId);
|
||||||
|
|
||||||
|
// 关键改进:如果提供了 id,优先使用 id 直接查找(像 call 方法一样)
|
||||||
|
if (req != null && req.getId() != null) {
|
||||||
|
calling = triageQueueItemService.getById(req.getId());
|
||||||
|
if (calling == null) {
|
||||||
|
return R.fail("队列项不存在");
|
||||||
|
}
|
||||||
|
// 验证状态:必须是"叫号中"状态
|
||||||
|
if (!STATUS_CALLING.equals(calling.getStatus())) {
|
||||||
|
return R.fail("只能对\"叫号中\"状态的患者执行\"下一患者\"操作,当前患者状态为:" + calling.getStatus());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 如果没有提供 id,通过查询条件查找(兼容旧逻辑)
|
||||||
|
Long orgId = req != null && req.getOrganizationId() != null ? req.getOrganizationId() : null;
|
||||||
|
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> callingWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
if (orgId != null) {
|
||||||
|
callingWrapper.eq(TriageQueueItem::getOrganizationId, orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
calling = triageQueueItemService.getOne(callingWrapper, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
Long actualOrgId = null;
|
||||||
|
|
||||||
|
// 当前叫号中 -> 完成(如果不存在,就当作从头找第一位等待)
|
||||||
|
if (calling != null) {
|
||||||
|
calling.setStatus(STATUS_COMPLETED).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(calling);
|
||||||
|
actualOrgId = calling.getOrganizationId(); // 使用叫号中患者所在的科室
|
||||||
|
} else {
|
||||||
|
// 如果没有叫号中的患者,使用请求中的 organizationId(如果有)
|
||||||
|
if (req != null && req.getOrganizationId() != null) {
|
||||||
|
actualOrgId = req.getOrganizationId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下一位等待 -> 叫号中(如果之前有叫号中的,就在同一科室找;否则在全科找)
|
||||||
|
// 注意:也包含"跳过"状态的患者,因为跳过后的患者也可以重新叫号(不限制日期)
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> nextWrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.and(w -> w.eq(TriageQueueItem::getStatus, STATUS_WAITING)
|
||||||
|
.or()
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_SKIPPED))
|
||||||
|
.orderByAsc(TriageQueueItem::getQueueOrder)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
|
||||||
|
if (actualOrgId != null) {
|
||||||
|
nextWrapper.eq(TriageQueueItem::getOrganizationId, actualOrgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
TriageQueueItem next = triageQueueItemService.getOne(nextWrapper, false);
|
||||||
|
|
||||||
|
// 调试日志:打印查询条件和结果
|
||||||
|
System.out.println(">>> [TriageQueue] next() 查询条件(不限制日期): tenantId=" + tenantId
|
||||||
|
+ ", actualOrgId=" + actualOrgId
|
||||||
|
+ ", deleteFlag=0"
|
||||||
|
+ ", status IN (WAITING, SKIPPED)");
|
||||||
|
System.out.println(">>> [TriageQueue] next() 查询结果: calling=" + (calling != null ? calling.getPatientName() + "(status=" + calling.getStatus() + ", queueDate=" + calling.getQueueDate() + ")" : "null")
|
||||||
|
+ ", next=" + (next != null ? next.getPatientName() + "(status=" + next.getStatus() + ", queueDate=" + next.getQueueDate() + ")" : "null"));
|
||||||
|
|
||||||
|
if (next == null) {
|
||||||
|
if (actualOrgId != null) {
|
||||||
|
recalcOrders(actualOrgId, null);
|
||||||
|
}
|
||||||
|
return R.fail("当前没有等待的患者");
|
||||||
|
}
|
||||||
|
|
||||||
|
next.setStatus(STATUS_CALLING).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(next);
|
||||||
|
|
||||||
|
if (next.getOrganizationId() != null) {
|
||||||
|
recalcOrders(next.getOrganizationId(), null);
|
||||||
|
}
|
||||||
|
return R.ok(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TriageQueueItem> listInternal(Long orgId, LocalDate qd) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
LambdaQueryWrapper<TriageQueueItem> wrapper = new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.ne(TriageQueueItem::getStatus, STATUS_COMPLETED);
|
||||||
|
// 如果 qd 不为 null,才添加日期限制
|
||||||
|
if (qd != null) {
|
||||||
|
wrapper.eq(TriageQueueItem::getQueueDate, qd);
|
||||||
|
}
|
||||||
|
return triageQueueItemService.list(wrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
private TriageQueueItem findCalling(Long orgId, LocalDate qd) {
|
||||||
|
Integer tenantId = SecurityUtils.getLoginUser().getTenantId();
|
||||||
|
return triageQueueItemService.getOne(new LambdaQueryWrapper<TriageQueueItem>()
|
||||||
|
.eq(TriageQueueItem::getTenantId, tenantId)
|
||||||
|
.eq(TriageQueueItem::getOrganizationId, orgId)
|
||||||
|
.eq(TriageQueueItem::getQueueDate, qd)
|
||||||
|
.eq(TriageQueueItem::getDeleteFlag, "0")
|
||||||
|
.eq(TriageQueueItem::getStatus, STATUS_CALLING)
|
||||||
|
.last("LIMIT 1"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recalcOrders(Long orgId, LocalDate qd) {
|
||||||
|
List<TriageQueueItem> list = listInternal(orgId, qd);
|
||||||
|
list.sort(Comparator.comparing(TriageQueueItem::getQueueOrder).thenComparing(TriageQueueItem::getId));
|
||||||
|
int i = 1;
|
||||||
|
for (TriageQueueItem it : list) {
|
||||||
|
if (!Objects.equals(it.getQueueOrder(), i)) {
|
||||||
|
it.setQueueOrder(i).setUpdateTime(LocalDateTime.now());
|
||||||
|
triageQueueItemService.updateById(it);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.controller;
|
||||||
|
|
||||||
|
import com.core.common.core.domain.R;
|
||||||
|
import com.openhis.web.triageandqueuemanage.appservice.TriageQueueAppService;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueActionReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAddReq;
|
||||||
|
import com.openhis.web.triageandqueuemanage.dto.TriageQueueAdjustReq;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("/triage/queue")
|
||||||
|
public class TriageQueueController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TriageQueueAppService triageQueueAppService;
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
public R<?> list(@RequestParam(value = "organizationId", required = false) Long organizationId,
|
||||||
|
@RequestParam(value = "date", required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate date) {
|
||||||
|
return triageQueueAppService.list(organizationId, date);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public R<?> add(@RequestBody TriageQueueAddReq req) {
|
||||||
|
return triageQueueAppService.add(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/remove/{id}")
|
||||||
|
public R<?> remove(@PathVariable("id") Long id) {
|
||||||
|
return triageQueueAppService.remove(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/adjust")
|
||||||
|
public R<?> adjust(@RequestBody TriageQueueAdjustReq req) {
|
||||||
|
return triageQueueAppService.adjust(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/call")
|
||||||
|
public R<?> call(@RequestBody TriageQueueActionReq req) {
|
||||||
|
return triageQueueAppService.call(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/complete")
|
||||||
|
public R<?> complete(@RequestBody(required = false) TriageQueueActionReq req) {
|
||||||
|
return triageQueueAppService.complete(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/requeue")
|
||||||
|
public R<?> requeue(@RequestBody(required = false) TriageQueueActionReq req) {
|
||||||
|
return triageQueueAppService.requeue(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/skip")
|
||||||
|
public R<?> skip(@RequestBody(required = false) TriageQueueActionReq req) {
|
||||||
|
return triageQueueAppService.skip(req);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/next")
|
||||||
|
public R<?> next(@RequestBody(required = false) TriageQueueActionReq req) {
|
||||||
|
return triageQueueAppService.next(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TriageQueueActionReq {
|
||||||
|
/** 目标队列项ID(例如:选呼时选中的患者) */
|
||||||
|
private Long id;
|
||||||
|
/** 科室ID(可选:不传则用当前登录人orgId) */
|
||||||
|
private Long organizationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TriageQueueAddReq {
|
||||||
|
/** 科室ID(就诊科室) */
|
||||||
|
private Long organizationId;
|
||||||
|
/** 科室名称(冗余存储,便于展示) */
|
||||||
|
private String organizationName;
|
||||||
|
/** 要加入队列的就诊记录 */
|
||||||
|
private List<TriageQueueEncounterItem> items;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TriageQueueAdjustReq {
|
||||||
|
private Long id;
|
||||||
|
/** up / down */
|
||||||
|
private String direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.openhis.web.triageandqueuemanage.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TriageQueueEncounterItem {
|
||||||
|
private Long encounterId;
|
||||||
|
private Long patientId;
|
||||||
|
private String patientName;
|
||||||
|
private String healthcareName;
|
||||||
|
private String practitionerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName(value = "hisdev.triage_candidate_exclusion")
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class TriageCandidateExclusion {
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer tenantId;
|
||||||
|
private LocalDate exclusionDate;
|
||||||
|
private Long encounterId;
|
||||||
|
private Long patientId;
|
||||||
|
private String patientName;
|
||||||
|
private Long organizationId;
|
||||||
|
private String organizationName;
|
||||||
|
|
||||||
|
/** 排除原因:ADDED_TO_QUEUE(加入队列)、MANUAL_REMOVE(手动移除)等 */
|
||||||
|
private String reason;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
private String deleteFlag;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName(value = "hisdev.triage_queue_item")
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class TriageQueueItem {
|
||||||
|
@TableId(type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Integer tenantId;
|
||||||
|
private LocalDate queueDate;
|
||||||
|
private Long organizationId;
|
||||||
|
private String organizationName;
|
||||||
|
|
||||||
|
private Long encounterId;
|
||||||
|
private Long patientId;
|
||||||
|
private String patientName;
|
||||||
|
|
||||||
|
private String healthcareName;
|
||||||
|
private String practitionerName;
|
||||||
|
|
||||||
|
/** WAITING / CALLING / SKIPPED / COMPLETED */
|
||||||
|
private String status;
|
||||||
|
private Integer queueOrder;
|
||||||
|
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
private String deleteFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface TriageCandidateExclusionMapper extends BaseMapper<TriageCandidateExclusion> {
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface TriageQueueItemMapper extends BaseMapper<TriageQueueItem> {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||||
|
|
||||||
|
public interface TriageCandidateExclusionService extends IService<TriageCandidateExclusion> {
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||||
|
|
||||||
|
public interface TriageQueueItemService extends IService<TriageQueueItem> {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageCandidateExclusion;
|
||||||
|
import com.openhis.triageandqueuemanage.mapper.TriageCandidateExclusionMapper;
|
||||||
|
import com.openhis.triageandqueuemanage.service.TriageCandidateExclusionService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TriageCandidateExclusionServiceImpl extends ServiceImpl<TriageCandidateExclusionMapper, TriageCandidateExclusion> implements TriageCandidateExclusionService {
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.openhis.triageandqueuemanage.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.openhis.triageandqueuemanage.domain.TriageQueueItem;
|
||||||
|
import com.openhis.triageandqueuemanage.mapper.TriageQueueItemMapper;
|
||||||
|
import com.openhis.triageandqueuemanage.service.TriageQueueItemService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TriageQueueItemServiceImpl extends ServiceImpl<TriageQueueItemMapper, TriageQueueItem> implements TriageQueueItemService {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
-- 智能分诊排队:候选池排除记录表
|
||||||
|
-- 用途:记录已从智能候选池中移除的患者(加入队列后不再出现在候选池)
|
||||||
|
-- 注意:必须在后端实际连接的 schema 中执行(dev环境是 hisdev,test环境是 histest,prd环境是 hisprd)
|
||||||
|
-- 执行前请先确认:SET search_path TO hisdev; (或对应的 schema)
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS hisdev.triage_candidate_exclusion (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
exclusion_date DATE NOT NULL,
|
||||||
|
encounter_id BIGINT NOT NULL,
|
||||||
|
patient_id BIGINT,
|
||||||
|
patient_name VARCHAR(255),
|
||||||
|
organization_id BIGINT,
|
||||||
|
organization_name VARCHAR(255),
|
||||||
|
reason VARCHAR(100) DEFAULT 'ADDED_TO_QUEUE', -- 排除原因:ADDED_TO_QUEUE(加入队列)、MANUAL_REMOVE(手动移除)等
|
||||||
|
create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
delete_flag CHAR(1) NOT NULL DEFAULT '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 常用查询索引:按租户/日期/就诊记录查询
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_triage_candidate_exclusion_list
|
||||||
|
ON hisdev.triage_candidate_exclusion (tenant_id, exclusion_date, delete_flag, encounter_id);
|
||||||
|
|
||||||
|
-- 防重复:同一天同租户同就诊记录只能有一条排除记录(未删除)
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_triage_candidate_exclusion_encounter
|
||||||
|
ON hisdev.triage_candidate_exclusion (tenant_id, exclusion_date, encounter_id, delete_flag)
|
||||||
|
WHERE delete_flag = '0';
|
||||||
|
|
||||||
|
-- 就诊记录ID索引(用于关联查询)
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_triage_candidate_exclusion_encounter_id
|
||||||
|
ON hisdev.triage_candidate_exclusion (encounter_id);
|
||||||
|
|
||||||
|
-- 注释
|
||||||
|
COMMENT ON TABLE hisdev.triage_candidate_exclusion IS '智能分诊排队候选池排除记录表';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.tenant_id IS '租户ID';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.exclusion_date IS '排除日期(通常为当天)';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.encounter_id IS '就诊记录ID(唯一标识)';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.patient_id IS '患者ID';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.patient_name IS '患者姓名';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.organization_id IS '科室ID';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.organization_name IS '科室名称';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.reason IS '排除原因:ADDED_TO_QUEUE(加入队列)、MANUAL_REMOVE(手动移除)等';
|
||||||
|
COMMENT ON COLUMN hisdev.triage_candidate_exclusion.delete_flag IS '删除标志:0-未删除,1-已删除';
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
-- 智能分诊排队:队列持久化表(与 TriageQueueItem.java 字段一致)
|
||||||
|
-- 注意:必须在后端实际连接的 schema 中执行(dev环境是 hisdev,test环境是 histest,prd环境是 hisprd)
|
||||||
|
-- 执行前请先确认:SET search_path TO hisdev; (或对应的 schema)
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS triage_queue_item (
|
||||||
|
id BIGSERIAL PRIMARY KEY,
|
||||||
|
tenant_id INTEGER NOT NULL,
|
||||||
|
queue_date DATE NOT NULL,
|
||||||
|
organization_id BIGINT NOT NULL,
|
||||||
|
organization_name VARCHAR(255),
|
||||||
|
encounter_id BIGINT NOT NULL,
|
||||||
|
patient_id BIGINT,
|
||||||
|
patient_name VARCHAR(255),
|
||||||
|
healthcare_name VARCHAR(255),
|
||||||
|
practitioner_name VARCHAR(255),
|
||||||
|
status VARCHAR(50) NOT NULL, -- WAITING/CALLING/SKIPPED/COMPLETED
|
||||||
|
queue_order INTEGER NOT NULL,
|
||||||
|
create_time TIMESTAMP,
|
||||||
|
update_time TIMESTAMP,
|
||||||
|
delete_flag CHAR(1) NOT NULL DEFAULT '0'
|
||||||
|
);
|
||||||
|
|
||||||
|
-- 常用查询索引:按租户/科室/日期/状态/顺序取队列
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_triage_queue_item_list
|
||||||
|
ON triage_queue_item (tenant_id, queue_date, organization_id, delete_flag, status, queue_order);
|
||||||
|
|
||||||
|
-- 防重复:同一天同租户同科室同就诊记录只能在队列里一条(未删除)
|
||||||
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_triage_queue_item_encounter
|
||||||
|
ON triage_queue_item (tenant_id, queue_date, organization_id, encounter_id, delete_flag)
|
||||||
|
WHERE delete_flag = '0';
|
||||||
|
|
||||||
|
-- 就诊记录ID索引(用于关联查询)
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_triage_queue_item_encounter_id
|
||||||
|
ON triage_queue_item (encounter_id);
|
||||||
|
|
||||||
108
openhis-server-new/sql/debug_queue_date_issue.sql
Normal file
108
openhis-server-new/sql/debug_queue_date_issue.sql
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 调试队列日期问题
|
||||||
|
-- 用途:检查数据库中的 queue_date 字段值,找出为什么查询不到数据
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 1. 查看所有队列记录的日期分布
|
||||||
|
SELECT
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
COUNT(*) AS count,
|
||||||
|
STRING_AGG(patient_name, ', ') AS patients
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
GROUP BY queue_date, status
|
||||||
|
ORDER BY queue_date DESC, status;
|
||||||
|
|
||||||
|
-- 2. 查看指定科室的所有记录(不限制日期)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
patient_name,
|
||||||
|
organization_id,
|
||||||
|
organization_name,
|
||||||
|
queue_order,
|
||||||
|
create_time
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND organization_id = 1995302136614969300
|
||||||
|
ORDER BY queue_date DESC, queue_order ASC;
|
||||||
|
|
||||||
|
-- 3. 查看今天的记录(使用 CURRENT_DATE)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
patient_name,
|
||||||
|
organization_id,
|
||||||
|
queue_order
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND organization_id = 1995302136614969300
|
||||||
|
ORDER BY queue_order ASC;
|
||||||
|
|
||||||
|
-- 4. 查看 2026-01-16 的记录
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
patient_name,
|
||||||
|
organization_id,
|
||||||
|
queue_order
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND queue_date = '2026-01-16'::DATE
|
||||||
|
AND organization_id = 1995302136614969300
|
||||||
|
ORDER BY queue_order ASC;
|
||||||
|
|
||||||
|
-- 5. 查看 2025-01-16 的记录(可能是昨天的数据)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
patient_name,
|
||||||
|
organization_id,
|
||||||
|
queue_order
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND queue_date = '2025-01-16'::DATE
|
||||||
|
AND organization_id = 1995302136614969300
|
||||||
|
ORDER BY queue_order ASC;
|
||||||
|
|
||||||
|
-- 6. 查看最近的记录(最近7天)
|
||||||
|
SELECT
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
COUNT(*) AS count
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND queue_date >= CURRENT_DATE - INTERVAL '7 days'
|
||||||
|
GROUP BY queue_date, status
|
||||||
|
ORDER BY queue_date DESC, status;
|
||||||
|
|
||||||
|
-- 7. 检查系统当前日期(PostgreSQL)
|
||||||
|
SELECT CURRENT_DATE AS current_date_in_db;
|
||||||
|
|
||||||
|
-- 8. 查看所有状态为 WAITING 或 SKIPPED 的记录(不限制日期)
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
queue_date,
|
||||||
|
status,
|
||||||
|
patient_name,
|
||||||
|
organization_id,
|
||||||
|
queue_order
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE tenant_id = 1
|
||||||
|
AND delete_flag = '0'
|
||||||
|
AND status IN ('WAITING', 'SKIPPED')
|
||||||
|
AND organization_id = 1995302136614969300
|
||||||
|
ORDER BY queue_date DESC, queue_order ASC;
|
||||||
|
|
||||||
313
openhis-server-new/sql/query_smart_candidate_pool.sql
Normal file
313
openhis-server-new/sql/query_smart_candidate_pool.sql
Normal file
@@ -0,0 +1,313 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 智能候选池查询SQL(当日已挂号患者)
|
||||||
|
-- 对应接口:GET /charge-manage/register/current-day-encounter
|
||||||
|
-- 用途:查询当日已挂号但未入队的患者,用于智能分诊排队管理
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 完整SQL查询(包含所有关联表)
|
||||||
|
SELECT T9.tenant_id AS tenantId,
|
||||||
|
T9.encounter_id AS encounterId,
|
||||||
|
T9.display_order AS displayOrder,
|
||||||
|
T9.organization_id AS organizationId,
|
||||||
|
T9.organization_name AS organizationName,
|
||||||
|
T9.healthcare_name AS healthcareName,
|
||||||
|
T9.practitioner_user_id AS practitionerUserId,
|
||||||
|
T9.practitioner_name AS practitionerName,
|
||||||
|
T9.contract_name AS contractName,
|
||||||
|
T9.patient_id AS patientId,
|
||||||
|
T9.patient_name AS patientName,
|
||||||
|
T9.phone,
|
||||||
|
T9.gender_enum AS genderEnum,
|
||||||
|
T9.id_card AS idCard,
|
||||||
|
T9.status_enum AS statusEnum,
|
||||||
|
T9.register_time AS registerTime,
|
||||||
|
T9.total_price AS totalPrice,
|
||||||
|
T9.account_name AS accountName,
|
||||||
|
T9.enterer_name AS entererName,
|
||||||
|
T9.charge_item_ids AS chargeItemIds,
|
||||||
|
T9.payment_id AS paymentId,
|
||||||
|
T9.picture_url AS pictureUrl,
|
||||||
|
T9.birth_date AS birthDate,
|
||||||
|
COALESCE(T9.identifier_no, T9.patient_bus_no, '') AS identifierNo
|
||||||
|
FROM (
|
||||||
|
SELECT T1.tenant_id AS tenant_id,
|
||||||
|
T1.id AS encounter_id,
|
||||||
|
T1.display_order AS display_order,
|
||||||
|
T1.organization_id AS organization_id,
|
||||||
|
T2.NAME AS organization_name,
|
||||||
|
T3.NAME AS healthcare_name,
|
||||||
|
T5.user_id AS practitioner_user_id,
|
||||||
|
T5.NAME AS practitioner_name,
|
||||||
|
T7.contract_name AS contract_name,
|
||||||
|
T8.id AS patient_id,
|
||||||
|
T8.NAME AS patient_name,
|
||||||
|
T8.phone AS phone,
|
||||||
|
T8.gender_enum AS gender_enum,
|
||||||
|
T8.id_card AS id_card,
|
||||||
|
T1.status_enum AS status_enum,
|
||||||
|
T1.create_time AS register_time,
|
||||||
|
T10.total_price,
|
||||||
|
T11."name" AS account_name,
|
||||||
|
T12."name" AS enterer_name,
|
||||||
|
T13.charge_item_ids,
|
||||||
|
T13.id AS payment_id,
|
||||||
|
ai.picture_url AS picture_url,
|
||||||
|
T8.birth_date AS birth_date,
|
||||||
|
T8.bus_no AS patient_bus_no,
|
||||||
|
T18.identifier_no AS identifier_no
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
-- 关联科室表
|
||||||
|
LEFT JOIN adm_organization AS T2
|
||||||
|
ON T1.organization_id = T2.ID
|
||||||
|
AND T2.delete_flag = '0'
|
||||||
|
-- 关联医疗服务类型表(号别)
|
||||||
|
LEFT JOIN adm_healthcare_service AS T3
|
||||||
|
ON T1.service_type_id = T3.ID
|
||||||
|
AND T3.delete_flag = '0'
|
||||||
|
-- 关联就诊参与者表(医生信息)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT *,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND (
|
||||||
|
-- 如果就诊状态为"进行中",查找"接诊医生"(admitter)
|
||||||
|
(type_code = 'admitter' AND EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
WHERE T1.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND T1.ID = encounter_id))
|
||||||
|
OR
|
||||||
|
-- 如果就诊状态不是"进行中",查找"挂号医生"(registration_doctor)
|
||||||
|
(type_code = 'registration_doctor' AND NOT EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
WHERE T1.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND T1.ID = encounter_id))
|
||||||
|
)
|
||||||
|
) t
|
||||||
|
WHERE rn = 1
|
||||||
|
) AS T4 ON T1.ID = T4.encounter_id
|
||||||
|
-- 关联医生表
|
||||||
|
LEFT JOIN adm_practitioner AS T5
|
||||||
|
ON T5.ID = T4.practitioner_id
|
||||||
|
AND T5.delete_flag = '0'
|
||||||
|
-- 关联账户表
|
||||||
|
LEFT JOIN adm_account AS T6
|
||||||
|
ON T1.ID = T6.encounter_id
|
||||||
|
AND T6.delete_flag = '0'
|
||||||
|
AND T6.encounter_flag = '1'
|
||||||
|
-- 关联合同表
|
||||||
|
LEFT JOIN fin_contract AS T7
|
||||||
|
ON T6.contract_no = T7.bus_no
|
||||||
|
AND T7.delete_flag = '0'
|
||||||
|
-- 关联患者表
|
||||||
|
LEFT JOIN adm_patient AS T8
|
||||||
|
ON T1.patient_id = T8.ID
|
||||||
|
AND T8.delete_flag = '0'
|
||||||
|
-- 关联患者标识表(身份证号等)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT patient_id,
|
||||||
|
identifier_no
|
||||||
|
FROM (
|
||||||
|
SELECT patient_id,
|
||||||
|
identifier_no,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY patient_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_patient_identifier
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND identifier_no IS NOT NULL
|
||||||
|
AND identifier_no != ''
|
||||||
|
) t
|
||||||
|
WHERE rn = 1
|
||||||
|
) AS T18 ON T8.id = T18.patient_id
|
||||||
|
-- 关联收费项目表(挂号费)
|
||||||
|
LEFT JOIN adm_charge_item AS T10
|
||||||
|
ON T1.id = T10.encounter_id
|
||||||
|
AND T10.delete_flag = '0'
|
||||||
|
AND T10.context_enum = 1 -- REGISTER(挂号)
|
||||||
|
-- 关联账户表(收费账户)
|
||||||
|
LEFT JOIN adm_account AS T11
|
||||||
|
ON T10.account_id = T11.id
|
||||||
|
AND T11.delete_flag = '0'
|
||||||
|
-- 关联医生表(收费医生)
|
||||||
|
LEFT JOIN adm_practitioner AS T12
|
||||||
|
ON T12.ID = T10.enterer_id
|
||||||
|
AND T12.delete_flag = '0'
|
||||||
|
-- 关联支付对账表(已支付)
|
||||||
|
LEFT JOIN fin_payment_reconciliation T13
|
||||||
|
ON T10.id::TEXT = ANY(string_to_array(T13.charge_item_ids,','))
|
||||||
|
AND T13.delete_flag = '0'
|
||||||
|
AND T13.status_enum = 1 -- SUCCESS(支付成功)
|
||||||
|
-- 关联退号记录(当状态为退号时,通过relation_id关联原支付记录)
|
||||||
|
LEFT JOIN fin_payment_reconciliation T14
|
||||||
|
ON T13.id = T14.relation_id
|
||||||
|
AND T14.delete_flag = '0'
|
||||||
|
AND T14.status_enum = 3 -- REFUND(退款)
|
||||||
|
AND T14.payment_enum = 1
|
||||||
|
-- 关联退号医生
|
||||||
|
LEFT JOIN adm_practitioner AS T15
|
||||||
|
ON T15.ID = T14.enterer_id
|
||||||
|
AND T15.delete_flag = '0'
|
||||||
|
-- 关联系统用户表
|
||||||
|
LEFT JOIN sys_user AS T17
|
||||||
|
ON T17.user_id = T15.user_id
|
||||||
|
AND T17.delete_flag = '0'
|
||||||
|
-- 关联退号支付详情,获取退款方式(聚合多个支付方式)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT reconciliation_id,
|
||||||
|
STRING_AGG(
|
||||||
|
CASE pay_enum
|
||||||
|
WHEN 220400 THEN '现金'
|
||||||
|
WHEN 220100 THEN '微信'
|
||||||
|
WHEN 220200 THEN '支付宝'
|
||||||
|
WHEN 220300 THEN '银联'
|
||||||
|
END,
|
||||||
|
','
|
||||||
|
ORDER BY pay_enum
|
||||||
|
) AS refund_method
|
||||||
|
FROM fin_payment_rec_detail
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND amount < 0
|
||||||
|
AND pay_enum IN (220400, 220100, 220200, 220300)
|
||||||
|
GROUP BY reconciliation_id
|
||||||
|
) AS T16 ON T14.id = T16.reconciliation_id
|
||||||
|
-- 关联发票表
|
||||||
|
LEFT JOIN adm_invoice AS ai
|
||||||
|
ON ai.reconciliation_id = T13.id
|
||||||
|
AND ai.delete_flag = '0'
|
||||||
|
WHERE T1.delete_flag = '0'
|
||||||
|
AND T1.class_enum = 1 -- 门诊(AMB)
|
||||||
|
AND T10.context_enum = 1 -- 挂号(REGISTER)
|
||||||
|
-- 动态条件(由前端传入,通过 ${ew.customSqlSegment} 注入)
|
||||||
|
-- 例如:AND T1.create_time::DATE = CURRENT_DATE -- 当日挂号
|
||||||
|
-- 例如:AND T1.status_enum != 6 -- 排除退号(statusEnum = -1时)
|
||||||
|
-- 例如:AND (T8.name LIKE '%关键词%' OR T2.name LIKE '%关键词%' ...) -- 模糊搜索
|
||||||
|
) AS T9
|
||||||
|
-- 动态查询条件(由 MyBatis-Plus QueryWrapper 生成)
|
||||||
|
-- ${ew.customSqlSegment}
|
||||||
|
ORDER BY T9.register_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 简化版查询(仅查询核心字段,用于快速测试)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
pt.birth_date AS birthDate,
|
||||||
|
org.id AS organizationId,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime,
|
||||||
|
enc.status_enum AS statusEnum
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt
|
||||||
|
ON enc.patient_id = pt.id
|
||||||
|
AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org
|
||||||
|
ON enc.organization_id = org.id
|
||||||
|
AND org.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service hcs
|
||||||
|
ON enc.service_type_id = hcs.id
|
||||||
|
AND hcs.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND type_code IN ('admitter', 'registration_doctor')
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
LEFT JOIN adm_practitioner pr
|
||||||
|
ON ep.practitioner_id = pr.id
|
||||||
|
AND pr.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci
|
||||||
|
ON enc.id = ci.encounter_id
|
||||||
|
AND ci.delete_flag = '0'
|
||||||
|
AND ci.context_enum = 1 -- 挂号
|
||||||
|
INNER JOIN fin_payment_reconciliation prc
|
||||||
|
ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0'
|
||||||
|
AND prc.status_enum = 1 -- 支付成功
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1 -- 门诊
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE -- 当日挂号
|
||||||
|
AND enc.status_enum != 6 -- 排除退号
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 查询条件说明
|
||||||
|
-- ============================================
|
||||||
|
-- 1. 基础条件:
|
||||||
|
-- - enc.delete_flag = '0' -- 未删除
|
||||||
|
-- - enc.class_enum = 1 -- 门诊(AMB)
|
||||||
|
-- - ci.context_enum = 1 -- 挂号(REGISTER)
|
||||||
|
-- - prc.status_enum = 1 -- 支付成功(SUCCESS)
|
||||||
|
--
|
||||||
|
-- 2. 日期过滤:
|
||||||
|
-- - enc.create_time::DATE = CURRENT_DATE -- 当日挂号(由前端传入 date 参数)
|
||||||
|
--
|
||||||
|
-- 3. 状态过滤:
|
||||||
|
-- - enc.status_enum != 6 -- 排除退号(当 statusEnum = -1 时)
|
||||||
|
-- - enc.status_enum = 2 -- 进行中(IN_PROGRESS,用于判断医生类型)
|
||||||
|
--
|
||||||
|
-- 4. 模糊搜索(由前端传入 searchKey 参数):
|
||||||
|
-- - patient_name(患者姓名)
|
||||||
|
-- - organization_name(科室名称)
|
||||||
|
-- - practitioner_name(医生姓名)
|
||||||
|
-- - healthcare_name(号别名称)
|
||||||
|
-- - identifier_no(身份证号)
|
||||||
|
--
|
||||||
|
-- 5. 租户过滤(由后端自动添加):
|
||||||
|
-- - tenant_id = ? -- 当前登录用户的租户ID
|
||||||
|
--
|
||||||
|
-- 6. 分页(由 MyBatis-Plus Page 对象处理):
|
||||||
|
-- - LIMIT ? OFFSET ?
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 常用查询示例
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 示例1:查询今天所有已挂号患者(排除退号)
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service hcs ON enc.service_type_id = hcs.id AND hcs.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0' AND type_code IN ('admitter', 'registration_doctor')
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- 示例2:查询指定科室的已挂号患者
|
||||||
|
-- 在示例1的基础上添加:
|
||||||
|
-- AND enc.organization_id = ? -- 科室ID
|
||||||
|
|
||||||
|
-- 示例3:按患者姓名模糊搜索
|
||||||
|
-- 在示例1的基础上添加:
|
||||||
|
-- AND pt.name LIKE '%关键词%'
|
||||||
|
|
||||||
|
-- 示例4:查询已加入队列的患者(用于去重)
|
||||||
|
SELECT DISTINCT encounter_id
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED';
|
||||||
|
|
||||||
268
openhis-server-new/sql/query_smart_candidate_pool_page.sql
Normal file
268
openhis-server-new/sql/query_smart_candidate_pool_page.sql
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 智能候选池查询SQL(智能分诊排队管理页面专用)
|
||||||
|
-- 页面:智能分诊排队管理 - 心内科
|
||||||
|
-- 用途:查询"已签到未入队"的患者(当日已挂号,但未加入队列)
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案一:完整查询(包含所有字段,排除已在队列中的患者)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
pt.birth_date AS birthDate,
|
||||||
|
-- 计算年龄(前端会调用 parseAge 函数)
|
||||||
|
CASE
|
||||||
|
WHEN pt.birth_date IS NOT NULL THEN
|
||||||
|
EXTRACT(YEAR FROM AGE(pt.birth_date))::TEXT || '岁'
|
||||||
|
ELSE ''
|
||||||
|
END AS age,
|
||||||
|
org.id AS organizationId,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime,
|
||||||
|
enc.status_enum AS statusEnum,
|
||||||
|
-- 其他字段(如果需要)
|
||||||
|
pt.phone,
|
||||||
|
pt.gender_enum AS genderEnum,
|
||||||
|
pt.id_card AS idCard
|
||||||
|
FROM adm_encounter enc
|
||||||
|
-- 关联患者表
|
||||||
|
INNER JOIN adm_patient pt
|
||||||
|
ON enc.patient_id = pt.id
|
||||||
|
AND pt.delete_flag = '0'
|
||||||
|
-- 关联科室表
|
||||||
|
LEFT JOIN adm_organization org
|
||||||
|
ON enc.organization_id = org.id
|
||||||
|
AND org.delete_flag = '0'
|
||||||
|
-- 关联医疗服务类型表(号别)
|
||||||
|
LEFT JOIN adm_healthcare_service hcs
|
||||||
|
ON enc.service_type_id = hcs.id
|
||||||
|
AND hcs.delete_flag = '0'
|
||||||
|
-- 关联就诊参与者表(医生信息)
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND (
|
||||||
|
-- 如果就诊状态为"进行中",查找"接诊医生"(admitter)
|
||||||
|
(type_code = 'admitter' AND EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS e
|
||||||
|
WHERE e.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND e.id = encounter_id))
|
||||||
|
OR
|
||||||
|
-- 如果就诊状态不是"进行中",查找"挂号医生"(registration_doctor)
|
||||||
|
(type_code = 'registration_doctor' AND NOT EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS e
|
||||||
|
WHERE e.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND e.id = encounter_id))
|
||||||
|
)
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
-- 关联医生表
|
||||||
|
LEFT JOIN adm_practitioner pr
|
||||||
|
ON ep.practitioner_id = pr.id
|
||||||
|
AND pr.delete_flag = '0'
|
||||||
|
-- 关联收费项目表(挂号费)
|
||||||
|
INNER JOIN adm_charge_item ci
|
||||||
|
ON enc.id = ci.encounter_id
|
||||||
|
AND ci.delete_flag = '0'
|
||||||
|
AND ci.context_enum = 1 -- REGISTER(挂号)
|
||||||
|
-- 关联支付对账表(已支付)
|
||||||
|
INNER JOIN fin_payment_reconciliation prc
|
||||||
|
ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0'
|
||||||
|
AND prc.status_enum = 1 -- SUCCESS(支付成功)
|
||||||
|
-- 排除已在队列中的患者(关键:LEFT JOIN + WHERE IS NULL)
|
||||||
|
LEFT JOIN hisdev.triage_queue_item tqi
|
||||||
|
ON enc.id = tqi.encounter_id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED' -- 排除已完成的状态
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1 -- 门诊(AMB)
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE -- 当日挂号(前端会过滤 registerTime)
|
||||||
|
AND enc.status_enum != 6 -- 排除退号(statusEnum = -1 时)
|
||||||
|
AND tqi.id IS NULL -- 关键:只查询不在队列中的患者
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案二:简化查询(仅核心字段,便于快速测试)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.id AS organizationId,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service hcs ON enc.service_type_id = hcs.id AND hcs.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0' AND type_code IN ('admitter', 'registration_doctor')
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
-- 排除已在队列中的患者
|
||||||
|
LEFT JOIN hisdev.triage_queue_item tqi
|
||||||
|
ON enc.id = tqi.encounter_id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6
|
||||||
|
AND tqi.id IS NULL -- 不在队列中
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案三:分步查询(便于调试和理解)
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 步骤1:查询当日已挂号的患者(不排除队列)
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.name AS organizationName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6;
|
||||||
|
|
||||||
|
-- 步骤2:查询已在队列中的患者
|
||||||
|
SELECT DISTINCT encounter_id
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED';
|
||||||
|
|
||||||
|
-- 步骤3:合并查询(使用 NOT EXISTS 或 NOT IN)
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.name AS organizationName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6
|
||||||
|
-- 排除已在队列中的患者
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hisdev.triage_queue_item tqi
|
||||||
|
WHERE tqi.encounter_id = enc.id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
)
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 查询条件说明
|
||||||
|
-- ============================================
|
||||||
|
-- 1. 基础条件:
|
||||||
|
-- - enc.delete_flag = '0' -- 未删除
|
||||||
|
-- - enc.class_enum = 1 -- 门诊(AMB)
|
||||||
|
-- - ci.context_enum = 1 -- 挂号(REGISTER)
|
||||||
|
-- - prc.status_enum = 1 -- 支付成功(SUCCESS)
|
||||||
|
--
|
||||||
|
-- 2. 日期过滤:
|
||||||
|
-- - enc.create_time::DATE = CURRENT_DATE -- 当日挂号
|
||||||
|
-- 注意:前端还会基于 registerTime 字段再次过滤今天的数据
|
||||||
|
--
|
||||||
|
-- 3. 状态过滤:
|
||||||
|
-- - enc.status_enum != 6 -- 排除退号(对应前端 statusEnum = -1)
|
||||||
|
--
|
||||||
|
-- 4. 队列去重:
|
||||||
|
-- - LEFT JOIN hisdev.triage_queue_item ... WHERE tqi.id IS NULL
|
||||||
|
-- 或者
|
||||||
|
-- - NOT EXISTS (SELECT 1 FROM hisdev.triage_queue_item ...)
|
||||||
|
-- 排除已在队列中且状态不是 COMPLETED 的患者
|
||||||
|
--
|
||||||
|
-- 5. 租户过滤(如果需要):
|
||||||
|
-- - enc.tenant_id = ? -- 当前登录用户的租户ID
|
||||||
|
--
|
||||||
|
-- 6. 模糊搜索(如果需要):
|
||||||
|
-- - pt.name LIKE '%关键词%' -- 患者姓名
|
||||||
|
-- - org.name LIKE '%关键词%' -- 科室名称
|
||||||
|
-- - pr.name LIKE '%关键词%' -- 医生姓名
|
||||||
|
-- - hcs.name LIKE '%关键词%' -- 号别名称
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 调试查询(检查数据是否正确)
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 1. 检查当日已挂号患者总数
|
||||||
|
SELECT COUNT(*) AS total_registered
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6;
|
||||||
|
|
||||||
|
-- 2. 检查已在队列中的患者数量
|
||||||
|
SELECT COUNT(DISTINCT encounter_id) AS in_queue_count
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED';
|
||||||
|
|
||||||
|
-- 3. 检查候选池应该显示的患者数量(已挂号 - 已在队列)
|
||||||
|
SELECT
|
||||||
|
(SELECT COUNT(*)
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6)
|
||||||
|
-
|
||||||
|
(SELECT COUNT(DISTINCT encounter_id)
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED')
|
||||||
|
AS candidate_pool_count;
|
||||||
|
|
||||||
|
-- 4. 查看队列中的患者详情(用于对比)
|
||||||
|
SELECT
|
||||||
|
tqi.encounter_id,
|
||||||
|
tqi.patient_name,
|
||||||
|
tqi.status,
|
||||||
|
tqi.queue_order
|
||||||
|
FROM hisdev.triage_queue_item tqi
|
||||||
|
WHERE tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
ORDER BY tqi.queue_order;
|
||||||
|
|
||||||
@@ -0,0 +1,366 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 智能候选池查询SQL(完整版 - 包含排除列表)
|
||||||
|
-- 页面:智能分诊排队管理 - 心内科
|
||||||
|
-- 用途:查询"已签到未入队"的患者(当日已挂号,但未加入队列,且未在排除列表中)
|
||||||
|
-- 更新日期:2025-01-15
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案一:完整查询(包含所有字段,排除已在队列和排除列表中的患者)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
T9.tenant_id AS tenantId,
|
||||||
|
T9.encounter_id AS encounterId,
|
||||||
|
T9.display_order AS displayOrder,
|
||||||
|
T9.organization_id AS organizationId,
|
||||||
|
T9.organization_name AS organizationName,
|
||||||
|
T9.healthcare_name AS healthcareName,
|
||||||
|
T9.practitioner_user_id AS practitionerUserId,
|
||||||
|
T9.practitioner_name AS practitionerName,
|
||||||
|
T9.contract_name AS contractName,
|
||||||
|
T9.patient_id AS patientId,
|
||||||
|
T9.patient_name AS patientName,
|
||||||
|
T9.phone,
|
||||||
|
T9.gender_enum AS genderEnum,
|
||||||
|
T9.id_card AS idCard,
|
||||||
|
T9.status_enum AS statusEnum,
|
||||||
|
T9.register_time AS registerTime,
|
||||||
|
T9.total_price AS totalPrice,
|
||||||
|
T9.account_name AS accountName,
|
||||||
|
T9.enterer_name AS entererName,
|
||||||
|
T9.charge_item_ids AS chargeItemIds,
|
||||||
|
T9.payment_id AS paymentId,
|
||||||
|
T9.picture_url AS pictureUrl,
|
||||||
|
T9.birth_date AS birthDate,
|
||||||
|
COALESCE(T9.identifier_no, T9.patient_bus_no, '') AS identifierNo,
|
||||||
|
-- 计算年龄(前端会调用 parseAge 函数)
|
||||||
|
CASE
|
||||||
|
WHEN T9.birth_date IS NOT NULL THEN
|
||||||
|
EXTRACT(YEAR FROM AGE(T9.birth_date))::TEXT || '岁'
|
||||||
|
ELSE ''
|
||||||
|
END AS age
|
||||||
|
FROM (
|
||||||
|
SELECT T1.tenant_id AS tenant_id,
|
||||||
|
T1.id AS encounter_id,
|
||||||
|
T1.display_order AS display_order,
|
||||||
|
T1.organization_id AS organization_id,
|
||||||
|
T2.NAME AS organization_name,
|
||||||
|
T3.NAME AS healthcare_name,
|
||||||
|
T5.user_id AS practitioner_user_id,
|
||||||
|
T5.NAME AS practitioner_name,
|
||||||
|
T7.contract_name AS contract_name,
|
||||||
|
T8.id AS patient_id,
|
||||||
|
T8.NAME AS patient_name,
|
||||||
|
T8.phone AS phone,
|
||||||
|
T8.gender_enum AS gender_enum,
|
||||||
|
T8.id_card AS id_card,
|
||||||
|
T1.status_enum AS status_enum,
|
||||||
|
T1.create_time AS register_time,
|
||||||
|
T10.total_price,
|
||||||
|
T11."name" AS account_name,
|
||||||
|
T12."name" AS enterer_name,
|
||||||
|
T13.charge_item_ids,
|
||||||
|
T13.id AS payment_id,
|
||||||
|
ai.picture_url AS picture_url,
|
||||||
|
T8.birth_date AS birth_date,
|
||||||
|
T8.bus_no AS patient_bus_no,
|
||||||
|
T18.identifier_no AS identifier_no
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT *,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND (
|
||||||
|
(type_code = 'admitter' AND EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
WHERE T1.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND T1.ID = encounter_id))
|
||||||
|
OR
|
||||||
|
(type_code = 'registration_doctor' AND NOT EXISTS(SELECT 1
|
||||||
|
FROM adm_encounter AS T1
|
||||||
|
WHERE T1.status_enum = 2 -- IN_PROGRESS
|
||||||
|
AND T1.ID = encounter_id))
|
||||||
|
)
|
||||||
|
) t
|
||||||
|
WHERE rn = 1
|
||||||
|
) AS T4 ON T1.ID = T4.encounter_id
|
||||||
|
LEFT JOIN adm_practitioner AS T5 ON T5.ID = T4.practitioner_id AND T5.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_account AS T6
|
||||||
|
ON T1.ID = T6.encounter_id AND T6.delete_flag = '0' AND T6.encounter_flag = '1'
|
||||||
|
LEFT JOIN fin_contract AS T7 ON T6.contract_no = T7.bus_no AND T7.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_patient AS T8 ON T1.patient_id = T8.ID AND T8.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT patient_id,
|
||||||
|
identifier_no
|
||||||
|
FROM (
|
||||||
|
SELECT patient_id,
|
||||||
|
identifier_no,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY patient_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_patient_identifier
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND identifier_no IS NOT NULL
|
||||||
|
AND identifier_no != ''
|
||||||
|
) t
|
||||||
|
WHERE rn = 1
|
||||||
|
) AS T18 ON T8.id = T18.patient_id
|
||||||
|
LEFT JOIN adm_charge_item AS T10 ON T1.id = T10.encounter_id AND T10.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_account AS T11 ON T10.account_id = T11.id AND T11.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_practitioner AS T12 ON T12.ID = T10.enterer_id AND T12.delete_flag = '0'
|
||||||
|
LEFT JOIN fin_payment_reconciliation T13
|
||||||
|
ON T10.id::TEXT = ANY(string_to_array(T13.charge_item_ids,','))
|
||||||
|
AND T13.delete_flag = '0'
|
||||||
|
AND T13.status_enum = 1 -- SUCCESS(支付成功)
|
||||||
|
LEFT JOIN adm_invoice AS ai
|
||||||
|
ON ai.reconciliation_id = T13.id AND ai.delete_flag = '0'
|
||||||
|
WHERE T1.delete_flag = '0'
|
||||||
|
AND T1.class_enum = 1 -- 门诊(AMB)
|
||||||
|
AND T1.create_time::DATE = CURRENT_DATE -- 当日挂号
|
||||||
|
AND T1.status_enum != 6 -- 排除退号
|
||||||
|
AND T10.context_enum = 1 -- REGISTER(挂号)
|
||||||
|
) AS T9
|
||||||
|
-- 排除已在队列中的患者(关键:LEFT JOIN + WHERE IS NULL)
|
||||||
|
LEFT JOIN hisdev.triage_queue_item tqi
|
||||||
|
ON T9.encounter_id = tqi.encounter_id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED' -- 排除已完成的状态
|
||||||
|
-- 排除已在排除列表中的患者(新增:关键:LEFT JOIN + WHERE IS NULL)
|
||||||
|
LEFT JOIN hisdev.triage_candidate_exclusion tce
|
||||||
|
ON T9.encounter_id = tce.encounter_id
|
||||||
|
AND tce.delete_flag = '0'
|
||||||
|
AND tce.exclusion_date = CURRENT_DATE
|
||||||
|
AND tce.tenant_id = T9.tenant_id -- 按租户过滤
|
||||||
|
WHERE tqi.id IS NULL -- 关键:只查询不在队列中的患者
|
||||||
|
AND tce.id IS NULL -- 关键:只查询不在排除列表中的患者
|
||||||
|
ORDER BY T9.register_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案二:简化查询(仅核心字段,便于快速测试)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.id AS organizationId,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service hcs ON enc.service_type_id = hcs.id AND hcs.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0' AND type_code IN ('admitter', 'registration_doctor')
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
-- 排除已在队列中的患者
|
||||||
|
LEFT JOIN hisdev.triage_queue_item tqi
|
||||||
|
ON enc.id = tqi.encounter_id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
-- 排除已在排除列表中的患者(新增)
|
||||||
|
LEFT JOIN hisdev.triage_candidate_exclusion tce
|
||||||
|
ON enc.id = tce.encounter_id
|
||||||
|
AND tce.delete_flag = '0'
|
||||||
|
AND tce.exclusion_date = CURRENT_DATE
|
||||||
|
AND tce.tenant_id = enc.tenant_id
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6
|
||||||
|
AND tqi.id IS NULL -- 不在队列中
|
||||||
|
AND tce.id IS NULL -- 不在排除列表中
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 方案三:使用 NOT EXISTS 子查询(性能可能更好)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
org.id AS organizationId,
|
||||||
|
org.name AS organizationName,
|
||||||
|
hcs.name AS healthcareName,
|
||||||
|
pr.name AS practitionerName,
|
||||||
|
enc.create_time AS registerTime
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization org ON enc.organization_id = org.id AND org.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_healthcare_service hcs ON enc.service_type_id = hcs.id AND hcs.delete_flag = '0'
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT encounter_id, practitioner_id,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY encounter_id ORDER BY create_time ASC) AS rn
|
||||||
|
FROM adm_encounter_participant
|
||||||
|
WHERE delete_flag = '0' AND type_code IN ('admitter', 'registration_doctor')
|
||||||
|
) ep ON enc.id = ep.encounter_id AND ep.rn = 1
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6
|
||||||
|
-- 排除已在队列中的患者
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hisdev.triage_queue_item tqi
|
||||||
|
WHERE tqi.encounter_id = enc.id
|
||||||
|
AND tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
)
|
||||||
|
-- 排除已在排除列表中的患者(新增)
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM hisdev.triage_candidate_exclusion tce
|
||||||
|
WHERE tce.encounter_id = enc.id
|
||||||
|
AND tce.delete_flag = '0'
|
||||||
|
AND tce.exclusion_date = CURRENT_DATE
|
||||||
|
AND tce.tenant_id = enc.tenant_id
|
||||||
|
)
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 查询条件说明
|
||||||
|
-- ============================================
|
||||||
|
-- 1. 基础条件:
|
||||||
|
-- - enc.delete_flag = '0' -- 未删除
|
||||||
|
-- - enc.class_enum = 1 -- 门诊(AMB)
|
||||||
|
-- - ci.context_enum = 1 -- 挂号(REGISTER)
|
||||||
|
-- - prc.status_enum = 1 -- 支付成功(SUCCESS)
|
||||||
|
--
|
||||||
|
-- 2. 日期过滤:
|
||||||
|
-- - enc.create_time::DATE = CURRENT_DATE -- 当日挂号
|
||||||
|
-- 注意:前端还会基于 registerTime 字段再次过滤今天的数据
|
||||||
|
--
|
||||||
|
-- 3. 状态过滤:
|
||||||
|
-- - enc.status_enum != 6 -- 排除退号(对应前端 statusEnum = -1)
|
||||||
|
--
|
||||||
|
-- 4. 队列去重:
|
||||||
|
-- - LEFT JOIN hisdev.triage_queue_item ... WHERE tqi.id IS NULL
|
||||||
|
-- 或者
|
||||||
|
-- - NOT EXISTS (SELECT 1 FROM hisdev.triage_queue_item ...)
|
||||||
|
-- 排除已在队列中且状态不是 COMPLETED 的患者
|
||||||
|
--
|
||||||
|
-- 5. 排除列表去重(新增):
|
||||||
|
-- - LEFT JOIN hisdev.triage_candidate_exclusion ... WHERE tce.id IS NULL
|
||||||
|
-- 或者
|
||||||
|
-- - NOT EXISTS (SELECT 1 FROM hisdev.triage_candidate_exclusion ...)
|
||||||
|
-- 排除已在排除列表中的患者(已加入队列后被记录)
|
||||||
|
--
|
||||||
|
-- 6. 租户过滤(如果需要):
|
||||||
|
-- - enc.tenant_id = ? -- 当前登录用户的租户ID
|
||||||
|
--
|
||||||
|
-- 7. 模糊搜索(如果需要):
|
||||||
|
-- - pt.name LIKE '%关键词%' -- 患者姓名
|
||||||
|
-- - org.name LIKE '%关键词%' -- 科室名称
|
||||||
|
-- - pr.name LIKE '%关键词%' -- 医生姓名
|
||||||
|
-- - hcs.name LIKE '%关键词%' -- 号别名称
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 调试查询(检查数据是否正确)
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 1. 检查当日已挂号患者总数
|
||||||
|
SELECT COUNT(*) AS total_registered
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6;
|
||||||
|
|
||||||
|
-- 2. 检查已在队列中的患者数量
|
||||||
|
SELECT COUNT(DISTINCT encounter_id) AS in_queue_count
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED';
|
||||||
|
|
||||||
|
-- 3. 检查已在排除列表中的患者数量(新增)
|
||||||
|
SELECT COUNT(DISTINCT encounter_id) AS in_exclusion_count
|
||||||
|
FROM hisdev.triage_candidate_exclusion
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND exclusion_date = CURRENT_DATE;
|
||||||
|
|
||||||
|
-- 4. 检查候选池应该显示的患者数量(已挂号 - 已在队列 - 已在排除列表)
|
||||||
|
SELECT
|
||||||
|
(SELECT COUNT(*)
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
INNER JOIN fin_payment_reconciliation prc ON ci.id::TEXT = ANY(string_to_array(prc.charge_item_ids,','))
|
||||||
|
AND prc.delete_flag = '0' AND prc.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.status_enum != 6)
|
||||||
|
-
|
||||||
|
(SELECT COUNT(DISTINCT encounter_id)
|
||||||
|
FROM hisdev.triage_queue_item
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND queue_date = CURRENT_DATE
|
||||||
|
AND status != 'COMPLETED')
|
||||||
|
-
|
||||||
|
(SELECT COUNT(DISTINCT encounter_id)
|
||||||
|
FROM hisdev.triage_candidate_exclusion
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND exclusion_date = CURRENT_DATE)
|
||||||
|
AS candidate_pool_count;
|
||||||
|
|
||||||
|
-- 5. 查看队列中的患者详情(用于对比)
|
||||||
|
SELECT
|
||||||
|
tqi.encounter_id,
|
||||||
|
tqi.patient_name,
|
||||||
|
tqi.status,
|
||||||
|
tqi.queue_order
|
||||||
|
FROM hisdev.triage_queue_item tqi
|
||||||
|
WHERE tqi.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
AND tqi.status != 'COMPLETED'
|
||||||
|
ORDER BY tqi.queue_order;
|
||||||
|
|
||||||
|
-- 6. 查看排除列表中的患者详情(新增)
|
||||||
|
SELECT
|
||||||
|
tce.encounter_id,
|
||||||
|
tce.patient_name,
|
||||||
|
tce.reason,
|
||||||
|
tce.create_time
|
||||||
|
FROM hisdev.triage_candidate_exclusion tce
|
||||||
|
WHERE tce.delete_flag = '0'
|
||||||
|
AND tce.exclusion_date = CURRENT_DATE
|
||||||
|
ORDER BY tce.create_time DESC;
|
||||||
|
|
||||||
|
-- 7. 查看重叠的患者(既在队列中,又在排除列表中)
|
||||||
|
SELECT
|
||||||
|
tqi.encounter_id,
|
||||||
|
tqi.patient_name AS queue_patient_name,
|
||||||
|
tce.patient_name AS exclusion_patient_name,
|
||||||
|
tqi.status,
|
||||||
|
tce.reason
|
||||||
|
FROM hisdev.triage_queue_item tqi
|
||||||
|
INNER JOIN hisdev.triage_candidate_exclusion tce
|
||||||
|
ON tqi.encounter_id = tce.encounter_id
|
||||||
|
AND tqi.queue_date = tce.exclusion_date
|
||||||
|
AND tqi.tenant_id = tce.tenant_id
|
||||||
|
WHERE tqi.delete_flag = '0'
|
||||||
|
AND tce.delete_flag = '0'
|
||||||
|
AND tqi.queue_date = CURRENT_DATE
|
||||||
|
ORDER BY tqi.encounter_id;
|
||||||
|
|
||||||
33
openhis-ui-vue3/src/api/system/lisConfig.js
Normal file
33
openhis-ui-vue3/src/api/system/lisConfig.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getLisConfigPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/lisConfig/init-page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLisConfigDetail(id) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/lisConfig/info-detail',
|
||||||
|
method: 'get',
|
||||||
|
params: { id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLisConfigList(searchKey, type) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/lisConfig/init-list',
|
||||||
|
method: 'get',
|
||||||
|
params: { searchKey, type }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function saveLisConfig(data) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/lisConfig/saveAll',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
48
openhis-ui-vue3/src/api/system/observation.js
Normal file
48
openhis-ui-vue3/src/api/system/observation.js
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function getObservationInit() {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/init',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObservationPage(query) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/information-page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObservationOne(id) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/information-one',
|
||||||
|
method: 'get',
|
||||||
|
params: { id }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addObservation(data) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/information',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateObservation(data) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/information',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deleteObservation(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/inspection/observation/information-status',
|
||||||
|
method: 'post',
|
||||||
|
data: { ids, type: '停用' }
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -266,6 +266,32 @@ export const dynamicRoutes = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
// 字典类型路由(直接复制这段)
|
||||||
|
{
|
||||||
|
path: '/system/dict',
|
||||||
|
component: Layout,
|
||||||
|
alwaysShow: true,
|
||||||
|
name: 'DictType',
|
||||||
|
meta: {
|
||||||
|
title: '字典类型管理',
|
||||||
|
icon: 'list' // 图标随便选一个,比如list、dict,不影响跳转
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: '',
|
||||||
|
component: () => import('@/views/system/dict/index.vue'),
|
||||||
|
name: 'DictTypeList',
|
||||||
|
meta: {title: '字典类型', noCache: false}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'data/:dictId?', // 带字典ID参数,?表示可选
|
||||||
|
component: () => import('@/views/system/dict/data.vue'), // 你的data.vue路径
|
||||||
|
name: 'DictData',
|
||||||
|
hidden: true, // 不在侧边栏显示(子页面)
|
||||||
|
meta: {title: '字典数据', activeMenu: '/system/dict'} // 保持侧边栏高亮
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// 合并常量路由和动态路由,确保所有路由都能被访问
|
// 合并常量路由和动态路由,确保所有路由都能被访问
|
||||||
|
|||||||
@@ -427,11 +427,7 @@ function handleNodeClick(res, node) {
|
|||||||
// 实际的节点点击处理逻辑
|
// 实际的节点点击处理逻辑
|
||||||
function continueHandleNodeClick(node) {
|
function continueHandleNodeClick(node) {
|
||||||
// 新增按钮是否 disable
|
// 新增按钮是否 disable
|
||||||
if (node.parent === null || node.level === 1) {
|
|
||||||
isAddDisable.value = true;
|
|
||||||
} else {
|
|
||||||
isAddDisable.value = false;
|
isAddDisable.value = false;
|
||||||
}
|
|
||||||
// 检查节点是否有子节点
|
// 检查节点是否有子节点
|
||||||
if (node.data.children && node.data.children.length > 0) {
|
if (node.data.children && node.data.children.length > 0) {
|
||||||
// proxy.$message.warning("不能选择父节点");
|
// proxy.$message.warning("不能选择父节点");
|
||||||
|
|||||||
@@ -1,55 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<el-form
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px"
|
||||||
:model="queryParams"
|
class="query-form">
|
||||||
ref="queryRef"
|
|
||||||
:inline="true"
|
|
||||||
v-show="showSearch"
|
|
||||||
label-width="68px"
|
|
||||||
class="query-form"
|
|
||||||
>
|
|
||||||
<el-form-item label="字典名称" prop="dictName">
|
<el-form-item label="字典名称" prop="dictName">
|
||||||
<el-input
|
<el-input v-model="queryParams.dictName" placeholder="请输入字典名称" clearable style="width: 240px"
|
||||||
v-model="queryParams.dictName"
|
@keyup.enter="handleQuery" />
|
||||||
placeholder="请输入字典名称"
|
|
||||||
clearable
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="字典类型" prop="dictType">
|
<el-form-item label="字典类型" prop="dictType">
|
||||||
<el-input
|
<el-input v-model="queryParams.dictType" placeholder="请输入字典类型" clearable style="width: 240px"
|
||||||
v-model="queryParams.dictType"
|
@keyup.enter="handleQuery" />
|
||||||
placeholder="请输入字典类型"
|
|
||||||
clearable
|
|
||||||
style="width: 240px"
|
|
||||||
@keyup.enter="handleQuery"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-select
|
<el-select v-model="queryParams.status" placeholder="字典状态" clearable style="width: 240px">
|
||||||
v-model="queryParams.status"
|
<el-option v-for="dict in sys_normal_disable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
||||||
placeholder="字典状态"
|
|
||||||
clearable
|
|
||||||
style="width: 240px"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="dict in sys_normal_disable"
|
|
||||||
:key="dict.value"
|
|
||||||
:label="dict.label"
|
|
||||||
:value="dict.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="创建时间" style="width: 308px">
|
<el-form-item label="创建时间" style="width: 308px">
|
||||||
<el-date-picker
|
<el-date-picker v-model="dateRange" value-format="YYYY-MM-DD" type="daterange" range-separator="-"
|
||||||
v-model="dateRange"
|
start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="search-buttons">
|
<el-form-item class="search-buttons">
|
||||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
@@ -59,76 +27,34 @@
|
|||||||
|
|
||||||
<el-row :gutter="10" class="button-group">
|
<el-row :gutter="10" class="button-group">
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:dict:add']">新增</el-button>
|
||||||
type="primary"
|
|
||||||
plain
|
|
||||||
icon="Plus"
|
|
||||||
@click="handleAdd"
|
|
||||||
v-hasPermi="['system:dict:add']"
|
|
||||||
>新增</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate"
|
||||||
type="success"
|
v-hasPermi="['system:dict:edit']">修改</el-button>
|
||||||
plain
|
|
||||||
icon="Edit"
|
|
||||||
:disabled="single"
|
|
||||||
@click="handleUpdate"
|
|
||||||
v-hasPermi="['system:dict:edit']"
|
|
||||||
>修改</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete"
|
||||||
type="danger"
|
v-hasPermi="['system:dict:remove']">删除</el-button>
|
||||||
plain
|
|
||||||
icon="Delete"
|
|
||||||
:disabled="multiple"
|
|
||||||
@click="handleDelete"
|
|
||||||
v-hasPermi="['system:dict:remove']"
|
|
||||||
>删除</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="warning" plain icon="Download" @click="handleExport"
|
||||||
type="warning"
|
v-hasPermi="['system:dict:export']">导出</el-button>
|
||||||
plain
|
|
||||||
icon="Download"
|
|
||||||
@click="handleExport"
|
|
||||||
v-hasPermi="['system:dict:export']"
|
|
||||||
>导出</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<el-button type="danger" plain icon="Refresh" @click="handleRefreshCache"
|
||||||
type="danger"
|
v-hasPermi="['system:dict:remove']">刷新缓存</el-button>
|
||||||
plain
|
|
||||||
icon="Refresh"
|
|
||||||
@click="handleRefreshCache"
|
|
||||||
v-hasPermi="['system:dict:remove']"
|
|
||||||
>刷新缓存</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div class="table-wrapper">
|
<div class="table-wrapper">
|
||||||
<el-table
|
<el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
|
||||||
v-loading="loading"
|
|
||||||
:data="typeList"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
<el-table-column label="字典编号" align="center" prop="dictId" />
|
<el-table-column label="字典编号" align="center" prop="dictId" />
|
||||||
<el-table-column
|
<el-table-column label="字典名称" align="center" prop="dictName" :show-overflow-tooltip="true" />
|
||||||
label="字典名称"
|
|
||||||
align="center"
|
|
||||||
prop="dictName"
|
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
/>
|
|
||||||
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
|
<el-table-column label="字典类型" align="center" :show-overflow-tooltip="true">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
|
<router-link :to="'/system/dict/data/' + scope.row.dictId" class="link-type">
|
||||||
<span>{{ scope.row.dictType }}</span>
|
<span>{{ scope.row.dictType }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
@@ -144,40 +70,18 @@
|
|||||||
<span>{{ parseTime(scope.row.createTime) }}</span>
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
|
||||||
label="操作"
|
|
||||||
align="center"
|
|
||||||
width="160"
|
|
||||||
class-name="small-padding fixed-width"
|
|
||||||
>
|
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
|
||||||
link
|
v-hasPermi="['system:dict:edit']" class="action-button">修改</el-button>
|
||||||
type="primary"
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
|
||||||
icon="Edit"
|
v-hasPermi="['system:dict:remove']" class="action-button">删除</el-button>
|
||||||
@click="handleUpdate(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:edit']"
|
|
||||||
class="action-button">修改</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
icon="Delete"
|
|
||||||
@click="handleDelete(scope.row)"
|
|
||||||
v-hasPermi="['system:dict:remove']"
|
|
||||||
class="action-button">删除</el-button
|
|
||||||
>
|
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<div class="pagination-container">
|
<div class="pagination-container">
|
||||||
<pagination
|
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
|
||||||
v-show="total > 0"
|
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||||
:total="total"
|
|
||||||
v-model:page="queryParams.pageNum"
|
|
||||||
v-model:limit="queryParams.pageSize"
|
|
||||||
@pagination="getList"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -213,7 +117,7 @@
|
|||||||
|
|
||||||
<script setup name="Dict">
|
<script setup name="Dict">
|
||||||
import useDictStore from '@/store/modules/dict';
|
import useDictStore from '@/store/modules/dict';
|
||||||
import {addType, delType, getType, listType, refreshCache, updateType,} from '@/api/system/dict/type';
|
import { addType, delType, getType, listType, refreshCache, updateType, } from '@/api/system/dict/type';
|
||||||
|
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
const { sys_normal_disable } = proxy.useDict('sys_normal_disable');
|
const { sys_normal_disable } = proxy.useDict('sys_normal_disable');
|
||||||
@@ -291,7 +195,7 @@ function handleAdd() {
|
|||||||
/** 多选框选中数据 */
|
/** 多选框选中数据 */
|
||||||
function handleSelectionChange(selection) {
|
function handleSelectionChange(selection) {
|
||||||
ids.value = selection.map((item) => item.dictId);
|
ids.value = selection.map((item) => item.dictId);
|
||||||
single.value = selection.length != 1;
|
single.value = selection.length !== 1;
|
||||||
multiple.value = !selection.length;
|
multiple.value = !selection.length;
|
||||||
}
|
}
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
@@ -308,14 +212,14 @@ function handleUpdate(row) {
|
|||||||
function submitForm() {
|
function submitForm() {
|
||||||
proxy.$refs['dictRef'].validate((valid) => {
|
proxy.$refs['dictRef'].validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (form.value.dictId != undefined) {
|
if (form.value.dictId !== undefined) {
|
||||||
updateType(form.value).then((response) => {
|
updateType(form.value).then(() => {
|
||||||
proxy.$modal.msgSuccess('修改成功');
|
proxy.$modal.msgSuccess('修改成功');
|
||||||
open.value = false;
|
open.value = false;
|
||||||
getList();
|
getList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
addType(form.value).then((response) => {
|
addType(form.value).then(() => {
|
||||||
proxy.$modal.msgSuccess('新增成功');
|
proxy.$modal.msgSuccess('新增成功');
|
||||||
open.value = false;
|
open.value = false;
|
||||||
getList();
|
getList();
|
||||||
@@ -336,7 +240,7 @@ function handleDelete(row) {
|
|||||||
getList();
|
getList();
|
||||||
proxy.$modal.msgSuccess('删除成功');
|
proxy.$modal.msgSuccess('删除成功');
|
||||||
})
|
})
|
||||||
.catch(() => {});
|
.catch(() => { });
|
||||||
}
|
}
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
function handleExport() {
|
function handleExport() {
|
||||||
|
|||||||
112
openhis-ui-vue3/src/views/system/user copy/authRole.vue
Normal file
112
openhis-ui-vue3/src/views/system/user copy/authRole.vue
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<el-form :model="form" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="登录账号" prop="userName">
|
||||||
|
<el-input v-model="form.userName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<h4 class="form-header h4">角色信息</h4>
|
||||||
|
<el-table v-loading="loading" :row-key="getRowKey" @row-click="clickRow" ref="roleRef" @selection-change="handleSelectionChange" :data="roles.slice((pageNum - 1) * pageSize, pageNum * pageSize)">
|
||||||
|
<el-table-column label="序号" width="55" type="index" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
|
||||||
|
<el-table-column label="角色编号" align="center" prop="roleId" />
|
||||||
|
<el-table-column label="角色名称" align="center" prop="roleName" />
|
||||||
|
<el-table-column label="权限字符" align="center" prop="roleKey" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination v-show="total > 0" :total="total" v-model:page="pageNum" v-model:limit="pageSize" />
|
||||||
|
|
||||||
|
<el-form label-width="100px">
|
||||||
|
<div style="text-align: center;margin-left:-120px;margin-top:30px;">
|
||||||
|
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||||
|
<el-button @click="close()">返回</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="AuthRole">
|
||||||
|
import {getAuthRole, updateAuthRole} from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const loading = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const pageNum = ref(1);
|
||||||
|
const pageSize = ref(10);
|
||||||
|
const roleIds = ref([]);
|
||||||
|
const roles = ref([]);
|
||||||
|
const form = ref({
|
||||||
|
nickName: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
userId: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 单击选中行数据 */
|
||||||
|
function clickRow(row) {
|
||||||
|
proxy.$refs["roleRef"].toggleRowSelection(row);
|
||||||
|
};
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
roleIds.value = selection.map(item => item.roleId);
|
||||||
|
};
|
||||||
|
/** 保存选中的数据编号 */
|
||||||
|
function getRowKey(row) {
|
||||||
|
return row.roleId;
|
||||||
|
};
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
const obj = { path: "/system/user" };
|
||||||
|
proxy.$tab.closeOpenPage(obj);
|
||||||
|
};
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
const userId = form.value.userId;
|
||||||
|
const rIds = roleIds.value.join(",");
|
||||||
|
updateAuthRole({ userId: userId, roleIds: rIds }).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("授权成功");
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
const userId = route.params && route.params.userId;
|
||||||
|
if (userId) {
|
||||||
|
loading.value = true;
|
||||||
|
getAuthRole(userId).then(response => {
|
||||||
|
form.value = response.user;
|
||||||
|
roles.value = response.roles;
|
||||||
|
total.value = roles.value.length;
|
||||||
|
nextTick(() => {
|
||||||
|
roles.value.forEach(row => {
|
||||||
|
if (row.flag) {
|
||||||
|
proxy.$refs["roleRef"].toggleRowSelection(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
621
openhis-ui-vue3/src/views/system/user copy/index.vue
Normal file
621
openhis-ui-vue3/src/views/system/user copy/index.vue
Normal file
@@ -0,0 +1,621 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<!--部门数据-->
|
||||||
|
<el-col :span="4" :xs="24">
|
||||||
|
<div class="head-container">
|
||||||
|
<el-input
|
||||||
|
v-model="deptName"
|
||||||
|
placeholder="请输入部门名称"
|
||||||
|
clearable
|
||||||
|
prefix-icon="Search"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="head-container">
|
||||||
|
<el-tree
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ label: 'label', children: 'children' }"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
ref="deptTreeRef"
|
||||||
|
node-key="id"
|
||||||
|
highlight-current
|
||||||
|
default-expand-all
|
||||||
|
@node-click="handleNodeClick"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<!--用户数据-->
|
||||||
|
<el-col :span="20" :xs="24">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.phonenumber"
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="用户状态"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" style="width: 308px;">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['system:user:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="Edit"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['system:user:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['system:user:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
icon="Upload"
|
||||||
|
@click="handleImport"
|
||||||
|
v-hasPermi="['system:user:import']"
|
||||||
|
>导入</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="Download"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['system:user:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
|
||||||
|
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
|
||||||
|
<el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.status"
|
||||||
|
active-value="0"
|
||||||
|
inactive-value="1"
|
||||||
|
@change="handleStatusChange(scope.row)"
|
||||||
|
></el-switch>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip content="修改" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="重置密码" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="分配角色" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="CircleCheck" @click="handleAuthRole(scope.row)" v-hasPermi="['system:user:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 添加或修改用户配置对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||||
|
<el-form :model="form" :rules="rules" ref="userRef" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="归属部门" prop="deptId">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="form.deptId"
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ value: 'id', label: 'label', children: 'children' }"
|
||||||
|
value-key="id"
|
||||||
|
placeholder="请选择归属部门"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
|
||||||
|
<el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
|
||||||
|
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户性别">
|
||||||
|
<el-select v-model="form.sex" placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in sys_user_sex"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>{{ dict.label }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="岗位">
|
||||||
|
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in postOptions"
|
||||||
|
:key="item.postId"
|
||||||
|
:label="item.postName"
|
||||||
|
:value="item.postId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="角色">
|
||||||
|
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in roleOptions"
|
||||||
|
:key="item.roleId"
|
||||||
|
:label="item.roleName"
|
||||||
|
:value="item.roleId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 用户导入对话框 -->
|
||||||
|
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
:limit="1"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
:headers="upload.headers"
|
||||||
|
:action="upload.url + '?updateSupport=' + upload.updateSupport"
|
||||||
|
:disabled="upload.isUploading"
|
||||||
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:on-success="handleFileSuccess"
|
||||||
|
:auto-upload="false"
|
||||||
|
drag
|
||||||
|
>
|
||||||
|
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||||
|
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||||
|
<el-button @click="upload.open = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="User">
|
||||||
|
import {getToken} from "@/utils/auth";
|
||||||
|
import {
|
||||||
|
addUser,
|
||||||
|
changeUserStatus,
|
||||||
|
delUser,
|
||||||
|
deptTreeSelect,
|
||||||
|
getUser,
|
||||||
|
listUser,
|
||||||
|
resetUserPwd,
|
||||||
|
updateUser
|
||||||
|
} from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
|
||||||
|
|
||||||
|
const userList = ref([]);
|
||||||
|
const open = ref(false);
|
||||||
|
const loading = ref(true);
|
||||||
|
const showSearch = ref(true);
|
||||||
|
const ids = ref([]);
|
||||||
|
const single = ref(true);
|
||||||
|
const multiple = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const title = ref("");
|
||||||
|
const dateRange = ref([]);
|
||||||
|
const deptName = ref("");
|
||||||
|
const deptOptions = ref(undefined);
|
||||||
|
const initPassword = ref(undefined);
|
||||||
|
const postOptions = ref([]);
|
||||||
|
const roleOptions = ref([]);
|
||||||
|
/*** 用户导入参数 */
|
||||||
|
const upload = reactive({
|
||||||
|
// 是否显示弹出层(用户导入)
|
||||||
|
open: false,
|
||||||
|
// 弹出层标题(用户导入)
|
||||||
|
title: "",
|
||||||
|
// 是否禁用上传
|
||||||
|
isUploading: false,
|
||||||
|
// 是否更新已经存在的用户数据
|
||||||
|
updateSupport: 0,
|
||||||
|
// 设置上传的请求头部
|
||||||
|
headers: { Authorization: "Bearer " + getToken() },
|
||||||
|
// 上传的地址
|
||||||
|
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
|
||||||
|
});
|
||||||
|
// 列显隐信息
|
||||||
|
const columns = ref([
|
||||||
|
{ key: 0, label: `用户编号`, visible: true },
|
||||||
|
{ key: 1, label: `用户名称`, visible: true },
|
||||||
|
{ key: 2, label: `用户昵称`, visible: true },
|
||||||
|
{ key: 3, label: `部门`, visible: true },
|
||||||
|
{ key: 4, label: `手机号码`, visible: true },
|
||||||
|
{ key: 5, label: `状态`, visible: true },
|
||||||
|
{ key: 6, label: `创建时间`, visible: true }
|
||||||
|
]);
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
userName: undefined,
|
||||||
|
phonenumber: undefined,
|
||||||
|
status: undefined,
|
||||||
|
deptId: undefined
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }],
|
||||||
|
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
||||||
|
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
||||||
|
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||||
|
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 通过条件过滤节点 */
|
||||||
|
const filterNode = (value, data) => {
|
||||||
|
if (!value) return true;
|
||||||
|
return data.label.indexOf(value) !== -1;
|
||||||
|
};
|
||||||
|
/** 根据名称筛选部门树 */
|
||||||
|
watch(deptName, val => {
|
||||||
|
proxy.$refs["deptTreeRef"].filter(val);
|
||||||
|
});
|
||||||
|
/** 查询部门下拉树结构 */
|
||||||
|
function getDeptTree() {
|
||||||
|
deptTreeSelect().then(response => {
|
||||||
|
deptOptions.value = response.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 查询用户列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
|
||||||
|
loading.value = false;
|
||||||
|
userList.value = res.rows;
|
||||||
|
total.value = res.total;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 节点单击事件 */
|
||||||
|
function handleNodeClick(data) {
|
||||||
|
queryParams.value.deptId = data.id;
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
dateRange.value = [];
|
||||||
|
proxy.resetForm("queryRef");
|
||||||
|
queryParams.value.deptId = undefined;
|
||||||
|
proxy.$refs.deptTreeRef.setCurrentKey(null);
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const userIds = row.userId || ids.value;
|
||||||
|
proxy.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function () {
|
||||||
|
return delUser(userIds);
|
||||||
|
}).then(() => {
|
||||||
|
getList();
|
||||||
|
proxy.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
};
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download("system/user/export", {
|
||||||
|
...queryParams.value,
|
||||||
|
},`user_${new Date().getTime()}.xlsx`);
|
||||||
|
};
|
||||||
|
/** 用户状态修改 */
|
||||||
|
function handleStatusChange(row) {
|
||||||
|
let text = row.status === "0" ? "启用" : "停用";
|
||||||
|
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
||||||
|
return changeUserStatus(row.userId, row.status);
|
||||||
|
}).then(() => {
|
||||||
|
proxy.$modal.msgSuccess(text + "成功");
|
||||||
|
}).catch(function () {
|
||||||
|
row.status = row.status === "0" ? "1" : "0";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 更多操作 */
|
||||||
|
function handleCommand(command, row) {
|
||||||
|
switch (command) {
|
||||||
|
case "handleResetPwd":
|
||||||
|
handleResetPwd(row);
|
||||||
|
break;
|
||||||
|
case "handleAuthRole":
|
||||||
|
handleAuthRole(row);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/** 跳转角色分配 */
|
||||||
|
function handleAuthRole(row) {
|
||||||
|
const userId = row.userId;
|
||||||
|
router.push("/system/user-auth/role/" + userId);
|
||||||
|
};
|
||||||
|
/** 重置密码按钮操作 */
|
||||||
|
function handleResetPwd(row) {
|
||||||
|
proxy.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
closeOnClickModal: false,
|
||||||
|
inputPattern: /^.{5,20}$/,
|
||||||
|
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
|
||||||
|
inputValidator: (value) => {
|
||||||
|
if (/<|>|"|'|\||\\/.test(value)) {
|
||||||
|
return "不能包含非法字符:< > \" ' \\\ |"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}).then(({ value }) => {
|
||||||
|
resetUserPwd(row.userId, value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功,新密码是:" + value);
|
||||||
|
});
|
||||||
|
}).catch(() => {});
|
||||||
|
};
|
||||||
|
/** 选择条数 */
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map(item => item.userId);
|
||||||
|
single.value = selection.length != 1;
|
||||||
|
multiple.value = !selection.length;
|
||||||
|
};
|
||||||
|
/** 导入按钮操作 */
|
||||||
|
function handleImport() {
|
||||||
|
upload.title = "用户导入";
|
||||||
|
upload.open = true;
|
||||||
|
};
|
||||||
|
/** 下载模板操作 */
|
||||||
|
function importTemplate() {
|
||||||
|
proxy.download("system/user/importTemplate", {
|
||||||
|
}, `user_template_${new Date().getTime()}.xlsx`);
|
||||||
|
};
|
||||||
|
/**文件上传中处理 */
|
||||||
|
const handleFileUploadProgress = (event, file, fileList) => {
|
||||||
|
upload.isUploading = true;
|
||||||
|
};
|
||||||
|
/** 文件上传成功处理 */
|
||||||
|
const handleFileSuccess = (response, file, fileList) => {
|
||||||
|
upload.open = false;
|
||||||
|
upload.isUploading = false;
|
||||||
|
proxy.$refs["uploadRef"].handleRemove(file);
|
||||||
|
proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
/** 提交上传文件 */
|
||||||
|
function submitFileForm() {
|
||||||
|
proxy.$refs["uploadRef"].submit();
|
||||||
|
};
|
||||||
|
/** 重置操作表单 */
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
userId: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
nickName: undefined,
|
||||||
|
password: undefined,
|
||||||
|
phonenumber: undefined,
|
||||||
|
email: undefined,
|
||||||
|
sex: undefined,
|
||||||
|
status: "0",
|
||||||
|
remark: undefined,
|
||||||
|
postIds: [],
|
||||||
|
roleIds: []
|
||||||
|
};
|
||||||
|
proxy.resetForm("userRef");
|
||||||
|
};
|
||||||
|
/** 取消按钮 */
|
||||||
|
function cancel() {
|
||||||
|
open.value = false;
|
||||||
|
reset();
|
||||||
|
};
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset();
|
||||||
|
getUser().then(response => {
|
||||||
|
postOptions.value = response.posts;
|
||||||
|
roleOptions.value = response.roles;
|
||||||
|
open.value = true;
|
||||||
|
title.value = "添加用户";
|
||||||
|
form.value.password = initPassword.value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset();
|
||||||
|
const userId = row.userId || ids.value;
|
||||||
|
getUser(userId).then(response => {
|
||||||
|
form.value = response.data;
|
||||||
|
postOptions.value = response.posts;
|
||||||
|
roleOptions.value = response.roles;
|
||||||
|
form.value.postIds = response.postIds;
|
||||||
|
form.value.roleIds = response.roleIds;
|
||||||
|
open.value = true;
|
||||||
|
title.value = "修改用户";
|
||||||
|
form.password = "";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.$refs["userRef"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.value.userId != undefined) {
|
||||||
|
updateUser(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addUser(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("新增成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getDeptTree();
|
||||||
|
getList();
|
||||||
|
</script>
|
||||||
87
openhis-ui-vue3/src/views/system/user copy/profile/index.vue
Normal file
87
openhis-ui-vue3/src/views/system/user copy/profile/index.vue
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="6" :xs="24">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template v-slot:header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>个人信息</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div>
|
||||||
|
<div class="text-center">
|
||||||
|
<userAvatar />
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-striped">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="user" />用户名称
|
||||||
|
<div class="pull-right">{{ state.user.userName }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="phone" />手机号码
|
||||||
|
<div class="pull-right">{{ state.user.phonenumber }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="email" />用户邮箱
|
||||||
|
<div class="pull-right">{{ state.user.email }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="tree" />所属部门
|
||||||
|
<div class="pull-right" v-if="state.user.dept">{{ state.user.dept.deptName }} / {{ state.postGroup }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="peoples" />所属角色
|
||||||
|
<div class="pull-right">{{ state.roleGroup }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="date" />创建日期
|
||||||
|
<div class="pull-right">{{ state.user.createTime }}</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="18" :xs="24">
|
||||||
|
<el-card>
|
||||||
|
<template v-slot:header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>基本资料</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="基本资料" name="userinfo">
|
||||||
|
<userInfo :user="state.user" />
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="修改密码" name="resetPwd">
|
||||||
|
<resetPwd />
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="Profile">
|
||||||
|
import userAvatar from "./userAvatar";
|
||||||
|
import userInfo from "./userInfo";
|
||||||
|
import resetPwd from "./resetPwd";
|
||||||
|
import {getUserProfile} from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const activeTab = ref("userinfo");
|
||||||
|
const state = reactive({
|
||||||
|
user: {},
|
||||||
|
roleGroup: {},
|
||||||
|
postGroup: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getUser() {
|
||||||
|
getUserProfile().then(response => {
|
||||||
|
state.user = response.data;
|
||||||
|
state.roleGroup = response.roleGroup;
|
||||||
|
state.postGroup = response.postGroup;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getUser();
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: 徐靖博 xujb@ccjb.com.cn
|
||||||
|
* @Date: 2025-03-26 10:49:30
|
||||||
|
* @LastEditTime: 2025-03-26 13:57:02
|
||||||
|
* @LastEditors: 徐靖博 xujb@ccjb.com.cn
|
||||||
|
* @Description:
|
||||||
|
* @FilePath: \openhis-ui-vue3\src\views\system\user copy\profile\resetPwd.vue
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-form ref="pwdRef" :model="user" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="旧密码" prop="oldPassword">
|
||||||
|
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新密码" prop="newPassword">
|
||||||
|
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="确认密码" prop="confirmPassword">
|
||||||
|
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submit">保存</el-button>
|
||||||
|
<el-button type="danger" @click="close">关闭</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {updateUserPwd} from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const user = reactive({
|
||||||
|
oldPassword: undefined,
|
||||||
|
newPassword: undefined,
|
||||||
|
confirmPassword: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const equalToPassword = (rule, value, callback) => {
|
||||||
|
if (user.newPassword !== value) {
|
||||||
|
callback(new Error("两次输入的密码不一致"));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const rules = ref({
|
||||||
|
oldPassword: [{ required: true, message: "旧密码不能为空", trigger: "blur" }],
|
||||||
|
newPassword: [{ required: true, message: "新密码不能为空", trigger: "blur" }, { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
||||||
|
confirmPassword: [{ required: true, message: "确认密码不能为空", trigger: "blur" }, { required: true, validator: equalToPassword, trigger: "blur" }]
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submit() {
|
||||||
|
proxy.$refs.pwdRef.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
updateUserPwd(user.oldPassword, user.newPassword).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
proxy.$tab.closePage();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<template>
|
||||||
|
<div class="user-info-head" @click="editCropper()">
|
||||||
|
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
||||||
|
<el-dialog :title="title" v-model="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
||||||
|
<el-row>
|
||||||
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
|
<vue-cropper
|
||||||
|
ref="cropper"
|
||||||
|
:img="options.img"
|
||||||
|
:info="true"
|
||||||
|
:autoCrop="options.autoCrop"
|
||||||
|
:autoCropWidth="options.autoCropWidth"
|
||||||
|
:autoCropHeight="options.autoCropHeight"
|
||||||
|
:fixedBox="options.fixedBox"
|
||||||
|
:outputType="options.outputType"
|
||||||
|
@realTime="realTime"
|
||||||
|
v-if="visible"
|
||||||
|
/>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
|
<div class="avatar-upload-preview">
|
||||||
|
<img :src="options.previews.url" :style="options.previews.img" />
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<br />
|
||||||
|
<el-row>
|
||||||
|
<el-col :lg="2" :md="2">
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
:http-request="requestUpload"
|
||||||
|
:show-file-list="false"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
>
|
||||||
|
<el-button>
|
||||||
|
选择
|
||||||
|
<el-icon class="el-icon--right"><Upload /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 2 }" :md="2">
|
||||||
|
<el-button icon="Plus" @click="changeScale(1)"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="Minus" @click="changeScale(-1)"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="RefreshLeft" @click="rotateLeft()"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="RefreshRight" @click="rotateRight()"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 2, offset: 6 }" :md="2">
|
||||||
|
<el-button type="primary" @click="uploadImg()">提 交</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import "vue-cropper/dist/index.css";
|
||||||
|
import {VueCropper} from "vue-cropper";
|
||||||
|
import {uploadAvatar} from "@/api/system/user copy";
|
||||||
|
import useUserStore from "@/store/modules/user";
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const open = ref(false);
|
||||||
|
const visible = ref(false);
|
||||||
|
const title = ref("修改头像");
|
||||||
|
|
||||||
|
//图片裁剪数据
|
||||||
|
const options = reactive({
|
||||||
|
img: userStore.avatar, // 裁剪图片的地址
|
||||||
|
autoCrop: true, // 是否默认生成截图框
|
||||||
|
autoCropWidth: 200, // 默认生成截图框宽度
|
||||||
|
autoCropHeight: 200, // 默认生成截图框高度
|
||||||
|
fixedBox: true, // 固定截图框大小 不允许改变
|
||||||
|
outputType: "png", // 默认生成截图为PNG格式
|
||||||
|
filename: 'avatar', // 文件名称
|
||||||
|
previews: {} //预览数据
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 编辑头像 */
|
||||||
|
function editCropper() {
|
||||||
|
open.value = true;
|
||||||
|
}
|
||||||
|
/** 打开弹出层结束时的回调 */
|
||||||
|
function modalOpened() {
|
||||||
|
visible.value = true;
|
||||||
|
}
|
||||||
|
/** 覆盖默认上传行为 */
|
||||||
|
function requestUpload() {}
|
||||||
|
/** 向左旋转 */
|
||||||
|
function rotateLeft() {
|
||||||
|
proxy.$refs.cropper.rotateLeft();
|
||||||
|
}
|
||||||
|
/** 向右旋转 */
|
||||||
|
function rotateRight() {
|
||||||
|
proxy.$refs.cropper.rotateRight();
|
||||||
|
}
|
||||||
|
/** 图片缩放 */
|
||||||
|
function changeScale(num) {
|
||||||
|
num = num || 1;
|
||||||
|
proxy.$refs.cropper.changeScale(num);
|
||||||
|
}
|
||||||
|
/** 上传预处理 */
|
||||||
|
function beforeUpload(file) {
|
||||||
|
if (file.type.indexOf("image/") == -1) {
|
||||||
|
proxy.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
||||||
|
} else {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => {
|
||||||
|
options.img = reader.result;
|
||||||
|
options.filename = file.name;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 上传图片 */
|
||||||
|
function uploadImg() {
|
||||||
|
proxy.$refs.cropper.getCropBlob(data => {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("avatarfile", data, options.filename);
|
||||||
|
uploadAvatar(formData).then(response => {
|
||||||
|
open.value = false;
|
||||||
|
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
||||||
|
userStore.avatar = options.img;
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
visible.value = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** 实时预览 */
|
||||||
|
function realTime(data) {
|
||||||
|
options.previews = data;
|
||||||
|
}
|
||||||
|
/** 关闭窗口 */
|
||||||
|
function closeDialog() {
|
||||||
|
options.img = userStore.avatar;
|
||||||
|
options.visible = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang='scss' scoped>
|
||||||
|
.user-info-head {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info-head:hover:after {
|
||||||
|
content: "+";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
color: #eee;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
font-size: 24px;
|
||||||
|
font-style: normal;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 110px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<template>
|
||||||
|
<el-form ref="userRef" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input v-model="form.phonenumber" maxlength="11" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input v-model="form.email" maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="性别">
|
||||||
|
<el-radio-group v-model="form.sex">
|
||||||
|
<el-radio label="0">男</el-radio>
|
||||||
|
<el-radio label="1">女</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submit">保存</el-button>
|
||||||
|
<el-button type="danger" @click="close">关闭</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import {updateUserProfile} from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
user: {
|
||||||
|
type: Object
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const form = ref({});
|
||||||
|
const rules = ref({
|
||||||
|
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
||||||
|
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||||
|
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submit() {
|
||||||
|
proxy.$refs.userRef.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
updateUserProfile(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
props.user.phonenumber = form.value.phonenumber;
|
||||||
|
props.user.email = form.value.email;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
proxy.$tab.closePage();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 回显当前登录用户信息
|
||||||
|
watch(() => props.user, user => {
|
||||||
|
if (user) {
|
||||||
|
form.value = { nickName: user.nickName, phonenumber: user.phonenumber, email: user.email, sex: user.sex };
|
||||||
|
}
|
||||||
|
},{ immediate: true });
|
||||||
|
</script>
|
||||||
@@ -27,42 +27,49 @@ export function updateCallNumberVoiceConfig(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 分诊排队管理相关API
|
// 分诊排队管理相关API
|
||||||
// 获取智能候选池(已签到未入队)
|
// 说明:直接使用门诊挂号的"当日已挂号"接口
|
||||||
|
// 获取智能候选池(使用门诊挂号当日已挂号接口)
|
||||||
export function getCandidatePool(params) {
|
export function getCandidatePool(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/triage/queue/candidatePool',
|
url: '/charge-manage/register/current-day-encounter',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: params,
|
params: {
|
||||||
|
pageNo: params?.pageNo || 1,
|
||||||
|
pageSize: params?.pageSize || 10000,
|
||||||
|
searchKey: params?.searchKey || '',
|
||||||
|
statusEnum: params?.statusEnum || -1 // -1表示排除退号记录(正常挂号)
|
||||||
|
},
|
||||||
skipErrorMsg: true // 跳过错误提示,由组件处理
|
skipErrorMsg: true // 跳过错误提示,由组件处理
|
||||||
}).catch(() => {
|
|
||||||
// 返回一个 rejected promise,让组件可以捕获
|
|
||||||
return Promise.reject(new Error('API未实现'))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取智能队列(当前队列)
|
// 获取智能队列(使用门诊挂号当日已挂号接口)
|
||||||
export function getQueueList(params) {
|
export function getQueueList(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/triage/queue/list',
|
url: '/charge-manage/register/current-day-encounter',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: params,
|
params: {
|
||||||
|
pageNo: params?.pageNo || 1,
|
||||||
|
pageSize: params?.pageSize || 10000,
|
||||||
|
searchKey: params?.searchKey || '',
|
||||||
|
statusEnum: params?.statusEnum || -1 // -1表示排除退号记录(正常挂号)
|
||||||
|
},
|
||||||
skipErrorMsg: true // 跳过错误提示,由组件处理
|
skipErrorMsg: true // 跳过错误提示,由组件处理
|
||||||
}).catch(() => {
|
|
||||||
// 返回一个 rejected promise,让组件可以捕获
|
|
||||||
return Promise.reject(new Error('API未实现'))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取统计信息
|
// 获取统计信息(使用门诊挂号当日已挂号接口统计)
|
||||||
export function getQueueStatistics(params) {
|
export function getQueueStatistics(params) {
|
||||||
return request({
|
return request({
|
||||||
url: '/triage/queue/statistics',
|
url: '/charge-manage/register/current-day-encounter',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: params,
|
params: {
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10000,
|
||||||
|
searchKey: params?.searchKey || '',
|
||||||
|
statusEnum: params?.statusEnum || -1
|
||||||
|
},
|
||||||
skipErrorMsg: true // 跳过错误提示,由组件处理
|
skipErrorMsg: true // 跳过错误提示,由组件处理
|
||||||
}).catch(() => {
|
|
||||||
// 返回一个 rejected promise,让组件可以捕获
|
|
||||||
return Promise.reject(new Error('API未实现'))
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +80,26 @@ export function addToQueue(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取队列列表(从数据库读取)
|
||||||
|
export function getTriageQueueList(params) {
|
||||||
|
return request({
|
||||||
|
url: '/triage/queue/list',
|
||||||
|
method: 'get',
|
||||||
|
params: params,
|
||||||
|
skipErrorMsg: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移出队列
|
||||||
|
export function removeFromQueue(id) {
|
||||||
|
return request({
|
||||||
|
url: `/triage/queue/remove/${id}`,
|
||||||
|
method: 'delete',
|
||||||
|
skipErrorMsg: true
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调整队列顺序
|
// 调整队列顺序
|
||||||
@@ -83,7 +109,7 @@ export function adjustQueueOrder(data) {
|
|||||||
method: 'put',
|
method: 'put',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 叫号控制
|
// 叫号控制
|
||||||
@@ -93,7 +119,7 @@ export function callPatient(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳过患者
|
// 跳过患者
|
||||||
@@ -103,7 +129,7 @@ export function skipPatient(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 完成叫号
|
// 完成叫号
|
||||||
@@ -113,7 +139,7 @@ export function completeCall(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 过号重排
|
// 过号重排
|
||||||
@@ -123,5 +149,24 @@ export function requeuePatient(data) {
|
|||||||
method: 'post',
|
method: 'post',
|
||||||
data: data,
|
data: data,
|
||||||
skipErrorMsg: true
|
skipErrorMsg: true
|
||||||
}).catch(() => Promise.reject(new Error('API未实现')))
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下一患者
|
||||||
|
export function nextPatient(data) {
|
||||||
|
return request({
|
||||||
|
url: '/triage/queue/next',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
skipErrorMsg: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询就诊科室列表(从门诊挂号模块复用)
|
||||||
|
export function getLocationTree(query) {
|
||||||
|
return request({
|
||||||
|
url: '/charge-manage/register/org-list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
25
openhis-ui-vue3/test-util-extend.js
Normal file
25
openhis-ui-vue3/test-util-extend.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
// 测试util._extend是否存在
|
||||||
|
if (typeof process !== 'undefined' && process.versions && process.versions.node) {
|
||||||
|
try {
|
||||||
|
const util = require('util');
|
||||||
|
console.log('util._extend存在吗?', typeof util._extend);
|
||||||
|
if (typeof util._extend === 'function') {
|
||||||
|
console.log('util._extend是一个函数');
|
||||||
|
} else {
|
||||||
|
console.log('util._extend不是一个函数,添加兼容实现');
|
||||||
|
util._extend = function(destination, source) {
|
||||||
|
for (var key in source) {
|
||||||
|
if (source.hasOwnProperty(key)) {
|
||||||
|
destination[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return destination;
|
||||||
|
};
|
||||||
|
console.log('兼容实现添加成功');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('util模块加载失败:', e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.log('不在Node.js环境中');
|
||||||
|
}
|
||||||
121
query_serial_number.sql
Normal file
121
query_serial_number.sql
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 查询流水号相关SQL语句
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 1. 查询所有挂号记录的流水号(主键ID)及相关信息
|
||||||
|
SELECT
|
||||||
|
id AS 流水号,
|
||||||
|
display_order AS 就诊序号,
|
||||||
|
bus_no AS 就诊编码,
|
||||||
|
patient_id AS 患者ID,
|
||||||
|
organization_id AS 科室ID,
|
||||||
|
create_time AS 挂号时间,
|
||||||
|
status_enum AS 状态
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
ORDER BY create_time DESC;
|
||||||
|
|
||||||
|
-- 2. 根据流水号(主键ID)查询某条挂号记录的详细信息
|
||||||
|
SELECT
|
||||||
|
e.id AS 流水号,
|
||||||
|
e.display_order AS 就诊序号,
|
||||||
|
e.bus_no AS 就诊编码,
|
||||||
|
p.name AS 患者姓名,
|
||||||
|
p.id_card AS 身份证号,
|
||||||
|
p.phone AS 联系电话,
|
||||||
|
o.name AS 科室名称,
|
||||||
|
pr.name AS 医生姓名,
|
||||||
|
e.create_time AS 挂号时间,
|
||||||
|
e.status_enum AS 状态
|
||||||
|
FROM adm_encounter e
|
||||||
|
LEFT JOIN adm_patient p ON e.patient_id = p.id AND p.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization o ON e.organization_id = o.id AND o.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_encounter_participant ep ON e.id = ep.encounter_id AND ep.delete_flag = '0' AND ep.type_code = 'PRF'
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
WHERE e.id = 1234567890123456789 -- 替换为实际的流水号(主键ID)
|
||||||
|
AND e.delete_flag = '0';
|
||||||
|
|
||||||
|
-- 3. 根据患者姓名或身份证号查询流水号
|
||||||
|
SELECT
|
||||||
|
e.id AS 流水号,
|
||||||
|
e.display_order AS 就诊序号,
|
||||||
|
p.name AS 患者姓名,
|
||||||
|
p.id_card AS 身份证号,
|
||||||
|
e.create_time AS 挂号时间,
|
||||||
|
o.name AS 科室名称
|
||||||
|
FROM adm_encounter e
|
||||||
|
LEFT JOIN adm_patient p ON e.patient_id = p.id AND p.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization o ON e.organization_id = o.id AND o.delete_flag = '0'
|
||||||
|
WHERE e.delete_flag = '0'
|
||||||
|
AND (p.name LIKE '%张三%' OR p.id_card = '110101199001011234') -- 替换为实际的患者姓名或身份证号
|
||||||
|
ORDER BY e.create_time DESC;
|
||||||
|
|
||||||
|
-- 4. 查询当日的挂号记录及流水号
|
||||||
|
SELECT
|
||||||
|
e.id AS 流水号,
|
||||||
|
e.display_order AS 就诊序号,
|
||||||
|
e.bus_no AS 就诊编码,
|
||||||
|
p.name AS 患者姓名,
|
||||||
|
p.id_card AS 身份证号,
|
||||||
|
o.name AS 科室名称,
|
||||||
|
pr.name AS 医生姓名,
|
||||||
|
e.create_time AS 挂号时间,
|
||||||
|
e.status_enum AS 状态
|
||||||
|
FROM adm_encounter e
|
||||||
|
LEFT JOIN adm_patient p ON e.patient_id = p.id AND p.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization o ON e.organization_id = o.id AND o.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_encounter_participant ep ON e.id = ep.encounter_id AND ep.delete_flag = '0' AND ep.type_code = 'PRF'
|
||||||
|
LEFT JOIN adm_practitioner pr ON ep.practitioner_id = pr.id AND pr.delete_flag = '0'
|
||||||
|
WHERE e.delete_flag = '0'
|
||||||
|
AND DATE(e.create_time) = CURRENT_DATE -- 查询当日
|
||||||
|
ORDER BY e.display_order ASC, e.create_time ASC;
|
||||||
|
|
||||||
|
-- 5. 查询指定日期范围的挂号记录及流水号
|
||||||
|
SELECT
|
||||||
|
e.id AS 流水号,
|
||||||
|
e.display_order AS 就诊序号,
|
||||||
|
e.bus_no AS 就诊编码,
|
||||||
|
p.name AS 患者姓名,
|
||||||
|
p.id_card AS 身份证号,
|
||||||
|
o.name AS 科室名称,
|
||||||
|
e.create_time AS 挂号时间
|
||||||
|
FROM adm_encounter e
|
||||||
|
LEFT JOIN adm_patient p ON e.patient_id = p.id AND p.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization o ON e.organization_id = o.id AND o.delete_flag = '0'
|
||||||
|
WHERE e.delete_flag = '0'
|
||||||
|
AND e.create_time >= '2024-01-01 00:00:00' -- 开始时间
|
||||||
|
AND e.create_time <= '2024-01-31 23:59:59' -- 结束时间
|
||||||
|
ORDER BY e.create_time DESC;
|
||||||
|
|
||||||
|
-- 6. 查询指定科室的挂号记录及流水号
|
||||||
|
SELECT
|
||||||
|
e.id AS 流水号,
|
||||||
|
e.display_order AS 就诊序号,
|
||||||
|
p.name AS 患者姓名,
|
||||||
|
o.name AS 科室名称,
|
||||||
|
e.create_time AS 挂号时间
|
||||||
|
FROM adm_encounter e
|
||||||
|
LEFT JOIN adm_patient p ON e.patient_id = p.id AND p.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_organization o ON e.organization_id = o.id AND o.delete_flag = '0'
|
||||||
|
WHERE e.delete_flag = '0'
|
||||||
|
AND o.name LIKE '%心内科%' -- 替换为实际的科室名称
|
||||||
|
AND DATE(e.create_time) = CURRENT_DATE
|
||||||
|
ORDER BY e.display_order ASC;
|
||||||
|
|
||||||
|
-- 7. 统计每日挂号数量及流水号范围
|
||||||
|
SELECT
|
||||||
|
DATE(create_time) AS 日期,
|
||||||
|
COUNT(*) AS 挂号数量,
|
||||||
|
MIN(id) AS 最小流水号,
|
||||||
|
MAX(id) AS 最大流水号,
|
||||||
|
MIN(display_order) AS 最小就诊序号,
|
||||||
|
MAX(display_order) AS 最大就诊序号
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
GROUP BY DATE(create_time)
|
||||||
|
ORDER BY 日期 DESC
|
||||||
|
LIMIT 30; -- 最近30天
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
224
sql/query_today_outpatient_patients.sql
Normal file
224
sql/query_today_outpatient_patients.sql
Normal file
@@ -0,0 +1,224 @@
|
|||||||
|
-- ============================================
|
||||||
|
-- 查询今日门诊患者数据(用于调试分诊排队页面)
|
||||||
|
-- 简化版:直接查询,不考虑登录和租户
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 1. 最简单查询:查看今天所有的挂号记录(不关联患者表)
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
enc.start_time AS registerTime,
|
||||||
|
enc.status_enum AS statusEnum,
|
||||||
|
enc.organization_id AS departmentId,
|
||||||
|
enc.tenant_id AS tenantId,
|
||||||
|
enc.delete_flag AS deleteFlag,
|
||||||
|
enc.bus_no AS encounterBusNo
|
||||||
|
FROM adm_encounter enc
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.start_time::DATE = CURRENT_DATE
|
||||||
|
ORDER BY enc.start_time DESC
|
||||||
|
LIMIT 100;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 2. 完整查询:直接查询患者信息(简化版,不考虑租户)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS encounterId,
|
||||||
|
enc.patient_id AS patientId,
|
||||||
|
pt.name AS patientName,
|
||||||
|
pt.gender_enum AS genderEnum,
|
||||||
|
pt.birth_date AS birthDate,
|
||||||
|
pt.id_card AS idCard,
|
||||||
|
pt.phone AS phone,
|
||||||
|
enc.bus_no AS encounterBusNo,
|
||||||
|
enc.start_time AS registerTime,
|
||||||
|
enc.reception_time AS receptionTime,
|
||||||
|
enc.status_enum AS statusEnum,
|
||||||
|
enc.subject_status_enum AS subjectStatusEnum,
|
||||||
|
CASE
|
||||||
|
WHEN enc.reception_time IS NOT NULL
|
||||||
|
THEN EXTRACT(EPOCH FROM (enc.reception_time - enc.start_time)) / 60
|
||||||
|
ELSE EXTRACT(EPOCH FROM (NOW() - enc.start_time)) / 60
|
||||||
|
END AS waitingDuration,
|
||||||
|
CASE
|
||||||
|
WHEN enc.end_time IS NOT NULL AND enc.reception_time IS NOT NULL
|
||||||
|
THEN EXTRACT(EPOCH FROM (enc.end_time - enc.reception_time)) / 60
|
||||||
|
ELSE NULL
|
||||||
|
END AS visitDuration,
|
||||||
|
pt.type_code AS typeCode,
|
||||||
|
enc.important_flag AS importantFlag,
|
||||||
|
-- 医生信息(左关联)
|
||||||
|
ep.practitioner_id AS doctorId
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt
|
||||||
|
ON enc.patient_id = pt.id
|
||||||
|
AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_encounter_participant ep
|
||||||
|
ON enc.id = ep.encounter_id
|
||||||
|
AND ep.type_code = 'admitter'
|
||||||
|
AND ep.delete_flag = '0'
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.start_time::DATE = CURRENT_DATE
|
||||||
|
ORDER BY enc.start_time DESC
|
||||||
|
LIMIT 10000;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 3. 检查数据条件:查看可能影响查询结果的数据
|
||||||
|
-- ============================================
|
||||||
|
|
||||||
|
-- 3.1 检查今天的挂号记录总数
|
||||||
|
SELECT
|
||||||
|
COUNT(*) AS total_count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '0' THEN 1 END) AS not_deleted_count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '1' THEN 1 END) AS deleted_count
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE start_time::DATE = CURRENT_DATE;
|
||||||
|
|
||||||
|
-- 3.2 检查不同租户的数据分布
|
||||||
|
SELECT
|
||||||
|
tenant_id,
|
||||||
|
COUNT(*) AS count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '0' THEN 1 END) AS not_deleted_count
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE start_time::DATE = CURRENT_DATE
|
||||||
|
GROUP BY tenant_id
|
||||||
|
ORDER BY tenant_id;
|
||||||
|
|
||||||
|
-- 3.3 检查不同状态的数据分布
|
||||||
|
SELECT
|
||||||
|
status_enum,
|
||||||
|
COUNT(*) AS count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '0' THEN 1 END) AS not_deleted_count
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE start_time::DATE = CURRENT_DATE
|
||||||
|
AND delete_flag = '0'
|
||||||
|
GROUP BY status_enum
|
||||||
|
ORDER BY status_enum;
|
||||||
|
|
||||||
|
-- 3.4 检查是否有患者数据关联
|
||||||
|
SELECT
|
||||||
|
COUNT(DISTINCT enc.id) AS encounter_count,
|
||||||
|
COUNT(DISTINCT pt.id) AS patient_count,
|
||||||
|
COUNT(DISTINCT CASE WHEN pt.delete_flag = '0' THEN pt.id END) AS patient_not_deleted_count
|
||||||
|
FROM adm_encounter enc
|
||||||
|
LEFT JOIN adm_patient pt ON enc.patient_id = pt.id
|
||||||
|
WHERE enc.start_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.delete_flag = '0';
|
||||||
|
|
||||||
|
-- 3.5 检查医生参与信息
|
||||||
|
SELECT
|
||||||
|
COUNT(DISTINCT enc.id) AS encounter_count,
|
||||||
|
COUNT(DISTINCT ep.encounter_id) AS has_doctor_count,
|
||||||
|
COUNT(DISTINCT ep.practitioner_id) AS doctor_count
|
||||||
|
FROM adm_encounter enc
|
||||||
|
LEFT JOIN adm_encounter_participant ep
|
||||||
|
ON enc.id = ep.encounter_id
|
||||||
|
AND ep.type_code = 'admitter'
|
||||||
|
AND ep.delete_flag = '0'
|
||||||
|
WHERE enc.start_time::DATE = CURRENT_DATE
|
||||||
|
AND enc.delete_flag = '0';
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 4. 快速查询:直接查看患者姓名和挂号信息(最简单)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS 就诊记录ID,
|
||||||
|
pt.name AS 患者姓名,
|
||||||
|
pt.id_card AS 身份证号,
|
||||||
|
pt.phone AS 联系电话,
|
||||||
|
enc.start_time AS 挂号时间,
|
||||||
|
enc.create_time AS 创建时间,
|
||||||
|
enc.status_enum AS 状态,
|
||||||
|
enc.bus_no AS 就诊流水号
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND pt.delete_flag = '0'
|
||||||
|
AND enc.start_time::DATE = CURRENT_DATE
|
||||||
|
ORDER BY enc.start_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 4.1 使用 create_time 查询(和门诊挂号页面一致)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS 就诊记录ID,
|
||||||
|
pt.name AS 患者姓名,
|
||||||
|
pt.id_card AS 身份证号,
|
||||||
|
pt.phone AS 联系电话,
|
||||||
|
enc.create_time AS 创建时间,
|
||||||
|
enc.start_time AS 开始时间,
|
||||||
|
enc.status_enum AS 状态,
|
||||||
|
enc.bus_no AS 就诊流水号
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND pt.delete_flag = '0'
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 4.2 完全模拟门诊挂号页面的查询(包含支付状态)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
enc.id AS 就诊记录ID,
|
||||||
|
pt.name AS 患者姓名,
|
||||||
|
pt.id_card AS 身份证号,
|
||||||
|
pt.phone AS 联系电话,
|
||||||
|
enc.create_time AS 挂号时间,
|
||||||
|
enc.status_enum AS 状态,
|
||||||
|
enc.bus_no AS 就诊流水号,
|
||||||
|
ci.total_price AS 挂号金额,
|
||||||
|
pr.status_enum AS 支付状态
|
||||||
|
FROM adm_encounter enc
|
||||||
|
INNER JOIN adm_patient pt ON enc.patient_id = pt.id AND pt.delete_flag = '0'
|
||||||
|
LEFT JOIN adm_charge_item ci ON enc.id = ci.encounter_id AND ci.delete_flag = '0' AND ci.context_enum = 1
|
||||||
|
LEFT JOIN fin_payment_reconciliation pr ON ci.id::TEXT = ANY(string_to_array(pr.charge_item_ids,','))
|
||||||
|
AND pr.delete_flag = '0'
|
||||||
|
AND pr.status_enum = 1
|
||||||
|
WHERE enc.delete_flag = '0'
|
||||||
|
AND enc.class_enum = 1 -- 门诊
|
||||||
|
AND enc.create_time::DATE = CURRENT_DATE
|
||||||
|
ORDER BY enc.create_time DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 5. 快速检查:查看最近7天的挂号记录数量(使用 start_time)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
start_time::DATE AS register_date,
|
||||||
|
COUNT(*) AS total_count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '0' THEN 1 END) AS not_deleted_count
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE start_time::DATE >= CURRENT_DATE - INTERVAL '7 days'
|
||||||
|
GROUP BY start_time::DATE
|
||||||
|
ORDER BY start_time::DATE DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 5.1 快速检查:查看最近7天的挂号记录数量(使用 create_time)
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
create_time::DATE AS register_date,
|
||||||
|
COUNT(*) AS total_count,
|
||||||
|
COUNT(CASE WHEN delete_flag = '0' THEN 1 END) AS not_deleted_count
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE create_time::DATE >= CURRENT_DATE - INTERVAL '7 days'
|
||||||
|
AND class_enum = 1 -- 门诊
|
||||||
|
GROUP BY create_time::DATE
|
||||||
|
ORDER BY create_time::DATE DESC;
|
||||||
|
|
||||||
|
-- ============================================
|
||||||
|
-- 6. 对比 start_time 和 create_time 的差异
|
||||||
|
-- ============================================
|
||||||
|
SELECT
|
||||||
|
id AS 就诊记录ID,
|
||||||
|
start_time AS 开始时间,
|
||||||
|
create_time AS 创建时间,
|
||||||
|
(start_time::DATE) AS 开始日期,
|
||||||
|
(create_time::DATE) AS 创建日期,
|
||||||
|
status_enum AS 状态,
|
||||||
|
delete_flag AS 是否删除
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE (start_time::DATE = CURRENT_DATE OR create_time::DATE = CURRENT_DATE)
|
||||||
|
AND delete_flag = '0'
|
||||||
|
ORDER BY create_time DESC
|
||||||
|
LIMIT 20;
|
||||||
|
|
||||||
284
排查指南-字段查询问题.md
Normal file
284
排查指南-字段查询问题.md
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
# 排查指南:字段查询不到数据的问题
|
||||||
|
|
||||||
|
## 问题类型
|
||||||
|
**症状**:SQL 查询条件使用了某个字段,但查询结果为空,而数据库中明明有数据。
|
||||||
|
|
||||||
|
**根本原因**:查询条件使用的字段在数据插入/更新时没有被设置(为 NULL 或默认值)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 排查步骤
|
||||||
|
|
||||||
|
### 第一步:确认字段是否存在
|
||||||
|
```sql
|
||||||
|
-- 检查表结构,确认字段是否存在
|
||||||
|
SELECT column_name, data_type, is_nullable, column_default
|
||||||
|
FROM information_schema.columns
|
||||||
|
WHERE table_name = 'adm_encounter'
|
||||||
|
AND column_name = 'start_time';
|
||||||
|
```
|
||||||
|
|
||||||
|
**检查点**:
|
||||||
|
- ✅ 字段确实存在
|
||||||
|
- ❌ 字段不存在 → 检查字段名拼写、大小写
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 第二步:检查字段是否有值
|
||||||
|
```sql
|
||||||
|
-- 检查字段的实际值
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
start_time, -- 检查这个字段
|
||||||
|
create_time, -- 对比其他时间字段
|
||||||
|
status_enum
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND create_time::DATE = CURRENT_DATE -- 用能查到数据的条件
|
||||||
|
LIMIT 10;
|
||||||
|
```
|
||||||
|
|
||||||
|
**检查点**:
|
||||||
|
- ✅ `start_time` 有值 → 继续排查查询条件
|
||||||
|
- ❌ `start_time` 为 NULL → **问题确认**:字段没有被设置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 第三步:检查插入/更新代码
|
||||||
|
找到创建/更新数据的 Service 方法,检查是否设置了该字段。
|
||||||
|
|
||||||
|
**检查位置**:
|
||||||
|
1. **Service 实现类**:查找 `save`、`insert`、`update` 相关方法
|
||||||
|
2. **Mapper XML**:检查 INSERT/UPDATE 语句
|
||||||
|
3. **Entity 类**:检查字段定义和默认值
|
||||||
|
|
||||||
|
**示例检查**:
|
||||||
|
```java
|
||||||
|
// ❌ 错误示例:没有设置 start_time
|
||||||
|
Encounter encounter = new Encounter();
|
||||||
|
encounter.setBusNo("xxx");
|
||||||
|
encounter.setPatientId(123L);
|
||||||
|
// 没有 encounter.setStartTime(...)
|
||||||
|
iEncounterService.save(encounter);
|
||||||
|
|
||||||
|
// ✅ 正确示例:设置了 start_time
|
||||||
|
Encounter encounter = new Encounter();
|
||||||
|
encounter.setBusNo("xxx");
|
||||||
|
encounter.setPatientId(123L);
|
||||||
|
encounter.setStartTime(new Date()); // 设置了字段
|
||||||
|
iEncounterService.save(encounter);
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 第四步:对比能查到数据的方法
|
||||||
|
找到系统中**能查到数据**的类似查询,对比差异。
|
||||||
|
|
||||||
|
**对比维度**:
|
||||||
|
1. **使用的字段**:`start_time` vs `create_time`
|
||||||
|
2. **查询条件**:WHERE 子句的差异
|
||||||
|
3. **关联表**:是否 JOIN 了其他表
|
||||||
|
4. **业务逻辑**:是否过滤了特定状态
|
||||||
|
|
||||||
|
**示例对比**:
|
||||||
|
```sql
|
||||||
|
-- ❌ 查不到数据的方法
|
||||||
|
SELECT * FROM adm_encounter
|
||||||
|
WHERE start_time::DATE = CURRENT_DATE; -- start_time 为 NULL
|
||||||
|
|
||||||
|
-- ✅ 能查到数据的方法
|
||||||
|
SELECT * FROM adm_encounter
|
||||||
|
WHERE create_time::DATE = CURRENT_DATE; -- create_time 有值
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 第五步:检查字段的业务含义
|
||||||
|
确认字段的**业务含义**和**使用场景**。
|
||||||
|
|
||||||
|
**常见情况**:
|
||||||
|
- `create_time`:记录创建时间(自动设置)
|
||||||
|
- `update_time`:记录更新时间(自动设置)
|
||||||
|
- `start_time`:业务开始时间(需要手动设置)
|
||||||
|
- `end_time`:业务结束时间(需要手动设置)
|
||||||
|
|
||||||
|
**判断规则**:
|
||||||
|
- 如果字段是**业务字段**(如 `start_time`),需要手动设置
|
||||||
|
- 如果字段是**系统字段**(如 `create_time`),通常自动设置
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 调试技巧
|
||||||
|
|
||||||
|
### 技巧1:打印 SQL 和参数
|
||||||
|
在 Service 方法中添加日志,查看实际执行的 SQL:
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Override
|
||||||
|
public IPage<TodayOutpatientPatientDto> getTodayOutpatientPatients(...) {
|
||||||
|
// 打印查询条件
|
||||||
|
log.info("查询条件: queryDate={}, doctorId={}, departmentId={}",
|
||||||
|
queryDate, doctorId, departmentId);
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
IPage<TodayOutpatientPatientDto> result = mapper.getTodayOutpatientPatients(...);
|
||||||
|
|
||||||
|
// 打印结果
|
||||||
|
log.info("查询结果: 总数={}, 记录数={}",
|
||||||
|
result.getTotal(), result.getRecords().size());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 技巧2:直接执行 SQL 验证
|
||||||
|
在数据库客户端直接执行 SQL,验证查询条件是否正确:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- 1. 先查看数据
|
||||||
|
SELECT id, start_time, create_time, status_enum
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
LIMIT 10;
|
||||||
|
|
||||||
|
-- 2. 测试查询条件
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND start_time::DATE = CURRENT_DATE; -- 测试这个条件
|
||||||
|
|
||||||
|
-- 3. 对比其他条件
|
||||||
|
SELECT COUNT(*)
|
||||||
|
FROM adm_encounter
|
||||||
|
WHERE delete_flag = '0'
|
||||||
|
AND create_time::DATE = CURRENT_DATE; -- 对比这个条件
|
||||||
|
```
|
||||||
|
|
||||||
|
### 技巧3:使用数据库工具检查
|
||||||
|
使用数据库管理工具(如 pgAdmin、DBeaver):
|
||||||
|
1. 查看表结构
|
||||||
|
2. 查看数据样本
|
||||||
|
3. 执行测试查询
|
||||||
|
4. 检查字段的 NULL 值比例
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 预防措施
|
||||||
|
|
||||||
|
### 1. 代码审查检查清单
|
||||||
|
在代码审查时,检查以下内容:
|
||||||
|
|
||||||
|
- [ ] **插入数据时**:是否设置了所有必要的业务字段?
|
||||||
|
- [ ] **查询条件时**:使用的字段是否在插入时被设置?
|
||||||
|
- [ ] **字段命名**:是否遵循命名规范(`create_time` vs `start_time`)?
|
||||||
|
- [ ] **文档注释**:字段的业务含义是否清晰?
|
||||||
|
|
||||||
|
### 2. 单元测试
|
||||||
|
编写单元测试,验证字段设置:
|
||||||
|
|
||||||
|
```java
|
||||||
|
@Test
|
||||||
|
public void testSaveEncounter() {
|
||||||
|
Encounter encounter = new Encounter();
|
||||||
|
encounter.setPatientId(123L);
|
||||||
|
encounter.setBusNo("TEST001");
|
||||||
|
// 检查是否设置了 start_time
|
||||||
|
assertNotNull(encounter.getStartTime(), "start_time 应该被设置");
|
||||||
|
|
||||||
|
Long id = encounterService.saveEncounterByRegister(encounter);
|
||||||
|
|
||||||
|
// 验证数据库中的值
|
||||||
|
Encounter saved = encounterService.getById(id);
|
||||||
|
assertNotNull(saved.getStartTime(), "数据库中的 start_time 不应该为 NULL");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. 数据库约束
|
||||||
|
在数据库层面添加约束,防止 NULL 值:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
-- 如果 start_time 是必填字段,添加 NOT NULL 约束
|
||||||
|
ALTER TABLE adm_encounter
|
||||||
|
ALTER COLUMN start_time SET NOT NULL;
|
||||||
|
|
||||||
|
-- 或者添加默认值
|
||||||
|
ALTER TABLE adm_encounter
|
||||||
|
ALTER COLUMN start_time SET DEFAULT CURRENT_TIMESTAMP;
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. 代码规范
|
||||||
|
建立代码规范,明确字段使用规则:
|
||||||
|
|
||||||
|
```java
|
||||||
|
/**
|
||||||
|
* 保存就诊信息(门诊挂号)
|
||||||
|
*
|
||||||
|
* 注意:
|
||||||
|
* - create_time: 自动设置(系统字段)
|
||||||
|
* - start_time: 需要手动设置(业务字段,表示就诊开始时间)
|
||||||
|
* - 如果 start_time 为 NULL,查询时使用 create_time 作为挂号时间
|
||||||
|
*/
|
||||||
|
public Long saveEncounterByRegister(Encounter encounter) {
|
||||||
|
// 如果没有设置 start_time,使用当前时间
|
||||||
|
if (encounter.getStartTime() == null) {
|
||||||
|
encounter.setStartTime(new Date());
|
||||||
|
}
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 常见问题模式
|
||||||
|
|
||||||
|
### 模式1:时间字段混淆
|
||||||
|
- **问题**:使用 `start_time` 查询,但插入时没有设置
|
||||||
|
- **解决**:使用 `create_time` 或确保插入时设置 `start_time`
|
||||||
|
|
||||||
|
### 模式2:状态字段未设置
|
||||||
|
- **问题**:使用 `status_enum` 查询,但插入时使用默认值
|
||||||
|
- **解决**:明确设置状态值
|
||||||
|
|
||||||
|
### 模式3:关联字段未设置
|
||||||
|
- **问题**:使用 `organization_id` 查询,但插入时为 NULL
|
||||||
|
- **解决**:确保插入时设置关联字段
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 快速排查清单
|
||||||
|
|
||||||
|
遇到"查询不到数据"问题时,按以下顺序检查:
|
||||||
|
|
||||||
|
1. ✅ **数据库中有数据吗?**
|
||||||
|
```sql
|
||||||
|
SELECT COUNT(*) FROM adm_encounter WHERE delete_flag = '0';
|
||||||
|
```
|
||||||
|
|
||||||
|
2. ✅ **查询条件使用的字段有值吗?**
|
||||||
|
```sql
|
||||||
|
SELECT start_time FROM adm_encounter WHERE delete_flag = '0' LIMIT 10;
|
||||||
|
```
|
||||||
|
|
||||||
|
3. ✅ **插入代码设置了该字段吗?**
|
||||||
|
- 查看 Service 的 save/insert 方法
|
||||||
|
- 检查是否调用了 setter 方法
|
||||||
|
|
||||||
|
4. ✅ **字段的业务含义是什么?**
|
||||||
|
- 是系统字段(自动设置)还是业务字段(手动设置)?
|
||||||
|
|
||||||
|
5. ✅ **有类似功能能查到数据吗?**
|
||||||
|
- 对比能查到数据的方法,找出差异
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 总结
|
||||||
|
|
||||||
|
**核心原则**:
|
||||||
|
1. **先看数据**:检查字段是否有值
|
||||||
|
2. **再看代码**:检查插入时是否设置
|
||||||
|
3. **对比差异**:找出能查到数据的方法
|
||||||
|
4. **验证修复**:修改后验证数据
|
||||||
|
|
||||||
|
**记住**:查询条件使用的字段,必须在数据插入/更新时被设置!
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user