feat(patient): 实现门诊挂号页面跳转到患者档案页面的精确定位功能

- 在门诊挂号页面添加患者ID和姓名查询参数传递到患者档案页面
- 在患者档案页面实现路由参数接收和按数据库ID精确查询功能
- 新增searchType字段支持按姓名和病人ID两种查询方式
- 优化患者档案页面初始化逻辑,分离字典数据加载和列表查询
- 修改后端服务实现,对精确ID查询跳过医生患者过滤条件以确保跳转查询成功
This commit is contained in:
2026-01-09 16:15:36 +08:00
parent 840983ac94
commit d332650bfa
4 changed files with 149 additions and 41 deletions

View File

@@ -143,6 +143,11 @@ public class PatientInformationServiceImpl implements IPatientInformationService
CommonConstants.FieldName.BusNo, CommonConstants.FieldName.PyStr, CommonConstants.FieldName.WbStr)),
request);
// 检查是否是精确ID查询从门诊挂号页面跳转时使用
boolean hasExactIdQuery = (patientBaseInfoDto.getId() != null);
// 只有非精确ID查询时才添加医生患者过滤条件
if (!hasExactIdQuery) {
// 查询当前用户对应的医生信息
LambdaQueryWrapper<com.openhis.administration.domain.Practitioner> practitionerQuery = new LambdaQueryWrapper<>();
practitionerQuery.eq(com.openhis.administration.domain.Practitioner::getUserId, userId);
@@ -166,6 +171,7 @@ public class PatientInformationServiceImpl implements IPatientInformationService
}
}
// 如果不是医生,查询所有患者
}
IPage<PatientBaseInfoDto> patientInformationPage
= patientManageMapper.getPatientPage(new Page<>(pageNo, pageSize), queryWrapper);

View File

