diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java index 3e67b3a03..dbe9bba32 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/appservice/impl/SurgeryAppServiceImpl.java @@ -366,7 +366,7 @@ public class SurgeryAppServiceImpl implements ISurgeryAppService { serviceRequest.setTherapyEnum(TherapyTimeType.TEMPORARY.getValue());// 治疗类型 serviceRequest.setQuantity(BigDecimal.valueOf(1)); // 请求数量 serviceRequest.setUnitCode("次"); // 请求单位编码 - serviceRequest.setCategoryEnum(4); // 请求类型:4-手术 + serviceRequest.setCategoryEnum(24); // 请求类型:24-手术(新值域,避开 adviceType 碰撞) serviceRequest.setActivityId(surgeryId); // 手术ID作为诊疗定义id serviceRequest.setPatientId(surgeryDto.getPatientId()); // 患者 serviceRequest.setRequesterId(practitionerId); // 开方医生 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 b96d2c076..abdf1e1b1 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 @@ -7,7 +7,6 @@ import com.core.common.core.domain.R; import com.core.common.core.domain.model.LoginUser; import com.core.common.utils.SecurityUtils; import com.openhis.administration.domain.Patient; -import com.openhis.administration.service.IOrganizationService; import com.openhis.administration.service.IPatientService; import com.openhis.clinical.domain.Surgery; import com.openhis.clinical.service.ISurgeryService; @@ -28,7 +27,6 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; import java.net.URLEncoder; -import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; import java.util.List; @@ -204,6 +202,8 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi return R.fail("新增手术安排失败"); } + syncSurgeryIncisionLevel(opSchedule.getOperCode(), opCreateScheduleDto.getIncisionLevel()); + // Bug #247 修复:更新手术申请单状态为已排期 (1) if (opCreateScheduleDto.getApplyId() != null) { try { @@ -300,6 +300,8 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi return R.fail("修改手术安排失败"); } + syncSurgeryIncisionLevel(opScheduleDto.getOperCode(), opScheduleDto.getIncisionLevel()); + return R.ok("修改手术安排成功"); } @@ -433,6 +435,28 @@ public class SurgicalScheduleAppServiceImpl implements ISurgicalScheduleAppServi return scheduleDate.format(java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); } + /** + * 同步手术申请表中的切口类型 + */ + private void syncSurgeryIncisionLevel(String surgeryNo, Integer incisionLevel) { + if (surgeryNo == null || surgeryNo.isEmpty() || incisionLevel == null) { + return; + } + + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Surgery::getSurgeryNo, surgeryNo) + .eq(Surgery::getDeleteFlag, "0"); + Surgery surgery = surgeryService.getOne(queryWrapper); + if (surgery == null) { + log.warn("未找到需要同步切口类型的手术申请记录 - surgeryNo: {}", surgeryNo); + return; + } + + surgery.setIncisionLevel(incisionLevel); + surgery.setUpdateTime(new Date()); + surgeryService.updateById(surgery); + } + /** * 填充手术申请中缺失的名称字段 * 在创建手术安排时调用,确保关联的cli_surgery表中的名称字段有值 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpCreateScheduleDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpCreateScheduleDto.java index c23d0217f..05554875e 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpCreateScheduleDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpCreateScheduleDto.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import java.math.BigDecimal; -import java.time.LocalDate; import java.time.LocalDateTime; @Data @@ -85,6 +84,11 @@ public class OpCreateScheduleDto { */ private String surgerySite; + /** + * 切口类型 + */ + private Integer incisionLevel; + /** * 入院时间 */ diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpScheduleDto.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpScheduleDto.java index 4fdb88480..ac243f385 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpScheduleDto.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/clinicalmanage/dto/OpScheduleDto.java @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonFormat; import com.openhis.surgicalschedule.domain.OpSchedule; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDate; @@ -93,6 +94,12 @@ public class OpScheduleDto extends OpSchedule { * 手术类型 */ private String surgeryType; + + /** + * 切口类型 + */ + private Integer incisionLevel; + /** * 申请科室 */ 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 1288f57bf..b538ef63a 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 @@ -35,6 +35,7 @@ import com.openhis.medication.service.IMedicationDispenseService; import com.openhis.medication.service.IMedicationRequestService; import com.openhis.web.chargemanage.mapper.OutpatientRegistrationAppMapper; import com.openhis.web.doctorstation.appservice.IDoctorStationAdviceAppService; +import com.openhis.web.doctorstation.appservice.IDoctorStationInspectionLabApplyService; import com.openhis.web.doctorstation.dto.*; import com.openhis.web.doctorstation.mapper.DoctorStationAdviceAppMapper; import com.openhis.web.doctorstation.utils.AdviceUtils; @@ -47,12 +48,15 @@ import com.openhis.workflow.domain.InventoryItem; import com.openhis.workflow.domain.ServiceRequest; import com.openhis.workflow.service.*; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.math.BigDecimal; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -62,6 +66,9 @@ import java.util.stream.Collectors; @Service public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAppService { + private static final Pattern INSPECTION_APPLY_NO_JSON = + Pattern.compile("\"applyNo\"\\s*:\\s*\"([^\"]+)\""); + @Resource AssignSeqUtil assignSeqUtil; @@ -118,6 +125,13 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp @Resource IInventoryItemService inventoryItemService; + /** + * 与检验申请实现存在循环依赖,需延迟注入;删除诊疗医嘱时按 contentJson 级联作废检验申请单。 + */ + @Resource + @Lazy + private IDoctorStationInspectionLabApplyService iDoctorStationInspectionLabApplyService; + // 缓存 key 前缀 private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:"; // 缓存过期时间(小时) @@ -1535,7 +1549,18 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp deviceRequest.setLotNumber(adviceSaveDto.getLotNumber());// 产品批号 deviceRequest.setCategoryEnum(adviceSaveDto.getCategoryEnum()); // 请求类型 - deviceRequest.setDeviceDefId(adviceSaveDto.getAdviceDefinitionId());// 耗材定义id + // 🔧 BugFix #498: categoryEnum=22(检查) 走 ServiceRequest,不走 DeviceRequest + // 检查申请单的诊疗定义ID存在 activityId,不在 adviceDefinitionId + // deviceDefId 对应耗材定义ID,不能用诊疗定义ID填充 + if (adviceSaveDto.getCategoryEnum() == 22) { + log.info("handDevice skip - 检查申请单(categoryEnum=22) 走 ServiceRequest 路径,跳过 DeviceRequest 保存"); + continue; // 跳过本次循环,不走耗材请求路径 + } else if (adviceSaveDto.getAdviceDefinitionId() != null) { + deviceRequest.setDeviceDefId(adviceSaveDto.getAdviceDefinitionId());// 耗材定义id + } else { + log.warn("handDevice - deviceDefId 为空,adviceDefinitionId=null, categoryEnum={}", adviceSaveDto.getCategoryEnum()); + } + deviceRequest.setPatientId(adviceSaveDto.getPatientId()); // 患者 deviceRequest.setRequesterId(adviceSaveDto.getPractitionerId()); // 开方医生 deviceRequest.setOrgId(adviceSaveDto.getFounderOrgId());// 开方人科室 @@ -1696,6 +1721,21 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp } } + /** + * 从诊疗医嘱 contentJson 中解析检验申请单号(检验保存时写入形如 {"applyNo":"..."})。 + */ + private String extractInspectionApplyNoFromContentJson(String contentJson) { + if (StringUtils.isBlank(contentJson) || !contentJson.contains("applyNo")) { + return null; + } + Matcher m = INSPECTION_APPLY_NO_JSON.matcher(contentJson); + if (!m.find()) { + return null; + } + String applyNo = m.group(1).trim(); + return StringUtils.isBlank(applyNo) ? null : applyNo; + } + /** * 处理诊疗 */ @@ -1744,6 +1784,8 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp } } } + // 检验申请单在医嘱 contentJson 中写入 applyNo;从医嘱删除时需先级联作废检验单,避免检验页签仍显示孤儿申请 + Map> labApplyNoToRequestIds = new LinkedHashMap<>(); for (AdviceSaveDto adviceSaveDto : deleteList) { Long requestId = adviceSaveDto.getRequestId(); // 🔧 Bug #442: 跳过 requestId 为 null 的记录,避免删除不存在的诊疗请求 @@ -1752,6 +1794,35 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp continue; } iServiceRequestService.removeById(requestId);// 删除诊疗 + ServiceRequest existing = iServiceRequestService.getById(adviceSaveDto.getRequestId()); + if (existing == null) { + continue; + } + String applyNo = extractInspectionApplyNoFromContentJson(existing.getContentJson()); + if (StringUtils.isNotBlank(applyNo)) { + labApplyNoToRequestIds.computeIfAbsent(applyNo, k -> new ArrayList<>()) + .add(adviceSaveDto.getRequestId()); + } + } + Set labCascadeSkippedRequestIds = new HashSet<>(); + for (Map.Entry> e : labApplyNoToRequestIds.entrySet()) { + R delLab = iDoctorStationInspectionLabApplyService.deleteInspectionLabApply(e.getKey()); + if (delLab != null && R.isSuccess(delLab)) { + labCascadeSkippedRequestIds.addAll(e.getValue()); + log.info("handService - 级联作废检验申请单 applyNo={},已跳过重复删除的医嘱 requestIds={}", + e.getKey(), e.getValue()); + } else { + String msg = delLab != null && StringUtils.isNotEmpty(delLab.getMsg()) ? delLab.getMsg() : "删除检验申请单失败"; + log.warn("handService - 级联作废检验申请单未成功 applyNo={} msg={},将回退为仅删除当前医嘱记录", + e.getKey(), msg); + } + } + for (AdviceSaveDto adviceSaveDto : deleteList) { + if (labCascadeSkippedRequestIds.contains(adviceSaveDto.getRequestId())) { + continue; + } + Long requestId = adviceSaveDto.getRequestId(); + iServiceRequestService.removeById(requestId);// 删除诊疗 iServiceRequestService.remove( new LambdaQueryWrapper().eq(ServiceRequest::getParentId, requestId));// 删除诊疗套餐对应的子项 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatientmanage/controller/NursingRecordController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatientmanage/controller/NursingRecordController.java index 19450eebf..0fb03f934 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatientmanage/controller/NursingRecordController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/inpatientmanage/controller/NursingRecordController.java @@ -31,6 +31,7 @@ public class NursingRecordController { * 获取住院患者信息 分页显示 * * @param nursingSearchParam 查询参数 + * * @param searchKey 模糊查询 * @param pageNo 当前页码 * @param pageSize 查询条数 diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java index 658e7540d..f865495d1 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/IRequestFormManageAppService.java @@ -63,4 +63,20 @@ public interface IRequestFormManageAppService { * @return 申请单 */ IPage getRequestFormPage(RequestFormDto requestFormDto); + + /** + * 删除申请单(仅待签发状态可删除) + * + * @param requestFormId 申请单ID + * @return 结果 + */ + R deleteRequestForm(Long requestFormId); + + /** + * 撤回申请单(已签发状态撤回至待签发) + * + * @param requestFormId 申请单ID + * @return 结果 + */ + R withdrawRequestForm(Long requestFormId); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java index 26afdbcd2..7f8f3028e 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/appservice/impl/AdviceManageAppServiceImpl.java @@ -761,6 +761,8 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { if (is_sign) { deviceRequest.setReqAuthoredTime(authoredTime); // 医嘱签发时间 } + // 保存或签发时都需要设置耗材定义ID(防止 sign 分支 deviceDefId 为空触发 NOT NULL 约束) + deviceRequest.setDeviceDefId(regAdviceSaveDto.getAdviceDefinitionId()); // 保存时处理的字段属性 if (is_save) { deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4)); @@ -798,6 +800,8 @@ public class AdviceManageAppServiceImpl implements IAdviceManageAppService { if (is_sign) { deviceRequest.setReqAuthoredTime(authoredTime); // 医嘱签发时间 } + // 保存或签发时都需要设置耗材定义ID(防止 sign 分支 deviceDefId 为空触发 NOT NULL 约束) + deviceRequest.setDeviceDefId(regAdviceSaveDto.getAdviceDefinitionId()); // 保存时处理的字段属性 if (is_save) { deviceRequest.setBusNo(assignSeqUtil.getSeqByDay(AssignSeqEnum.DEVICE_RES_NO.getPrefix(), 4)); 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 3c8974e9b..6948cd48d 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 @@ -1,6 +1,7 @@ package com.openhis.web.regdoctorstation.appservice.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; @@ -294,7 +295,7 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer surgeryServiceRequest.setTherapyEnum(TherapyTimeType.TEMPORARY.getValue()); surgeryServiceRequest.setQuantity(BigDecimal.valueOf(1)); surgeryServiceRequest.setUnitCode("次"); - surgeryServiceRequest.setCategoryEnum(4); // 4-手术 + surgeryServiceRequest.setCategoryEnum(24); // 24-手术(新值域,避开 adviceType 碰撞) // 优先从 activityList 获取手术 ID if (activityList != null && !activityList.isEmpty()) { Long activityId = activityList.get(0).getAdviceDefinitionId(); @@ -490,4 +491,90 @@ public class RequestFormManageAppServiceImpl implements IRequestFormManageAppSer return requestFormManageAppMapper.getRequestFormPage(requestFormDto, page); } + @Override + public R deleteRequestForm(Long requestFormId) { + if (requestFormId == null) { + return R.fail("申请单ID不能为空"); + } + RequestForm requestForm = iRequestFormService.getById(requestFormId); + if (requestForm == null) { + return R.fail("申请单不存在"); + } + String prescriptionNo = requestForm.getPrescriptionNo(); + + // 查询该申请单下所有 ServiceRequest(含子项) + List serviceRequests = iServiceRequestService.list( + new LambdaQueryWrapper() + .eq(ServiceRequest::getPrescriptionNo, prescriptionNo)); + if (serviceRequests == null || serviceRequests.isEmpty()) { + return R.fail("未找到关联的诊疗医嘱"); + } + + // 校验:只有待签发(status=0)的申请单可删除 + boolean allDraft = serviceRequests.stream() + .allMatch(sr -> RequestStatus.DRAFT.getValue().equals(sr.getStatusEnum())); + if (!allDraft) { + return R.fail("只有待签发状态的申请单可删除"); + } + + List serviceRequestIds = serviceRequests.stream() + .map(ServiceRequest::getId).collect(Collectors.toList()); + + // 1. 删除关联的费用项 + for (Long srId : serviceRequestIds) { + iChargeItemService.deleteByServiceTableAndId( + CommonConstants.TableName.WOR_SERVICE_REQUEST, srId); + } + // 2. 删除子项 ServiceRequest(parentId 非空) + iServiceRequestService.remove( + new LambdaQueryWrapper() + .in(ServiceRequest::getId, serviceRequestIds) + .isNotNull(ServiceRequest::getParentId)); + // 3. 删除主项 ServiceRequest + iServiceRequestService.removeByIds(serviceRequestIds); + // 4. 删除申请单 + iRequestFormService.removeById(requestFormId); + + log.info("检查申请单删除成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo); + return R.ok("删除成功"); + } + + @Override + public R withdrawRequestForm(Long requestFormId) { + if (requestFormId == null) { + return R.fail("申请单ID不能为空"); + } + RequestForm requestForm = iRequestFormService.getById(requestFormId); + if (requestForm == null) { + return R.fail("申请单不存在"); + } + String prescriptionNo = requestForm.getPrescriptionNo(); + + // 查询该申请单下所有 ServiceRequest + List serviceRequests = iServiceRequestService.list( + new LambdaQueryWrapper() + .eq(ServiceRequest::getPrescriptionNo, prescriptionNo)); + if (serviceRequests == null || serviceRequests.isEmpty()) { + return R.fail("未找到关联的诊疗医嘱"); + } + + // 校验:只有已签发(status=2)的申请单可撤回 + boolean allActive = serviceRequests.stream() + .allMatch(sr -> RequestStatus.ACTIVE.getValue().equals(sr.getStatusEnum())); + if (!allActive) { + return R.fail("只有已签发状态的申请单可撤回"); + } + + // 将所有 ServiceRequest 状态改回待签发(DRAFT=0) + List serviceRequestIds = serviceRequests.stream() + .map(ServiceRequest::getId).collect(Collectors.toList()); + iServiceRequestService.update( + new ServiceRequest().setStatusEnum(RequestStatus.DRAFT.getValue()), + new LambdaUpdateWrapper() + .in(ServiceRequest::getId, serviceRequestIds)); + + log.info("检查申请单撤回成功,requestFormId={}, prescriptionNo={}", requestFormId, prescriptionNo); + return R.ok("撤回成功"); + } + } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/controller/RequestFormManageController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/controller/RequestFormManageController.java index eeaa6d707..e3e929fe3 100755 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/controller/RequestFormManageController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/regdoctorstation/controller/RequestFormManageController.java @@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*; import java.time.LocalDate; import java.util.List; +import java.util.Map; /** * 申请单管理 controller @@ -185,4 +186,26 @@ public class RequestFormManageController { public R> getRequestFormPage(@RequestBody RequestFormDto requestFormDto) { return R.ok(iRequestFormManageAppService.getRequestFormPage(requestFormDto)); } + + /** + * 删除申请单(仅待签发状态可删除) + * + * @param data 包含 requestFormId 的请求体 + * @return 结果 + */ + @PostMapping(value = "/delete") + public R deleteRequestForm(@RequestBody Map data) { + return iRequestFormManageAppService.deleteRequestForm(data.get("requestFormId")); + } + + /** + * 撤回申请单(已签发状态撤回至待签发) + * + * @param data 包含 requestFormId 的请求体 + * @return 结果 + */ + @PostMapping(value = "/withdraw") + public R withdrawRequestForm(@RequestBody Map data) { + return iRequestFormManageAppService.withdrawRequestForm(data.get("requestFormId")); + } } diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml index c3d9da2da..30aeee339 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/chargemanage/OutpatientChargeAppMapper.xml @@ -97,6 +97,10 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.surgery_name + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE( + wsr.content_json::json->>'surgeryName', + wsr.content_json::json->>'adviceName', + T9sr.surgery_name) WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name") WHEN T1.context_enum = 6 THEN T2."name" WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name") @@ -108,6 +112,7 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN NULL + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN NULL WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL WHEN T1.context_enum = 6 THEN T2.yb_no WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL @@ -118,6 +123,7 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.id + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(T9sr.id, wsr.activity_id) WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0 WHEN T1.context_enum = 6 THEN T2.id WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0 @@ -159,6 +165,11 @@ LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0' LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0' LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0' + LEFT JOIN cli_surgery AS T9sr ON T1.context_enum = 6 + AND T1.service_table = 'wor_service_request' + AND wsr.activity_id IS NOT NULL + AND wsr.activity_id = T9sr.id + AND T9sr.delete_flag = '0' LEFT JOIN wor_service_request AS wsrp ON wsrp.id = wsr.parent_id AND wsrp.delete_flag = '0' WHERE T1.encounter_id = #{encounterId} AND T1.status_enum IN (0 @@ -223,6 +234,10 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.surgery_name WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.surgery_name + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE( + wsr.content_json::json->>'surgeryName', + wsr.content_json::json->>'adviceName', + T9sr.surgery_name) WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name") WHEN T1.context_enum = 6 THEN T2."name" WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN COALESCE(wsr.content_json::json->>'adviceName', T2."name") @@ -234,6 +249,7 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN NULL WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN NULL + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN NULL WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL WHEN T1.context_enum = 6 THEN T2.yb_no WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN NULL @@ -244,6 +260,7 @@ CASE WHEN T1.context_enum = #{activity} AND T1.product_table = 'cli_surgery' THEN T9.id WHEN T1.context_enum = 6 AND T1.product_table = 'cli_surgery' THEN T9.id + WHEN T1.context_enum = 6 AND T1.service_table = 'wor_service_request' THEN COALESCE(T9sr.id, wsr.activity_id) WHEN T1.context_enum = 6 AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0 WHEN T1.context_enum = 6 THEN T2.id WHEN T1.context_enum = #{activity} AND T1.product_id = 0 AND T1.service_table = 'wor_service_request' THEN 0 @@ -286,6 +303,11 @@ LEFT JOIN med_medication_request AS mmr ON mmr.id = T1.service_id AND mmr.delete_flag = '0' LEFT JOIN wor_device_request AS wdr ON wdr.id = T1.service_id AND wdr.delete_flag = '0' LEFT JOIN wor_service_request AS wsr ON wsr.id = T1.service_id AND wsr.delete_flag = '0' + LEFT JOIN cli_surgery AS T9sr ON T1.context_enum = 6 + AND T1.service_table = 'wor_service_request' + AND wsr.activity_id IS NOT NULL + AND wsr.activity_id = T9sr.id + AND T9sr.delete_flag = '0' WHERE T1.encounter_id = #{encounterId} AND T1.status_enum IN (0 , #{planned} diff --git a/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgicalScheduleAppMapper.xml b/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgicalScheduleAppMapper.xml index 305c3e8e3..74abd7a4f 100755 --- a/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgicalScheduleAppMapper.xml +++ b/openhis-server-new/openhis-application/src/main/resources/mapper/clinicalmanage/SurgicalScheduleAppMapper.xml @@ -71,7 +71,7 @@ AND os.delete_flag = '0' - ORDER BY os.create_time DESC + ORDER BY os.create_time DESC, os.schedule_id DESC