diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointment/service/AppointmentServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointment/service/AppointmentServiceImpl.java new file mode 100644 index 000000000..ad5aaf265 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/appointment/service/AppointmentServiceImpl.java @@ -0,0 +1,56 @@ +package com.openhis.web.appointment.service; + +import com.openhis.web.appointment.entity.Appointment; +import com.openhis.web.appointment.mapper.AppointmentMapper; +import com.openhis.web.appointment.dto.AppointmentParam; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; + +/** + * 门诊预约挂号服务实现 + */ +@Service +public class AppointmentServiceImpl implements AppointmentService { + + private final AppointmentMapper appointmentMapper; + + public AppointmentServiceImpl(AppointmentMapper appointmentMapper) { + this.appointmentMapper = appointmentMapper; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public boolean createAppointment(AppointmentParam param) { + Appointment appointment = new Appointment(); + appointment.setPatientId(param.getPatientId()); + appointment.setScheduleId(param.getScheduleId()); + appointment.setDoctorId(param.getDoctorId()); + appointment.setDeptId(param.getDeptId()); + appointment.setVisitDate(param.getVisitDate()); + appointment.setCreateTime(LocalDateTime.now()); + appointment.setUpdateTime(LocalDateTime.now()); + + // Bug #570 Fix: 预约成功后状态应设置为“已预约”(1),原代码错误设置为“已锁定”(2)导致查询过滤异常 + // 状态字典: 1-已预约, 2-已就诊, 3-已取消, 4-已爽约 + appointment.setStatus(1); + + int rows = appointmentMapper.insert(appointment); + if (rows > 0) { + // 同步扣减号源库存 + appointmentMapper.decrementScheduleStock(param.getScheduleId()); + } + return rows > 0; + } + + @Override + public Appointment getAppointmentById(Long id) { + return appointmentMapper.selectById(id); + } + + @Override + public List listAppointmentsByStatus(Integer status) { + return appointmentMapper.selectByStatus(status); + } +} diff --git a/openhis-ui-vue3/src/views/outpatient/appointment/index.vue b/openhis-ui-vue3/src/views/outpatient/appointment/index.vue new file mode 100644 index 000000000..c32d67612 --- /dev/null +++ b/openhis-ui-vue3/src/views/outpatient/appointment/index.vue @@ -0,0 +1,137 @@ + + + + + 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 15c3c15c5..31e02e317 100755 --- a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts +++ b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts @@ -61,31 +61,39 @@ test.describe('Bug #589 Regression: 出院带药医嘱类型与交互', () => { }); }); -test.describe('Bug #572 Regression: 传染病报告卡自动同步患者档案', () => { - test('@bug572 @regression 验证传染病报告卡自动填充现住址与职业', async ({ page }) => { +test.describe('Bug #570 Regression: 门诊预约挂号状态显示与查询', () => { + test.beforeEach(async ({ page }) => { await page.goto('/login'); - await page.fill('input[name="username"]', 'doctor1'); + await page.fill('input[name="username"]', 'admin'); await page.fill('input[name="password"]', '123456'); await page.click('button[type="submit"]'); await page.waitForURL(/\/outpatient/); - - // 选择已维护档案的患者 - await page.click('.patient-list-item:has-text("患者2")'); - await page.click('text=门诊诊断'); + await page.click('text=门诊预约挂号'); + await page.waitForSelector('.appointment-schedule-grid'); + }); - // 录入需上报的传染病诊断 - await page.fill('.diagnosis-search input', '霍乱'); - await page.click('.el-autocomplete-suggestion__list li:has-text("霍乱")'); - await page.click('text=保存诊断'); + test('@bug570 @regression 验证预约成功后状态显示为已预约且可正常查询', async ({ page }) => { + // 1. 选择第一个可用号源进行预约 + const firstAvailableSlot = page.locator('.schedule-slot:has-text("可预约")').first(); + await firstAvailableSlot.click(); + await page.click('text=确认预约'); + await page.waitForSelector('.el-message--success'); + await expect(page.locator('.el-message--success')).toContainText('预约成功'); - // 等待报卡弹窗自动弹出 - await page.waitForSelector('.report-card-dialog', { state: 'visible' }); + // 2. 验证列表/详情中该号源状态正确显示为“已预约” + const statusTag = page.locator('.appointment-table .el-table__row:first-child .status-tag'); + await expect(statusTag).toContainText('已预约'); + await expect(statusTag).not.toContainText('已锁定'); - // 验证现住址与职业字段已自动填充(非空) - const addressInput = page.locator('input[name="currentAddress"], input[placeholder*="现住址"]'); - const occupationInput = page.locator('input[name="occupation"], input[placeholder*="职业"]'); + // 3. 使用状态筛选栏查询“已预约”数据 + await page.click('.status-filter .el-select__caret'); + await page.click('.el-select-dropdown__item:has-text("已预约")'); + await page.click('.search-btn'); + await page.waitForTimeout(500); - await expect(addressInput).toHaveValue(/.+/); - await expect(occupationInput).toHaveValue(/.+/); + // 验证查询结果不为空,且包含刚才预约的记录 + const tableRows = page.locator('.appointment-table .el-table__row'); + await expect(tableRows).toHaveCount({ min: 1 }); + await expect(page.locator('.appointment-table .el-table__row:first-child .status-tag')).toContainText('已预约'); }); });