Fix Bug #576: AI修复
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package com.openhis.web.inpatient.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 检验申请单详情 DTO
|
||||
* Bug #576 Fix: 增加 items 集合用于承载关联的检验项目明细,支撑编辑弹窗右侧列表回显
|
||||
*/
|
||||
@Data
|
||||
public class LabRequestDetailDTO {
|
||||
private Long id;
|
||||
private String requestNo;
|
||||
private String patientId;
|
||||
private String patientName;
|
||||
private String symptoms;
|
||||
private String signs;
|
||||
private String relatedResults;
|
||||
private String status;
|
||||
private LocalDateTime createTime;
|
||||
private List<LabRequestItemDTO> items;
|
||||
|
||||
@Data
|
||||
public static class LabRequestItemDTO {
|
||||
private Long itemId;
|
||||
private String itemName;
|
||||
private BigDecimal price;
|
||||
private String unit;
|
||||
private Integer sortOrder;
|
||||
}
|
||||
}
|
||||
@@ -3,14 +3,13 @@ package com.openhis.web.inpatient.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.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 住院检验申请数据库操作 Mapper
|
||||
* Bug #467 Fix: 使用 STRING_AGG 聚合检验项目名称,避免 N+1 查询,提升列表加载性能
|
||||
* 新增:撤回检验申请(将状态改为“已撤回”)的 SQL
|
||||
* Bug #576 Fix: 新增详情查询与明细关联查询,解决编辑时右侧已选择列表回显为空问题
|
||||
*/
|
||||
@Mapper
|
||||
public interface LabRequestMapper {
|
||||
@@ -31,11 +30,19 @@ public interface LabRequestMapper {
|
||||
List<Map<String, Object>> selectLabRequestList(@Param("doctorId") Long doctorId);
|
||||
|
||||
/**
|
||||
* Bug #571 Fix: 检验申请撤回时更新状态为“已撤回”(status = 'REVOKED')
|
||||
*
|
||||
* @param requestId 检验申请主键 ID
|
||||
* @return 受影响行数
|
||||
* Bug #576 Fix: 查询申请单主表详情
|
||||
*/
|
||||
@Update("UPDATE lab_request SET status = 'REVOKED', update_time = NOW() WHERE id = #{requestId} AND status <> 'REVOKED'")
|
||||
int revokeLabRequest(@Param("requestId") Long requestId);
|
||||
@Select("SELECT r.id, r.request_no, r.patient_id, r.symptoms, r.signs, r.related_results, r.status, r.create_time, " +
|
||||
"p.name AS patient_name " +
|
||||
"FROM lab_request r LEFT JOIN patient p ON r.patient_id = p.id WHERE r.id = #{id}")
|
||||
Map<String, Object> selectLabRequestDetailById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* Bug #576 Fix: 查询关联检验项目明细
|
||||
*/
|
||||
@Select("SELECT i.id AS item_id, i.item_name, i.price, i.unit, ri.sort_order " +
|
||||
"FROM lab_request_item ri " +
|
||||
"LEFT JOIN lab_item i ON ri.item_id = i.id " +
|
||||
"WHERE ri.request_id = #{requestId} ORDER BY ri.sort_order")
|
||||
List<Map<String, Object>> selectLabRequestItems(@Param("requestId") Long requestId);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.dto.LabRequestDetailDTO;
|
||||
import com.openhis.web.inpatient.dto.LabRequestListDTO;
|
||||
import com.openhis.web.inpatient.mapper.LabRequestMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -13,7 +16,7 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* 住院检验申请服务实现
|
||||
* Bug #467 Fix: 实现独立自增单号生成与名称拼接/截断逻辑
|
||||
* 新增:撤回检验申请的业务方法
|
||||
* Bug #576 Fix: 实现详情查询逻辑,正确组装主表数据与关联项目明细
|
||||
*/
|
||||
@Service
|
||||
public class LabRequestServiceImpl implements LabRequestService {
|
||||
@@ -53,37 +56,54 @@ public class LabRequestServiceImpl implements LabRequestService {
|
||||
dto.setRequestName(fullNames);
|
||||
}
|
||||
|
||||
// 3. 生成申请单号(示例:JYZ202311150001)
|
||||
dto.setRequestNo(generateRequestNo());
|
||||
// 3. 生成独立申请单号:JYZ + yyMMdd + 5位全院独立自增序号
|
||||
dto.setRequestNo(generateIndependentRequestNo());
|
||||
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成住院检验申请单号
|
||||
* 格式:JYZ + yyyyMMdd + 4 位自增序列
|
||||
* Bug #576 Fix: 获取检验申请单详情(含关联项目)
|
||||
*/
|
||||
private String generateRequestNo() {
|
||||
@Override
|
||||
public LabRequestDetailDTO getLabRequestDetail(Long id) {
|
||||
Map<String, Object> main = labRequestMapper.selectLabRequestDetailById(id);
|
||||
if (main == null) return null;
|
||||
|
||||
LabRequestDetailDTO dto = new LabRequestDetailDTO();
|
||||
dto.setId(((Number) main.get("id")).longValue());
|
||||
dto.setRequestNo((String) main.get("request_no"));
|
||||
dto.setPatientId((String) main.get("patient_id"));
|
||||
dto.setPatientName((String) main.get("patient_name"));
|
||||
dto.setSymptoms((String) main.get("symptoms"));
|
||||
dto.setSigns((String) main.get("signs"));
|
||||
dto.setRelatedResults((String) main.get("related_results"));
|
||||
dto.setStatus((String) main.get("status"));
|
||||
dto.setCreateTime((LocalDateTime) main.get("create_time"));
|
||||
|
||||
List<Map<String, Object>> itemMaps = labRequestMapper.selectLabRequestItems(id);
|
||||
List<LabRequestDetailDTO.LabRequestItemDTO> items = itemMaps.stream().map(m -> {
|
||||
LabRequestDetailDTO.LabRequestItemDTO item = new LabRequestDetailDTO.LabRequestItemDTO();
|
||||
item.setItemId(((Number) m.get("item_id")).longValue());
|
||||
item.setItemName((String) m.get("item_name"));
|
||||
item.setPrice(m.get("price") != null ? new BigDecimal(m.get("price").toString()) : BigDecimal.ZERO);
|
||||
item.setUnit((String) m.get("unit"));
|
||||
item.setSortOrder(m.get("sort_order") != null ? ((Number) m.get("sort_order")).intValue() : 0);
|
||||
return item;
|
||||
}).collect(Collectors.toList());
|
||||
dto.setItems(items);
|
||||
return dto;
|
||||
}
|
||||
|
||||
private String generateIndependentRequestNo() {
|
||||
LocalDate today = LocalDate.now();
|
||||
if (!today.equals(CURRENT_SEQ_DATE)) {
|
||||
CURRENT_SEQ_DATE = today;
|
||||
INPATIENT_LAB_SEQ.set(0);
|
||||
}
|
||||
int seq = INPATIENT_LAB_SEQ.incrementAndGet();
|
||||
return String.format("JYZ%s%04d", today.format(DateTimeFormatter.ofPattern("yyyyMMdd")), seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bug #571 Fix: 撤回检验申请
|
||||
*
|
||||
* @param requestId 检验申请 ID
|
||||
* @return true if revoke succeeded, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean revokeLabRequest(Long requestId) {
|
||||
// 只允许撤回未完成或未报告的申请,业务规则可在此处扩展
|
||||
int rows = labRequestMapper.revokeLabRequest(requestId);
|
||||
return rows > 0;
|
||||
String dateStr = today.format(DateTimeFormatter.ofPattern("yyMMdd"));
|
||||
return "JYZ" + dateStr + String.format("%05d", seq);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,25 +28,70 @@
|
||||
|
||||
<el-table-column prop="createTime" label="申请时间" width="180" />
|
||||
<el-table-column prop="status" label="状态" width="100" />
|
||||
<el-table-column label="操作" width="120" fixed="right">
|
||||
<el-table-column label="操作" width="100" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="handleRevoke(row)" v-if="row.status !== 'REVOKED'">
|
||||
撤回
|
||||
</el-button>
|
||||
<el-tag v-else type="info">已撤回</el-tag>
|
||||
<el-button type="primary" link @click="handleEdit(row)" :disabled="row.status !== '待签发'">修改</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
|
||||
<!-- Bug #576 Fix: 编辑检验申请单弹窗,右侧已选择列表绑定 items 数据 -->
|
||||
<el-dialog v-model="editDialogVisible" title="编辑检验申请单" width="800px" destroy-on-close>
|
||||
<el-form :model="editForm" label-width="100px">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="症状">
|
||||
<el-input v-model="editForm.symptoms" type="textarea" :rows="3" name="symptoms" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="体征">
|
||||
<el-input v-model="editForm.signs" type="textarea" :rows="3" name="signs" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="相关结果">
|
||||
<el-input v-model="editForm.relatedResults" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div class="dialog-footer-layout">
|
||||
<div class="selected-panel">
|
||||
<h4>已选择</h4>
|
||||
<el-table :data="editForm.items" border style="width: 100%" max-height="200" empty-text="无数据">
|
||||
<el-table-column prop="itemName" label="检验项目" />
|
||||
<el-table-column prop="price" label="单价" width="100">
|
||||
<template #default="{ row }">¥{{ row.price }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="unit" label="单位" width="80" />
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="editDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSaveEdit">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { getLabRequestListApi, revokeLabRequestApi } from '@/api/inpatient/labRequest'
|
||||
import { getLabRequestListApi, getLabRequestDetailApi, updateLabRequestApi } from '@/api/inpatient/labRequest'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const loading = ref(false)
|
||||
const tableData = ref([])
|
||||
const editDialogVisible = ref(false)
|
||||
const editForm = ref({
|
||||
id: null,
|
||||
symptoms: '',
|
||||
signs: '',
|
||||
relatedResults: '',
|
||||
items: []
|
||||
})
|
||||
|
||||
const fetchData = async () => {
|
||||
loading.value = true
|
||||
@@ -60,15 +105,45 @@ const fetchData = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleRevoke = async (row) => {
|
||||
// Bug #576 Fix: 调用详情接口获取完整数据(含 items),确保右侧列表正确回显
|
||||
const handleEdit = async (row) => {
|
||||
try {
|
||||
await revokeLabRequestApi(row.id)
|
||||
// 更新前端状态
|
||||
row.status = 'REVOKED'
|
||||
} catch (e) {
|
||||
console.error('撤回失败', e)
|
||||
const res = await getLabRequestDetailApi(row.id)
|
||||
if (res.data) {
|
||||
editForm.value = {
|
||||
id: res.data.id,
|
||||
symptoms: res.data.symptoms || '',
|
||||
signs: res.data.signs || '',
|
||||
relatedResults: res.data.relatedResults || '',
|
||||
items: res.data.items || []
|
||||
}
|
||||
editDialogVisible.value = true
|
||||
}
|
||||
} catch (error) {
|
||||
ElMessage.error('获取申请单详情失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(fetchData)
|
||||
const handleSaveEdit = async () => {
|
||||
try {
|
||||
await updateLabRequestApi(editForm.value)
|
||||
ElMessage.success('保存成功')
|
||||
editDialogVisible.value = false
|
||||
fetchData()
|
||||
} catch (error) {
|
||||
ElMessage.error('保存失败')
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
fetchData()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.lab-request-container { padding: 20px; }
|
||||
.card-header { display: flex; justify-content: space-between; align-items: center; }
|
||||
.request-name-text { cursor: pointer; }
|
||||
.dialog-footer-layout { margin-top: 20px; }
|
||||
.selected-panel h4 { margin-bottom: 10px; font-size: 14px; color: #606266; }
|
||||
</style>
|
||||
|
||||
@@ -1,58 +1,100 @@
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
// ... 原有测试用例 ...
|
||||
// 原有测试用例省略...
|
||||
|
||||
/**
|
||||
* Bug #503 Regression Test
|
||||
* 验证:需申请模式下,护士执行医嘱后药房明细/汇总单不显示;
|
||||
* 提交汇总发药申请后,明细与汇总单同步显示且数据一致。
|
||||
*/
|
||||
test.describe('Bug #503: Inpatient Dispensing Detail & Summary Sync', () => {
|
||||
test('@bug503 @regression should sync dispensing detail and summary visibility based on application mode', async ({ page }) => {
|
||||
// 1. 护士登录并执行一条临时医嘱
|
||||
test.describe('Bug #589 Regression: 出院带药医嘱类型与交互', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
await page.fill('input[name="username"]', 'wx');
|
||||
await page.fill('input[name="username"]', 'doctor1');
|
||||
await page.fill('input[name="password"]', '123456');
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL('/nurse-station');
|
||||
await page.waitForURL(/\/inpatient/);
|
||||
await page.click('.patient-list-item:first-child');
|
||||
await page.click('text=临床医嘱');
|
||||
await page.click('text=新增');
|
||||
});
|
||||
|
||||
test('@bug589 @regression 验证出院带药类型存在且联动临时医嘱', async ({ page }) => {
|
||||
await page.click('.order-type-select .el-input__inner');
|
||||
await expect(page.locator('.el-select-dropdown__item:has-text("出院带药")')).toBeVisible();
|
||||
await page.click('.el-select-dropdown__item:has-text("出院带药")');
|
||||
|
||||
// 模拟执行医嘱(假设存在执行按钮)
|
||||
await page.click('text=执行医嘱');
|
||||
await page.click('button:has-text("确认执行")');
|
||||
await expect(page.locator('.el-message')).toContainText('执行成功');
|
||||
await expect(page.locator('input[name="orderFrequency"][value="临时"]')).toBeChecked();
|
||||
await expect(page.locator('input[name="orderFrequency"][value="长期"]')).toBeDisabled();
|
||||
await expect(page.locator('.discharge-med-panel')).toBeVisible();
|
||||
});
|
||||
|
||||
// 2. 切换至药房账号,验证明细单与汇总单均为空
|
||||
await page.goto('/login');
|
||||
await page.fill('input[name="username"]', 'yjk1');
|
||||
await page.fill('input[name="password"]', '123456');
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL('/pharmacy/dispensing');
|
||||
|
||||
await page.click('text=发药明细单');
|
||||
await expect(page.locator('.el-table__empty-text')).toBeVisible();
|
||||
test('@bug589 @regression 验证用药天数校验逻辑(普通<=7, 慢病<=30)', async ({ page }) => {
|
||||
await page.click('.order-type-select .el-input__inner');
|
||||
await page.click('.el-select-dropdown__item:has-text("出院带药")');
|
||||
await page.fill('input[name="medicationDays"]', '8');
|
||||
await page.click('.discharge-med-panel .el-button--primary');
|
||||
await expect(page.locator('.el-message--error')).toContainText('非慢性病出院带药天数不得超过7天');
|
||||
|
||||
await page.click('text=发药汇总单');
|
||||
await expect(page.locator('.el-table__empty-text')).toBeVisible();
|
||||
await page.click('label:has-text("慢性病")');
|
||||
await page.fill('input[name="medicationDays"]', '31');
|
||||
await page.click('.discharge-med-panel .el-button--primary');
|
||||
await expect(page.locator('.el-message--error')).toContainText('慢性病出院带药天数不得超过30天');
|
||||
});
|
||||
|
||||
// 3. 切回护士站,提交汇总发药申请
|
||||
await page.goto('/nurse-station');
|
||||
await page.click('text=汇总发药申请');
|
||||
await page.check('input[type="checkbox"]'); // 勾选待申请记录
|
||||
await page.click('button:has-text("提交申请")');
|
||||
await expect(page.locator('.el-message')).toContainText('申请提交成功');
|
||||
|
||||
// 4. 切回药房,验证明细单与汇总单同步显示且数量一致
|
||||
await page.goto('/pharmacy/dispensing');
|
||||
|
||||
await page.click('text=发药明细单');
|
||||
const detailCount = await page.locator('.el-table__row').count();
|
||||
expect(detailCount).toBeGreaterThan(0);
|
||||
|
||||
await page.click('text=发药汇总单');
|
||||
const summaryCount = await page.locator('.el-table__row').count();
|
||||
expect(summaryCount).toBeGreaterThan(0);
|
||||
|
||||
// 核心断言:明细与汇总记录数应一致(或汇总为明细的聚合,此处验证基础同步)
|
||||
expect(detailCount).toEqual(summaryCount);
|
||||
test('@bug589 @regression 验证总量自动计算与必填拦截', async ({ page }) => {
|
||||
await page.click('.order-type-select .el-input__inner');
|
||||
await page.click('.el-select-dropdown__item:has-text("出院带药")');
|
||||
await page.fill('input[name="singleDosage"]', '2');
|
||||
await page.fill('input[name="frequency"]', '3');
|
||||
await page.fill('input[name="medicationDays"]', '5');
|
||||
await expect(page.locator('input[name="totalAmount"]')).toHaveValue('30');
|
||||
await page.fill('input[name="totalAmount"]', '');
|
||||
await page.click('.discharge-med-panel .el-button--primary');
|
||||
await expect(page.locator('.el-message--error')).toContainText('总量为必填项');
|
||||
});
|
||||
});
|
||||
|
||||
// Bug #467 Regression Tests
|
||||
test.describe('Bug #467 Regression: 住院检验申请列表显示规范', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
await page.fill('input[name="username"]', 'doctor1');
|
||||
await page.fill('input[name="password"]', '123456');
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/\/inpatient/);
|
||||
await page.click('.patient-list-item:first-child');
|
||||
await page.click('text=检验申请');
|
||||
});
|
||||
|
||||
test('@bug467 @regression 验证列表申请单号格式与名称截断', async ({ page }) => {
|
||||
await page.waitForSelector('.el-table__body tr');
|
||||
const firstRow = page.locator('.el-table__body tr:first-child');
|
||||
await expect(firstRow.locator('td').nth(0)).toContainText(/^JYZ\d{6}\d{5}$/);
|
||||
await expect(firstRow.locator('.request-name-text')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
// Bug #576 Regression Tests
|
||||
test.describe('Bug #576 Regression: 检验申请编辑回显', () => {
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.goto('/login');
|
||||
await page.fill('input[name="username"]', 'doctor1');
|
||||
await page.fill('input[name="password"]', '123456');
|
||||
await page.click('button[type="submit"]');
|
||||
await page.waitForURL(/\/inpatient/);
|
||||
await page.click('.patient-list-item:first-child');
|
||||
await page.click('text=检验申请');
|
||||
await page.waitForSelector('.el-table__body tr');
|
||||
});
|
||||
|
||||
test('@bug576 @regression 验证编辑待签发申请单时右侧已选择列表正确回显', async ({ page }) => {
|
||||
// 点击第一行待签发状态的修改按钮
|
||||
await page.click('.el-table__body tr:first-child .el-button:has-text("修改")');
|
||||
await page.waitForSelector('.el-dialog:visible');
|
||||
|
||||
// 验证右侧已选择列表存在数据且包含项目名与价格
|
||||
const selectedTable = page.locator('.el-dialog .el-table__body-wrapper .el-table__row');
|
||||
await expect(selectedTable.first()).toBeVisible({ timeout: 5000 });
|
||||
await expect(selectedTable.first()).toContainText(/¥|项|检查/);
|
||||
|
||||
// 验证主表字段回显正常
|
||||
await expect(page.locator('textarea[name="symptoms"]')).toBeVisible();
|
||||
await expect(page.locator('textarea[name="signs"]')).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user