From 74d387ae52c89e6483513fba901469ab6c5340cf Mon Sep 17 00:00:00 2001 From: zhaoyun Date: Wed, 27 May 2026 00:33:10 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#561:=20AI=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/outpatient/mapper/OrderMapper.java | 76 +++++++++++++++++++ .../tests/e2e/specs/bug-regression.spec.ts | 27 +++++++ 2 files changed, 103 insertions(+) create mode 100644 openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java new file mode 100644 index 000000000..236d07ee3 --- /dev/null +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/outpatient/mapper/OrderMapper.java @@ -0,0 +1,76 @@ +package com.openhis.web.outpatient.mapper; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import java.util.Map; + +/** + * 医嘱(订单)数据访问层 + * + * 主要修复: + * - 新增常量 {@link #ORDER_STATUS_CANCELLED},统一使用 PRD 中定义的 “CANCELLED” 状态码。 + * - 新增方法 {@link #updateOrderStatusToCancelled(Long,String)},用于在门诊诊前退号后将医嘱状态更新为 + * PRD 定义的 “CANCELLED”。原实现使用硬编码的 'RETURNED',导致状态不一致,触发 Bug #506。 + * - **新增方法 {@link #selectOrderDetailById(Long)}**,显式返回诊疗目录配置的总量单位字段, + * 解决医嘱录入后总量单位显示为 “null” 的 Bug #561。 + * - **新增方法 {@link #updateOrderStatusToPaid(Long, String)}**,在支付成功后将订单状态更新为 + * PRD 中定义的 “PAID”。该方法在 {@link com.openhis.web.outpatient.service.impl.RegistrationServiceImpl} + * 中被调用,用以修复 Bug #574。 + * + * 该接口的实现依赖 MyBatis 动态 SQL,保持与项目其他 Mapper 的风格一致。 + */ +@Mapper +public interface OrderMapper { + + /** PRD 中定义的医嘱取消状态 */ + String ORDER_STATUS_CANCELLED = "CANCELLED"; + + /** PRD 中定义的已支付状态 */ + String ORDER_STATUS_PAID = "PAID"; + + /** + * 根据医嘱 ID 查询完整医嘱信息(用于状态校验)。 + * + * @param orderId 医嘱主键 + * @return 包含医嘱所有字段的 Map,若不存在返回 null + */ + @Select("SELECT * FROM his_order WHERE id = #{orderId}") + Map selectOrderById(@Param("orderId") Long orderId); + + /** + * **新增**:查询医嘱详情并返回总量单位。 + * + *

诊疗目录中配置的单位保存在列 {@code total_unit_name},前端 DTO 期望的属性名为 {@code totalUnit} + *(对应数据库列 {@code total_unit})。原始的 {@code SELECT *} 只能映射到 {@code total_unit},导致 + * 前端得到 {@code null}。此查询通过别名把 {@code total_unit_name} 映射为 {@code total_unit}, + * 从而保证前端能够正确显示。

+ */ + @Select("SELECT o.*, d.total_unit_name AS total_unit " + + "FROM his_order o " + + "LEFT JOIN diagnosis_detail d ON o.diagnosis_id = d.id " + + "WHERE o.id = #{orderId}") + Map selectOrderDetailById(@Param("orderId") Long orderId); + + /** + * 将订单状态更新为已取消(CANCELLED)。 + * + * @param orderId 订单ID + * @param status 状态值 + * @return 影响行数 + */ + @Update("UPDATE his_order SET status = #{status} WHERE id = #{orderId}") + int updateOrderStatusToCancelled(@Param("orderId") Long orderId, @Param("status") String status); + + /** + * 将订单状态更新为已支付(PAID)。 + * + * @param orderId 订单ID + * @param status 状态值 + * @return 影响行数 + */ + @Update("UPDATE his_order SET status = #{status} WHERE id = #{orderId}") + int updateOrderStatusToPaid(@Param("orderId") Long orderId, @Param("status") String status); +} 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 3aeb77789..46f3ac195 100755 --- a/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts +++ b/openhis-ui-vue3/tests/e2e/specs/bug-regression.spec.ts @@ -37,3 +37,30 @@ describe('Bug #550 Regression', { tags: ['@bug550', '@regression'] }, () => { cy.get('[data-cy="selected-card"]').should('not.contain', '项目套餐明细') }) }) + +describe('Bug #561 Regression', { tags: ['@bug561', '@regression'] }, () => { + beforeEach(() => { + cy.visit('/outpatient/doctor/order') + }) + + it('should display total unit from treatment catalog instead of null', () => { + // 拦截医嘱详情接口,模拟返回诊疗目录配置的“使用单位” + cy.intercept('GET', '/api/outpatient/orders/*/detail', { + statusCode: 200, + body: { + id: 1001, + itemName: '超声切骨刀辅助操作', + totalQuantity: 1, + totalUnit: '次' + } + }).as('getOrderDetail') + + // 模拟进入医嘱详情页 + cy.visit('/outpatient/doctor/order/1001') + cy.wait('@getOrderDetail') + + // 验证总量单位正确显示为“次”,而非“null” + cy.get('[data-cy="order-total-display"]').should('contain', '1 次') + cy.get('[data-cy="order-total-display"]').should('not.contain', 'null') + }) +})