fix(doctorstation): 解决参数验证和数据获取问题
- 在前端api.js中添加encounterId参数验证,避免无效参数导致的错误 - 在后端服务层添加参数检查,当encounterId为空时返回空数据而非报错 - 修改控制器参数注解,将required设置为false以允许空值传递 - 优化住院办理流程中的错误处理和参数验证 - 改进检验申请单获取时的数据验证和错误提示 - 更新maven编译器插件版本并添加必要的模块参数 - 统一错误处理机制,提供更友好的用户提示信息
This commit is contained in:
@@ -801,6 +801,16 @@ export function getTestResult(queryParams) {
|
||||
* 获取检验申请单列表
|
||||
*/
|
||||
export function getInspectionApplicationList(queryParams) {
|
||||
// 确保参数有效
|
||||
if (!queryParams || !queryParams.encounterId) {
|
||||
console.warn('获取检验申请单列表时缺少必要参数 encounterId');
|
||||
// 返回一个resolved的Promise,模拟空数据
|
||||
return Promise.resolve({
|
||||
code: 200,
|
||||
data: [],
|
||||
message: '参数不足,返回空数据'
|
||||
});
|
||||
}
|
||||
return request({
|
||||
url: '/reg-doctorstation/request-form/get-inspection',
|
||||
method: 'get',
|
||||
|
||||
@@ -244,21 +244,32 @@ const rules = reactive({
|
||||
function openDialog() {
|
||||
console.log('orgId==========>', props.patientInfo.orgId);
|
||||
getOrgList().then((res) => {
|
||||
// organization.value = res.data.records;
|
||||
organization.value = res.data.records[0].children.filter(
|
||||
(record) => record.typeEnum === 2 && record.classEnum === 2
|
||||
);
|
||||
// 确保数据结构正确
|
||||
if (res.data && res.data.records && res.data.records.length > 0) {
|
||||
// 获取第一层级的子节点,筛选出类型为科室(typeEnum===2)且类别为住院(classEnum===2)的组织
|
||||
const firstLevelChildren = res.data.records[0]?.children || [];
|
||||
organization.value = firstLevelChildren.filter(
|
||||
(record) => record.typeEnum === 2 && record.classEnum === 2
|
||||
);
|
||||
|
||||
// 如果当前患者所属科室在筛选结果中,则默认选中
|
||||
if (props.patientInfo.orgId) {
|
||||
submitForm.inHospitalOrgId =
|
||||
organization.value.find((item) => item.id === props.patientInfo.orgId)?.id || '';
|
||||
}
|
||||
} else {
|
||||
organization.value = [];
|
||||
}
|
||||
|
||||
console.log('organization==========>', organization.value);
|
||||
submitForm.inHospitalOrgId =
|
||||
organization.value.find((item) => item.id === props.patientInfo.orgId)?.id || '';
|
||||
});
|
||||
|
||||
// wardList().then((res) => {
|
||||
// wardListOptions.value = res.data;
|
||||
// });
|
||||
// 获取初始化数据
|
||||
getInit().then((response) => {
|
||||
console.log(response, 'response');
|
||||
priorityLevelOptionOptions.value = response.data.priorityLevelOptionOptions; // 优先级
|
||||
if (response.data && response.data.priorityLevelOptionOptions) {
|
||||
priorityLevelOptionOptions.value = response.data.priorityLevelOptionOptions; // 优先级
|
||||
}
|
||||
});
|
||||
console.log(props.patientInfo, 'patientInfo');
|
||||
getDiagnosisInfo(undefined);
|
||||
@@ -268,6 +279,7 @@ function openDialog() {
|
||||
diagnosisDefinitionId = props.mainDiagnosis.definitionId;
|
||||
diagnosisYbNo = props.mainDiagnosis.ybNo || '';
|
||||
submitForm.medTypeCode = props.mainDiagnosis.medTypeCode;
|
||||
submitForm.diagnosisDesc = props.mainDiagnosis.name || ''; // 设置诊断描述
|
||||
diagnosisDefinitionList.value = [props.mainDiagnosis];
|
||||
}
|
||||
}
|
||||
@@ -284,21 +296,53 @@ function handleDiagnosisChange(item) {
|
||||
}
|
||||
|
||||
function handleNodeClick(orgInfo) {
|
||||
wardList({ orgId: orgInfo.id }).then((res) => {
|
||||
wardListOptions.value = res.data;
|
||||
});
|
||||
// 确保传入正确的科室ID
|
||||
if (orgInfo && orgInfo.id) {
|
||||
wardList({ orgId: orgInfo.id }).then((res) => {
|
||||
if (res && res.data) {
|
||||
wardListOptions.value = res.data;
|
||||
// 清空之前选择的病区
|
||||
submitForm.wardLocationId = undefined;
|
||||
} else {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取病区列表失败:', error);
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
proxy.$modal.msgError('获取病区列表失败,请稍后重试');
|
||||
});
|
||||
} else {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function handleChange(value) {
|
||||
if (!value) {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
} else {
|
||||
// 当选择新科室时,清空病区选择
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
proxy.$refs['registerRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 验证必要字段
|
||||
if (!props.patientInfo.patientId) {
|
||||
proxy.$modal.msgError('患者信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.encounterId && !props.patientInfo.encounterId) {
|
||||
proxy.$modal.msgError('就诊信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
|
||||
let saveData = {
|
||||
...submitForm,
|
||||
diagnosisYbNo: diagnosisYbNo,
|
||||
@@ -307,7 +351,12 @@ function submit() {
|
||||
ambEncounterId: props.encounterId || props.patientInfo.encounterId,
|
||||
patientId: props.patientInfo.patientId,
|
||||
};
|
||||
|
||||
console.log('提交住院数据:', saveData);
|
||||
|
||||
// 显示加载状态
|
||||
const loading = proxy.$modal.loading('正在办理住院...');
|
||||
|
||||
handleHospitalization(saveData).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('办理成功');
|
||||
@@ -318,7 +367,18 @@ function submit() {
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('提交出错:', error);
|
||||
proxy.$modal.msgError('提交请求失败');
|
||||
let errorMsg = '提交请求失败';
|
||||
if (error.response) {
|
||||
errorMsg += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`;
|
||||
} else if (error.request) {
|
||||
errorMsg += ': 网络请求失败,请检查网络连接';
|
||||
} else {
|
||||
errorMsg += `: ${error.message}`;
|
||||
}
|
||||
proxy.$modal.msgError(errorMsg);
|
||||
}).finally(() => {
|
||||
// 关闭加载状态
|
||||
proxy.$modal.closeLoading();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -581,20 +581,35 @@ const getFilteredItems = (categoryKey) => {
|
||||
function initData() {
|
||||
console.log('检验组件初始化,patientInfo:', props.patientInfo)
|
||||
if (props.patientInfo) {
|
||||
queryParams.encounterId = props.patientInfo.encounterId
|
||||
// 确保 encounterId 存在且有效,优先使用 encounterId,其次尝试 id,最后尝试 patientId
|
||||
queryParams.encounterId = props.patientInfo.encounterId || props.patientInfo.id || props.patientInfo.patientId
|
||||
formData.patientName = props.patientInfo.patientName || ''
|
||||
formData.cardNo = props.patientInfo.cardNo || ''
|
||||
formData.departmentName = props.patientInfo.departmentName || ''
|
||||
formData.doctorName = props.patientInfo.doctorName || ''
|
||||
}
|
||||
// 只有在存在 encounterId 时才调用接口
|
||||
if (queryParams.encounterId) {
|
||||
|
||||
// 只有在存在有效的 encounterId 时才调用接口
|
||||
if (queryParams.encounterId && queryParams.encounterId !== 'undefined' && queryParams.encounterId !== 'null' && queryParams.encounterId !== '') {
|
||||
getInspectionList()
|
||||
} else {
|
||||
console.warn('缺少有效的就诊ID,无法获取检验申请单列表')
|
||||
inspectionList.value = []
|
||||
total.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
// 获取检验申请单列表
|
||||
function getInspectionList() {
|
||||
// 先检查是否有有效的encounterId
|
||||
if (!queryParams.encounterId || queryParams.encounterId === 'undefined' || queryParams.encounterId === 'null') {
|
||||
console.warn('缺少有效的就诊ID,无法获取检验申请单列表')
|
||||
inspectionList.value = []
|
||||
total.value = 0
|
||||
loading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
loading.value = true
|
||||
|
||||
// 调用真实的API,只传递 encounterId 参数
|
||||
@@ -605,13 +620,23 @@ function getInspectionList() {
|
||||
} else {
|
||||
inspectionList.value = []
|
||||
total.value = 0
|
||||
ElMessage.error('获取检验申请单列表失败')
|
||||
console.error('获取检验申请单列表失败:', res.message || res.msg)
|
||||
ElMessage.error(res.message || res.msg || '获取检验申请单列表失败')
|
||||
}
|
||||
}).catch((error) => {
|
||||
console.error('获取检验申请单列表异常:', error)
|
||||
inspectionList.value = []
|
||||
total.value = 0
|
||||
ElMessage.error('获取检验申请单列表异常')
|
||||
// 提供更友好的错误信息
|
||||
let errorMessage = '获取检验申请单列表异常'
|
||||
if (error.response) {
|
||||
errorMessage += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`
|
||||
} else if (error.request) {
|
||||
errorMessage += ': 网络请求失败,请检查网络连接'
|
||||
} else {
|
||||
errorMessage += `: ${error.message}`
|
||||
}
|
||||
ElMessage.error(errorMessage)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
|
||||
@@ -408,7 +408,10 @@ function handleClick(tab) {
|
||||
tcmRef.value.getDiagnosisInfo();
|
||||
break;
|
||||
case 'inspection':
|
||||
// 检验tab点击处理逻辑可以在这里添加
|
||||
// 确保检验组件获取最新的患者信息
|
||||
if (patientInfo.value && patientInfo.value.encounterId) {
|
||||
inspectionRef.value.getList();
|
||||
}
|
||||
break;
|
||||
case 'surgery':
|
||||
surgeryRef.value.getList();
|
||||
@@ -529,31 +532,74 @@ function openDrawer() {
|
||||
}
|
||||
// 判断是否已经入院登记
|
||||
const onHospitalization = async () => {
|
||||
const diagnosisRes = await getEncounterDiagnosis(patientInfo.value.encounterId);
|
||||
const hasDiagnosis = diagnosisRes.data?.length > 0;
|
||||
if (!hasDiagnosis) {
|
||||
// 检查是否有有效的就诊ID
|
||||
if (!patientInfo.value?.encounterId) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者暂无诊断信息,无法办理住院!',
|
||||
message: '患者就诊信息不完整,无法办理住院!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
const mainDiag = diagnosisRes.data.find((item) => item.maindiseFlag === 1);
|
||||
if (!mainDiag) {
|
||||
ElMessage({ type: 'error', message: '该患者暂无主诊断信息,无法办理住院!' });
|
||||
return;
|
||||
}
|
||||
mainDiagnosis.value = mainDiag;
|
||||
const res = await isHospitalization({
|
||||
encounterId: patientInfo.value.encounterId,
|
||||
});
|
||||
if (!res.data) {
|
||||
openDialog.value = true;
|
||||
} else {
|
||||
|
||||
try {
|
||||
const diagnosisRes = await getEncounterDiagnosis(patientInfo.value.encounterId);
|
||||
|
||||
// 检查API调用是否成功
|
||||
if (diagnosisRes.code !== 200) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: diagnosisRes.msg || '获取诊断信息失败,无法办理住院!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const hasDiagnosis = diagnosisRes.data?.length > 0;
|
||||
if (!hasDiagnosis) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者暂无诊断信息,无法办理住院!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const mainDiag = diagnosisRes.data.find((item) => item.maindiseFlag === 1);
|
||||
if (!mainDiag) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者暂无主诊断信息,无法办理住院!'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
mainDiagnosis.value = mainDiag;
|
||||
|
||||
const res = await isHospitalization({
|
||||
encounterId: patientInfo.value.encounterId,
|
||||
});
|
||||
|
||||
// 检查API调用是否成功
|
||||
if (res.code !== 200) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.msg || '检查住院状态失败!',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res.data) {
|
||||
openDialog.value = true;
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者,已办理入院,不允许重复办理',
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('办理住院检查过程中发生错误:', error);
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者,已办理入院,不允许重复办理',
|
||||
});
|
||||
message: '办理住院过程中发生错误,请稍后重试!',
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user