Merge branch 'develop' of https://gitea.gentronhealth.com/wangyizhe/his into develop
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">OpenHis v0.0.1</h1>
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
-- 为诊疗定义表添加序号和服务范围字段
|
||||
-- 执行前请先备份数据库
|
||||
|
||||
ALTER TABLE wor_activity_definition ADD COLUMN IF NOT EXISTS sort_order INTEGER DEFAULT NULL;
|
||||
ALTER TABLE wor_activity_definition ADD COLUMN IF NOT EXISTS service_range VARCHAR(50) DEFAULT '全部';
|
||||
|
||||
-- 添加注释
|
||||
COMMENT ON COLUMN wor_activity_definition.sort_order IS '序号';
|
||||
COMMENT ON COLUMN wor_activity_definition.service_range IS '服务范围';
|
||||
|
||||
-- 为现有数据设置默认值
|
||||
UPDATE wor_activity_definition SET service_range = '全部' WHERE service_range IS NULL;
|
||||
@@ -54,6 +54,12 @@
|
||||
<artifactId>oshi-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- spring security 安全认证 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 系统模块-->
|
||||
<dependency>
|
||||
<groupId>com.core</groupId>
|
||||
@@ -65,6 +71,12 @@
|
||||
<artifactId>core-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis-Plus 支持 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSQLParser - 用于MyBatis Plus -->
|
||||
<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
|
||||
@@ -18,6 +18,12 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- MyBatis-Plus 支持 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
@@ -36,6 +42,24 @@
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok 支持 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson 注解支持 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -23,6 +23,12 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- MyBatis-Plus 支持 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 通用工具-->
|
||||
<dependency>
|
||||
<groupId>com.core</groupId>
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.openhis.workflow.service.IDeviceDispenseService;
|
||||
import com.openhis.workflow.service.IDeviceRequestService;
|
||||
import com.openhis.workflow.service.IServiceRequestService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -92,6 +93,7 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
@Resource
|
||||
DoctorStationSendApplyUtil doctorStationSendApplyUtil;
|
||||
|
||||
|
||||
/**
|
||||
* 查询医嘱信息
|
||||
*
|
||||
@@ -111,6 +113,20 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
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) {
|
||||
|
||||
// 生成缓存键,处理可能的null值
|
||||
String safeSearchKey = searchKey != null ? searchKey : "";
|
||||
String safeAdviceTypesStr = "";
|
||||
if (adviceTypes != null && !adviceTypes.isEmpty()) {
|
||||
safeAdviceTypesStr = String.join(",", adviceTypes.stream().map(String::valueOf).collect(Collectors.toList()));
|
||||
}
|
||||
String safeOrganizationId = organizationId != null ? organizationId.toString() : "";
|
||||
String safePricingFlag = pricingFlag != null ? pricingFlag.toString() : "";
|
||||
String safePageNo = pageNo != null ? pageNo.toString() : "";
|
||||
String safePageSize = pageSize != null ? pageSize.toString() : "";
|
||||
|
||||
log.info("从数据库查询医嘱基础信息");
|
||||
|
||||
// 设置默认科室 (不取前端传的了)
|
||||
organizationId = SecurityUtils.getLoginUser().getOrgId();
|
||||
|
||||
@@ -172,98 +188,190 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
.add(cfg.getLocationId());
|
||||
}
|
||||
}
|
||||
// 费用定价子表信息
|
||||
List<AdvicePriceDto> childCharge = doctorStationAdviceAppMapper
|
||||
.getChildCharge(ConditionCode.LOT_NUMBER_PRICE.getCode(), chargeItemDefinitionIdList);
|
||||
// 费用定价主表信息
|
||||
List<AdvicePriceDto> mainCharge
|
||||
= doctorStationAdviceAppMapper.getMainCharge(chargeItemDefinitionIdList, PublicationStatus.ACTIVE.getValue());
|
||||
// 费用定价子表信息 - 使用分批处理避免大量参数问题
|
||||
List<AdvicePriceDto> childCharge = new ArrayList<>();
|
||||
if (chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
||||
// 分批处理,每批最多1000个ID,增加批次大小以减少查询次数
|
||||
int batchSize = 1000;
|
||||
for (int i = 0; i < chargeItemDefinitionIdList.size(); i += batchSize) {
|
||||
int endIndex = Math.min(i + batchSize, chargeItemDefinitionIdList.size());
|
||||
List<Long> batch = chargeItemDefinitionIdList.subList(i, endIndex);
|
||||
childCharge.addAll(doctorStationAdviceAppMapper
|
||||
.getChildCharge(ConditionCode.LOT_NUMBER_PRICE.getCode(), batch));
|
||||
}
|
||||
}
|
||||
|
||||
// 费用定价主表信息 - 使用分批处理避免大量参数问题
|
||||
List<AdvicePriceDto> mainCharge = new ArrayList<>();
|
||||
if (chargeItemDefinitionIdList != null && !chargeItemDefinitionIdList.isEmpty()) {
|
||||
// 分批处理,每批最多500个ID
|
||||
int batchSize = 500;
|
||||
for (int i = 0; i < chargeItemDefinitionIdList.size(); i += batchSize) {
|
||||
int endIndex = Math.min(i + batchSize, chargeItemDefinitionIdList.size());
|
||||
List<Long> batch = chargeItemDefinitionIdList.subList(i, endIndex);
|
||||
mainCharge.addAll(doctorStationAdviceAppMapper.getMainCharge(batch, PublicationStatus.ACTIVE.getValue()));
|
||||
}
|
||||
}
|
||||
String unitCode = ""; // 包装单位
|
||||
Long chargeItemDefinitionId; // 费用定价主表ID
|
||||
for (AdviceBaseDto baseDto : adviceBaseDtoList) {
|
||||
switch (baseDto.getAdviceTableName()) {
|
||||
case CommonConstants.TableName.MED_MEDICATION_DEFINITION: // 药品
|
||||
// 是否皮试
|
||||
baseDto
|
||||
.setSkinTestFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getSkinTestFlag()));
|
||||
// 是否为注射药物
|
||||
baseDto.setInjectFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getInjectFlag()));
|
||||
case CommonConstants.TableName.ADM_DEVICE_DEFINITION: // 耗材
|
||||
// 每一条医嘱的库存集合信息 , 包装单位库存前端计算
|
||||
List<AdviceInventoryDto> inventoryList = adviceInventory.stream().filter(e -> baseDto
|
||||
.getAdviceDefinitionId().equals(e.getItemId())
|
||||
&& baseDto.getAdviceTableName().equals(e.getItemTable())
|
||||
&& (pharmacyMultipleChoice
|
||||
|| (baseDto.getPositionId() == null || baseDto.getPositionId().equals(e.getLocationId()))))
|
||||
.collect(Collectors.toList());
|
||||
// 库存信息
|
||||
baseDto.setInventoryList(inventoryList);
|
||||
// 设置默认产品批号
|
||||
if (!inventoryList.isEmpty()) {
|
||||
// 库存大于0
|
||||
List<AdviceInventoryDto> hasInventoryList = inventoryList.stream()
|
||||
.filter(e -> e.getQuantity().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
|
||||
if (!hasInventoryList.isEmpty()) {
|
||||
baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber());
|
||||
}
|
||||
}
|
||||
if (!inventoryList.isEmpty() && !medLocationConfig.isEmpty()) {
|
||||
// 第一步:在medLocationConfig中匹配categoryCode
|
||||
AdviceInventoryDto result1 = medLocationConfig.stream()
|
||||
.filter(dto -> baseDto.getCategoryCode().equals(dto.getCategoryCode())).findFirst()
|
||||
.orElse(null);
|
||||
if (result1 != null) {
|
||||
// 第二步:在inventoryList中匹配locationId
|
||||
AdviceInventoryDto result2 = inventoryList.stream()
|
||||
.filter(dto -> result1.getLocationId().equals(dto.getLocationId())).findFirst()
|
||||
.orElse(null);
|
||||
if (result2 != null && result2.getLotNumber() != null) {
|
||||
baseDto.setDefaultLotNumber(result2.getLotNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
String tableName = baseDto.getAdviceTableName();
|
||||
if (CommonConstants.TableName.MED_MEDICATION_DEFINITION.equals(tableName)) { // 药品
|
||||
// 是否皮试
|
||||
baseDto
|
||||
.setSkinTestFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getSkinTestFlag()));
|
||||
// 是否为注射药物
|
||||
baseDto.setInjectFlag_enumText(EnumUtils.getInfoByValue(Whether.class, baseDto.getInjectFlag()));
|
||||
|
||||
unitCode = baseDto.getUnitCode();
|
||||
chargeItemDefinitionId = baseDto.getChargeItemDefinitionId();
|
||||
List<AdvicePriceDto> priceDtoList = new ArrayList<>();
|
||||
// 库存信息里取 命中条件 去匹配价格
|
||||
for (AdviceInventoryDto adviceInventoryDto : inventoryList) {
|
||||
Long finalChargeItemDefinitionId = chargeItemDefinitionId;
|
||||
String finalUnitCode = unitCode;
|
||||
// 从定价子表取价格(适用于批次售卖场景)
|
||||
List<AdvicePriceDto> childPrice = childCharge.stream()
|
||||
.filter(e -> e.getDefinitionId().equals(finalChargeItemDefinitionId)
|
||||
&& e.getConditionValue().equals(adviceInventoryDto.getLotNumber()))
|
||||
.peek(e -> e.setUnitCode(finalUnitCode)) // 设置 unitCode
|
||||
.collect(Collectors.toList());
|
||||
// 从定价主表取价格(适用于统一零售价场景)
|
||||
List<AdvicePriceDto> mainPrice = mainCharge.stream()
|
||||
.filter(e -> baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||
.collect(Collectors.toList());
|
||||
// 按批次售价
|
||||
if (OrderPricingSource.BATCH_SELLING_PRICE.getCode().equals(orderPricingSource)) {
|
||||
priceDtoList.addAll(childPrice);
|
||||
} else {
|
||||
priceDtoList.addAll(mainPrice);
|
||||
// fallthrough to 耗材处理逻辑(保持原有逻辑)
|
||||
// 每一条医嘱的库存集合信息 , 包装单位库存前端计算
|
||||
List<AdviceInventoryDto> inventoryList = adviceInventory.stream().filter(e ->
|
||||
baseDto.getAdviceDefinitionId() != null && e.getItemId() != null
|
||||
&& baseDto.getAdviceDefinitionId().equals(e.getItemId())
|
||||
&& baseDto.getAdviceTableName() != null && e.getItemTable() != null
|
||||
&& baseDto.getAdviceTableName().equals(e.getItemTable())
|
||||
&& (pharmacyMultipleChoice
|
||||
|| (baseDto.getPositionId() == null || (e.getLocationId() != null && baseDto.getPositionId().equals(e.getLocationId())))))
|
||||
.collect(Collectors.toList());
|
||||
// 库存信息
|
||||
baseDto.setInventoryList(inventoryList);
|
||||
// 设置默认产品批号
|
||||
if (!inventoryList.isEmpty()) {
|
||||
// 库存大于0
|
||||
List<AdviceInventoryDto> hasInventoryList = inventoryList.stream()
|
||||
.filter(e -> e.getQuantity().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
|
||||
if (!hasInventoryList.isEmpty()) {
|
||||
baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber());
|
||||
}
|
||||
}
|
||||
if (!inventoryList.isEmpty() && !medLocationConfig.isEmpty()) {
|
||||
// 第一步:在medLocationConfig中匹配categoryCode
|
||||
AdviceInventoryDto result1 = medLocationConfig.stream()
|
||||
.filter(dto -> baseDto.getCategoryCode() != null && dto.getCategoryCode() != null
|
||||
&& baseDto.getCategoryCode().equals(dto.getCategoryCode())).findFirst()
|
||||
.orElse(null);
|
||||
if (result1 != null) {
|
||||
// 第二步:在inventoryList中匹配locationId
|
||||
AdviceInventoryDto result2 = inventoryList.stream()
|
||||
.filter(dto -> result1.getLocationId() != null && dto.getLocationId() != null
|
||||
&& result1.getLocationId().equals(dto.getLocationId())).findFirst()
|
||||
.orElse(null);
|
||||
if (result2 != null && result2.getLotNumber() != null) {
|
||||
baseDto.setDefaultLotNumber(result2.getLotNumber());
|
||||
}
|
||||
}
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceDtoList);
|
||||
break;
|
||||
case CommonConstants.TableName.WOR_ACTIVITY_DEFINITION: // 诊疗
|
||||
List<AdvicePriceDto> priceList
|
||||
= mainCharge.stream().filter(e -> baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||
.collect(Collectors.toList());
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceList);
|
||||
// 活动类型
|
||||
baseDto.setActivityType_enumText(
|
||||
EnumUtils.getInfoByValue(ActivityType.class, baseDto.getActivityType()));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
unitCode = baseDto.getUnitCode();
|
||||
chargeItemDefinitionId = baseDto.getChargeItemDefinitionId();
|
||||
List<AdvicePriceDto> priceDtoList = new ArrayList<>();
|
||||
// 库存信息里取 命中条件 去匹配价格
|
||||
for (AdviceInventoryDto adviceInventoryDto : inventoryList) {
|
||||
Long finalChargeItemDefinitionId = chargeItemDefinitionId;
|
||||
String finalUnitCode = unitCode;
|
||||
// 从定价子表取价格(适用于批次售卖场景)
|
||||
List<AdvicePriceDto> childPrice = childCharge.stream()
|
||||
.filter(e -> e.getDefinitionId() != null && finalChargeItemDefinitionId != null
|
||||
&& e.getDefinitionId().equals(finalChargeItemDefinitionId)
|
||||
&& e.getConditionValue() != null && adviceInventoryDto.getLotNumber() != null
|
||||
&& e.getConditionValue().equals(adviceInventoryDto.getLotNumber()))
|
||||
.peek(e -> e.setUnitCode(finalUnitCode)) // 设置 unitCode
|
||||
.collect(Collectors.toList());
|
||||
// 从定价主表取价格(适用于统一零售价场景)
|
||||
List<AdvicePriceDto> mainPrice = mainCharge.stream()
|
||||
.filter(e -> baseDto.getChargeItemDefinitionId() != null && e.getDefinitionId() != null
|
||||
&& baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||
.collect(Collectors.toList());
|
||||
// 按批次售价
|
||||
if (OrderPricingSource.BATCH_SELLING_PRICE.getCode().equals(orderPricingSource)) {
|
||||
priceDtoList.addAll(childPrice);
|
||||
} else {
|
||||
priceDtoList.addAll(mainPrice);
|
||||
}
|
||||
}
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceDtoList);
|
||||
} else if (CommonConstants.TableName.ADM_DEVICE_DEFINITION.equals(tableName)) { // 耗材
|
||||
// 每一条医嘱的库存集合信息 , 包装单位库存前端计算
|
||||
List<AdviceInventoryDto> inventoryList = adviceInventory.stream().filter(e ->
|
||||
baseDto.getAdviceDefinitionId() != null && e.getItemId() != null
|
||||
&& baseDto.getAdviceDefinitionId().equals(e.getItemId())
|
||||
&& baseDto.getAdviceTableName() != null && e.getItemTable() != null
|
||||
&& baseDto.getAdviceTableName().equals(e.getItemTable())
|
||||
&& (pharmacyMultipleChoice
|
||||
|| (baseDto.getPositionId() == null || (e.getLocationId() != null && baseDto.getPositionId().equals(e.getLocationId())))))
|
||||
.collect(Collectors.toList());
|
||||
// 库存信息
|
||||
baseDto.setInventoryList(inventoryList);
|
||||
// 设置默认产品批号
|
||||
if (!inventoryList.isEmpty()) {
|
||||
// 库存大于0
|
||||
List<AdviceInventoryDto> hasInventoryList = inventoryList.stream()
|
||||
.filter(e -> e.getQuantity().compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
|
||||
if (!hasInventoryList.isEmpty()) {
|
||||
baseDto.setDefaultLotNumber(hasInventoryList.get(0).getLotNumber());
|
||||
}
|
||||
}
|
||||
if (!inventoryList.isEmpty() && !medLocationConfig.isEmpty()) {
|
||||
// 第一步:在medLocationConfig中匹配categoryCode
|
||||
AdviceInventoryDto result1 = medLocationConfig.stream()
|
||||
.filter(dto -> baseDto.getCategoryCode() != null && dto.getCategoryCode() != null
|
||||
&& baseDto.getCategoryCode().equals(dto.getCategoryCode())).findFirst()
|
||||
.orElse(null);
|
||||
if (result1 != null) {
|
||||
// 第二步:在inventoryList中匹配locationId
|
||||
AdviceInventoryDto result2 = inventoryList.stream()
|
||||
.filter(dto -> result1.getLocationId() != null && dto.getLocationId() != null
|
||||
&& result1.getLocationId().equals(dto.getLocationId())).findFirst()
|
||||
.orElse(null);
|
||||
if (result2 != null && result2.getLotNumber() != null) {
|
||||
baseDto.setDefaultLotNumber(result2.getLotNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unitCode = baseDto.getUnitCode();
|
||||
chargeItemDefinitionId = baseDto.getChargeItemDefinitionId();
|
||||
List<AdvicePriceDto> priceDtoList = new ArrayList<>();
|
||||
// 库存信息里取 命中条件 去匹配价格
|
||||
for (AdviceInventoryDto adviceInventoryDto : inventoryList) {
|
||||
Long finalChargeItemDefinitionId = chargeItemDefinitionId;
|
||||
String finalUnitCode = unitCode;
|
||||
// 从定价子表取价格(适用于批次售卖场景)
|
||||
List<AdvicePriceDto> childPrice = childCharge.stream()
|
||||
.filter(e -> e.getDefinitionId() != null && finalChargeItemDefinitionId != null
|
||||
&& e.getDefinitionId().equals(finalChargeItemDefinitionId)
|
||||
&& e.getConditionValue() != null && adviceInventoryDto.getLotNumber() != null
|
||||
&& e.getConditionValue().equals(adviceInventoryDto.getLotNumber()))
|
||||
.peek(e -> e.setUnitCode(finalUnitCode)) // 设置 unitCode
|
||||
.collect(Collectors.toList());
|
||||
// 从定价主表取价格(适用于统一零售价场景)
|
||||
List<AdvicePriceDto> mainPrice = mainCharge.stream()
|
||||
.filter(e -> baseDto.getChargeItemDefinitionId() != null && e.getDefinitionId() != null
|
||||
&& baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||
.collect(Collectors.toList());
|
||||
// 按批次售价
|
||||
if (OrderPricingSource.BATCH_SELLING_PRICE.getCode().equals(orderPricingSource)) {
|
||||
priceDtoList.addAll(childPrice);
|
||||
} else {
|
||||
priceDtoList.addAll(mainPrice);
|
||||
}
|
||||
}
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceDtoList);
|
||||
} else if (CommonConstants.TableName.WOR_ACTIVITY_DEFINITION.equals(tableName)) { // 诊疗
|
||||
List<AdvicePriceDto> priceList
|
||||
= mainCharge.stream().filter(e -> baseDto.getChargeItemDefinitionId() != null && e.getDefinitionId() != null
|
||||
&& baseDto.getChargeItemDefinitionId().equals(e.getDefinitionId()))
|
||||
.collect(Collectors.toList());
|
||||
// 价格信息
|
||||
baseDto.setPriceList(priceList);
|
||||
// 活动类型
|
||||
baseDto.setActivityType_enumText(
|
||||
EnumUtils.getInfoByValue(ActivityType.class, baseDto.getActivityType()));
|
||||
}
|
||||
}
|
||||
|
||||
return adviceBaseInfo;
|
||||
}
|
||||
|
||||
@@ -288,83 +396,99 @@ public class DoctorStationAdviceAppServiceImpl implements IDoctorStationAdviceAp
|
||||
*/
|
||||
@Override
|
||||
public R<?> saveAdvice(AdviceSaveParam adviceSaveParam, String adviceOpType) {
|
||||
// 患者挂号对应的科室id
|
||||
Long organizationId = adviceSaveParam.getOrganizationId();
|
||||
// 医嘱分类信息
|
||||
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
|
||||
// 药品
|
||||
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 耗材
|
||||
List<AdviceSaveDto> deviceList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.DEVICE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 诊疗活动
|
||||
List<AdviceSaveDto> activityList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
try {
|
||||
// 患者挂号对应的科室id
|
||||
Long organizationId = adviceSaveParam.getOrganizationId();
|
||||
// 医嘱分类信息
|
||||
List<AdviceSaveDto> adviceSaveList = adviceSaveParam.getAdviceSaveList();
|
||||
// 药品
|
||||
List<AdviceSaveDto> medicineList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.MEDICINE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 耗材
|
||||
List<AdviceSaveDto> deviceList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.DEVICE.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 诊疗活动
|
||||
List<AdviceSaveDto> activityList = adviceSaveList.stream()
|
||||
.filter(e -> ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
|
||||
/**
|
||||
* 保存时,校验库存
|
||||
*/
|
||||
if (AdviceOpType.SAVE_ADVICE.getCode().equals(adviceOpType)) {
|
||||
List<AdviceSaveDto> medUpdateList
|
||||
= medicineList.stream().filter(e -> e.getRequestId() != null).collect(Collectors.toList());
|
||||
List<AdviceSaveDto> devUpdateList
|
||||
= deviceList.stream().filter(e -> e.getRequestId() != null).collect(Collectors.toList());
|
||||
// 编辑时,释放本身占用的库存发放
|
||||
for (AdviceSaveDto adviceSaveDto : medUpdateList) {
|
||||
iMedicationDispenseService.deleteMedicationDispense(adviceSaveDto.getRequestId());
|
||||
/**
|
||||
* 保存时,校验库存
|
||||
*/
|
||||
if (AdviceOpType.SAVE_ADVICE.getCode().equals(adviceOpType)) {
|
||||
List<AdviceSaveDto> medUpdateList
|
||||
= medicineList.stream().filter(e -> e.getRequestId() != null).collect(Collectors.toList());
|
||||
List<AdviceSaveDto> devUpdateList
|
||||
= deviceList.stream().filter(e -> e.getRequestId() != null).collect(Collectors.toList());
|
||||
// 编辑时,释放本身占用的库存发放
|
||||
for (AdviceSaveDto adviceSaveDto : medUpdateList) {
|
||||
iMedicationDispenseService.deleteMedicationDispense(adviceSaveDto.getRequestId());
|
||||
}
|
||||
for (AdviceSaveDto adviceSaveDto : devUpdateList) {
|
||||
iDeviceDispenseService.deleteDeviceDispense(adviceSaveDto.getRequestId());
|
||||
}
|
||||
|
||||
List<AdviceSaveDto> needCheckList
|
||||
= adviceSaveList.stream().filter(e -> !DbOpType.DELETE.getCode().equals(e.getDbOpType())
|
||||
&& !ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 校验库存
|
||||
String tipRes = adviceUtils.checkInventory(needCheckList);
|
||||
if (tipRes != null) {
|
||||
return R.fail(null, tipRes);
|
||||
}
|
||||
}
|
||||
for (AdviceSaveDto adviceSaveDto : devUpdateList) {
|
||||
iDeviceDispenseService.deleteDeviceDispense(adviceSaveDto.getRequestId());
|
||||
// 当前时间
|
||||
Date curDate = new Date();
|
||||
// 医嘱签发编码
|
||||
String signCode = assignSeqUtil.getSeq(AssignSeqEnum.ADVICE_SIGN.getPrefix(), 10);
|
||||
|
||||
/**
|
||||
* 处理药品请求
|
||||
*/
|
||||
List<String> medRequestIdList
|
||||
= this.handMedication(medicineList, curDate, adviceOpType, organizationId, signCode);
|
||||
|
||||
/**
|
||||
* 处理诊疗项目请求
|
||||
*/
|
||||
this.handService(activityList, curDate, adviceOpType, organizationId, signCode);
|
||||
|
||||
/**
|
||||
* 处理耗材请求
|
||||
*/
|
||||
this.handDevice(deviceList, curDate, adviceOpType);
|
||||
|
||||
// 签发时,把草稿状态的账单更新为待收费
|
||||
if (AdviceOpType.SIGN_ADVICE.getCode().equals(adviceOpType) && !adviceSaveList.isEmpty()) {
|
||||
// 签发的医嘱id集合
|
||||
List<Long> requestIds = adviceSaveList.stream()
|
||||
.filter(e -> !DbOpType.DELETE.getCode().equals(e.getDbOpType()) && e.getRequestId() != null)
|
||||
.collect(Collectors.toList()).stream().map(AdviceSaveDto::getRequestId).collect(Collectors.toList());
|
||||
// 就诊id
|
||||
Long encounterId = adviceSaveList.get(0).getEncounterId();
|
||||
iChargeItemService.update(new LambdaUpdateWrapper<ChargeItem>()
|
||||
.set(ChargeItem::getStatusEnum, ChargeItemStatus.PLANNED.getValue())
|
||||
.eq(ChargeItem::getEncounterId, encounterId)
|
||||
.eq(ChargeItem::getStatusEnum, ChargeItemStatus.DRAFT.getValue())
|
||||
.in(ChargeItem::getServiceId, requestIds));
|
||||
}
|
||||
|
||||
List<AdviceSaveDto> needCheckList
|
||||
= adviceSaveList.stream().filter(e -> !DbOpType.DELETE.getCode().equals(e.getDbOpType())
|
||||
&& !ItemType.ACTIVITY.getValue().equals(e.getAdviceType())).collect(Collectors.toList());
|
||||
// 校验库存
|
||||
String tipRes = adviceUtils.checkInventory(needCheckList);
|
||||
if (tipRes != null) {
|
||||
return R.fail(null, tipRes);
|
||||
}
|
||||
// 数据变更后清理相关缓存
|
||||
clearRelatedCache();
|
||||
|
||||
return R.ok(medRequestIdList,
|
||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"门诊医嘱"}));
|
||||
} catch (Exception e) {
|
||||
// 异常处理
|
||||
throw e;
|
||||
}
|
||||
// 当前时间
|
||||
Date curDate = new Date();
|
||||
// 医嘱签发编码
|
||||
String signCode = assignSeqUtil.getSeq(AssignSeqEnum.ADVICE_SIGN.getPrefix(), 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理药品请求
|
||||
*/
|
||||
List<String> medRequestIdList
|
||||
= this.handMedication(medicineList, curDate, adviceOpType, organizationId, signCode);
|
||||
|
||||
/**
|
||||
* 处理诊疗项目请求
|
||||
*/
|
||||
this.handService(activityList, curDate, adviceOpType, organizationId, signCode);
|
||||
|
||||
/**
|
||||
* 处理耗材请求
|
||||
*/
|
||||
this.handDevice(deviceList, curDate, adviceOpType);
|
||||
|
||||
// 签发时,把草稿状态的账单更新为待收费
|
||||
if (AdviceOpType.SIGN_ADVICE.getCode().equals(adviceOpType) && !adviceSaveList.isEmpty()) {
|
||||
// 签发的医嘱id集合
|
||||
List<Long> requestIds = adviceSaveList.stream()
|
||||
.filter(e -> !DbOpType.DELETE.getCode().equals(e.getDbOpType()) && e.getRequestId() != null)
|
||||
.collect(Collectors.toList()).stream().map(AdviceSaveDto::getRequestId).collect(Collectors.toList());
|
||||
// 就诊id
|
||||
Long encounterId = adviceSaveList.get(0).getEncounterId();
|
||||
iChargeItemService.update(new LambdaUpdateWrapper<ChargeItem>()
|
||||
.set(ChargeItem::getStatusEnum, ChargeItemStatus.PLANNED.getValue())
|
||||
.eq(ChargeItem::getEncounterId, encounterId)
|
||||
.eq(ChargeItem::getStatusEnum, ChargeItemStatus.DRAFT.getValue())
|
||||
.in(ChargeItem::getServiceId, requestIds));
|
||||
}
|
||||
|
||||
return R.ok(medRequestIdList,
|
||||
MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[]{"门诊医嘱"}));
|
||||
/**
|
||||
* 清理相关缓存
|
||||
*/
|
||||
private void clearRelatedCache() {
|
||||
// 目前不使用缓存,此方法为空实现
|
||||
// 如果将来启用缓存,可以在这里实现缓存清理逻辑
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -395,20 +395,18 @@
|
||||
T1.condition_value,
|
||||
T1.condition_code,
|
||||
T1.amount AS price
|
||||
FROM
|
||||
adm_charge_item_def_detail AS T1
|
||||
LEFT JOIN adm_charge_item_definition AS T2 ON T2.ID = T1.definition_id
|
||||
AND T2.delete_flag = '0'
|
||||
WHERE
|
||||
T1.delete_flag = '0'
|
||||
AND T1.condition_code = #{conditionCode}
|
||||
FROM adm_charge_item_def_detail AS T1
|
||||
INNER JOIN adm_charge_item_definition AS T2 ON T2.ID = T1.definition_id
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T2.delete_flag = '0'
|
||||
AND T1.condition_code = #{conditionCode}
|
||||
<if test="chargeItemDefinitionIdList != null and !chargeItemDefinitionIdList.isEmpty()">
|
||||
AND T1.definition_id IN
|
||||
<foreach collection="chargeItemDefinitionIdList" item="itemId" open="(" separator="," close=")">
|
||||
#{itemId}
|
||||
</foreach>
|
||||
</if>
|
||||
ORDER BY T1.priority DESC
|
||||
ORDER BY T1.priority DESC, T1.definition_id
|
||||
</select>
|
||||
|
||||
<select id="getMainCharge" resultType="com.openhis.web.doctorstation.dto.AdvicePriceDto">
|
||||
|
||||
@@ -26,11 +26,29 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson 注解支持 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MyBatis-Plus 支持 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- CORE-->
|
||||
<dependency>
|
||||
<groupId>com.core</groupId>
|
||||
<artifactId>core-admin</artifactId>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.core</groupId>
|
||||
<artifactId>core-common</artifactId>
|
||||
|
||||
@@ -56,6 +56,16 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- JSON工具类 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<!-- Jackson 注解支持 -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<!-- MyBatis-Plus 支持 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
|
||||
Reference in New Issue
Block a user