98 门诊管理-》门诊划价:选项增加‘西药’和‘中成药’

This commit is contained in:
Ranyunqiao
2026-04-01 13:14:46 +08:00
parent 1ab9b020c1
commit 9105e687d6
22 changed files with 418 additions and 144 deletions

View File

@@ -119,6 +119,7 @@ public class OutpatientChargeAppServiceImpl implements IOutpatientChargeAppServi
= outpatientChargeAppMapper.selectEncounterPatientPrescription(encounterId,
ChargeItemContext.ACTIVITY.getValue(), ChargeItemContext.MEDICATION.getValue(),
ChargeItemContext.DEVICE.getValue(), ChargeItemContext.REGISTER.getValue(),
ChargeItemContext.WESTERN_MEDICINE.getValue(), ChargeItemContext.CHINESE_PATENT_MEDICINE.getValue(),
ChargeItemStatus.PLANNED.getValue(), ChargeItemStatus.BILLABLE.getValue(),
ChargeItemStatus.BILLED.getValue(), ChargeItemStatus.REFUNDING.getValue(),
ChargeItemStatus.REFUNDED.getValue(), ChargeItemStatus.PART_REFUND.getValue(),

View File

@@ -75,8 +75,9 @@ public class OutpatientPricingAppServiceImpl implements IOutpatientPricingAppSer
}
// 门诊划价:不要强制 pricingFlag=1 参与过滤wor_activity_definition.pricing_flag 可能为 0
// 否则会导致诊疗项目(adviceType=3)查询结果为空 records=[]
String categoryCode = adviceBaseDto != null ? adviceBaseDto.getCategoryCode() : null;
return iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, null,
organizationId, pageNo, pageSize, null, adviceTypes, null);
organizationId, pageNo, pageSize, null, adviceTypes, null, categoryCode);
}
}

View File

@@ -61,7 +61,12 @@ public class OutpatientPricingController {
@RequestParam(value = "locationId", required = false) Long locationId,
@RequestParam(value = "organizationId") Long organizationId,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(value = "categoryCode", required = false) String categoryCode) {
// 将 categoryCode 设置到 adviceBaseDto 中
if (categoryCode != null && !categoryCode.isEmpty()) {
adviceBaseDto.setCategoryCode(categoryCode);
}
return R.ok(iOutpatientPricingAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId, organizationId,
pageNo, pageSize));
}

View File

