开单科室维护的取药药房药在医生开处方药做好过滤限制,没有维护的药房/药库或者药品类型过滤掉。

This commit is contained in:
2025-11-07 13:35:06 +08:00
parent 945182c6f8
commit 2e45c6c029

View File

@@ -140,6 +140,17 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
adviceUtils.subtractInventory(adviceInventoryList, adviceDraftInventoryList); adviceUtils.subtractInventory(adviceInventoryList, adviceDraftInventoryList);
// 查询取药科室配置 // 查询取药科室配置
List<AdviceInventoryDto> medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId); List<AdviceInventoryDto> medLocationConfig = doctorStationAdviceAppMapper.getMedLocationConfig(organizationId);
// 将配置转为 {categoryCode -> 允许的locationId集合}
Map<String, Set<Long>> allowedLocByCategory = new HashMap<>();
if (medLocationConfig != null && !medLocationConfig.isEmpty()) {
for (AdviceInventoryDto cfg : medLocationConfig) {
if (cfg.getCategoryCode() == null || cfg.getLocationId() == null) {
continue;
}
allowedLocByCategory.computeIfAbsent(String.valueOf(cfg.getCategoryCode()), k -> new HashSet<>())
.add(cfg.getLocationId());
}
}
// 费用定价子表信息 // 费用定价子表信息
List<AdvicePriceDto> childCharge = doctorStationAdviceAppMapper List<AdvicePriceDto> childCharge = doctorStationAdviceAppMapper
.getChildCharge(ConditionCode.LOT_NUMBER_COST.getCode(), chargeItemDefinitionIdList); .getChildCharge(ConditionCode.LOT_NUMBER_COST.getCode(), chargeItemDefinitionIdList);
@@ -163,6 +174,19 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
.filter(e -> baseDto.getAdviceDefinitionId().equals(e.getItemId()) .filter(e -> baseDto.getAdviceDefinitionId().equals(e.getItemId())
&& baseDto.getAdviceTableName().equals(e.getItemTable())) && baseDto.getAdviceTableName().equals(e.getItemTable()))
.collect(Collectors.toList()); .collect(Collectors.toList());
// 当存在按科室配置时:仅保留被允许的药房/药库的库存;
// 若该药品类别未在配置中出现,则视为不可开立(清空库存以便前端过滤掉)
if (!allowedLocByCategory.isEmpty()) {
Set<Long> allowedLoc =
allowedLocByCategory.get(String.valueOf(baseDto.getCategoryCode()));
if (allowedLoc == null || allowedLoc.isEmpty()) {
inventoryList = Collections.emptyList();
} else {
inventoryList = inventoryList.stream()
.filter(inv -> allowedLoc.contains(inv.getLocationId()))
.collect(Collectors.toList());
}
}
// 库存信息 // 库存信息
baseDto.setInventoryList(inventoryList); baseDto.setInventoryList(inventoryList);
// 设置默认产品批号 // 设置默认产品批号
@@ -174,18 +198,15 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber()); baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber());
} }
} }
if (!inventoryList.isEmpty() && !medLocationConfig.isEmpty()) { if (!inventoryList.isEmpty() && !allowedLocByCategory.isEmpty()) {
// 第一步在medLocationConfig中匹配categoryCode Set<Long> allowedLoc =
AdviceInventoryDto result1 = medLocationConfig.stream() allowedLocByCategory.get(String.valueOf(baseDto.getCategoryCode()));
.filter(dto -> baseDto.getCategoryCode().equals(dto.getCategoryCode())).findFirst() if (allowedLoc != null && !allowedLoc.isEmpty()) {
.orElse(null); AdviceInventoryDto hit = inventoryList.stream()
if (result1 != null) { .filter(inv -> allowedLoc.contains(inv.getLocationId()))
// 第二步在inventoryList中匹配locationId .findFirst().orElse(null);
AdviceInventoryDto result2 = inventoryList.stream() if (hit != null && hit.getLotNumber() != null) {
.filter(dto -> result1.getLocationId().equals(dto.getLocationId())).findFirst() baseDto.setDefaultLotNumber(hit.getLotNumber());
.orElse(null);
if (result2 != null && result2.getLotNumber() != null) {
baseDto.setDefaultLotNumber(result2.getLotNumber());
} }
} }
} }