diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java index 3676f387..2f159586 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inhospitalnursestation/appservice/impl/ATDManageAppServiceImpl.java @@ -14,10 +14,13 @@ import com.core.common.utils.SecurityUtils; import com.core.common.utils.StringUtils; import com.openhis.administration.domain.Encounter; import com.openhis.administration.domain.EncounterLocation; +import com.openhis.administration.domain.EncounterParticipant; +import com.openhis.administration.domain.Practitioner; import com.openhis.administration.service.IEncounterLocationService; import com.openhis.administration.service.IEncounterParticipantService; import com.openhis.administration.service.IEncounterService; import com.openhis.administration.service.ILocationService; +import com.openhis.administration.service.IPractitionerService; import com.openhis.common.constant.CommonConstants; import com.openhis.common.enums.*; import com.openhis.common.utils.EnumUtils; @@ -95,6 +98,9 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { @Resource private IServiceRequestService serviceRequestService; + @Resource + private IPractitionerService practitionerService; + /** * 入出转管理页面初始化 * @@ -215,24 +221,150 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { */ @Override public R getAdmissionPatientInfo(Long encounterId) { - // 查询住院患者详细信息 + log.info("========== 查询患者信息 - encounterId: {} ==========", encounterId); + Integer active = EncounterActivityStatus.ACTIVE.getValue(); + String primaryNurse = ParticipantType.PRIMARY_NURSE.getCode(); + String attendingDoctor = ParticipantType.ATTENDING_DOCTOR.getCode(); + String admittingDoctor = ParticipantType.ADMITTING_DOCTOR.getCode(); + String chiefDoctor = ParticipantType.CHIEF_DOCTOR.getCode(); + log.info("查询参数 - encounterId: {}, active: {} (type: {}), primaryNurse: {} (type: {}), attendingDoctor: {} (type: {}), admittingDoctor: {} (type: {}), chiefDoctor: {} (type: {})", + encounterId, active, active.getClass().getSimpleName(), + primaryNurse, primaryNurse.getClass().getSimpleName(), + attendingDoctor, attendingDoctor.getClass().getSimpleName(), + admittingDoctor, admittingDoctor.getClass().getSimpleName(), + chiefDoctor, chiefDoctor.getClass().getSimpleName()); + + // 先通过简单的 SQL 查询患者基本信息 AdmissionPatientInfoDto admissionPatientInfoDto - = atdManageAppMapper.selectAdmissionPatientInfo(encounterId, EncounterActivityStatus.ACTIVE.getValue(), + = atdManageAppMapper.selectAdmissionPatientInfo(encounterId, active, LocationForm.WARD.getValue(), LocationForm.HOUSE.getValue(), LocationForm.BED.getValue(), - ParticipantType.PRIMARY_NURSE.getCode(), ParticipantType.ATTENDING_DOCTOR.getCode(), - ParticipantType.ADMITTING_DOCTOR.getCode(), ParticipantType.CHIEF_DOCTOR.getCode()); - // 年龄 - if (admissionPatientInfoDto.getBirthDate() != null) { - admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate())); + primaryNurse, attendingDoctor, admittingDoctor, chiefDoctor); + + // 从 EncounterParticipant 表手动获取医生护士信息 + List participantList = encounterParticipantService.getEncounterParticipantList(encounterId); + log.info("从 EncounterParticipant 获取到 {} 条记录", participantList.size()); + + // 调试:打印所有 participant 的详细信息 + for (EncounterParticipant ep : participantList) { + log.info("调试 - typeCode: '{}', practitionerId: {}, statusEnum: {}, deleteFlag: '{}'", + ep.getTypeCode(), ep.getPractitionerId(), ep.getStatusEnum(), ep.getDeleteFlag()); } - // 性别 - admissionPatientInfoDto.setGenderEnum_enumText( - EnumUtils.getInfoByValue(AdministrativeGender.class, admissionPatientInfoDto.getGenderEnum())); - // 病情 - admissionPatientInfoDto.setPriorityEnum_enumText( - EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum())); - // 获取入院体征 - getAdmissionSigns(encounterId, admissionPatientInfoDto); + + // 查找各个角色 - 使用 Integer 类型进行比较 + Integer primaryNurseValue = ParticipantType.PRIMARY_NURSE.getValue(); + Integer attendingDoctorValue = ParticipantType.ATTENDING_DOCTOR.getValue(); + Integer admittingDoctorValue = ParticipantType.ADMITTING_DOCTOR.getValue(); + Integer chiefDoctorValue = ParticipantType.CHIEF_DOCTOR.getValue(); + + log.info("枚举值 - primaryNurse: {} ({})", primaryNurseValue, primaryNurse); + log.info("枚举值 - attendingDoctor: {} ({})", attendingDoctorValue, attendingDoctor); + log.info("枚举值 - admittingDoctor: {} ({})", admittingDoctorValue, admittingDoctor); + log.info("枚举值 - chiefDoctor: {} ({})", chiefDoctorValue, chiefDoctor); + + // 查找各个角色 + Long primaryNurseId = null; + String primaryNurseName = null; + Long attendingDoctorId = null; + String attendingDoctorName = null; + Long admittingDoctorId = null; + String admittingDoctorName = null; + Long chiefDoctorId = null; + String chiefDoctorName = null; + + for (EncounterParticipant ep : participantList) { + if (ep.getStatusEnum() == null || !ep.getStatusEnum().equals(active)) { + log.info("跳过 - statusEnum: {} vs active: {}", ep.getStatusEnum(), active); + continue; + } + if (ep.getTypeCode() == null) { + log.info("跳过 - typeCode 为空"); + continue; + } + + // 尝试将 typeCode 转换为 Integer 进行比较 + Integer typeCodeValue = null; + try { + typeCodeValue = Integer.parseInt(ep.getTypeCode().trim()); + } catch (NumberFormatException e) { + log.warn("typeCode 无法转换为 Integer: {}", ep.getTypeCode()); + } + + log.info("检查 typeCode: {} (Integer: {}) vs primaryNurseValue: {}, attendingDoctorValue: {}, admittingDoctorValue: {}, chiefDoctorValue: {}", + ep.getTypeCode(), typeCodeValue, primaryNurseValue, attendingDoctorValue, admittingDoctorValue, chiefDoctorValue); + + // 根据 typeCode 的 Integer 值匹配并获取 practitioner 名称 + if (typeCodeValue != null && typeCodeValue.equals(primaryNurseValue)) { + primaryNurseId = ep.getPractitionerId(); + // 查询 practitioner 名称 + if (primaryNurseId != null) { + Practitioner practitioner = practitionerService.getById(primaryNurseId); + if (practitioner != null) { + primaryNurseName = practitioner.getName(); + } + } + log.info("找到责任护士 - id: {}, name: {}", primaryNurseId, primaryNurseName); + } else if (typeCodeValue != null && typeCodeValue.equals(attendingDoctorValue)) { + attendingDoctorId = ep.getPractitionerId(); + if (attendingDoctorId != null) { + Practitioner practitioner = practitionerService.getById(attendingDoctorId); + if (practitioner != null) { + attendingDoctorName = practitioner.getName(); + } + } + log.info("找到主治医生 - id: {}, name: {}", attendingDoctorId, attendingDoctorName); + } else if (typeCodeValue != null && typeCodeValue.equals(admittingDoctorValue)) { + admittingDoctorId = ep.getPractitionerId(); + if (admittingDoctorId != null) { + Practitioner practitioner = practitionerService.getById(admittingDoctorId); + if (practitioner != null) { + admittingDoctorName = practitioner.getName(); + } + } + log.info("找到入院医生 - id: {}, name: {}", admittingDoctorId, admittingDoctorName); + } else if (typeCodeValue != null && typeCodeValue.equals(chiefDoctorValue)) { + chiefDoctorId = ep.getPractitionerId(); + if (chiefDoctorId != null) { + Practitioner practitioner = practitionerService.getById(chiefDoctorId); + if (practitioner != null) { + chiefDoctorName = practitioner.getName(); + } + } + log.info("找到主任医生 - id: {}, name: {}", chiefDoctorId, chiefDoctorName); + } else { + log.info("未匹配到任何角色 typeCode: {} (value: {})", ep.getTypeCode(), typeCodeValue); + } + } + + // 手动设置医生护士信息到 DTO + if (admissionPatientInfoDto != null) { + admissionPatientInfoDto.setPrimaryNurseId(primaryNurseId); + admissionPatientInfoDto.setPrimaryNurseName(primaryNurseName); + admissionPatientInfoDto.setAttendingDoctorId(attendingDoctorId); + admissionPatientInfoDto.setAttendingDoctorName(attendingDoctorName); + admissionPatientInfoDto.setAdmittingDoctorId(admittingDoctorId); + admissionPatientInfoDto.setAdmittingDoctorName(admittingDoctorName); + admissionPatientInfoDto.setChiefDoctorId(chiefDoctorId); + admissionPatientInfoDto.setChiefDoctorName(chiefDoctorName); + + // 年龄 + if (admissionPatientInfoDto.getBirthDate() != null) { + admissionPatientInfoDto.setAge(AgeCalculatorUtil.getAge(admissionPatientInfoDto.getBirthDate())); + } + // 性别 + admissionPatientInfoDto.setGenderEnum_enumText( + EnumUtils.getInfoByValue(AdministrativeGender.class, admissionPatientInfoDto.getGenderEnum())); + // 病情 + admissionPatientInfoDto.setPriorityEnum_enumText( + EnumUtils.getInfoByValue(PriorityLevel.class, admissionPatientInfoDto.getPriorityEnum())); + // 获取入院体征 + getAdmissionSigns(encounterId, admissionPatientInfoDto); + } + + log.info("查询结果 - admittingDoctorId: {}, attendingDoctorId: {}, chiefDoctorId: {}, primaryNurseId: {}", + admissionPatientInfoDto != null ? admissionPatientInfoDto.getAdmittingDoctorId() : "null", + admissionPatientInfoDto != null ? admissionPatientInfoDto.getAttendingDoctorId() : "null", + admissionPatientInfoDto != null ? admissionPatientInfoDto.getChiefDoctorId() : "null", + admissionPatientInfoDto != null ? admissionPatientInfoDto.getPrimaryNurseId() : "null"); return R.ok(admissionPatientInfoDto); } @@ -288,6 +420,7 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { @Override @Transactional(rollbackFor = Exception.class) public R admissionBedAssignment(AdmissionPatientInfoDto admissionPatientInfoDto) { + log.info("===== admissionBedAssignment 开始 ====="); // 住院id Long encounterId = admissionPatientInfoDto.getEncounterId(); @@ -301,7 +434,10 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { Long targetBedId = admissionPatientInfoDto.getTargetBedId(); // 进入编辑患者信息,不更换床位 - if (Whether.YES.getCode().equals(admissionPatientInfoDto.getEditFlag())) { + if ("1".equals(admissionPatientInfoDto.getEditFlag())) { + log.info("编辑模式 - encounterId: {}, admittingDoctorId: {}, attendingDoctorId: {}, chiefDoctorId: {}, primaryNurseId: {}", + encounterId, admissionPatientInfoDto.getAdmittingDoctorId(), admissionPatientInfoDto.getAttendingDoctorId(), + admissionPatientInfoDto.getChiefDoctorId(), admissionPatientInfoDto.getPrimaryNurseId()); // 更新患者病情(如果提供了) if (admissionPatientInfoDto.getPriorityEnum() != null) { encounterService.updatePriorityEnumById(encounterId, admissionPatientInfoDto.getPriorityEnum()); @@ -329,6 +465,13 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { encounterParticipantService.creatEncounterParticipants(encounterId, startTime, admissionPatientInfoDto.getChiefDoctorId(), ParticipantType.CHIEF_DOCTOR.getCode()); } + // 保存后立即查询确认数据 + List savedParticipants = encounterParticipantService.getEncounterParticipantList(encounterId); + log.info("保存后查询参与者 - encounterId: {}, 数量: {}", encounterId, savedParticipants.size()); + for (EncounterParticipant ep : savedParticipants) { + log.info("参与者详情 - typeCode: {}, practitionerId: {}, statusEnum: {}", + ep.getTypeCode(), ep.getPractitionerId(), ep.getStatusEnum()); + } // 更新入院体征(在事务外执行,避免影响参与者数据保存) try { saveOrUpdateAdmissionSigns(encounterId, admissionPatientInfoDto, startTime); @@ -338,6 +481,11 @@ public class ATDManageAppServiceImpl implements IATDManageAppService { return R.ok("患者信息更新成功"); } + // 新分配床位时,校验床位信息 + if (targetBedId == null || admissionPatientInfoDto.getTargetHouseId() == null) { + return R.fail("床位分配失败,请选择有效的床位"); + } + // 判断患者是否已经在床 if (oldBedId != null) { // 判断目标床位是否已经被占用 diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/inhospitalnursestation/ATDManageAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/inhospitalnursestation/ATDManageAppMapper.xml index ab7deb1c..63fb2c0c 100644 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/inhospitalnursestation/ATDManageAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/inhospitalnursestation/ATDManageAppMapper.xml @@ -289,49 +289,49 @@ LIMIT 1 ) AS ward ON ward.encounter_id = ae.id LEFT JOIN ( - SELECT aep.encounter_id, - pra.id AS practitioner_id, - pra."name" AS practitioner_name - FROM adm_encounter_participant aep - LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' - WHERE aep.status_enum = #{active} - AND aep.delete_flag = '0' - AND aep.type_code = #{primaryNurse} - LIMIT 1 - ) AS primaryNurse ON primaryNurse.encounter_id = ae.id + SELECT aep.encounter_id, + aep.practitioner_id AS practitioner_id, + pra."name" AS practitioner_name + FROM adm_encounter_participant aep + LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' + WHERE aep.status_enum = #{active} + AND aep.delete_flag = '0' + AND aep.type_code::text = CAST(#{primaryNurse} AS TEXT) + LIMIT 1 + ) AS primaryNurse ON primaryNurse.encounter_id = ae.id LEFT JOIN ( - SELECT aep.encounter_id, - pra.id AS practitioner_id, - pra."name" AS practitioner_name - FROM adm_encounter_participant aep - LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' - WHERE aep.status_enum = #{active} - AND aep.delete_flag = '0' - AND aep.type_code = #{attendingDoctor} - LIMIT 1 - ) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id + SELECT aep.encounter_id, + aep.practitioner_id AS practitioner_id, + pra."name" AS practitioner_name + FROM adm_encounter_participant aep + LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' + WHERE aep.status_enum = #{active} + AND aep.delete_flag = '0' + AND aep.type_code::text = CAST(#{attendingDoctor} AS TEXT) + LIMIT 1 + ) AS attendingDoctor ON attendingDoctor.encounter_id = ae.id LEFT JOIN ( - SELECT aep.encounter_id, - pra.id AS practitioner_id, - pra."name" AS practitioner_name - FROM adm_encounter_participant aep - LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' - WHERE aep.status_enum = #{active} - AND aep.delete_flag = '0' - AND aep.type_code = #{admittingDoctor} - LIMIT 1 - ) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id + SELECT aep.encounter_id, + aep.practitioner_id AS practitioner_id, + pra."name" AS practitioner_name + FROM adm_encounter_participant aep + LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' + WHERE aep.status_enum = #{active} + AND aep.delete_flag = '0' + AND aep.type_code::text = CAST(#{admittingDoctor} AS TEXT) + LIMIT 1 + ) AS admittingDoctor ON admittingDoctor.encounter_id = ae.id LEFT JOIN ( - SELECT aep.encounter_id, - pra.id AS practitioner_id, - pra."name" AS practitioner_name - FROM adm_encounter_participant aep - LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' - WHERE aep.status_enum = #{active} - AND aep.delete_flag = '0' - AND aep.type_code = #{chiefDoctor} - LIMIT 1 - ) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id + SELECT aep.encounter_id, + aep.practitioner_id AS practitioner_id, + pra."name" AS practitioner_name + FROM adm_encounter_participant aep + LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' + WHERE aep.status_enum = #{active} + AND aep.delete_flag = '0' + AND aep.type_code::text = CAST(#{chiefDoctor} AS TEXT) + LIMIT 1 + ) AS chiefDoctor ON chiefDoctor.encounter_id = ae.id LEFT JOIN adm_organization ao ON ao.id = ae.organization_id AND ao.delete_flag = '0' @@ -575,7 +575,7 @@ ON ae.id = aep.encounter_id AND aep.delete_flag = '0' AND aep.status_enum = #{active} - AND aep.type_code = #{admittingDoctor} + AND aep.type_code::text = #{admittingDoctor}::text LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' @@ -709,7 +709,7 @@ ON ae.id = aep.encounter_id AND aep.delete_flag = '0' AND aep.status_enum = #{active} - AND aep.type_code = #{admittingDoctor} + AND aep.type_code::text = #{admittingDoctor}::text LEFT JOIN adm_practitioner pra ON aep.practitioner_id = pra.id AND pra.delete_flag = '0' diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/EncounterParticipantServiceImpl.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/EncounterParticipantServiceImpl.java index deb233a6..c510b476 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/EncounterParticipantServiceImpl.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/administration/service/impl/EncounterParticipantServiceImpl.java @@ -59,6 +59,8 @@ public class EncounterParticipantServiceImpl extends ServiceImpl { if (!props.pendingInfo?.encounterId) { return; } + console.log('查询患者信息的 encounterId:', props.pendingInfo.encounterId); getPatientInfo({ encounterId: props.pendingInfo.encounterId }).then((res) => { + console.log('后端返回的患者信息:', res.data); pendingInfo.value = res.data; // 从后端获取数据后设置医生和护士 ID + // 医生使用 ToStringSerializer,返回字符串;护士直接返回数字 + console.log('admittingDoctorId:', res.data.admittingDoctorId); + console.log('attendingDoctorId:', res.data.attendingDoctorId); + console.log('chiefDoctorId:', res.data.chiefDoctorId); + console.log('primaryNurseId:', res.data.primaryNurseId); if (res.data.admittingDoctorId) { - interventionForm.value.admittingDoctorId = res.data.admittingDoctorId; + interventionForm.value.admittingDoctorId = String(res.data.admittingDoctorId); } if (res.data.attendingDoctorId) { - interventionForm.value.attendingDoctorId = res.data.attendingDoctorId; + interventionForm.value.attendingDoctorId = String(res.data.attendingDoctorId); } if (res.data.chiefDoctorId) { - interventionForm.value.chiefDoctorId = res.data.chiefDoctorId; + interventionForm.value.chiefDoctorId = String(res.data.chiefDoctorId); } if (res.data.primaryNurseId) { - interventionForm.value.primaryNurseId = res.data.primaryNurseId; + // 护士ID也转换为字符串以匹配护士选项 + interventionForm.value.primaryNurseId = String(res.data.primaryNurseId); } if (res.data.startTime) { interventionForm.value.startTime = dayjs(res.data.startTime).format( @@ -435,21 +443,23 @@ const loadPatientInfo = () => { watch( () => props.pendingInfo?.encounterId, (newVal, oldVal) => { - // 只在 encounterId 存在且发生变化时才获取数据 - if (newVal && newVal !== oldVal) { + // encounterId 存在时就获取数据 + if (newVal) { + console.log('watch 触发, newVal:', newVal, 'oldVal:', oldVal); loadPatientInfo(); } - }, - { immediate: true } + } ); /* 初始化数据 */ const init = () => { initCurrentInPatient(); - getInit() + + const promises = []; + + const initPromise = getInit() .then((res) => { InitInfoOptions.value = res.data; - // 安全地设置priorityListOptions if (res.data && res.data.priorityListOptions) { priorityListOptions.value = res.data.priorityListOptions; } @@ -457,9 +467,10 @@ const init = () => { .catch((error) => { console.error('获取初始化数据失败:', error); }); + promises.push(initPromise); if (props.pendingInfo.wardLocationId) { - getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId }) + const bedPromise = getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId }) .then((res) => { bedInfoOptions.value = res.data || []; }) @@ -467,44 +478,55 @@ const init = () => { console.error('获取床位信息失败:', error); bedInfoOptions.value = []; }); + promises.push(bedPromise); } if (props.pendingInfo.organizationId) { - // 主任医生 - getDoctorInfo({ organizationId: props.pendingInfo.organizationId }) + const doctorPromise = getDoctorInfo({ organizationId: props.pendingInfo.organizationId }) .then((res) => { doctorInfoOptions.value = res.data.records || []; - nextTick(() => { - // 如果存在主任医师显示主任,如果没有选择第一个展示 - if (doctorInfoOptions.value.length > 0) { - let selectId = ''; - doctorInfoOptions.value.forEach((item: any) => { - if (item.drProfttlCode == '231') { - selectId = item.id; + // 只有在新分配床位模式(entranceType != 1)时才设置默认主任医生 + // 并且只在当前没有选择主任医生时才设置默认值(避免覆盖已从后端获取的数据) + if (props.pendingInfo.entranceType != 1) { + nextTick(() => { + if (doctorInfoOptions.value.length > 0 && !interventionForm.value.chiefDoctorId) { + let selectId = ''; + doctorInfoOptions.value.forEach((item: any) => { + if (item.drProfttlCode == '231') { + selectId = item.id; + } + }); + if (selectId.length > 0) { + interventionForm.value.chiefDoctorId = selectId; + } else { + interventionForm.value.chiefDoctorId = doctorInfoOptions.value[0].id; } - }); - if (selectId.length > 0) { - interventionForm.value.chiefDoctorId = selectId; - } else { - interventionForm.value.chiefDoctorId = doctorInfoOptions.value[0].id; } - } - }); + }); + } }) .catch((error) => { console.error('获取医生信息失败:', error); doctorInfoOptions.value = []; }); + promises.push(doctorPromise); - getNurseInfo({ organizationId: props.pendingInfo.organizationId }) + const nursePromise = getNurseInfo({ organizationId: props.pendingInfo.organizationId }) .then((res) => { - nurseInfoOptions.value = res.data || []; + // 将护士ID转换为字符串以匹配医生选项的数据类型 + nurseInfoOptions.value = (res.data || []).map((item: any) => ({ + ...item, + practitionerId: String(item.practitionerId), + })); }) .catch((error) => { console.error('获取护士信息失败:', error); nurseInfoOptions.value = []; }); + promises.push(nursePromise); } + + return Promise.all(promises); }; const rules = reactive({ @@ -544,16 +566,27 @@ const handleSubmit = async () => { try { const valid = await interventionFormRef.value.validate(); if (valid) { + // 过滤掉空字符串的字段,只保留用户实际选择的值 + const formData = {}; + Object.keys(interventionForm.value).forEach(key => { + const value = interventionForm.value[key]; + // 保留非空的值(0、false等有效值也需要保留) + if (value !== '' && value !== null && value !== undefined) { + formData[key] = value; + } + }); const params = { ...pendingInfo.value, - ...interventionForm.value, + ...formData, targetBedId: props.pendingInfo.bedId, busNo: props.pendingInfo.busNo, inHosTime: props.pendingInfo.inHosTime, targetHouseId: props.pendingInfo.targetHouseId, targetEncounterId: props.pendingInfo.targetEncounterId, - editFlag: props.pendingInfo.entranceType == 1 ? 1 : 0, + editFlag: props.pendingInfo.entranceType == 1 ? '1' : '0', }; + console.log('提交参数:', params); + console.log('startTime:', interventionForm.value.startTime); bedAssignment(params) .then((res: any) => { @@ -583,9 +616,10 @@ const handleSubmit = async () => { }; const openAct = () => { - init(); - // 重新加载患者详细信息(包括医生、护士等) - loadPatientInfo(); + // 先初始化数据(包括医生护士列表),等待完成后再加载患者信息 + init().then(() => { + loadPatientInfo(); + }); }; const closedAct = () => {