diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java index 2054417ef..9386c2d93 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatient/service/impl/OrderVerificationServiceImpl.java @@ -58,23 +58,24 @@ public class OrderVerificationServiceImpl implements OrderVerificationService { String chargeStatus = String.valueOf(order.get("charge_status")); // 3. 核心状态约束校验(修复 Bug #505 根因) - // - 执行状态:必须为“未执行” - // - 发药状态:必须为“未发药” - // - 计费状态:必须为“未计费” - if ("已执行".equals(execStatus) || "EXECUTED".equals(execStatus)) { - throw new RuntimeException("已执行的医嘱不能撤回"); + // 执行状态:必须为“未执行” + if (!"未执行".equals(execStatus) && !"NOT_EXECUTED".equalsIgnoreCase(execStatus)) { + throw new RuntimeException("该医嘱已执行,请先执行取消执行流程,不可直接退回"); } - if ("已发药".equals(dispenseStatus) || "DISPENSED".equals(dispenseStatus)) { - throw new RuntimeException("已发药的医嘱不能撤回"); + // 物理状态:必须为“未发药/未领药” + if (!"未发药".equals(dispenseStatus) && !"未领药".equals(dispenseStatus) && + !"NOT_DISPENSED".equalsIgnoreCase(dispenseStatus)) { + throw new RuntimeException("该药品已由药房发放,请先执行退药处理,不可直接退回"); } - if ("已计费".equals(chargeStatus) || "CHARGED".equals(chargeStatus)) { - throw new RuntimeException("已计费的医嘱不能撤回"); + // 财务状态:必须为“未计费” + if (!"未计费".equals(chargeStatus) && !"NOT_CHARGED".equalsIgnoreCase(chargeStatus)) { + throw new RuntimeException("该医嘱已产生费用,请先撤销计费,不可直接退回"); } - // 4. 通过状态校验后,统一将医嘱状态更新为 CANCELLED + // 4. 校验通过,执行退回逻辑 int updated = orderMapper.updateOrderStatusToCancelled(orderId, OrderMapper.ORDER_STATUS_CANCELLED); if (updated == 0) { - throw new RuntimeException("医嘱撤回失败,状态更新异常"); + throw new RuntimeException("医嘱退回失败,状态更新异常"); } } } 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 6ca8cca26..a5b65567a 100755 --- a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts +++ b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts @@ -10,31 +10,6 @@ describe('HIS System Regression Tests', () => { cy.get('.dashboard-container').should('be.visible') }) - // @bug544 @regression - describe('Bug #544: Triage Queue List & Historical Query', () => { - it('should display completed status patients and support historical date query', () => { - cy.visit('/triage/queue') - - // 1. 验证默认加载当天数据 - cy.get('[data-cy="queue-table"]').should('exist') - cy.get('[data-cy="date-range-picker"]').should('contain', new Date().toISOString().slice(0, 10)) - - // 2. 验证可筛选“完诊”状态患者 - cy.get('[data-cy="status-select"]').select('完诊') - cy.get('[data-cy="search-btn"]').click() - cy.get('[data-cy="queue-table"] tbody tr').should('have.length.greaterThan', 0) - cy.get('[data-cy="queue-table"] .status-tag').should('contain', '完诊') - - // 3. 验证历史队列查询功能(按时间范围检索) - cy.get('[data-cy="start-date"]').clear().type('2026-05-01') - cy.get('[data-cy="end-date"]').clear().type('2026-05-02') - cy.get('[data-cy="search-btn"]').click() - cy.get('[data-cy="queue-table"]').should('exist') - cy.url().should('include', 'startDate=2026-05-01') - cy.url().should('include', 'endDate=2026-05-02') - }) - }) - // @bug550 @regression describe('Bug #550: Exam Item Selection Interaction Optimization', () => { it('should decouple item/method selection, display full names without "套餐" prefix, and show hierarchical collapsed details', () => { @@ -60,4 +35,47 @@ describe('HIS System Regression Tests', () => { cy.get('[data-cy="selected-card"] .details-panel').should('not.contain', '项目套餐明细') // 验证冗余标签已移除 }) }) + + // @bug544 @regression + describe('Bug #544: Triage Queue List & Historical Query', () => { + it('should display completed status patients and support historical date query', () => { + cy.visit('/triage/queue') + + // 1. 验证默认加载当天数据 + cy.get('[data-cy="queue-table"]').should('exist') + cy.get('[data-cy="date-range-picker"]').should('contain', new Date().toISOString().slice(0, 10)) + + // 2. 验证可筛选“完诊”状态患者 + cy.get('[data-cy="status-select"]').select('完诊') + cy.get('[data-cy="search-btn"]').click() + cy.get('[data-cy="queue-table"] tbody tr').should('have.length.greaterThan', 0) + cy.get('[data-cy="queue-table"] .status-tag').should('contain', '完诊') + + // 3. 验证历史队列查询功能(按时间范围检索) + cy.get('[data-cy="start-date"]').clear().type('2026-05-01') + cy.get('[data-cy="end-date"]').clear().type('2026-05-02') + cy.get('[data-cy="search-btn"]').click() + cy.get('[data-cy="queue-table"]').should('exist') + cy.url().should('include', 'startDate=2026-05-01') + cy.url().should('include', 'endDate=2026-05-02') + }) + }) + + // @bug505 @regression + describe('Bug #505: Prevent Return of Dispensed Medication Orders', () => { + it('should block return action and show warning when order is already dispensed', () => { + cy.visit('/inpatient/order/verification') + cy.get('[data-cy="verified-tab"]').click() + + // 模拟勾选一条已发药的医嘱 + cy.get('[data-cy="order-list"] tbody tr').first().click() + + // 点击退回按钮 + cy.get('[data-cy="return-btn"]').click() + + // 验证系统拦截并弹出指定警示 + cy.get('.el-message--error, .el-message--warning, .el-dialog').should('be.visible') + cy.contains('该药品已由药房发放,请先执行退药处理,不可直接退回').should('be.visible') + }) + }) })