bug 573 578 584

This commit is contained in:
Ranyunqiao
2026-06-04 17:36:48 +08:00
parent 0eaf133a8d
commit b8d719429d
12 changed files with 446 additions and 46 deletions

View File

@@ -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<ServiceRequest> serviceRequests = iServiceRequestService.list(
new LambdaQueryWrapper<ServiceRequest>()
.eq(ServiceRequest::getPrescriptionNo, opSchedule.getOperCode())
.eq(ServiceRequest::getCategoryEnum, 24)
.eq(ServiceRequest::getDeleteFlag, "0"));
if (serviceRequests != null && !serviceRequests.isEmpty()) {
List<Long> 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) {

View File

@@ -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<Surgery>().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();

View File

@@ -98,4 +98,12 @@ public class RequestFormPageDto {
* 就诊卡号
*/
private String identifierNo;
/**
* 手术名称(来自 cli_surgery.surgery_name
*/
private String surgeryName;
/**
* 术前诊断(来自 cli_surgery.preoperative_diagnosis
*/
private String preoperativeDiagnosis;
}

View File

@@ -186,11 +186,13 @@
<result column="incision_level" property="incisionLevel"/>
<result column="surgery_level" property="surgeryLevel"/>
<result column="identifier_no" property="identifierNo"/>
<result column="surgery_name" property="surgeryName"/>
<result column="preoperative_diagnosis" property="preoperativeDiagnosis"/>
</resultMap>
<!-- 分页查询申请单 -->
<select id="getRequestFormPage" resultMap="RequestFormPageDtoMap">
SELECT
SELECT DISTINCT
drf.prescription_no AS surgery_no,
drf.desc_json,
drf.create_by AS apply_doctor_name,
@@ -210,6 +212,8 @@
cs.anesthesia_type_enum,
cs.incision_level,
cs.surgery_level,
cs.surgery_name,
cs.preoperative_diagnosis,
fc.contract_name AS fee_type,
COALESCE(pi.identifier_no, ap.bus_no, '') AS identifier_no
FROM doc_request_form drf

View File

@@ -48,11 +48,11 @@ public class OpSchedule extends HisBaseEntity {
private String operName;
/** 术前诊断 */
@TableField(value = "preoperative_diagnosis", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "preoperative_diagnosis")
private String preoperativeDiagnosis;
/** 术后诊断 */
@TableField(value = "postoperative_diagnosis", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "postoperative_diagnosis")
private String postoperativeDiagnosis;
/** 手术安排日期时间 */
@@ -95,43 +95,43 @@ public class OpSchedule extends HisBaseEntity {
private String tableNo;
/** 麻醉方式 */
@TableField(value = "anes_method", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "anes_method")
private String anesMethod;
/** 麻醉医生1编码 */
@TableField(value = "anes_doctor1_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "anes_doctor1_code")
private String anesDoctor1Code;
/** 麻醉医生2编码 */
@TableField(value = "anes_doctor2_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "anes_doctor2_code")
private String anesDoctor2Code;
/** 麻醉医生3编码 */
@TableField(value = "anes_doctor3_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "anes_doctor3_code")
private String anesDoctor3Code;
/** 洗手护士编码 */
@TableField(value = "scrub_nurse_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "scrub_nurse_code")
private String scrubNurseCode;
/** 巡回护士1编码 */
@TableField(value = "circu_nurse1_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "circu_nurse1_code")
private String circuNurse1Code;
/** 巡回护士2编码 */
@TableField(value = "circu_nurse2_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "circu_nurse2_code")
private String circuNurse2Code;
/** 器械护士1编码 */
@TableField(value = "scrub_nurse1_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "scrub_nurse1_code")
private String scrubNurse1Code;
/** 器械护士2编码 */
@TableField(value = "scrub_nurse2_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "scrub_nurse2_code")
private String scrubNurse2Code;
/** 主刀医生编码 */
@TableField(value = "surgeon_code", insertStrategy = FieldStrategy.NEVER)
@TableField(value = "surgeon_code")
private String surgeonCode;
/** 助手1编码 */