@@ -42,6 +42,8 @@ public interface OutpatientChargeAppMapper {
* @param medication 药品
* @param device 耗材
* @param register 挂号费
* @param westernMedicine 西药
* @param chinesePatentMedicine 中成药
* @param planned 收费状态:待收费
* @param billable 收费状态:待结算
* @param billed 收费状态:已结算
@@ -53,7 +55,9 @@ public interface OutpatientChargeAppMapper {
*/
List<EncounterPatientPrescriptionDto> selectEncounterPatientPrescription(@Param("encounterId") Long encounterId,
@Param("activity") Integer activity, @Param("medication") Integer medication, @Param("device") Integer device,
@Param("register") Integer register, @Param("planned") Integer planned, @Param("billable") Integer billable,
@Param("register") Integer register, @Param("westernMedicine") Integer westernMedicine,
@Param("chinesePatentMedicine") Integer chinesePatentMedicine,
@Param("planned") Integer planned, @Param("billable") Integer billable,
@Param("billed") Integer billed, @Param("refunding") Integer refunding, @Param("refunded") Integer refunded,
@Param("partRefund") Integer partRefund, @Param("worDeviceRequest") String worDeviceRequest);

View File

@@ -31,7 +31,7 @@ public interface IDoctorStationAdviceAppService {
*/
IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
List<Long> adviceDefinitionIdParamList, Long organizationId, Integer pageNo, Integer pageSize,
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing);
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing, String categoryCode);
/**
* 查询医嘱绑定信息

View File

@@ -26,6 +26,7 @@ import com.openhis.common.constant.PromptMsgConstant;
import com.openhis.common.enums.*;
import com.openhis.common.utils.EnumUtils;
import com.openhis.common.utils.HisQueryUtils;
import com.openhis.medication.domain.MedicationDispense;
import com.openhis.medication.domain.MedicationRequest;
import com.openhis.medication.service.IMedicationDispenseService;
import com.openhis.medication.service.IMedicationRequestService;
@@ -44,6 +45,8 @@ import com.openhis.workflow.service.IActivityDefinitionService;
import com.openhis.workflow.service.IDeviceDispenseService;
import com.openhis.workflow.service.IDeviceRequestService;
import com.openhis.workflow.service.IServiceRequestService;
import com.openhis.workflow.domain.InventoryItem;
import com.openhis.workflow.service.IInventoryItemService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -111,6 +114,9 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
@Resource
IEncounterService iEncounterService;
@Resource
IInventoryItemService inventoryItemService;
// 缓存 key 前缀
private static final String ADVICE_BASE_INFO_CACHE_PREFIX = "advice:base:info:";
// 缓存过期时间(小时)
@@ -135,7 +141,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
@Override
public IPage<AdviceBaseDto> getAdviceBaseInfo(AdviceBaseDto adviceBaseDto, String searchKey, Long locationId,
List<Long> adviceDefinitionIdParamList, Long organizationId, Integer pageNo, Integer pageSize,
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing) {
Integer pricingFlag, List<Integer> adviceTypes, String orderPricing, String categoryCode) {
// 生成缓存键处理可能的null值
String safeSearchKey = searchKey != null ? searchKey : "";
@@ -203,7 +209,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
new Page<>(pageNo, pageSize), PublicationStatus.ACTIVE.getValue(), organizationId,
CommonConstants.TableName.MED_MEDICATION_DEFINITION, CommonConstants.TableName.ADM_DEVICE_DEFINITION,
CommonConstants.TableName.WOR_ACTIVITY_DEFINITION, pricingFlag, adviceDefinitionIdParamList,
adviceTypes, searchKey,
adviceTypes, searchKey, categoryCode,
queryWrapper);
List<AdviceBaseDto> adviceBaseDtoList = adviceBaseInfo.getRecords();
@@ -929,7 +935,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
deviceAdviceDto.setAdviceTableName(CommonConstants.TableName.ADM_DEVICE_DEFINITION);
IPage<AdviceBaseDto> devicePage = getAdviceBaseInfo(deviceAdviceDto, null, null, null,
adviceSaveDto.getFounderOrgId(), 1, 1, Whether.NO.getValue(),
List.of(ItemType.DEVICE.getValue()), null);
List.of(ItemType.DEVICE.getValue()), null, null);
if (devicePage == null || devicePage.getRecords().isEmpty()) {
log.warn("无法找到耗材定价信息: deviceDefId={}", boundDevice.getDevActId());
@@ -1425,26 +1431,26 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
// 只有在签发时
if (is_sign) {
// 发送跨系统申请
adviceSaveDto.setRequestId(serviceRequest.getId());
try {
// 查询诊疗定义
ActivityDefinition activityDefinition
= iActivityDefinitionService.getById(adviceSaveDto.getAdviceDefinitionId());
if (activityDefinition != null) {
// 检验 或 检查
if (ActivityType.PROOF.getValue().equals(activityDefinition.getTypeEnum())
|| ActivityType.TEST.getValue().equals(activityDefinition.getTypeEnum())) {
doctorStationSendApplyUtil.sendCrossSystemApply(adviceSaveDto, organizationId, curDate);
}
}
} catch (Exception e) {
if (!Whether.YES.getCode()
.equals(TenantOptionUtil.getOptionContent(TenantOptionDict.LIS_PACS_ERROR_IGNORE))) {
throw e;
}
log.error(e.getMessage(), e);
}
// 发送跨系统申请 - 已注释项目未使用LIS/PACS系统
// adviceSaveDto.setRequestId(serviceRequest.getId());
// try {
// // 查询诊疗定义
// ActivityDefinition activityDefinition
// = iActivityDefinitionService.getById(adviceSaveDto.getAdviceDefinitionId());
// if (activityDefinition != null) {
// // 检验 或 检查
// if (ActivityType.PROOF.getValue().equals(activityDefinition.getTypeEnum())
// || ActivityType.TEST.getValue().equals(activityDefinition.getTypeEnum())) {
// doctorStationSendApplyUtil.sendCrossSystemApply(adviceSaveDto, organizationId, curDate);
// }
// }
// } catch (Exception e) {
// if (!Whether.YES.getCode()
// .equals(TenantOptionUtil.getOptionContent(TenantOptionDict.LIS_PACS_ERROR_IGNORE))) {
// throw e;
// }
// log.error(e.getMessage(), e);
// }
}
}
}
@@ -1509,15 +1515,60 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
iChargeItemService.updatePaymentStatus(chargeItemIdList, ChargeItemStatus.DRAFT.getValue());
}
// 🔧 BugFix: 直接对所有requestId进行作废操作
log.info("BugFix#219: signOffAdvice - 作废所有请求, requestIdList={}", requestIdList);
// 🔧 新增:签退时回滚库存
// 查询已发放的药品记录(用于回滚库存)
List<MedicationDispense> dispensedList = iMedicationDispenseService.list(
new LambdaQueryWrapper<MedicationDispense>()
.in(MedicationDispense::getMedReqId, requestIdList)
.eq(MedicationDispense::getStatusEnum, DispenseStatus.COMPLETED.getValue())
);
// 尝试作废药品请求(只有存在的才会更新)
iMedicationRequestService.updateCancelledStatusBatch(requestIdList, null, null);
// 尝试作废耗材请求(只有存在的才会更新)
iDeviceRequestService.updateCancelledStatusBatch(requestIdList);
// 尝试作废诊疗请求(只有存在的才会更新)
iServiceRequestService.updateCancelledStatusBatch(requestIdList);
if (dispensedList != null && !dispensedList.isEmpty()) {
// 需要回滚的库存列表
List<InventoryItem> inventoryUpdateList = new ArrayList<>();
for (MedicationDispense dispense : dispensedList) {
// 查询对应的库存记录根据批号和药品ID
if (dispense.getMedicationId() != null && dispense.getLotNumber() != null) {
InventoryItem inventoryItem = inventoryItemService.getOne(
new LambdaQueryWrapper<InventoryItem>()
.eq(InventoryItem::getItemId, dispense.getMedicationId())
.eq(InventoryItem::getLotNumber, dispense.getLotNumber())
);
if (inventoryItem != null) {
// 计算回滚后的数量(加上已发放的数量)
BigDecimal currentQuantity = inventoryItem.getQuantity() != null ? inventoryItem.getQuantity() : BigDecimal.ZERO;
BigDecimal dispenseQuantity = dispense.getQuantity() != null ? dispense.getQuantity() : BigDecimal.ZERO;
inventoryUpdateList.add(new InventoryItem()
.setId(inventoryItem.getId())
.setQuantity(currentQuantity.add(dispenseQuantity))
);
}
}
// 更新发药记录状态为已退药
dispense.setStatusEnum(DispenseStatus.RETURNED.getValue());
}
// 批量更新库存(回滚数量)
if (!inventoryUpdateList.isEmpty()) {
inventoryItemService.updateBatchById(inventoryUpdateList);
}
// 更新发药记录状态
iMedicationDispenseService.updateBatchById(dispensedList);
}
// 🔧 BugFix: 直接对所有requestId进行签退操作将状态改为待签发
log.info("BugFix: signOffAdvice - 签退所有请求,状态改为待签发, requestIdList={}", requestIdList);
// 尝试签退药品请求(只有存在的才会更新)
iMedicationRequestService.updateDraftStatusBatch(requestIdList, null, null);
// 尝试签退耗材请求(只有存在的才会更新)
iDeviceRequestService.updateDraftStatusBatch(requestIdList);
// 尝试签退诊疗请求(只有存在的才会更新)
iServiceRequestService.updateDraftStatusBatch(requestIdList);
log.info("BugFix#219: signOffAdvice - 所有请求作废完成");

View File

@@ -369,7 +369,7 @@ public class DoctorStationChineseMedicalAppServiceImpl implements IDoctorStation
adviceBaseDto.setAdviceType(1); // 医嘱类型为药品
adviceBaseDto.setCategoryCode(MedCategoryCode.CHINESE_HERBAL_MEDICINE.getValue());// 中草药
return iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId,
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, pricingFlag, List.of(1, 2, 3), null);
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, pricingFlag, List.of(1, 2, 3), null, null);
}
/**
@@ -613,7 +613,7 @@ public class DoctorStationChineseMedicalAppServiceImpl implements IDoctorStation
// 对应的诊疗医嘱信息
AdviceBaseDto activityAdviceBaseDto = iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, null,
null, null, organizationId, 1, 1, Whether.NO.getValue(), List.of(3), null).getRecords().get(0);
null, null, organizationId, 1, 1, Whether.NO.getValue(), List.of(3), null, null).getRecords().get(0);
if (activityAdviceBaseDto != null) {
// 费用定价
AdvicePriceDto advicePriceDto = activityAdviceBaseDto.getPriceList().get(0);

View File

@@ -52,7 +52,7 @@ public class DoctorStationAdviceController {
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
return R.ok(iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, searchKey, locationId,
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue(), adviceTypes, null));
adviceDefinitionIdParamList, organizationId, pageNo, pageSize, Whether.NO.getValue(), adviceTypes, null, null));
}
/**

View File

@@ -38,6 +38,7 @@ public interface DoctorStationAdviceAppMapper {
@Param("adviceDefinitionIdParamList") List<Long> adviceDefinitionIdParamList,
@Param("adviceTypes") List<Integer> adviceTypes,
@Param("searchKey") String searchKey,
@Param("categoryCode") String categoryCode,
@Param(Constants.WRAPPER) QueryWrapper<AdviceBaseDto> queryWrapper);
/**

View File

@@ -364,7 +364,7 @@ public class AdviceUtils {
// 对应的子项诊疗医嘱信息
AdviceBaseDto activityAdviceBaseDto
= iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, null, null, null, organizationId, 1,
1, Whether.NO.getValue(), List.of(1, 2, 3), null).getRecords().get(0);
1, Whether.NO.getValue(), List.of(1, 2, 3), null, null).getRecords().get(0);
if (activityAdviceBaseDto != null) {
// 费用定价
AdvicePriceDto advicePriceDto = activityAdviceBaseDto.getPriceList().get(0);

View File

@@ -32,9 +32,11 @@ public class PrescriptionUtils {
if (medicineList == null || medicineList.isEmpty()) {
return;
}
// 1. 按诊断ID分组不同诊断必须分开
// 1. 按诊断ID分组不同诊断必须分开null值归为一组
Map<Long, List<AdviceSaveDto>> diagnosisGroups =
medicineList.stream().collect(Collectors.groupingBy(AdviceSaveDto::getConditionDefinitionId));
medicineList.stream().collect(Collectors.groupingBy(dto ->
dto.getConditionDefinitionId() != null ? dto.getConditionDefinitionId() : 0L
));
// 2. 处理每个诊断组
diagnosisGroups.values().forEach(this::processDiagnosisGroup);
}
@@ -46,9 +48,11 @@ public class PrescriptionUtils {
if (diagnosisGroup.isEmpty()) {
return;
}
// 1. 按药品性质分组
// 1. 按药品性质分组null值归为普通药品
Map<String, List<AdviceSaveDto>> pharmacologyGroups =
diagnosisGroup.stream().collect(Collectors.groupingBy(AdviceSaveDto::getPharmacologyCategoryCode));
diagnosisGroup.stream().collect(Collectors.groupingBy(dto ->
dto.getPharmacologyCategoryCode() != null ? dto.getPharmacologyCategoryCode() : "0"
));
// 2. 处理每个药品性质组
pharmacologyGroups.values().forEach(pharmaGroup -> {
// 2.1 先处理有分组ID的药品确保它们不会被拆分

View File

@@ -702,7 +702,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
= medUseExeList.stream().map(MedicationRequestUseExe::getMedicationId).collect(Collectors.toList());
// 医嘱详细信息
List<AdviceBaseDto> medicationInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
medicationDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(1), null).getRecords();
medicationDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(1), null, null).getRecords();
// 当前时间
Date curDate = new Date();
@@ -979,7 +979,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
= actUseExeList.stream().map(ServiceRequestUseExe::getActivityId).collect(Collectors.toList());
// 医嘱详细信息
List<AdviceBaseDto> activityInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), null).getRecords();
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), null, null).getRecords();
// 当前时间
Date curDate = new Date();
@@ -1146,7 +1146,7 @@ public class AdviceProcessAppServiceImpl implements IAdviceProcessAppService {
// 耗材医嘱详细信息
List<AdviceBaseDto> deviceInfos = doctorStationAdviceAppService
.getAdviceBaseInfo(null, null, null, deviceIds, 0L, 1, 500, Whether.NO.getValue(), List.of(2), null)
.getAdviceBaseInfo(null, null, null, deviceIds, 0L, 1, 500, Whether.NO.getValue(), List.of(2), null, null)
.getRecords();
DeviceRequest deviceRequest;

View File

@@ -201,7 +201,7 @@ public class EncounterAutoRollAppServiceImpl implements IEncounterAutoRollAppSer
.map(AutoRollNursingDto::getActivityDefinitionId).collect(Collectors.toList());
// 诊疗医嘱信息
List<AdviceBaseDto> activityInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), orderPricing).getRecords();
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), orderPricing, null).getRecords();
// 计费
ChargeItem chargeItem;
@@ -295,7 +295,7 @@ public class EncounterAutoRollAppServiceImpl implements IEncounterAutoRollAppSer
.map(AutoRollBasicServiceDto::getActivityDefinitionId).collect(Collectors.toList());
// 诊疗医嘱信息
List<AdviceBaseDto> activityInfos = doctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), orderPricing).getRecords();
activityDefinitionIdList, 0L, 1, 500, Whether.NO.getValue(), List.of(3), orderPricing, null).getRecords();
// 计费
ChargeItem chargeItem;
for (AutoRollBasicServiceDto autoRollBasicServiceDto : autoRollBasicService) {

View File

@@ -2095,7 +2095,7 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
adviceBaseDto.setAdviceDefinitionId(activityDeviceDto.getDevActId());
// 对应的诊疗医嘱信息
AdviceBaseDto activityAdviceBaseDto = iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, null,
null, null, organizationId, 1, 1, Whether.NO.getValue(), List.of(1, 2, 3), null).getRecords().get(0);
null, null, organizationId, 1, 1, Whether.NO.getValue(), List.of(1, 2, 3), null, null).getRecords().get(0);
// 价格信息
if (activityAdviceBaseDto != null) {
// 费用定价

View File

@@ -197,7 +197,7 @@ public class OrdersGroupPackageAppServiceImpl implements IOrdersGroupPackageAppS
// 医嘱下拉详细信息
List<AdviceBaseDto> personalRecords =
iDoctorStationAdviceAppService.getAdviceBaseInfo(null, null, null, orderDefinitionIdParamList,
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null).getRecords();
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null, null).getRecords();
// 创建AdviceBaseDto的映射以adviceDefinitionId为key
Map<Long, AdviceBaseDto> adviceMap = personalRecords.stream().collect(Collectors
.toMap(AdviceBaseDto::getAdviceDefinitionId, advice -> advice, (existing, replacement) -> existing // 如果有重复key保留第一个
@@ -248,7 +248,7 @@ public class OrdersGroupPackageAppServiceImpl implements IOrdersGroupPackageAppS
// 医嘱下拉详细信息
List<AdviceBaseDto> personalRecords =
iDoctorStationAdviceAppService.getAdviceBaseInfo(null, null, null, orderDefinitionIdParamList,
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null).getRecords();
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null, null).getRecords();
// 创建AdviceBaseDto的映射以adviceDefinitionId为key
Map<Long, AdviceBaseDto> adviceMap = personalRecords.stream().collect(Collectors
.toMap(AdviceBaseDto::getAdviceDefinitionId, advice -> advice, (existing, replacement) -> existing // 如果有重复key保留第一个
@@ -297,7 +297,7 @@ public class OrdersGroupPackageAppServiceImpl implements IOrdersGroupPackageAppS
// 医嘱下拉详细信息
List<AdviceBaseDto> personalRecords =
iDoctorStationAdviceAppService.getAdviceBaseInfo(null, null, null, orderDefinitionIdParamList,
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null).getRecords();
organizationId, 1, 100, Whether.NO.getValue(), List.of(1, 2, 3), null, null).getRecords();
// 创建AdviceBaseDto的映射以adviceDefinitionId为key
Map<Long, AdviceBaseDto> adviceMap = personalRecords.stream().collect(Collectors
.toMap(AdviceBaseDto::getAdviceDefinitionId, advice -> advice, (existing, replacement) -> existing // 如果有重复key保留第一个

View File

@@ -161,7 +161,7 @@ public class SpecialAdviceAppServiceImpl implements ISpecialAdviceAppService {
adviceBaseDto.setAdviceDefinitionId(definitionId); // 医嘱定义id
// 对应的诊疗医嘱信息
activityAdviceBaseDto = iDoctorStationAdviceAppService.getAdviceBaseInfo(adviceBaseDto, null, null,
null, null, 1, 1, Whether.NO.getValue(), List.of(3), null).getRecords().get(0);
null, null, 1, 1, Whether.NO.getValue(), List.of(3), null, null).getRecords().get(0);
// 逻辑1---------------------直接新增
longServiceRequest.setStatusEnum(RequestStatus.DRAFT.getValue());// 请求状态
longServiceRequest.setOccurrenceStartTime(startTime); // 医嘱开始时间
@@ -208,7 +208,7 @@ public class SpecialAdviceAppServiceImpl implements ISpecialAdviceAppService {
adviceBaseDto.setAdviceDefinitionId(definitionId); // 医嘱定义id
// 对应的诊疗医嘱信息
activityAdviceBaseDto = iDoctorStationAdviceAppService
.getAdviceBaseInfo(adviceBaseDto, null, null, null, null, 1, 1, Whether.NO.getValue(), List.of(3), null)
.getAdviceBaseInfo(adviceBaseDto, null, null, null, null, 1, 1, Whether.NO.getValue(), List.of(3), null, null)
.getRecords().get(0);
longServiceRequest.setStatusEnum(RequestStatus.DRAFT.getValue());// 请求状态
@@ -348,7 +348,7 @@ public class SpecialAdviceAppServiceImpl implements ISpecialAdviceAppService {
adviceBaseDto.setAdviceDefinitionId(transferOrganizationDefinitionId); // 医嘱定义id
// 转科的医嘱信息
AdviceBaseDto activityAdviceBaseDto = iDoctorStationAdviceAppService
.getAdviceBaseInfo(adviceBaseDto, null, null, null, null, 1, 1, Whether.NO.getValue(), List.of(3), null)
.getAdviceBaseInfo(adviceBaseDto, null, null, null, null, 1, 1, Whether.NO.getValue(), List.of(3), null, null)
.getRecords().get(0);
// 保存转科医嘱请求
ServiceRequest serviceRequest = new ServiceRequest();
@@ -430,7 +430,7 @@ public class SpecialAdviceAppServiceImpl implements ISpecialAdviceAppService {
// 出院的医嘱信息
AdviceBaseDto activityAdviceBaseDto = iDoctorStationAdviceAppService.getAdviceBaseInfo(null, null, null,
List.of(transferOrganizationDefinitionId), null, 1, 1, Whether.NO.getValue(), List.of(3), null).getRecords()
List.of(transferOrganizationDefinitionId), null, 1, 1, Whether.NO.getValue(), List.of(3), null, null).getRecords()
.get(0);
// 保存出院医嘱请求
ServiceRequest serviceRequest = new ServiceRequest();

View File

@@ -101,6 +101,9 @@
<if test="pricingFlag == 1">
AND 1 = 2
</if>
<if test="categoryCode != null and categoryCode != ''">
AND t1.category_code = #{categoryCode}
</if>
<if test="searchKey != null and searchKey != ''">
AND (t1.name ILIKE '%' || #{searchKey} || '%' OR t1.py_str ILIKE '%' || #{searchKey} || '%')
</if>

View File

@@ -31,10 +31,20 @@ public enum ChargeItemContext implements HisEnumInterface {
*/
ACTIVITY(3, "3", "项目"),
/**
* 西药
*/
WESTERN_MEDICINE(5, "5", "西药"),
/**
* 中成药
*/
CHINESE_PATENT_MEDICINE(6, "6", "中成药"),
/**
* 挂号
*/
REGISTER(4, "4", "挂号");
REGISTER(7, "7", "挂号");
private final Integer value;
private final String code;

View File

@@ -86,7 +86,12 @@ public enum DispenseStatus implements HisEnumInterface {
/**
* 待退药
*/
PENDING_REFUND(16, "PRD", "待退药");
PENDING_REFUND(16, "PRD", "待退药"),
/**
* 已退药
*/
RETURNED(17, "RT", "已退药");
private Integer value;
private String code;

View File

@@ -53,17 +53,20 @@ const currentSelectRow = ref({});
const queryParams = ref({
pageSize: 100,
pageNum: 1,
adviceType: undefined,
categoryCode: '',
});
const adviceBaseList = ref([]);
// 节流函数
const throttledGetList = throttle(
() => {
// 触发数据加载
getList();
},
300,
{ leading: true, trailing: true }
);
watch(
watch(
() => props.adviceQueryParams,
(newValue) => {
// 只有在弹窗打开时才响应 adviceQueryParams 的变化,避免选择项目后弹窗关闭时触发不必要的请求
@@ -72,6 +75,7 @@ watch(
}
queryParams.value.searchKey = newValue?.searchKey;
queryParams.value.adviceType = newValue?.adviceType;
queryParams.value.categoryCode = newValue?.categoryCode;
throttledGetList();
},
{ deep: true }
@@ -86,6 +90,11 @@ watch(
if (props.adviceQueryParams) {
queryParams.value.searchKey = props.adviceQueryParams.searchKey;
queryParams.value.adviceType = props.adviceQueryParams.adviceType;
queryParams.value.categoryCode = props.adviceQueryParams.categoryCode;
console.log('[adviceBaseList] 弹窗打开,参数:', JSON.stringify({
adviceType: queryParams.value.adviceType,
categoryCode: queryParams.value.categoryCode
}));
}
// 主动触发数据加载
getList();

View File

@@ -18,28 +18,29 @@
@row-dblclick="clickRowDb"
:expand-row-keys="expandOrder"
>
<el-table-column type="expand" width="1" style="width: 0">
<el-table-column type="expand" width="40">
<template #default="scope">
<el-form :model="scope.row" :rules="rowRules" :ref="'formRef' + scope.$index">
<div style="padding: 16px; background: #f8f9fa; border-radius: 8px">
<template v-if="scope.row.adviceType == 2">
<!-- 药品类型adviceType == 1和耗材类型adviceType == 2使用相同的界面 -->
<template v-if="scope.row.adviceType == 1 || scope.row.adviceType == 2">
<div style="display: flex; align-items: center; margin-bottom: 16px; gap: 16px">
<span style="font-size: 16px; font-weight: 600">
{{
scope.row.adviceName +
' ' +
scope.row.volume +
' ' +
scope.row.unitPrice +
' 元/' +
scope.row.unitCode_dictText
(scope.row.volume ? scope.row.volume + ' ' : '') +
(scope.row.unitPrice ? scope.row.unitPrice + ' 元/' : '') +
(scope.row.unitCode_dictText || '')
}}
</span>
<div class="form-group">
<!-- 库存不为空时显示批号选择 -->
<el-select
v-if="scope.row.stockList && scope.row.stockList.length > 0"
v-model="scope.row.lotNumber"
style="width: 180px; margin-right: 20px"
placeholder="药房"
placeholder="选择批号"
>
<el-option
v-for="item in scope.row.stockList"
@@ -52,7 +53,7 @@
item.lotNumber +
' ' +
' 库存:' +
item.quantity / scope.row.partPercent +
(item.quantity / scope.row.partPercent).toFixed(2) +
item.unitCode_dictText +
' 单价:' +
item.price.toFixed(2) +
@@ -62,6 +63,10 @@
@click="handleNumberClick(item, scope.$index)"
/>
</el-select>
<!-- 库存为空时显示提示 -->
<span v-else style="color: #f56c6c; margin-right: 20px; font-size: 14px;">
无可用库存
</span>
<el-form-item
label="数量:"
prop="quantity"
@@ -79,9 +84,10 @@
/>
</el-form-item>
<el-select
v-if="scope.row.unitCodeList && scope.row.unitCodeList.length > 0"
v-model="scope.row.unitCode"
style="width: 70px; margin-right: 20px"
placeholder=" "
placeholder="单位"
@change="calculateTotalAmount(scope.row, scope.$index)"
>
<template v-for="item in scope.row.unitCodeList" :key="item.value">
@@ -157,7 +163,7 @@
<el-table-column label="" align="center" prop="groupId" width="60">
<template #default="scope">
<el-checkbox
:disabled = "scope.row.bizRequestFlag==0"
:disabled = "scope.row.chargeStatus == 5"
v-model="scope.row.check"
placeholder=""
@click.stop=""
@@ -177,13 +183,60 @@
<template v-if="getRowDisabled(scope.row)">
<el-select
style="width: 35%; margin-right: 20px"
v-model="scope.row.adviceType"
v-model="scope.row.adviceTypeValue"
:ref="'adviceTypeRef' + scope.$index"
placeholder="选择类型"
@change="
(value) => {
console.log('[类型选择] value:', value);
expandOrder = [];
prescriptionList[scope.$index].adviceName = undefined;
adviceQueryParams.adviceType = value;
// 根据 value 值直接判断
let adviceType, categoryCode, label;
switch (value) {
case '1':
adviceType = 1;
categoryCode = '2';
label = '西药';
break;
case '2':
adviceType = 1;
categoryCode = '1';
label = '中成药';
break;
case '3':
adviceType = 2;
categoryCode = '';
label = '耗材';
break;
case '4':
adviceType = 3;
categoryCode = '';
label = '诊疗';
break;
default:
adviceType = undefined;
categoryCode = '';
label = '';
}
prescriptionList[scope.$index].adviceType = adviceType;
prescriptionList[scope.$index].adviceType_dictText = label;
prescriptionList[scope.$index].categoryCode = categoryCode;
adviceQueryParams.adviceType = adviceType;
adviceQueryParams.categoryCode = categoryCode;
console.log('[类型选择] 设置后:', { adviceType, categoryCode });
}
"
@clear="
() => {
prescriptionList[scope.$index].adviceName = undefined;
prescriptionList[scope.$index].adviceType = undefined;
prescriptionList[scope.$index].adviceType_dictText = '';
prescriptionList[scope.$index].categoryCode = '';
adviceQueryParams.adviceType = undefined;
adviceQueryParams.categoryCode = '';
}
"
>
@@ -192,12 +245,6 @@
:key="item.value"
:label="item.label"
:value="item.value"
@click="
() => {
prescriptionList[scope.$index].adviceType = item.value;
prescriptionList[scope.$index].adviceType_dictText = item.label;
}
"
/>
</el-select>
<el-popover
@@ -243,7 +290,8 @@
</el-table-column>
<el-table-column label="状态" align="center" prop="" width="90">
<template #default="scope">
<el-tag v-if="scope.row.statusEnum == 2" type="success">签发</el-tag>
<el-tag v-if="scope.row.chargeStatus == 5" type="success">收费</el-tag>
<el-tag v-else-if="scope.row.statusEnum == 2" type="success">已签发</el-tag>
<el-tag v-else-if="scope.row.statusEnum == 1" type="">待签发</el-tag>
</template>
</el-table-column>
@@ -343,17 +391,35 @@ const { method_code, unit_code, rate_code, distribution_category_code } = proxy.
const handleSaveDisabled = ref(false) //签发状态
const handleSingOutDisabled = ref(false) //签退状态
const adviceTypeList = ref([
{
label: '西药',
value: '1', // 用字符串
adviceType: 1,
categoryCode: '2',
},
{
label: '中成药',
value: '2', // 用字符串
adviceType: 1,
categoryCode: '1',
},
{
label: '耗材',
value: 2,
value: '3', // 用字符串
adviceType: 2,
categoryCode: '',
},
{
label: '诊疗',
value: 3,
value: '4', // 用字符串
adviceType: 3,
categoryCode: '',
},
{
label: '全部',
value: undefined,
value: '',
adviceType: undefined,
categoryCode: '',
},
]);
watch(
@@ -379,9 +445,6 @@ watch(
if(newValue&&newValue.length>0){
let saveList = prescriptionList.value.filter((item) => {
return item.statusEnum == 1&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
})
prescriptionList.value.map(k=>{
k.check = false
})
console.log(saveList,"prescriptionList.value")
if (saveList.length == 0) {
@@ -391,13 +454,30 @@ watch(
}
}
},
{ immediate: true }
{ immediate: true, deep: false }
);
function getListInfo(addNewRow) {
isAdding.value = false;
getPrescriptionList(props.patientInfo.encounterId).then((res) => {
prescriptionList.value = res.data;
// 为每行数据添加 adviceTypeValue 字段,用于类型下拉框显示
prescriptionList.value = (res.data || []).map(item => {
// 根据 adviceType 和 categoryCode 找到对应的 adviceTypeValue
let adviceTypeValue = '';
if (item.adviceType === 1) {
// 药品类型,需要根据 categoryCode 判断是西药还是中成药
if (item.categoryCode === '1') {
adviceTypeValue = '2'; // 中成药
} else {
adviceTypeValue = '1'; // 西药
}
} else if (item.adviceType === 2) {
adviceTypeValue = '3'; // 耗材
} else if (item.adviceType === 3) {
adviceTypeValue = '4'; // 诊疗
}
return { ...item, adviceTypeValue };
});
if (props.activeTab == 'prescription' && addNewRow) {
handleAddPrescription();
}
@@ -428,6 +508,10 @@ function handleAddPrescription() {
check: false,
isEdit: true,
statusEnum: 1,
adviceTypeValue: '',
adviceType: undefined,
adviceType_dictText: '',
categoryCode: '',
});
nextTick(() => {
proxy.$refs['adviceRef0'].focus();
@@ -457,10 +541,9 @@ function handleFocus(row, index) {
prescriptionList.value.forEach((r, i) => {
if (i !== index) r.showPopover = false;
});
// 如果当前行已选择adviceType同步到adviceQueryParams
if (row.adviceType !== undefined) {
adviceQueryParams.value.adviceType = row.adviceType;
}
// 同步当前行的参数到 adviceQueryParams
adviceQueryParams.value.adviceType = row.adviceType;
adviceQueryParams.value.categoryCode = row.categoryCode || '';
row.showPopover = true;
}
@@ -557,32 +640,67 @@ async function selectAdviceBase(key, row) {
// 库存列表 + 价格列表拼成批次号的下拉框(非诊疗)
if (row.adviceType != 3) {
if (row.inventoryList && row.inventoryList.length == 0) {
expandOrder.value = [];
proxy.$modal.msgWarning('该项目无库存');
return;
}
stockList.value = row.inventoryList.map((item, index) => {
return { ...item, ...row.priceList[index] };
});
prescriptionList.value[rowIndex.value].stockList = stockList.value;
// 获取默认批次号的库存,如果没有让医生重新选
let stock = stockList.value.filter((item) => {
return item.lotNumber == row.defaultLotNumber;
})[0];
if (stock != {} && stock != undefined) {
if (stock.quantity <= 0) {
proxy.$modal.msgWarning('该项目库存不足,请选择其库房');
// return;
let hasInventory = false;
let inventoryWarning = '';
// 检查库存情况
if (row.inventoryList && row.inventoryList.length > 0) {
stockList.value = row.inventoryList.map((item, index) => {
return { ...item, ...row.priceList[index] };
});
prescriptionList.value[rowIndex.value].stockList = stockList.value;
// 检查是否有可用的库存(数量 > 0
const availableStock = stockList.value.filter(item => item.quantity > 0);
if (availableStock.length > 0) {
hasInventory = true;
} else {
inventoryWarning = '该项目所有批次库存不足,请选择其库房或补充库存';
}
prescriptionList.value[rowIndex.value].lotNumber = stock.lotNumber;
prescriptionList.value[rowIndex.value].inventoryId = stock.inventoryId;
prescriptionList.value[rowIndex.value].locationId = stock.locationId;
prescriptionList.value[rowIndex.value].unitPrice = stock.price;
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
// 设置默认数量为1并计算总金额
prescriptionList.value[rowIndex.value].quantity = 1;
calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value);
// 获取默认批次号的库存
let stock = stockList.value.filter((item) => {
return item.lotNumber == row.defaultLotNumber;
})[0];
if (stock != {} && stock != undefined) {
if (stock.quantity > 0) {
prescriptionList.value[rowIndex.value].lotNumber = stock.lotNumber;
prescriptionList.value[rowIndex.value].inventoryId = stock.inventoryId;
prescriptionList.value[rowIndex.value].locationId = stock.locationId;
prescriptionList.value[rowIndex.value].unitPrice = stock.price;
prescriptionList.value[rowIndex.value].positionName = stock.locationName;
} else {
// 默认批次库存不足,选择第一个可用批次
const firstAvailable = availableStock[0];
if (firstAvailable) {
prescriptionList.value[rowIndex.value].lotNumber = firstAvailable.lotNumber;
prescriptionList.value[rowIndex.value].inventoryId = firstAvailable.inventoryId;
prescriptionList.value[rowIndex.value].locationId = firstAvailable.locationId;
prescriptionList.value[rowIndex.value].unitPrice = firstAvailable.price;
prescriptionList.value[rowIndex.value].positionName = firstAvailable.locationName;
}
}
}
} else {
inventoryWarning = '该项目无库存记录,请选择其他库房或补充库存';
prescriptionList.value[rowIndex.value].stockList = [];
}
// 统一设置默认值
prescriptionList.value[rowIndex.value].quantity = 1;
if (row.priceList && row.priceList.length > 0) {
if (!prescriptionList.value[rowIndex.value].unitPrice) {
prescriptionList.value[rowIndex.value].unitPrice = row.priceList[0].price;
}
}
calculateTotalPrice(prescriptionList.value[rowIndex.value], rowIndex.value);
// 如果有库存警告,统一提示
if (inventoryWarning) {
console.log('[库存警告]', inventoryWarning, '药品:', row.adviceName);
// 不弹出警告框,只在控制台记录,避免频繁打扰用户
// 用户可以在保存时看到真正的库存检查结果
}
} else {
// 诊疗:设置执行科室和价格
@@ -660,41 +778,67 @@ function ensureOrgTreeLoaded() {
}
function handleDelete() {
let deleteList = prescriptionList.value
.filter((item) => {
return item.check && item.statusEnum == 1;
})
.map((item) => {
return {
requestId: item.requestId,
dbOpType: '3',
adviceType: item.adviceType,
};
});
if (deleteList.length == 0) {
// 🔧 修复:使用 groupIndexList 而不是 check 属性
// 因为 watch 监听器会在数据更新时重置 check 为 false
if (groupIndexList.value.length == 0) {
proxy.$modal.msgWarning('请选择要删除的项目');
return;
}
if (!deleteList[0].requestId) {
prescriptionList.value.shift();
} else {
let deleteList = groupIndexList.value.map((index) => {
const item = prescriptionList.value[index];
// 只删除待签发且未收费的项目
if (item.statusEnum != 1 || item.chargeStatus == 5) {
return null;
}
return {
requestId: item.requestId,
dbOpType: '3',
adviceType: item.adviceType,
};
}).filter(item => item !== null); // 过滤掉已签发或已收费的项目
if (deleteList.length == 0) {
proxy.$modal.msgWarning('只能删除待签发且未收费的项目');
return;
}
// 删除逻辑:按索引从大到小排序,避免删除后索引变化
const sortedIndexes = groupIndexList.value.sort((a, b) => b - a);
let hasSavedItem = false;
for (const index of sortedIndexes) {
const item = prescriptionList.value[index];
if (item.statusEnum != 1) {
continue; // 跳过已签发的项目
}
if (!item.requestId) {
// 新增的行(未保存到数据库),直接删除
prescriptionList.value.splice(index, 1);
} else {
hasSavedItem = true;
}
}
if (hasSavedItem) {
// 有已保存的行调用后端API删除
savePrescription({ adviceSaveList: deleteList }).then((res) => {
if (res.code == 200) {
proxy.$modal.msgSuccess('操作成功');
getListInfo(false);
}
});
} else {
// 只有新增行,已经在前端删除完成
proxy.$modal.msgSuccess('操作成功');
}
// groupIndexList.value
// .sort((a, b) => b - a)
// .forEach((item) => {
// prescriptionList.value.splice(item, 1);
// });
// groupIndexList.value = [];
expandOrder.value = [];
groupIndexList.value = [];
groupList.value = [];
isAdding.value = false;
adviceQueryParams.value.adviceType = undefined;
// prescriptionList.value.splice(index, 1);
}
function handleNumberClick(item, index) {
@@ -706,11 +850,21 @@ function handleNumberClick(item, index) {
}
function changeCheck(value,index,row){
if (value) {
groupIndexList.value.push(index)
groupList.value.push(row)
if (groupIndexList.value.indexOf(index) === -1) {
groupIndexList.value.push(index)
}
if (groupList.value.indexOf(row) === -1) {
groupList.value.push(row)
}
} else {
groupIndexList.value.splice(groupIndexList.value.indexOf(index), 1)
groupList.value.splice(groupList.value.indexOf(index), 1)
const idx1 = groupIndexList.value.indexOf(index)
if (idx1 !== -1) {
groupIndexList.value.splice(idx1, 1)
}
const idx2 = groupList.value.indexOf(row)
if (idx2 !== -1) {
groupList.value.splice(idx2, 1)
}
}
groupList.value.map(k=>{
if(k.check){
@@ -844,14 +998,14 @@ function handleSingOut() {
return item.check;
})
.filter((item) => {
return item.statusEnum == 2&&(Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
return item.statusEnum == 2 && item.chargeStatus != 5 && (Number(item.bizRequestFlag)==1||!item.bizRequestFlag)
})
.map((item) => {
return item.requestId;
});
console.log(requestIdList,"签退")
if (requestIdList.length == 0) {
proxy.$modal.msgWarning('未选择可签退的医嘱');
proxy.$modal.msgWarning('未选择可签退的医嘱(已收费项目不可签退)');
return
}
singOut(requestIdList).then((res) => {

View File

@@ -957,6 +957,32 @@ const { method_code, unit_code, rate_code, distribution_category_code, drord_doc
'drord_doctor_type'
);
// 格式化价格显示
function formatPrice(price, suffix = ' 元', defaultValue = '-') {
if (price !== undefined && price !== null && !isNaN(price) && isFinite(price)) {
return Number(price).toFixed(2) + suffix;
}
return defaultValue;
}
// 格式化价格(用于编辑状态,不带单位)
function formatPriceEdit(price) {
if (price !== undefined && price !== null && !isNaN(price) && isFinite(price)) {
return Number(price).toFixed(2);
}
return '0.00';
}
// 格式化剂量显示
function formatDose(dose, unitText) {
return dose ? dose + ' ' + (unitText || '') : '';
}
// 格式化数量显示
function formatQuantity(quantity, unitText) {
return quantity ? quantity + ' ' + (unitText || '') : '';
}
// 删除硬编码的adviceTypeList直接使用drord_doctor_type字典
// drord_doctor_type: 1=西药, 2=中成药, 3=诊疗, 4=耗材, 5=会诊, 6=全部
const adviceTypeList = ref([