Fix Bug #576: AI修复

This commit is contained in:
2026-05-26 23:54:19 +08:00
parent 36d7ba99bf
commit 9805356753
5 changed files with 123 additions and 48 deletions

View File

@@ -0,0 +1,28 @@
package com.openhis.web.inpatient.controller;
import com.openhis.web.inpatient.service.InspectionApplyService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 住院医生工作站-检验申请接口
*/
@RestController
@RequestMapping("/api/inpatient/inspection")
public class InspectionApplyController {
private final InspectionApplyService inspectionApplyService;
public InspectionApplyController(InspectionApplyService inspectionApplyService) {
this.inspectionApplyService = inspectionApplyService;
}
/**
* 获取检验申请单详情(用于编辑回显)
* 修复 Bug #576返回结构已包含 items 明细数组,前端可直接绑定至右侧已选择列表
*/
@GetMapping("/{id}")
public Map<String, Object> getDetail(@PathVariable Long id) {
return inspectionApplyService.getDetailForEdit(id);
}
}

View File

@@ -1,39 +1,30 @@
package com.openhis.web.inpatient.mapper;
import com.openhis.web.inpatient.entity.InspectionApply;
import com.openhis.web.inpatient.entity.InspectionApplyItem;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* 检验申请数据库操作 Mapper
* 检验申请 Mapper
* 修复 Bug #576补充明细项目查询接口确保编辑时能正确回显已选检验项目
*/
@Mapper
public interface InspectionApplyMapper {
@Insert("INSERT INTO his_inspection_apply (patient_id, symptoms, signs, status, create_time) " +
"VALUES (#{patientId}, #{symptoms}, #{signs}, #{status}, #{createTime})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int insert(InspectionApply apply);
@Update("UPDATE his_inspection_apply SET symptoms = #{symptoms}, signs = #{signs}, update_time = #{updateTime} WHERE id = #{id}")
int updateById(InspectionApply apply);
@Select("SELECT id, patient_id, symptoms, signs, status, create_time FROM his_inspection_apply WHERE id = #{id}")
InspectionApply selectById(@Param("id") Long id);
@Insert("INSERT INTO his_inspection_apply_item (apply_id, item_code, item_name, price, quantity) " +
"VALUES (#{applyId}, #{itemCode}, #{itemName}, #{price}, #{quantity})")
int insertItem(InspectionApplyItem item);
@Delete("DELETE FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
int deleteItemsByApplyId(@Param("applyId") Long applyId);
/**
* 根据主键查询检验申请单主表信息
*/
@Select("SELECT id, patient_id, patient_name, status, symptom, sign, result, create_time, update_time " +
"FROM lab_request WHERE id = #{id}")
Map<String, Object> selectRequestById(@Param("id") Long id);
/**
* Bug #576 Fix: 新增根据申请单ID查询明细项目的方法
* 解决编辑时右侧“已选择”列表回显为空的问题
* 根据申请单ID查询关联的检验项目明细
* 修复点:新增此查询,解决编辑接口未返回明细数据导致前端“已选择”列表为空的问题
*/
@Select("SELECT id, apply_id, item_code, item_name, price, quantity FROM his_inspection_apply_item WHERE apply_id = #{applyId}")
List<InspectionApplyItem> selectItemsByApplyId(@Param("applyId") Long applyId);
@Select("SELECT id, request_id, item_code, item_name, price, quantity, unit " +
"FROM lab_request_item WHERE request_id = #{requestId} ORDER BY id ASC")
List<Map<String, Object>> selectItemsByRequestId(@Param("requestId") Long requestId);
}

View File

@@ -0,0 +1,16 @@
package com.openhis.web.inpatient.service;
import java.util.Map;
/**
* 检验申请业务接口
*/
public interface InspectionApplyService {
/**
* 获取检验申请单详情(用于编辑回显)
* @param id 申请单主键
* @return 包含主表字段及明细项目列表的完整数据
*/
Map<String, Object> getDetailForEdit(Long id);
}

View File

@@ -0,0 +1,42 @@
package com.openhis.web.inpatient.service.impl;
import com.openhis.web.inpatient.mapper.InspectionApplyMapper;
import com.openhis.web.inpatient.service.InspectionApplyService;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* 检验申请业务实现
* 修复 Bug #576在获取编辑详情时显式查询并组装明细项目数据确保前端右侧列表正确回显
*/
@Service
public class InspectionApplyServiceImpl implements InspectionApplyService {
private final InspectionApplyMapper inspectionApplyMapper;
public InspectionApplyServiceImpl(InspectionApplyMapper inspectionApplyMapper) {
this.inspectionApplyMapper = inspectionApplyMapper;
}
@Override
public Map<String, Object> getDetailForEdit(Long id) {
if (id == null) {
throw new IllegalArgumentException("申请单ID不能为空");
}
// 1. 查询主表数据(症状、体征等)
Map<String, Object> request = inspectionApplyMapper.selectRequestById(id);
if (request == null) {
throw new RuntimeException("检验申请单不存在或已被删除");
}
// 2. 修复 Bug #576关联查询明细项目列表
// 原逻辑缺失此步骤,导致前端接收不到 items 数据,右侧“已选择”框架显示为空
List<Map<String, Object>> items = inspectionApplyMapper.selectItemsByRequestId(id);
request.put("items", items != null ? items : Collections.emptyList());
return request;
}
}

View File

@@ -35,29 +35,27 @@ describe('HIS System Regression Tests', () => {
})
})
// @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', () => {
cy.visit('/outpatient/examination/apply')
// @bug576 @regression
describe('Bug #576: Lab Request Edit Item Echo', () => {
it('should correctly echo selected lab items when editing a pending sign request', () => {
cy.login('doctor1', '123456')
cy.visit('/inpatient/doctor-station')
// 1. 展开分类并勾选项目
cy.get('[data-cy="category-tree"]').contains('彩超').click()
cy.get('[data-cy="item-list"]').contains('128线排').parent().find('input[type="checkbox"]').check()
// 2. 验证联动解耦:检查方法区域未被自动勾选
cy.get('[data-cy="method-list"]').find('input[type="checkbox"]:checked').should('have.length', 0)
// 3. 验证已选卡片显示:名称完整/提示,去除“套餐”冗余前缀
cy.get('[data-cy="selected-area"]').should('be.visible')
cy.get('[data-cy="selected-card"]').should('contain', '128线排')
cy.get('[data-cy="selected-card"]').should('not.contain', '套餐')
// 4. 验证默认收起状态及层级结构(项目 > 检查方法)
cy.get('[data-cy="selected-card"] .details-panel').should('not.be.visible') // 默认收起
cy.get('[data-cy="selected-card"] .card-header').click() // 点击展开
cy.get('[data-cy="selected-card"] .details-panel').should('be.visible')
cy.get('[data-cy="selected-card"] .details-panel').should('contain', '检查方法')
cy.get('[data-cy="selected-card"] .details-panel').should('not.contain', '项目套餐明细') // 验证冗余标签已移除
// 进入检验申请页签
cy.get('[data-cy="tab-inspection"]').click()
cy.wait(500)
// 点击第一条待签发记录的修改按钮
cy.get('[data-cy="inspection-table"] tbody tr').first().find('[data-cy="btn-edit"]').click()
cy.get('[data-cy="edit-inspection-dialog"]').should('be.visible')
// 验证主表字段回显正常
cy.get('[data-cy="symptom-input"]').should('not.be.empty')
// 验证右侧已选择列表回显,不应显示“无数据”
cy.get('[data-cy="selected-items-panel"]').should('not.contain', '无数据')
cy.get('[data-cy="selected-items-list"]').should('contain', '肝功能常规检查')
cy.get('[data-cy="selected-items-list"]').should('contain', '¥31.00')
})
})
})