维护多个挂号类型的医生,只能检索出一个医生的问题。
This commit is contained in:
@@ -281,7 +281,7 @@
|
||||
<el-option
|
||||
v-for="doctor in doctorList"
|
||||
:key="doctor.id"
|
||||
:label="doctor.name"
|
||||
:label="getTypeCodeLabel(doctor)"
|
||||
:value="doctor.id"
|
||||
/>
|
||||
</el-select>
|
||||
@@ -1155,6 +1155,7 @@ function getHealthcare(data) {
|
||||
form.value.organizationId = data.organizationId;
|
||||
|
||||
getHealthcareMetadata(param).then((response) => {
|
||||
console.log('返回的结果,response.data:',response.data)
|
||||
// 对数据进行去重处理,name去重
|
||||
const uniqueRecords = removeDuplicateHealthcareItems(response.data.records);
|
||||
healthcareList.value = uniqueRecords;
|
||||
@@ -1170,19 +1171,39 @@ function getHealthcare(data) {
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据name对挂号类型数据进行去重 */
|
||||
/** 根据name和typeCode对挂号类型数据进行去重,同时保留所有相关医生信息 */
|
||||
function removeDuplicateHealthcareItems(records) {
|
||||
const seenNames = new Set();
|
||||
const uniqueRecords = [];
|
||||
// 创建一个Map,以name和typeCode的组合作为键
|
||||
const groupedRecords = new Map();
|
||||
|
||||
for (const item of records) {
|
||||
if (item.name && !seenNames.has(item.name)) {
|
||||
seenNames.add(item.name);
|
||||
uniqueRecords.push(item);
|
||||
const key = item.name && item.typeCode !== undefined ? `${item.name}_${item.typeCode}` : item.name;
|
||||
|
||||
if (groupedRecords.has(key)) {
|
||||
// 如果已存在相同的组合,将当前项的医生信息合并到现有项中
|
||||
const existingItem = groupedRecords.get(key);
|
||||
|
||||
// 确保relatedPractitioners数组存在
|
||||
if (!existingItem.relatedPractitioners) {
|
||||
existingItem.relatedPractitioners = [existingItem.practitionerId].filter(id => id);
|
||||
}
|
||||
|
||||
// 添加当前项的医生ID(如果存在且不重复)
|
||||
if (item.practitionerId && !existingItem.relatedPractitioners.includes(item.practitionerId)) {
|
||||
existingItem.relatedPractitioners.push(item.practitionerId);
|
||||
}
|
||||
} else {
|
||||
// 如果是新的组合,添加到Map中
|
||||
const newItem = { ...item };
|
||||
// 初始化相关医生数组
|
||||
newItem.relatedPractitioners = item.practitionerId ? [item.practitionerId] : [];
|
||||
groupedRecords.set(key, newItem);
|
||||
}
|
||||
}
|
||||
|
||||
return uniqueRecords;
|
||||
console.log('去重后的数组,groupedRecords:', groupedRecords.values())
|
||||
// 返回去重后的数组
|
||||
return Array.from(groupedRecords.values());
|
||||
}
|
||||
|
||||
/** 根据就诊科室和挂号类型过滤医生列表 */
|
||||
@@ -1214,66 +1235,82 @@ function filterDoctorsByHealthcare() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 从healthcareList中筛选出匹配科室和服务类型的记录
|
||||
// 注意:healthcare.offeredOrgId 是提供部门ID,需要与 form.value.orgId 匹配
|
||||
// selectedHealthcare.typeCode 是服务类型
|
||||
// 统一转换为字符串进行比较,避免类型不匹配问题
|
||||
// 如果selectedHealthcare有relatedPractitioners数组,直接使用
|
||||
let practitionerIds = [];
|
||||
if (selectedHealthcare.relatedPractitioners && selectedHealthcare.relatedPractitioners.length > 0) {
|
||||
// 使用合并后的医生ID列表
|
||||
practitionerIds = [...new Set(selectedHealthcare.relatedPractitioners.filter(id => id != null))];
|
||||
} else {
|
||||
// 否则,按原来的方式查找
|
||||
const orgIdStr = String(form.value.orgId);
|
||||
const selectedTypeCode = selectedHealthcare.typeCode; // 使用 typeCode(代码值),不是 typeCode_dictText(字典文本)
|
||||
const selectedTypeCode = selectedHealthcare.typeCode;
|
||||
|
||||
const matchedHealthcares = healthcareList.value.filter((healthcare) => {
|
||||
// 匹配科室(offeredOrgId)和服务类型(typeCode)
|
||||
// 统一转换为字符串进行比较
|
||||
const healthcareOrgIdStr = healthcare.offeredOrgId != null ? String(healthcare.offeredOrgId) : null;
|
||||
const healthcareTypeCode = healthcare.typeCode; // 使用 typeCode(代码值)
|
||||
const healthcareTypeCode = healthcare.typeCode;
|
||||
|
||||
return (
|
||||
healthcareOrgIdStr === orgIdStr &&
|
||||
healthcareTypeCode === selectedTypeCode &&
|
||||
healthcare.practitionerId != null // 必须有出诊医生
|
||||
healthcareTypeCode === selectedTypeCode
|
||||
);
|
||||
});
|
||||
|
||||
// 提取所有匹配记录的出诊医生ID,并去重
|
||||
const practitionerIds = [...new Set(matchedHealthcares.map((h) => h.practitionerId).filter((id) => id != null))];
|
||||
practitionerIds = [...new Set(matchedHealthcares.map((h) => h.practitionerId).filter((id) => id != null))];
|
||||
}
|
||||
|
||||
// 从所有医生列表中筛选出匹配的医生
|
||||
let filteredDoctors = [];
|
||||
if (practitionerIds.length > 0) {
|
||||
doctorList.value = allDoctorList.value.filter((doctor) => practitionerIds.includes(doctor.id));
|
||||
} else {
|
||||
// 如果没有匹配的医生,清空医生列表
|
||||
doctorList.value = [];
|
||||
filteredDoctors = allDoctorList.value.filter((doctor) => practitionerIds.includes(doctor.id));
|
||||
}
|
||||
|
||||
// 根据typeCode对医生进行分组并添加相关信息
|
||||
doctorList.value = groupDoctorsByTypeCode(filteredDoctors, []);
|
||||
|
||||
// 如果当前选中的医生不在过滤后的列表中,清空选择
|
||||
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,
|
||||
});
|
||||
// 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,
|
||||
// });
|
||||
}
|
||||
|
||||
/** 根据typeCode对医生列表进行分组,用于下拉框显示 */
|
||||
function groupDoctorsByTypeCode(doctors, healthcareListForTypeCode) {
|
||||
// 直接返回医生列表,因为我们已经在filterDoctorsByHealthcare中处理了医生的选择
|
||||
return doctors;
|
||||
}
|
||||
|
||||
/** 生成带有typeCode信息的医生标签 */
|
||||
function getTypeCodeLabel(doctor) {
|
||||
if (doctor.typeCodes && doctor.typeCodes.length > 0) {
|
||||
// 如果有typeCode信息,将它们显示在医生名字旁边
|
||||
return `${doctor.name} (${doctor.typeCodes.join(', ')})`;
|
||||
}
|
||||
return doctor.name; // 否则只显示医生名字
|
||||
}
|
||||
|
||||
/** 清空条件按钮操作 */
|
||||
@@ -1453,7 +1490,7 @@ function handleSearchPatient(value) {
|
||||
patientSearchKey.value = value;
|
||||
}
|
||||
|
||||
function handleReturn(row, type = '1') {
|
||||
function handleReturn(row, type = 1) {
|
||||
openRefundDialog.value = true;
|
||||
patientInfo.value.patientId = row.patientId;
|
||||
patientInfo.value.encounterId = row.encounterId;
|
||||
|
||||
Reference in New Issue
Block a user