|
|
|
@ -1,13 +1,19 @@
|
|
|
|
|
package com.supervision.manage.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.supervision.manage.service.ConfigTreatmentPlanManageService;
|
|
|
|
|
import com.supervision.manage.service.DrugManageService;
|
|
|
|
|
import com.supervision.model.ConfigDrug;
|
|
|
|
|
import com.supervision.model.ConfigTreatmentPlan;
|
|
|
|
|
import com.supervision.model.DiseaseTreatmentPlanDrug;
|
|
|
|
|
import com.supervision.service.ConfigDrugService;
|
|
|
|
|
import com.supervision.service.ConfigTreatmentPlanService;
|
|
|
|
|
import com.supervision.service.DiseaseTreatmentPlanDrugService;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
@ -15,7 +21,9 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
|
public class DrugManageServiceImpl implements DrugManageService {
|
|
|
|
|
|
|
|
|
|
private final ConfigDrugService configDrugService;;
|
|
|
|
|
private final ConfigDrugService configDrugService;
|
|
|
|
|
|
|
|
|
|
private final DiseaseTreatmentPlanDrugService diseaseTreatmentPlanDrugService;
|
|
|
|
|
@Override
|
|
|
|
|
public ConfigDrug saveDrug(ConfigDrug configDrug) {
|
|
|
|
|
Assert.notEmpty(configDrug.getDrugName(), "药品名称不能为空");
|
|
|
|
@ -27,10 +35,18 @@ public class DrugManageServiceImpl implements DrugManageService {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean deleteDrugById(String id) {
|
|
|
|
|
Assert.notEmpty(id, "药品id不能为空");
|
|
|
|
|
assertDrugIsUsed(id);
|
|
|
|
|
|
|
|
|
|
return configDrugService.removeById(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void assertDrugIsUsed(String id) {
|
|
|
|
|
boolean diseasePlanIsUsed = diseaseTreatmentPlanDrugService.lambdaQuery().eq(DiseaseTreatmentPlanDrug::getDrugId, id).count() > 0;
|
|
|
|
|
Assert.isFalse(diseasePlanIsUsed, "药品已经在疾病处置计划中使用");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean updateDrug(ConfigDrug configDrug) {
|
|
|
|
|
Assert.notEmpty(configDrug.getId(), "药品id不能为空");
|
|
|
|
|