@@ -961,8 +961,21 @@ async function handleReadCard(value) {
/** 跳转到患者档案页面 */
function goToPatientRecord() {
// 如果已选择患者,则跳转到档案页面并定位到该患者
if (form.value.patientId) {
// 使用患者ID作为查询参数传递到档案页面
router.push({
path: '/patient/patientmgr',
query: {
patientId: form.value.patientId,
patientName: form.value.name
}
});
} else {
// 未选择患者时,直接跳转到档案页面
router.push('/patient/patientmgr');
}
}
/** 新增用户信息弹窗 */
function handleAddPatient() {

View File

@@ -118,9 +118,14 @@
<script setup name="patientManagement">
import pcas from 'china-division/dist/pcas-code.json';
import {nextTick, ref} from 'vue';
import {useRoute} from 'vue-router';
import {useRouter} from 'vue-router';
import {addPatient, listPatient, lists, updatePatient} from './component/api';
import PatientAddDialog from '@/views/charge/outpatientregistration/components/patientAddDialog';
const route = useRoute();
const router = useRouter();
const showSearch = ref(true);
const open = ref(false);
const title = ref('');
@@ -178,7 +183,9 @@ const data = reactive({
pageNo: 1,
pageSize: 10,
searchKey: undefined,
name: undefined
name: undefined,
patientId: undefined, // 新增: 专门用于数据库ID查询
searchType: 'name' // 新增: 查询类型, 'name'按姓名查询, 'patientId'按病人ID查询
},
rules: {
name: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
@@ -242,13 +249,25 @@ const findNodeByCode = (data, code) => {
return null;
};
/** 查询患者列表 */
/** 查询患者列表 - 基础查询方法,用于初始化等操作 */
function getList() {
// 执行查询
listPatient(queryParams.value).then((response) => {
patientList.value = response.data.records;
total.value = response.data.total;
console.log('patientList======>', JSON.stringify(patientList.value));
});
// 初始化字典数据(仅在第一次加载时执行)
if (!listsFlag.value) {
getInitDictData();
listsFlag.value = true;
}
}
/** 初始化字典数据 - 分离字典数据加载逻辑 */
const listsFlag = ref(false);
function getInitDictData() {
lists().then((response) => {
console.log(response);
occupationtypeList.value = response.data.occupationType;
@@ -262,6 +281,86 @@ function getList() {
});
}
/** 搜索按钮操作 - 支持按姓名和病人ID两种查询方式 */
function handleQuery() {
queryParams.value.pageNo = 1;
queryParams.value.createTimeSTime =
dateRange.value && dateRange.value.length == 2 ? dateRange.value[0] : '';
queryParams.value.createTimeETime =
dateRange.value && dateRange.value.length == 2 ? dateRange.value[1] : '';
// 根据查询类型设置查询参数
if (queryParams.value.searchType === 'patientId') {
// 按病人ID查询(数据库ID) - 直接传递ID参数
const queryParamsCopy = {
pageNo: queryParams.value.pageNo,
pageSize: queryParams.value.pageSize,
id: queryParams.value.patientId,
searchKey: undefined
};
console.log('按数据库ID查询参数:', queryParamsCopy);
// 执行查询
listPatient(queryParamsCopy).then((response) => {
patientList.value = response.data.records;
total.value = response.data.total;
console.log('查询结果:', response.data);
});
} else {
// 按姓名/拼音码/病人ID查询(兼容原有逻辑)
queryParams.value.id = undefined;
// 执行查询
listPatient(queryParams.value).then((response) => {
patientList.value = response.data.records;
total.value = response.data.total;
});
}
}
/** 重置按钮操作 */
function resetQuery() {
dateRange.value = [];
proxy.resetForm('queryRef');
queryParams.value.patientId = undefined;
queryParams.value.searchType = 'name';
queryParams.value.id = undefined;
queryParams.value.name = undefined;
handleQuery();
}
/** 从门诊挂号页面跳转时的精确查询 - 按数据库ID查询 */
function queryByPatientId(patientId) {
console.log('收到门诊挂号传递的patientId:', patientId);
// 直接构造查询参数,避免受到其他条件干扰
const exactQueryParams = {
pageNo: 1,
pageSize: 10,
id: patientId, // 直接使用ID字段进行精确查询
searchKey: undefined
};
console.log('精确查询参数:', exactQueryParams);
// 执行查询
listPatient(exactQueryParams).then((response) => {
patientList.value = response.data.records;
total.value = response.data.total;
console.log('按数据库ID查询结果:', JSON.stringify(patientList.value));
console.log('查询到的患者数量:', response.data.records.length);
// 如果查询成功,清空patientId以免影响后续查询
if (response.data.records && response.data.records.length > 0) {
console.log('查询成功,找到患者:', response.data.records[0].name);
} else {
console.warn('未找到匹配的患者,ID:', patientId);
}
}).catch(error => {
console.error('查询失败:', error);
});
}
/** 表单重置 */
function reset() {
form.value = {
@@ -305,23 +404,6 @@ function handlePatientAdded(patientData) {
// 患者添加成功后刷新列表
getList();
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNo = 1;
queryParams.value.createTimeSTime =
dateRange.value && dateRange.value.length == 2 ? dateRange.value[0] : '';
queryParams.value.createTimeETime =
dateRange.value && dateRange.value.length == 2 ? dateRange.value[1] : '';
// 执行查询
getList();
}
/** 重置按钮操作 */
function resetQuery() {
dateRange.value = [];
proxy.resetForm('queryRef');
handleQuery();
}
/** 新增按钮操作 */
function handleAdd() {
patientAddRef.value.show(); // 使用与门诊挂号一致的方式显示新增患者组件
@@ -640,7 +722,14 @@ function submitForm() {
}
onMounted(() => {
// 检查是否从门诊挂号页面跳转过来,并携带了patientId参数
if (route.query.patientId) {
// 使用精确查询方法按数据库ID查询
queryByPatientId(route.query.patientId);
} else {
// 正常加载患者列表
getList();
}
});
</script>