diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/constants/ScheduleSlotStatus.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/constants/ScheduleSlotStatus.java index 6ea887246..ebbf23f4b 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/constants/ScheduleSlotStatus.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/constants/ScheduleSlotStatus.java @@ -1,13 +1,38 @@ package com.openhis.application.constants; /** - * 号源 Slot 状态常量 - * - * 新增:AVAILABLE(可预约)对应 PRD 中的“可预约”状态 + * 号源状态枚举 + * 修复 Bug #570:移除冗余的“已锁定”状态,统一预约成功后的状态为“已预约”, + * 确保前后端状态流转与查询过滤一致。 */ -public class ScheduleSlotStatus { - public static final String BOOKED = "BOOKED"; // 已预约 - public static final String OCCUPIED = "OCCUPIED"; // 已占用(就诊中) - public static final String AVAILABLE = "AVAILABLE"; // 可预约(退号后恢复) - public static final String DISABLED = "DISABLED"; // 禁用 +public enum ScheduleSlotStatus { + AVAILABLE(0, "可预约"), + BOOKED(1, "已预约"), + CANCELLED(2, "已取消"), + COMPLETED(3, "已就诊"); + + private final int code; + private final String name; + + ScheduleSlotStatus(int code, String name) { + this.code = code; + this.name = name; + } + + public int getCode() { + return code; + } + + public String getName() { + return name; + } + + public static ScheduleSlotStatus fromCode(int code) { + for (ScheduleSlotStatus status : values()) { + if (status.code == code) { + return status; + } + } + return null; + } } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/ScheduleSlotServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/ScheduleSlotServiceImpl.java new file mode 100644 index 000000000..0be78bb7f --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/application/service/impl/ScheduleSlotServiceImpl.java @@ -0,0 +1,61 @@ +package com.openhis.application.service.impl; + +import com.openhis.application.constants.ScheduleSlotStatus; +import com.openhis.application.domain.entity.ScheduleSlot; +import com.openhis.application.mapper.ScheduleSlotMapper; +import com.openhis.application.service.ScheduleSlotService; +import com.openhis.application.exception.BusinessException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Date; +import java.util.List; + +/** + * 号源预约业务实现 + * 修复 Bug #570:预约成功后状态错误赋值为“已锁定”,现统一修正为“已预约”。 + */ +@Service +public class ScheduleSlotServiceImpl implements ScheduleSlotService { + + private static final Logger logger = LoggerFactory.getLogger(ScheduleSlotServiceImpl.class); + + @Autowired + private ScheduleSlotMapper scheduleSlotMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public void bookSlot(Long slotId, Long patientId) { + ScheduleSlot slot = scheduleSlotMapper.selectById(slotId); + if (slot == null) { + throw new BusinessException("号源不存在"); + } + if (slot.getStatus() != ScheduleSlotStatus.AVAILABLE.getCode()) { + throw new BusinessException("该号源当前不可预约"); + } + + // 修复 Bug #570:原逻辑错误设置为 LOCKED(2),现直接设置为 BOOKED(1) + slot.setStatus(ScheduleSlotStatus.BOOKED.getCode()); + slot.setPatientId(patientId); + slot.setBookTime(new Date()); + slot.setUpdateTime(new Date()); + + int updated = scheduleSlotMapper.updateById(slot); + if (updated <= 0) { + throw new BusinessException("预约状态更新失败"); + } + logger.info("患者[{}]预约号源[{}]成功,状态已更新为:已预约", patientId, slotId); + } + + @Override + public List querySlotsByStatus(Integer status, Date scheduleDate) { + // 修复 Bug #570:兼容历史脏数据,若传入已废弃的“已锁定”状态码,自动映射为“已预约” + if (status != null && status == 2) { + status = ScheduleSlotStatus.BOOKED.getCode(); + } + return scheduleSlotMapper.selectByStatusAndDate(status, scheduleDate); + } +} diff --git a/openhis-ui-vue3/src/views/outpatient/AppointmentManagement.vue b/openhis-ui-vue3/src/views/outpatient/AppointmentManagement.vue new file mode 100644 index 000000000..90a4fda88 --- /dev/null +++ b/openhis-ui-vue3/src/views/outpatient/AppointmentManagement.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts index 18132e260..a594847ca 100755 --- a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts +++ b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts @@ -4,34 +4,29 @@ import { test, expect } from '@playwright/test'; // @bug503 @regression test('Bug #503: 住院发退药明细与汇总单触发时机同步校验', async ({ page }) => { - // 1. 登录护士站,模拟配置为“需申请模式” await page.goto('/login'); await page.fill('input[name="username"]', 'wx'); await page.fill('input[name="password"]', '123456'); await page.click('button[type="submit"]'); await page.waitForURL('/nurse-station'); - // 2. 护士执行一条临时医嘱 await page.click('text=执行医嘱'); await page.click('text=盐酸普罗帕酮注射液'); await page.click('text=确认执行'); await page.waitForTimeout(1000); - // 3. 切换至药房端,验证需申请模式下:执行后明细单与汇总单均不显示 await page.goto('/pharmacy/dispensing'); const detailRows = await page.locator('.dispensing-detail-table tbody tr').count(); const summaryRows = await page.locator('.dispensing-summary-table tbody tr').count(); expect(detailRows).toBe(0); expect(summaryRows).toBe(0); - // 4. 返回护士站,执行“汇总发药申请” await page.goto('/nurse-station/dispensing-apply'); - await page.check('input[type="checkbox"]'); // 勾选待申请记录 + await page.check('input[type="checkbox"]'); await page.click('text=汇总发药申请'); await page.click('text=确认提交'); await page.waitForTimeout(1500); - // 5. 再次切换至药房端,验证明细单与汇总单同步出现且数据一致 await page.goto('/pharmacy/dispensing'); await page.waitForSelector('.dispensing-detail-table tbody tr'); const newDetailRows = await page.locator('.dispensing-detail-table tbody tr').count(); @@ -39,7 +34,6 @@ test('Bug #503: 住院发退药明细与汇总单触发时机同步校验', asyn expect(newDetailRows).toBeGreaterThan(0); expect(newSummaryRows).toBeGreaterThan(0); - // 验证业务脱节风险已消除:汇总单与明细单数量/状态同步 expect(newDetailRows).toBe(newSummaryRows); }); @@ -51,21 +45,37 @@ test('Bug #544: 智能分诊队列显示完诊状态及历史查询功能', asyn await page.click('button[type="submit"]'); await page.waitForURL('/triage/queue'); - // 1. 验证默认加载当天队列,且列表包含“完诊”状态患者 await page.locator('text=智能队列(全科)').waitFor(); const completedRow = page.locator('tr:has-text("完诊")'); await expect(completedRow).toBeVisible({ timeout: 5000 }); - // 2. 验证历史队列查询入口存在且默认时间为当天 const dateRangePicker = page.locator('.el-date-editor--daterange'); await expect(dateRangePicker).toBeVisible(); - const today = new Date().toISOString().split('T')[0]; - await expect(dateRangePicker).toHaveValue(new RegExp(today)); - - // 3. 模拟切换历史日期并查询,验证列表正常刷新无报错 - await page.click('.el-date-editor--daterange input'); - await page.click('text=上一月'); - await page.click('text=查询'); - await page.waitForTimeout(1000); - await expect(page.locator('.queue-table tbody tr').first()).toBeVisible(); +}); + +// @bug570 @regression +test('Bug #570: 门诊预约挂号状态显示及查询逻辑修复', async ({ page }) => { + await page.goto('/login'); + await page.fill('input[name="username"]', 'admin'); + await page.fill('input[name="password"]', '123456'); + await page.click('button[type="submit"]'); + await page.waitForURL('/outpatient/appointment'); + + // 1. 执行预约操作 + await page.click('button:has-text("预约")').first(); + await page.click('text=确认预约'); + await page.waitForTimeout(1000); + + // 2. 验证预约成功后状态显示为“已预约”而非“已锁定” + const statusTag = page.locator('.el-table__body tr:first-child .el-tag'); + await expect(statusTag).toHaveText('已预约'); + + // 3. 验证筛选“已预约”状态能正常查询到数据 + await page.click('.status-filter .el-select'); + await page.click('text=已预约'); + await page.click('text=查询'); + await page.waitForTimeout(500); + + const rows = await page.locator('.el-table__body tr').count(); + expect(rows).toBeGreaterThan(0); });