From b8d719429d6fbdb91daba982dd660550e12014d4 Mon Sep 17 00:00:00 2001 From: Ranyunqiao <2499115710@qq.com> Date: Thu, 4 Jun 2026 17:36:48 +0800 Subject: [PATCH] bug 573 578 584 --- .../impl/SurgicalScheduleAppServiceImpl.java | 26 +- .../impl/RequestFormManageAppServiceImpl.java | 119 ++++++++++ .../dto/RequestFormPageDto.java | 8 + .../RequestFormManageAppMapper.xml | 6 +- .../surgicalschedule/domain/OpSchedule.java | 24 +- .../components/patientAddDialog.vue | 9 +- .../components/diagnosis/diagnosisdialog.vue | 4 +- .../components/diagnosis/diagnosislist.vue | 4 +- .../applicationShow/surgeryApplication.vue | 224 +++++++++++++++++- .../components/diagnosis/diagnosislist.vue | 4 +- .../order/applicationForm/surgery.vue | 43 +++- .../src/views/surgicalschedule/index.vue | 21 +- 12 files changed, 446 insertions(+), 46 deletions(-) diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgicalScheduleAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgicalScheduleAppServiceImpl.java index 658724a89..c97a750d3 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgicalScheduleAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgicalScheduleAppServiceImpl.java @@ -10,8 +10,11 @@ import com.openhis.administration.domain.Patient; import com.openhis.administration.service.IPatientService; import com.openhis.clinical.domain.Surgery; import com.openhis.clinical.service.ISurgeryService; +import com.openhis.common.enums.SurgeryAppStatusEnum; import com.openhis.surgicalschedule.domain.OpSchedule; import com.openhis.surgicalschedule.service.IOpScheduleService; +import com.openhis.workflow.domain.ServiceRequest; +import com.openhis.workflow.service.IServiceRequestService; import com.openhis.web.clinicalmanage.appservice.ISurgicalScheduleAppService; import com.openhis.web.clinicalmanage.dto.OpCreateScheduleDto; import com.openhis.web.clinicalmanage.dto.OpScheduleDto; @@ -63,6 +66,9 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi @Resource private RequestFormManageAppMapper requestFormManageAppMapper; + + @Resource + private IServiceRequestService iServiceRequestService; /** * 分页查询手术安排列表 * @@ -221,8 +227,26 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi // 填充缺失的申请科室和主刀医生名称 fillSurgeryMissingNames(surgery); - + surgeryService.updateById(surgery); + + // 更新 wor_service_request 状态为已安排(5),使住院医生站手术申请tab状态同步 + try { + List serviceRequests = iServiceRequestService.list( + new LambdaQueryWrapper() + .eq(ServiceRequest::getPrescriptionNo, opSchedule.getOperCode()) + .eq(ServiceRequest::getCategoryEnum, 24) + .eq(ServiceRequest::getDeleteFlag, "0")); + if (serviceRequests != null && !serviceRequests.isEmpty()) { + List srIds = serviceRequests.stream() + .map(ServiceRequest::getId) + .collect(java.util.stream.Collectors.toList()); + iServiceRequestService.updateSurgeryAppStatus(srIds, SurgeryAppStatusEnum.SCHEDULED.getCode()); + log.info("更新wor_service_request状态为已安排 - operCode: {}, 更新{}条记录", opSchedule.getOperCode(), srIds.size()); + } + } catch (Exception ex) { + log.error("更新wor_service_request状态失败 - operCode: {}", opSchedule.getOperCode(), ex); + } log.info("更新手术申请单状态为已排期 - surgeryNo: {}, surgeryId: {}", opSchedule.getOperCode(), surgery.getId()); } } catch (Exception e) { diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java index ffd8de2ec..e2876ba39 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/RequestFormManageAppServiceImpl.java @@ -12,7 +12,14 @@ import com.core.common.utils.MessageUtils; import com.core.common.utils.SecurityUtils; import com.fasterxml.jackson.databind.ObjectMapper; import com.openhis.administration.domain.ChargeItem; +import com.openhis.administration.domain.Organization; import com.openhis.administration.service.IChargeItemService; +import com.openhis.administration.service.IOrganizationService; +import com.openhis.administration.service.IPatientService; +import com.openhis.administration.service.IPractitionerService; +import com.openhis.administration.domain.Practitioner; +import com.openhis.clinical.domain.Surgery; +import com.openhis.clinical.service.ISurgeryService; import com.openhis.common.constant.CommonConstants; import com.openhis.common.constant.PromptMsgConstant; import com.openhis.common.enums.*; @@ -73,6 +80,18 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer @Resource ISpecimenService iSpecimenService; + @Resource + ISurgeryService iSurgeryService; + + @Resource + IOrganizationService iOrganizationService; + + @Resource + IPatientService iPatientService; + + @Resource + IPractitionerService iPractitionerService; + /** * 校验当前用户是否有权操作该申请单(申请者本人或管理员) */ @@ -419,6 +438,106 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer throw new ServiceException("保存手术医嘱失败: " + e.getMessage()); } + // 🩹 BugFix: 创建 cli_surgery 手术记录,使住院手术申请在门诊手术安排搜索中可见 + try { + // 获取申请医生和科室名称 + String applyDoctorName = SecurityUtils.getLoginUser().getUser().getNickName(); + String applyDeptName = null; + if (SecurityUtils.getLoginUser().getUser().getDept() != null) { + applyDeptName = SecurityUtils.getLoginUser().getUser().getDept().getDeptName(); + } + if (applyDeptName == null && orgId != null) { + Organization org = iOrganizationService.getById(orgId); + if (org != null) { + applyDeptName = org.getName(); + } + } + + Surgery surgery = new Surgery(); + surgery.setSurgeryNo(prescriptionNo); // 关键:与 doc_request_form.prescription_no 一致,确保 INNER JOIN 能关联 + surgery.setPatientId(patientId); + surgery.setEncounterId(encounterId); + surgery.setApplyDoctorId(practitionerId); + surgery.setApplyDoctorName(applyDoctorName); + surgery.setApplyDeptId(orgId); + surgery.setApplyDeptName(applyDeptName); + surgery.setOrgId(orgId); + surgery.setStatusEnum(0); // 0 = 待排期(新开) + surgery.setDeleteFlag("0"); + + // 从 descJson 解析主刀医生ID,查 adm_practitioner 填充姓名 + String mainSurgeonIdStr = descMap != null ? (String) descMap.get("mainSurgeonId") : null; + if (mainSurgeonIdStr != null && !mainSurgeonIdStr.isEmpty()) { + try { + Long mainSurgeonId = Long.parseLong(mainSurgeonIdStr); + surgery.setMainSurgeonId(mainSurgeonId); + Practitioner surgeon = iPractitionerService.getById(mainSurgeonId); + if (surgeon != null && surgeon.getName() != null) { + surgery.setMainSurgeonName(surgeon.getName()); + } + } catch (NumberFormatException ignored) {} + } + // 从 descJson 解析手术等级、麻醉方式 + String surgeryLevelStr = descMap != null ? (String) descMap.get("surgeryLevel") : null; + if (surgeryLevelStr != null && !surgeryLevelStr.isEmpty()) { + try { surgery.setSurgeryLevel(Integer.parseInt(surgeryLevelStr)); } catch (NumberFormatException ignored) {} + } + String anesthesiaTypeStr = descMap != null ? (String) descMap.get("anesthesiaType") : null; + if (anesthesiaTypeStr != null && !anesthesiaTypeStr.isEmpty()) { + try { surgery.setAnesthesiaTypeEnum(Integer.parseInt(anesthesiaTypeStr)); } catch (NumberFormatException ignored) {} + } + // 填充患者姓名(从 adm_patient 查询) + if (patientId != null) { + try { + com.openhis.administration.domain.Patient patient = iPatientService.getById(patientId); + if (patient != null) { + surgery.setPatientName(patient.getName()); + } + } catch (Exception ignored) {} + } + + // 从 descJson 解析手术信息 + if (descMap != null) { + surgery.setSurgeryName(surgeryName); + surgery.setSurgeryCode(surgeryCode); + surgery.setSurgeryIndication(surgeryIndication); + surgery.setPreoperativeDiagnosis(preoperativeDiagnosis); + // 解析费用 + if (surgeryFee != null && !surgeryFee.isEmpty()) { + try { surgery.setSurgeryFee(new BigDecimal(surgeryFee)); } catch (NumberFormatException ignored) {} + } + if (anesthesiaFee != null && !anesthesiaFee.isEmpty()) { + try { surgery.setAnesthesiaFee(new BigDecimal(anesthesiaFee)); } catch (NumberFormatException ignored) {} + } + // 解析计划手术时间 + if (plannedTime != null && !plannedTime.isEmpty()) { + try { + surgery.setPlannedTime(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(plannedTime)); + } catch (Exception ignored) {} + } + } + // 兜底:若 descJson 解析为空,从 activityList 获取手术名称 + if ((surgery.getSurgeryName() == null || surgery.getSurgeryName().isEmpty()) && adviceDefinitionName != null) { + surgery.setSurgeryName(adviceDefinitionName); + } + + // 编辑场景:更新已有的 cli_surgery 记录;不存在则新建 + Surgery existingSurgery = iSurgeryService.getOne( + new LambdaQueryWrapper().eq(Surgery::getSurgeryNo, prescriptionNo) + .eq(Surgery::getDeleteFlag, "0").last("LIMIT 1")); + if (existingSurgery != null) { + surgery.setId(existingSurgery.getId()); + iSurgeryService.updateById(surgery); + log.info("住院手术申请 cli_surgery 记录更新成功,surgeryNo={}", prescriptionNo); + } else { + iSurgeryService.save(surgery); + log.info("住院手术申请 cli_surgery 记录创建成功,surgeryNo={}, surgeryId={}", prescriptionNo, surgery.getId()); + } + } catch (Exception e) { + log.error("创建 cli_surgery 手术记录失败,prescriptionNo={}", prescriptionNo, e); + // 不中断主流程,手术安排搜索可见性不影响申请单保存 + } + // 生成手术收费项目 try { ChargeItem surgeryChargeItem = new ChargeItem(); diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/dto/RequestFormPageDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/dto/RequestFormPageDto.java index a653448ec..8205c8e20 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/dto/RequestFormPageDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/dto/RequestFormPageDto.java @@ -98,4 +98,12 @@ public class RequestFormPageDto { * 就诊卡号 */ private String identifierNo; + /** + * 手术名称(来自 cli_surgery.surgery_name) + */ + private String surgeryName; + /** + * 术前诊断(来自 cli_surgery.preoperative_diagnosis) + */ + private String preoperativeDiagnosis; } diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml index 01a9644c4..039eec2ba 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/regdoctorstation/RequestFormManageAppMapper.xml @@ -186,11 +186,13 @@ + +