From a55884a71001b17cc9e77f25ced02379039be673 Mon Sep 17 00:00:00 2001 From: wangjian963 <15215920+aprilry@user.noreply.gitee.com> Date: Tue, 3 Feb 2026 15:15:55 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E6=8A=A4=E5=A4=9A=E4=B8=AA=E6=8C=82?= =?UTF-8?q?=E5=8F=B7=E7=B1=BB=E5=9E=8B=E7=9A=84=E5=8C=BB=E7=94=9F=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E8=83=BD=E6=A3=80=E7=B4=A2=E5=87=BA=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=8C=BB=E7=94=9F=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../charge/outpatientregistration/index.vue | 151 +++++++++++------- 1 file changed, 94 insertions(+), 57 deletions(-) diff --git a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue index 470da838..afa88e0e 100644 --- a/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue +++ b/openhis-ui-vue3/src/views/charge/outpatientregistration/index.vue @@ -281,7 +281,7 @@ @@ -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 是服务类型 - // 统一转换为字符串进行比较,避免类型不匹配问题 - 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 // 必须有出诊医生 - ); - }); + // 如果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; - // 提取所有匹配记录的出诊医生ID,并去重 - const practitionerIds = [...new Set(matchedHealthcares.map((h) => h.practitionerId).filter((id) => id != null))]; + const matchedHealthcares = healthcareList.value.filter((healthcare) => { + const healthcareOrgIdStr = healthcare.offeredOrgId != null ? String(healthcare.offeredOrgId) : null; + const healthcareTypeCode = healthcare.typeCode; + + return ( + healthcareOrgIdStr === orgIdStr && + healthcareTypeCode === selectedTypeCode + ); + }); + + 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;