diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java index 5c9ab5d49..f50c30307 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/doctorstation/appservice/impl/DoctorStationAdviceAppServiceImpl.java @@ -1539,11 +1539,22 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp deviceRequest.setRequesterId(adviceSaveDto.getPractitionerId()); // 开方医生 deviceRequest.setOrgId(adviceSaveDto.getFounderOrgId());// 开方人科室 deviceRequest.setReqAuthoredTime(curDate); // 请求开始时间 - // 发放耗材房(若前端未传locationId,使用登录用户的科室作为默认值) + // 发放耗材房(若前端未传locationId,优先沿用已有DeviceRequest的performLocation,否则使用登录用户科室) Long locId = adviceSaveDto.getLocationId(); if (locId == null) { - locId = SecurityUtils.getLoginUser().getOrgId(); - log.info("耗材locationId为空,使用登录用户科室作为默认值: locationId={}", locId); + // 尝试从已有DeviceRequest获取原始的performLocation + if (adviceSaveDto.getRequestId() != null) { + DeviceRequest existingDevice = iDeviceRequestService.getById(adviceSaveDto.getRequestId()); + if (existingDevice != null && existingDevice.getPerformLocation() != null) { + locId = existingDevice.getPerformLocation(); + log.info("耗材locationId为空,使用已有DeviceRequest的performLocation: locationId={}", locId); + } + } + // 如果已有记录也没有performLocation,则使用登录用户科室作为兜底 + if (locId == null) { + locId = SecurityUtils.getLoginUser().getOrgId(); + log.info("耗材locationId为空且无已有记录,使用登录用户科室作为默认值: locationId={}", locId); + } } deviceRequest.setPerformLocation(locId); deviceRequest.setEncounterId(adviceSaveDto.getEncounterId()); // 就诊id diff --git a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue index 5fcfe6cc1..709e4303c 100755 --- a/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue +++ b/openhis-ui-vue3/src/views/clinicmanagement/bargain/component/prescriptionlist.vue @@ -1036,6 +1036,14 @@ function handleSave() { requestId: item.requestId, dbOpType: '1', groupId: item.groupId, + // 🔧 Bug #443: 补充顶层关键字段(这些不在 contentJson 中,需从 API 响应顶层提取) + encounterId: item.encounterId, + patientId: item.patientId, + locationId: item.positionId, + adviceType: item.adviceType, + adviceTableName: item.adviceTableName, + adviceDefinitionId: item.adviceDefinitionId, + chargeItemId: item.chargeItemId, }; }); savePrescriptionSign({