门诊挂号-》医生字段,对字段医生进行过滤,让医生和、就诊科室、挂号类型形成对照。
This commit is contained in:
@@ -239,6 +239,7 @@
|
|||||||
highlight-current
|
highlight-current
|
||||||
default-expand-all
|
default-expand-all
|
||||||
@node-click="handleNodeClick"
|
@node-click="handleNodeClick"
|
||||||
|
@clear="handleOrgClear"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -250,7 +251,7 @@
|
|||||||
placeholder="挂号类型"
|
placeholder="挂号类型"
|
||||||
clearable
|
clearable
|
||||||
style="width: 240px"
|
style="width: 240px"
|
||||||
@change="setchargeItem"
|
@change="handleServiceTypeChange"
|
||||||
ref="serviceTypeRef"
|
ref="serviceTypeRef"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@@ -754,7 +755,8 @@ const patientInfoList = ref(undefined);
|
|||||||
// 费用性质
|
// 费用性质
|
||||||
const contractList = ref(undefined);
|
const contractList = ref(undefined);
|
||||||
// const locationOptions = ref(undefined); // 地点树选项
|
// const locationOptions = ref(undefined); // 地点树选项
|
||||||
const doctorList = ref(undefined); // 医生选项
|
const doctorList = ref(undefined); // 医生选项(过滤后的)
|
||||||
|
const allDoctorList = ref(undefined); // 所有医生选项(用于过滤)
|
||||||
const healthcareList = ref(undefined); // 挂号项目选项
|
const healthcareList = ref(undefined); // 挂号项目选项
|
||||||
const orgOptions = ref(undefined); // 科室选项
|
const orgOptions = ref(undefined); // 科室选项
|
||||||
const readCardLoading = ref(false);
|
const readCardLoading = ref(false);
|
||||||
@@ -1073,6 +1075,29 @@ function setchargeItem() {
|
|||||||
healthcareData.length > 0 ? healthcareData[0].price + healthcareData[0].activityPrice : '';
|
healthcareData.length > 0 ? healthcareData[0].price + healthcareData[0].activityPrice : '';
|
||||||
form.value.definitionId = healthcareData.length > 0 ? healthcareData[0].definitionId : '';
|
form.value.definitionId = healthcareData.length > 0 ? healthcareData[0].definitionId : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 处理挂号类型变化 */
|
||||||
|
function handleServiceTypeChange() {
|
||||||
|
// 先设置费用项信息
|
||||||
|
setchargeItem();
|
||||||
|
// 然后根据就诊科室和挂号类型过滤医生
|
||||||
|
filterDoctorsByHealthcare();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 处理科室清空 */
|
||||||
|
function handleOrgClear() {
|
||||||
|
// 清空科室时,清空相关数据
|
||||||
|
form.value.orgId = undefined;
|
||||||
|
form.value.organizationId = undefined;
|
||||||
|
healthcareList.value = [];
|
||||||
|
form.value.serviceTypeId = undefined;
|
||||||
|
form.value.practitionerId = undefined;
|
||||||
|
form.value.doctorName = '';
|
||||||
|
// 如果有医生列表,显示所有医生
|
||||||
|
if (allDoctorList.value) {
|
||||||
|
doctorList.value = allDoctorList.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
/** 查询患者信息 */
|
/** 查询患者信息 */
|
||||||
function getList() {
|
function getList() {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
@@ -1132,6 +1157,7 @@ function handleNodeClick(data) {
|
|||||||
// handleQuery();
|
// handleQuery();
|
||||||
console.log('handleNodeClick', 'data', data);
|
console.log('handleNodeClick', 'data', data);
|
||||||
form.value.organ = data.id;
|
form.value.organ = data.id;
|
||||||
|
// 先获取医生和服务项目,然后在回调中过滤
|
||||||
getPractitioner(data);
|
getPractitioner(data);
|
||||||
getHealthcare(data);
|
getHealthcare(data);
|
||||||
}
|
}
|
||||||
@@ -1144,7 +1170,15 @@ function getPractitioner(data) {
|
|||||||
console.log('getPractitioner', 'param', param);
|
console.log('getPractitioner', 'param', param);
|
||||||
getPractitionerMetadata(param).then((response) => {
|
getPractitionerMetadata(param).then((response) => {
|
||||||
console.log('getPractitioner', 'response', response.data);
|
console.log('getPractitioner', 'response', response.data);
|
||||||
doctorList.value = response.data.records;
|
// 保存所有医生列表用于后续过滤
|
||||||
|
allDoctorList.value = response.data.records;
|
||||||
|
// 如果已选择挂号类型,则根据科室和挂号类型过滤医生
|
||||||
|
if (form.value.serviceTypeId) {
|
||||||
|
filterDoctorsByHealthcare();
|
||||||
|
} else {
|
||||||
|
// 如果未选择挂号类型,显示所有医生
|
||||||
|
doctorList.value = allDoctorList.value;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,6 +1193,104 @@ function getHealthcare(data) {
|
|||||||
getHealthcareMetadata(param).then((response) => {
|
getHealthcareMetadata(param).then((response) => {
|
||||||
healthcareList.value = response.data.records;
|
healthcareList.value = response.data.records;
|
||||||
console.log('getHealthcareMetadata', 'response', response.data);
|
console.log('getHealthcareMetadata', 'response', response.data);
|
||||||
|
// 使用 nextTick 确保数据更新后再过滤
|
||||||
|
nextTick(() => {
|
||||||
|
// 如果已选择挂号类型,则根据科室和挂号类型过滤医生
|
||||||
|
if (form.value.serviceTypeId && allDoctorList.value) {
|
||||||
|
filterDoctorsByHealthcare();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 根据就诊科室和挂号类型过滤医生列表 */
|
||||||
|
function filterDoctorsByHealthcare() {
|
||||||
|
// 如果没有医生列表,直接返回
|
||||||
|
if (!allDoctorList.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果未选择科室或挂号类型,显示所有医生
|
||||||
|
if (!form.value.orgId || !form.value.serviceTypeId || !healthcareList.value) {
|
||||||
|
doctorList.value = allDoctorList.value;
|
||||||
|
// 如果当前选中的医生不在列表中,清空选择
|
||||||
|
if (form.value.practitionerId && !doctorList.value.some((d) => d.id === form.value.practitionerId)) {
|
||||||
|
form.value.practitionerId = undefined;
|
||||||
|
form.value.doctorName = '';
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取选中的挂号类型信息
|
||||||
|
const selectedHealthcare = healthcareList.value.find(
|
||||||
|
(healthcare) => healthcare.id === form.value.serviceTypeId
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!selectedHealthcare) {
|
||||||
|
// 如果找不到选中的挂号类型,显示所有医生
|
||||||
|
doctorList.value = allDoctorList.value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从healthcareList中筛选出匹配科室和服务类型的记录
|
||||||
|
// 注意:healthcare.offeredOrgId 是提供部门ID,需要与 form.value.orgId 匹配
|
||||||
|
// selectedHealthcare.typeCode 是服务类型
|
||||||
|
// 统一转换为字符串进行比较,避免类型不匹配问题
|
||||||
|
const orgIdStr = String(form.value.orgId);
|
||||||
|
const selectedTypeCode = selectedHealthcare.typeCode; // 使用 typeCode(代码值),不是 typeCode_dictText(字典文本)
|
||||||
|
|
||||||
|
const matchedHealthcares = healthcareList.value.filter((healthcare) => {
|
||||||
|
// 匹配科室(offeredOrgId)和服务类型(typeCode)
|
||||||
|
// 统一转换为字符串进行比较
|
||||||
|
const healthcareOrgIdStr = healthcare.offeredOrgId != null ? String(healthcare.offeredOrgId) : null;
|
||||||
|
const healthcareTypeCode = healthcare.typeCode; // 使用 typeCode(代码值)
|
||||||
|
|
||||||
|
return (
|
||||||
|
healthcareOrgIdStr === orgIdStr &&
|
||||||
|
healthcareTypeCode === selectedTypeCode &&
|
||||||
|
healthcare.practitionerId != null // 必须有出诊医生
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 提取所有匹配记录的出诊医生ID,并去重
|
||||||
|
const practitionerIds = [...new Set(matchedHealthcares.map((h) => h.practitionerId).filter((id) => id != null))];
|
||||||
|
|
||||||
|
// 从所有医生列表中筛选出匹配的医生
|
||||||
|
if (practitionerIds.length > 0) {
|
||||||
|
doctorList.value = allDoctorList.value.filter((doctor) => practitionerIds.includes(doctor.id));
|
||||||
|
} else {
|
||||||
|
// 如果没有匹配的医生,清空医生列表
|
||||||
|
doctorList.value = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果当前选中的医生不在过滤后的列表中,清空选择
|
||||||
|
if (form.value.practitionerId && !doctorList.value.some((d) => d.id === form.value.practitionerId)) {
|
||||||
|
form.value.practitionerId = undefined;
|
||||||
|
form.value.doctorName = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('filterDoctorsByHealthcare', {
|
||||||
|
orgId: form.value.orgId,
|
||||||
|
orgIdStr: orgIdStr,
|
||||||
|
serviceTypeId: form.value.serviceTypeId,
|
||||||
|
selectedTypeCode: selectedTypeCode,
|
||||||
|
selectedHealthcare: selectedHealthcare,
|
||||||
|
healthcareListSample: healthcareList.value.slice(0, 3).map(h => ({
|
||||||
|
id: h.id,
|
||||||
|
offeredOrgId: h.offeredOrgId,
|
||||||
|
typeCode: h.typeCode,
|
||||||
|
typeCode_dictText: h.typeCode_dictText,
|
||||||
|
practitionerId: h.practitionerId
|
||||||
|
})),
|
||||||
|
matchedHealthcares: matchedHealthcares.length,
|
||||||
|
matchedHealthcaresDetail: matchedHealthcares.map(h => ({
|
||||||
|
id: h.id,
|
||||||
|
offeredOrgId: h.offeredOrgId,
|
||||||
|
typeCode: h.typeCode,
|
||||||
|
practitionerId: h.practitionerId
|
||||||
|
})),
|
||||||
|
practitionerIds: practitionerIds,
|
||||||
|
filteredDoctors: doctorList.value.length,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user